PostgreSQL Shell Commands vs Prisma ORM
Commands
• Connect to DB
PostgreSQL: \c dbname
Prisma: prisma.$connect()
• Show databases
PostgreSQL: \l
Prisma: Not directly (list via schema inspector / raw query)
• Show tables
PostgreSQL: \dt
Prisma: prisma..findMany()
• Describe table
PostgreSQL: \d tablename
Prisma: prisma..findMany({ select: {...} })
• Create database
PostgreSQL: CREATE DATABASE dbname;
Prisma: Use migrations: npx prisma migrate dev --name init
• Drop database
PostgreSQL: DROP DATABASE dbname;
Prisma: Handled outside Prisma (raw SQL or DB tool)
• Create table
PostgreSQL: CREATE TABLE ...;
Prisma: Define model in schema.prisma + migrate
• Drop table
PostgreSQL: DROP TABLE tablename;
Prisma: Remove model + migrate
• Insert row
PostgreSQL: INSERT INTO table (...) VALUES (...);
Prisma: prisma..create({ data: {...} })
• Update row
PostgreSQL: UPDATE table SET ... WHERE ...;
Prisma: prisma..update({ where: {...}, data: {...} })
• Delete row
PostgreSQL: DELETE FROM table WHERE ...;
Prisma: prisma..delete({ where: {...} })
• Select rows
PostgreSQL: SELECT * FROM table;
Prisma: prisma..findMany()
• Select with condition
PostgreSQL: SELECT * FROM table WHERE ...;
Prisma: prisma..findMany({ where: {...} })
• Count rows
PostgreSQL: SELECT COUNT(*) FROM table;
Prisma: prisma..count()
• Raw query
PostgreSQL: Any SQL
Prisma: prisma.$queryRaw`SQL_QUERY`