HELLO!This is my SQL skillset! Recording What I learnd about SQL. TBC
CREATE DATABASE database_name
ALTER DATABASE database_name RENAME TO new_name
DROP DATABASE database_name
CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype,....);
DROP TABLE table_name;
Add column:ALTER TABLE table_name ADD column_name datatype;
Drop column:ALTER TABLE table_name DROP COLUMN column_name;
Rename column: ALTER TABLE table_name RENAME COLUMN old_name To new_name;
Change column datatype: ALTER TABLE table_name MODIFY COLUMN column_name datatype;
Constraints can be specified when the table is created with the CREATE TABLE statement, or after the table is created with the ALTER TABLE statement.
CREATE TABLE table_name (
column1 datatype constraint,
column2 datatype constraint,
column3 datatype constraint,...);
The following constraints are commonly used in SQL:
NOT NULL: Ensures that a column cannot have a NULL value
UNIQUE: Ensures that all values in a column are different
PRIMARY KEY: A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table
FOREIGN KEY: Prevents actions that would destroy links between tables
CHECK: Ensures that the values in a column satisfies a specific condition
DEFAULT: Sets a default value for a column if no value is specified
INSERT INTO table_name (column1, column2, column3, ...)VALUES (value1, value2, value3, ...);
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
DELETE FROM table_name WHERE condition;
SELECT column1, column2, ...FROM table_name;
SELECT * FROM table_name;
SELECT COUNT() FROM table_name;
SELECT DISTINCT() FROM table_name;
SELECT column1, column2, ...
FROM table_name
WHERE condition;
AND: WHERE condition1 AND condition2 AND condition3 ...;
OR: WHERE condition1 OR condition2 OR condition3 ...;
NOT:WHERE NOT condition;
OTHERS:=,>,<,>=,<=,<>,BETWEEN...AND...,LIKE,IN
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;