0% found this document useful (0 votes)
98 views5 pages

Using of DDL Statements To Create and Manage The Tables: Create Database Create Int Varchar

The document discusses using DDL statements to create and manage tables in databases. It provides examples of creating databases called WEATHER and asad, and tables called STATION, EMPLOYEE, and cus within those databases. A variety of DDL commands are demonstrated, including creating, inserting, altering, renaming, and dropping columns and tables.

Uploaded by

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

Using of DDL Statements To Create and Manage The Tables: Create Database Create Int Varchar

The document discusses using DDL statements to create and manage tables in databases. It provides examples of creating databases called WEATHER and asad, and tables called STATION, EMPLOYEE, and cus within those databases. A variety of DDL commands are demonstrated, including creating, inserting, altering, renaming, and dropping columns and tables.

Uploaded by

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

USING OF DDL STATEMENTS TO CREATE AND MANAGE THE TABLES

• Create a database with your name and add the following table. Also add another column
name salary in this table. And at last drop the table and database.

• Create a WEATHER database and add a table STATION to store information about
weather observation stations:

Add the following columns in table.

1) ID

2) CITY

3) STATE

4) state number

• Create a table EMPLOYEE with following attributes: (Emp_no, E_name, E_address,


E_ph_no, Dept_no, Dept_name, Job_id , Salary).

• Add a new column; HIRE_DATE to the existing relation.

• Change the datatype of JOB_ID from char to varchar2.

• Change the name of column/field Emp_no to E_no.

• Modify the column width of the job field of emp table.

• Delete the column Salary and Add new column Sal

create database asad;

create table cus(

customer_id int,

cust_Name varchar(100),
city varchar(100),S

grade varchar(100),

salesman_id int,

salary varchar(200)

);

insert into cus(customer_id,cust_Name,city,grade,salesman_id,salary)

values(1,'asad','lhr','A',34,5000)

insert into cus(customer_id,cust_Name,city,grade,salesman_id,salary)

values(2,'ali','sahiwal','A',34,5000)

insert into cus(customer_id,cust_Name,city,grade,salesman_id,salary)

values(3,'zain','kashmir','A',34,5000)

insert into cus(customer_id,cust_Name,city,grade,salesman_id,salary)

values(4,'ahmad','islamabad','A',34,5000)

insert into cus(customer_id,cust_Name,city,grade,salesman_id,salary)

values(5,'malik','karachi','B',30,6000)

select * from cus

Drop database asad;

Drop table cus;


create database WEATHER

create table station1(

id int,

city varchar(200),

state varchar(200),

state_Number int

);

create table EMPLOYEE(

Emp_no int,

E_name varchar(200),

E_address varchar(200),

E_ph_no int,

Dept_no int,

Dept_name varchar(200),

Job_id int,

Salary int

);

insert into station1(id,city,state,state_Number)

values(1,'fsd','punjab',12)

insert into station1(id,city,state,state_Number)

values(1,'quetta','balochistan',11)

insert into station1(id,city,state,state_Number)

values(1,'karachi','sindh',13)

insert into station1(id,city,state,state_Number)

values(1,'peshawar','kpk',14)

insert into station1(id,city,state,state_Number)

values(1,'muzafabas','kashmir',15)

select * from station1

insert into EMPLOYEE(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name, Job_id ,


Salary)

values(1,'asad','lhr',12324,234,'English',21,24000)

insert into EMPLOYEE(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name, Job_id ,


Salary)

values(2,'zain','sahiwal',4232,344,'Physics',23,54000)

insert into EMPLOYEE(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name, Job_id ,


Salary)

values(3,'ahmad','kashmir',89244,114,'Chemistry',24,14000)

insert into EMPLOYEE(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name, Job_id ,


Salary)

values(4,'malik','karachi',1234,343,'Computer',26,13000)

insert into EMPLOYEE(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name, Job_id ,


Salary)

values(5,'hamza','isb',2525,240,'Science',255,31000)

select * from EMPLOYEE

alter table EMPLOYEE

add HIRE_DATE varchar(200);

ALTER TABLE EMPLOYEE

ALTER COLUMN JOB_ID varchar(200);

ALTER TABLE EMPLOYEE

RENAME Emp_no TO E_noSS

You might also like