0% found this document useful (0 votes)
29 views

1 Data Definition Language

The document discusses SQL DDL commands like CREATE, ALTER, and DROP used to define and modify database tables. It shows the CREATE command being used to define two tables - student and employee, with the employee table defining various column constraints. The ALTER command is demonstrated modifying an existing column's data type and adding a new column. And the DROP command deletes the employee table.

Uploaded by

12viji
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

1 Data Definition Language

The document discusses SQL DDL commands like CREATE, ALTER, and DROP used to define and modify database tables. It shows the CREATE command being used to define two tables - student and employee, with the employee table defining various column constraints. The ALTER command is demonstrated modifying an existing column's data type and adding a new column. And the DROP command deletes the employee table.

Uploaded by

12viji
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

DATA DEFINITION LANGUAGE (DDL) COMMANDS

CREATE COMMAND:
SQL> create table student (Regno number(10),Name char(15),Course char(18));
Table created.
SQL> desc student;
Name
Null? Type
----------------------------------------- -------- ---------------------------REGNO
NUMBER(10)
NAME
CHAR(15)
COURSE
CHAR(18)
SQL> commit;
Commit complete.
CREATE TABLE USING ALL CONSTRAINTS:
SQL> create table employee (Empno number(15) primary key, Name char(12) not null,
2 design char(12) unique, salary number(10,2) check(salary>5000));
Table created.
SQL> desc employee;
Name
Null? Type
----------------------------------------- -------- ---------------------------EMPNO
NOT NULL NUMBER(15)
NAME
NOT NULL CHAR(12)
DESIGN
CHAR(12)
SALARY
NUMBER(10,2)
ALTER COMMAND:
ALTER TABLE ( TO MODIFY A FIELD)
SQL> alter table employee modify (Name char(20));
Table altered.

DISPLAY THE SCHEMA


SQL> desc employee;
Name
Null? Type
----------------------------------------- -------- ---------------------------EMPNO
NOT NULL NUMBER(15)
NAME
NOT NULL CHAR(20)
DESIGN
CHAR(12)
SALARY
NUMBER(10,2)

ALTER TABLE ( TO ADD A FIELD)


SQL> alter table employee add (phoneno number(12));
Table altered.
DISPLAY THE SCHEMA
SQL> desc employee;
Name
Null? Type
----------------------------------------- -------- ---------------------------EMPNO
NOT NULL NUMBER(15)
NAME
NOT NULL CHAR(20)
DESIGN
CHAR(12)
SALARY
NUMBER(10,2)
PHONENO
NUMBER(12)
DROP TABLE :
SQL> drop table employee;
Table dropped.

You might also like