In this presentation, we delve into the first DDL (Data Definition Language) command: the CREATE command. SQL consists of four sublanguages:
We will focus on the DDL sublanguage and specifically on the CREATE command.
DDL involves defining the structure of database objects, which are automatically committed. DDL comprises five commands:
We aim to illustrate how to use the CREATE command to construct a table.
CREATE TABLE table_name (
column1_name data_type,
column2_name data_type,
...
columnN_name data_type
);
CREATE TABLE Employee (
ID INTEGER(4),
Name VARCHAR(50),
DepartmentName VARCHAR(40),
Salary INTEGER(10)
);
Example 1: Basic employee table structure
CREATE TABLE Employee (
ID INTEGER(4),
Name VARCHAR(50)
);
Example 2: Including department and salary
CREATE TABLE Employee (
ID INTEGER(4),
Name VARCHAR(50),
DepartmentName VARCHAR(40),
Salary INTEGER(10)
);
Example 3: Different data types including float and date
CREATE TABLE Employee (
RollNumber INTEGER(10),
Name VARCHAR(50),
DateOfBirth DATE,
Percentage FLOAT(2)
);
Write a SQL DDL command to create a table with the following columns and choose appropriate data types:
Post your SQL CREATE statement in the comments section.
This presentation covered creating tables in SQL without constraints. Future lessons will explore how to apply conditions or constraints when defining tables.
Thank you for watching.
[Applause]