2. SQL
• SQL is structured query language, which is a computer
language for storing, manipulating and retrieving data
stored in a relational database.
• SQL was the first commercial language introduced for
E.F. Codd’s Relational Model
• Today almost RDMBS (MySQL, Oracle, Infomix, Sybase,
MS Access) uses SQL as the standard database
language.
3/1/2023 PRESENTATION TITLE 2
3. SQL
• SQL functions fit into two broad
categories:
• Data Definition Language (DDL)
• Data Manipulation language (DML)
3/1/2023 PRESENTATION TITLE 3
4. DATA DEFINITION LANGUAGE
• Data Definition Language (DDL) statements are used
to define the database structure or schema.
• All DDL commands are auto-committed. That means it
saves all the changes permanently in the database.
3/1/2023 PRESENTATION TITLE 4
5. DDL COMMANDS
3/1/2023 PRESENTATION TITLE 5
COMMAND DESCRIPTION
CREATE To create new table or database
ALTER For alteration
TRUNCATE Delete data from table
DROP To drop a table
RENAME To rename a table
6. CREATE Command
• CREATE is a DDL command used to create a table or
database.
• Following is the syntax:
CREATE DATABASE database_name
Example:
CREATE DATABASE Books
3/1/2023 PRESENTATION TITLE 6
8. ALTER Command
ALTER TABLE - ADD Column
To add a column in a table, use the following syntax:
ALTER TABLE table_name
ADD column_name datatype;
ALTER TABLE Customers
ADD Email varchar(255);
3/1/2023 PRESENTATION TITLE 8
9. ALTER Command
ALTER TABLE - DROP Column
To delete a column in a table, use the following syntax (notice
that some database systems don't allow deleting a column):
ALTER TABLE table_name
DROP COLUMN column_name;
ALTER TABLE Authors
DROP COLUMN Email;
3/1/2023 PRESENTATION TITLE 9
10. ALTER Command
ALTER TABLE - DROP Column
To delete a column in a table, use the following syntax (notice
that some database systems don't allow deleting a column):
ALTER TABLE table_name
DROP COLUMN column_name;
ALTER TABLE Authors
DROP COLUMN Email;
3/1/2023 PRESENTATION TITLE 10