0% found this document useful (0 votes)
168 views3 pages

Data Definition Language - DDL: Create Table

The document discusses several data definition language (DDL) commands in SQL including CREATE TABLE to create a table, ALTER TABLE to add, modify, or drop columns, DESCRIBE TABLE to view the table structure, TRUNCATE TABLE to empty the table without deleting it, and DROP TABLE to delete the table. Examples are provided of each command being used to define and manipulate a student table.

Uploaded by

Govarathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
168 views3 pages

Data Definition Language - DDL: Create Table

The document discusses several data definition language (DDL) commands in SQL including CREATE TABLE to create a table, ALTER TABLE to add, modify, or drop columns, DESCRIBE TABLE to view the table structure, TRUNCATE TABLE to empty the table without deleting it, and DROP TABLE to delete the table. Examples are provided of each command being used to define and manipulate a student table.

Uploaded by

Govarathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

DATA DEFINITION LANGUAGE – DDL

CREATE TABLE

SQL> create table student(Reg_No number(15), Name Varchar2(30), Gender varchar2(10), DOB date,
Dept varchar2(10));

Table created.

DESCRIBE TABLE

SQL> desc student;

Name Null? Type

--------------------- -------- ----------------------------

REG_NO NUMBER(15)

NAME VARCHAR2(30)

GENDER VARCHAR2(10)

DOB DATE

DEPT VARCHAR2(10)

ALTER TABLE

(A) ADD

SQL> alter table student add (Batch varchar2(10));

Table altered.

SQL> desc student;

Name Null? Type

---------------------- -------- ----------------------------

REG_NO NUMBER(15)

NAME VARCHAR2(30)

GENDER VARCHAR2(10)

DOB DATE

DEPT VARCHAR2(10)

BATCH VARCHAR2(10)
(B) MODIFY

SQL> alter table student modify (Dept varchar2(20));

Table altered.

SQL> desc student;

Name Null? Type

----------------------- -------- ----------------------------

REG_NO NUMBER(15)

NAME VARCHAR2(30)

GENDER VARCHAR2(10)

DOB DATE

DEPT VARCHAR2(20)

BATCH VARCHAR2(10)

(C) DROP

SQL> alter table student drop (Batch);

Table altered.

SQL> desc student;

Name Null? Type

-------------------- -------- ----------------------------

REG_NO NUMBER(15)

NAME VARCHAR2(30)

GENDER VARCHAR2(10)

DOB DATE

DEPT VARCHAR2(20)

TRUNCATE TABLE

SQL> truncate table student;

Table truncated.

SQL> desc student;

Name Null? Type


--------------------- -------- ----------------------------

REG_NO NUMBER(15)

NAME VARCHAR2(30)

GENDER VARCHAR2(10)

DOB DATE

DEPT VARCHAR2(20)

SQL> select * from student;

no rows selected

DROP TABLE

SQL> drop table student;

Table dropped.

SQL> desc student;

ERROR:

ORA-04043: object student does not exist

SQL> select * from student;

select * from student

ERROR at line 1:

ORA-00942: table or view does not exist

SQL>

You might also like