Save
...
10.0 Fundamentals of databases
10.3 Structured Query Language (SQL)
10.3.1 Data definition language (DDL)
Save
Share
Learn
Content
Leaderboard
Share
Learn
Cards (99)
What does DDL stand for in SQL?
Data Definition Language
DDL in SQL is used to define and manage the structure of a
database
Name three common DDL commands in SQL.
CREATE, ALTER, DROP
The CREATE command in
DDL
is used to define new tables.
Within tables, DDL allows you to define columns and their
data types
What are primary keys and foreign keys used for in DDL?
Specifying relationships between tables
The ALTER command in
DDL
can be used to modify the structure of existing tables.
Using the ALTER command, you can add, modify, or delete
columns
What is the purpose of the RENAME command in DDL?
Rename tables
The DROP command in DDL is used to delete entire
tables
.
DDL is a subset of SQL used to define and manage the structure of a
database
What is the purpose of the CREATE command in DDL?
Defines new database objects
What is the purpose of the ALTER command in DDL?
Modifies existing database objects
What is the purpose of the DROP command in DDL?
Removes database objects
The TRUNCATE command in
DDL
empties a table while keeping its structure intact.
The CREATE command in DDL is used to define new database objects, primarily
tables
What is the basic syntax for the CREATE TABLE command in DDL?
CREATE TABLE TableName ( ColumnName1 DataType1, ColumnName2 DataType2, ... );</latex>
What does DDL stand for in SQL?
Data Definition Language
Key DDL commands include CREATE, ALTER, DROP, and
TRUNCATE
What is the primary function of the CREATE command in DDL?
Defines new database objects
The ALTER command in
DDL
is used to modify existing database objects.
The TRUNCATE command empties a table while keeping its
structure
Which DDL command modifies existing database objects?
ALTER
What is the purpose of the DROP command in DDL?
Removes database objects
The TRUNCATE command removes the table structure along with the data.
False
What is the basic syntax for the CREATE TABLE command in DDL?
C
R
E
A
T
E
T
A
B
L
E
T
a
b
l
e
N
a
m
e
(
C
o
l
u
m
n
N
a
m
e
1
D
a
t
a
T
y
p
e
1
,
.
.
.
)
;
CREATE TABLE TableName ( ColumnName1 DataType1, ... );
CRE
A
TET
A
B
L
ET
ab
l
e
N
am
e
(
C
o
l
u
mn
N
am
e
1
D
a
t
a
T
y
p
e
1
,
...
)
;
Common data types used in SQL include INT, VARCHAR, DATE, and
FLOAT
What type of data is stored in a column with the INT data type?
Whole numbers
What is the purpose of the DATE data type in SQL?
Stores calendar dates
Match the primary key feature with its description:
Purpose ↔️ Uniquely identify each row
Usage ↔️ Each table must have one
Values ↔️ Must be unique and non-null
What is an example of a primary key constraint in SQL?
S
t
u
d
e
n
t
I
D
I
N
T
P
R
I
M
A
R
Y
K
E
Y
StudentID INT PRIMARY KEY
St
u
d
e
n
t
I
D
I
NTPR
I
M
A
R
Y
K
E
Y
A table can have multiple primary keys.
False
Primary key values must be unique and non-
null
What is an example of a foreign key constraint in SQL?
CourseID INT FOREIGN KEY REFERENCES Courses(CourseID)</latex>
The
DROP COLUMN
command is used to delete an existing column in a table.
What is the syntax to add a column to an existing table using the ALTER TABLE command?
A
L
T
E
R
T
A
B
L
E
T
a
b
l
e
N
a
m
e
A
D
D
C
O
L
U
M
N
C
o
l
u
m
n
N
a
m
e
D
a
t
a
T
y
p
e
;
ALTER TABLE TableName ADD COLUMN ColumnName DataType;
A
L
TERT
A
B
L
ET
ab
l
e
N
am
e
A
DD
CO
LU
MNC
o
l
u
mn
N
am
eD
a
t
a
T
y
p
e
;
To modify the data type of a column, you use the ALTER TABLE command with the MODIFY
COLUMN
clause.
Order the actions performed on a table using the ALTER TABLE command:
1️⃣ Add a column
2️⃣ Modify a column
3️⃣ Drop a column
What command is used to modify the structure of an existing table in SQL?
ALTER TABLE
To add a column in a table, the syntax is
ALTER TABLE TableName ADD COLUMN ColumnName DataType;
See all 99 cards