What is the difference between the psql and sql commands?

Asked 1 years ago, Updated 1 years ago, 73 views

It's a beginner who started studying databases.
I'm very sorry for the sudden question, but are the psql and sql commands the same? Or is it something else?

I used this site as a reference.

PostgreSQL Commands

SQL Commands

linux sql postgresql

2022-09-30 21:11

2 Answers

The psql command is a program called psql that runs on the OS.
Launch psql to connect to PostgreSQL and do more.

By the way, there are programs called mysql for MySQL, sqlcmd.exe for SQL Server, and sql.exe for Oracle.

SQL commands are database languages for manipulating and defining data that is available throughout the Relational Database Management System (RDBMS).Standardized for use in a variety of RDBMS, not just PostgreSQL.It also has an extended syntax for each RDBMS.

Typical SQL Commands

  • SELECT...:query query
  • INSERT...:adding records
  • UPDATE...:updating columns
  • DELETE...:deleting records

The actual usage is an image that runs the psql command on the OS to connect to PostgreSQL and then queries the database using SQL commands.

Example Start psql & Connect to PostgreSQL

$psql-h localhost-Udbuser-ddbname
Password for user dbuser—Enter password here

Example Run the SQL command (SELECT statement) on the hoge table on psql.

dbname=>SELECT* FROM hoge;← Run SQL here.ddbname=> は is the psql prompt.
       id | city ← SQL results below
----------+-------
        1 | Tokyo 
        2 | osaka
        3 | sapporo


2022-09-30 21:11

In my experience, in the case of postgresql, when you say "psql" and "SQL" commands, you may sometimes say (sometimes) the following different uses:I don't know any other DBs, so I can't say anything.

  • psql command—A command name that can be executed from the shell, a command-line tool named psql
  • SQL commands:instructions (commands) that allow you to create and delete tables used after running psql from the command line

Note:
psql (PostgreSQL 9.2.4)
SQL Commands (PostgreSQL 9.2.4)


2022-09-30 21:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.