SQL Syntax

Here are some basic SQL commands:

  1. CREATE – used to create a new table, database, or other objects in the database
  2. SELECT – used to select data from a database
  3. INSERT – used to insert data into a table
  4. UPDATE – used to update existing data in a table
  5. DELETE – used to delete data from a table
  6. ALTER – used to alter the structure of a table
  7. DROP – used to delete an entire table, database or other objects in the database
  8. WHERE – used to filter results based on certain conditions
  9. AND/OR – used to combine multiple conditions in a WHERE clause
  10. ORDER BY – used to sort the result set based on one or more columns

SQL syntax follows certain rules and conventions, such as keywords being written in uppercase and using semicolons to separate statements.

Examples:

CREATE

CREATE TABLE table_name
(
column1 data_type constraint,
column2 data_type constraint,
...
);

SELECT

SELECT column1, column2, ...
FROM table_name;

INSERT

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

UPDATE

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE some_column = some_value;

DELETE

DELETE FROM table_name
WHERE some_column = some_value;

ALTER

ALTER TABLE table_name
ADD column_name data_type constraint;

DROP

DROP TABLE table_name;