Skip to content

The SQL Language

Jennifer Scheuerell edited this page Feb 3, 2020 · 2 revisions

The SQL Language

"Many relational database systems have an option of using the SQL (Structured Query Language) for querying and maintaining the database."

Writing SQL

From https://www.postgresql.org/docs/12/tutorial-table.html: You can enter [code] into psql with the line breaks. psql will recognize that the command is not terminated until the semicolon.

White space (i.e., spaces, tabs, and newlines) can be used freely in SQL commands. That means you can type the command aligned differently than above, or even all on one line.

Two dashes (“--”) introduce comments. Whatever follows them is ignored up to the end of the line.

SQL is case insensitive about key words and identifiers, except when identifiers are double-quoted to preserve the case (not done above).

DDL

create / alter / drop table insert / copy

DML

select

  • where
  • math
  • extract
  • order by
  • distinct
  • group by
  • join / left / right
  • count / sum / avg / max / min (aggregate functions)
  • subqueries
  • having
  • update
  • delete

Clone this wiki locally