Here are some basic SQL commands:
- CREATE – used to create a new table, database, or other objects in the database
- SELECT – used to select data from a database
- INSERT – used to insert data into a table
- UPDATE – used to update existing data in a table
- DELETE – used to delete data from a table
- ALTER – used to alter the structure of a table
- DROP – used to delete an entire table, database or other objects in the database
- WHERE – used to filter results based on certain conditions
- AND/OR – used to combine multiple conditions in a WHERE clause
- 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;