























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























































Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples: CREATE - to create objects in the database ALTER - alters the structure of the database DROP - delete objects from the database TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed COMMENT - add comments to the data dictionary RENAME - rename an object
Table Employee
Data Control Language (DCL) statements. Some examples: GRANT - gives user's access privileges to database REVOKE - withdraw access privileges given with the GRANT command
ALTER TABLE table_name ADD column_name column-definition; ALTER TABLE table_name MODIFY column_name column_type; ALTER TABLE table_name DROP COLUMN column_name;
ALTER TABLE table_name RENAME COLUMN old_name to new_name; ALTER TABLE table_name RENAME TO new_table_name; ALTER TABLE table_name ADD CONSTRAINT constraint_name PRIMARY KEY (column1, column2, ... column_n);
CREATE TABLE table_name ( column datatype null/not null, column2 datatype null/ not null, ... CONSTRAINT fk_column FOREIGN KEY (column1, column2, ... column_n) REFERENCES parent_table (column1, column2, ... column_n) );
CREATE TABLE table_name ( column datatype null/not null, column2 datatype null/ not null, ... CONSTRAINT constraint_name CHECK (column_name condition) [DISABLE] );
CREATE TABLE table_name ( column datatype [ NULL | NOT NULL ], column datatype [ NULL | NOT NULL ], ... CONSTRAINT constraint_name UNIQUE (column1, column2, ... column_n) );
age < 25; SELECT ID, NAME, SALARY FROM CUSTOMERS WHERE SALARY > 2000 OR age < 25;
SELECT first_name, last_name, games FROM student_details WHERE NOT games = 'Football'
SELECT * FROM customers WHERE customer_id NOT BETWEEN 3000 AND 3500;
SELECT first_name, last_name, age FROM student_details WHERE age BETWEEN 10 AND 15; The IN operator is used when you want to compare a column with more than one value. It is similar to an OR condition.