0% found this document useful (0 votes)
39 views4 pages

03 Exp3 Abhishek

The document discusses using DDL and DML commands to create and populate a database. It shows how to create a table using DDL, insert and manipulate data using DML commands like INSERT, UPDATE, DELETE, and SELECT. Examples are provided to create a table called "steproy", populate it with sample data, rename the table, add and alter fields, and finally drop the table. Another table "jash3998" is then created, data is inserted, updated, deleted and selected from it using DML commands to demonstrate populating the database.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

03 Exp3 Abhishek

The document discusses using DDL and DML commands to create and populate a database. It shows how to create a table using DDL, insert and manipulate data using DML commands like INSERT, UPDATE, DELETE, and SELECT. Examples are provided to create a table called "steproy", populate it with sample data, rename the table, add and alter fields, and finally drop the table. Another table "jash3998" is then created, data is inserted, updated, deleted and selected from it using DML commands to demonstrate populating the database.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EXP.

3 Create and populate database using Data Definition Language (DDL) and DML
Commands for you‘re the specified System.
Aim: Create and populate database using Data Definition Language (DDL) and DML

Commands for you‘re the specified System.

Theory: DDL Commands


Create a table

SQL> create table steproy


2 (
3 sname varchar(20),
4 age int,
5 roll int,
6 dob date,
7 gender char,
8 primary key(roll)
9 );

Table created.
Display the table description

SQL> desc steproy

Name Null? Type


---------------------------------------- ----------- ----------------------------
SNAME VARCHAR2(20)
AGE NUMBER(38)
ROLL NOT NULL NUMBER(38)
DOB DATE
GENDER CHAR(1)

Rename the table

SQL> rename steproy to roystep;

Table renamed.
SQL> desc roystep;
Name Null? Type
---------------------------------------- ----------- ----------------------------
SNAME VARCHAR2(20)
AGE NUMBER(38)
ROLL NOT NULL NUMBER(38)
DOB DATE
GENDER CHAR(1)

Alter the table

SQL> alter table roystep modify (sname varchar (11));

Table altered.

Alter the table

SQL> alter table roystep add (sname varchar (11));

Table altered.

Drop the table

SQL>drop table roystep;

Table dropped

DML:-DATA MANIPULATION LANGUAGE


SQL> create table jash3998(pid number,pname char(10),page number,dob date,jtime
timestamp);

Table created.
SQL> insert into jash3998 values(1,'JASH',20,'03-sep-1998','23-jun-2007,10.00.00.000000
AM');

1 row created.

SQL> insert into jash3998 values(2,'VIKAS',20,'19-aug-1998','24-jun-2007,10.00.00.000000


AM');

1 row created.

SQL> insert into jash3998 values(3,'DIKSHA',20,'22-may-1998','25-jun-2007,10.00.00.000000


AM');

1 row created.

SQL> insert into jash3998 values(4,'MEHAJ',20,'27-oct-1998','29-jun-2007,10.00.00.000000


AM');

1 row created.
SQL> select * from jash3998;

PID PNAME PAGE DOB JTIME


---------- ---------- ---------- --------- ---------------------------------------------------------
1 JASH 20 03-SEP-98 23-JUN-07 10.00.00.000000 AM
2 VIKAS 20 19-AUG-98 24-JUN-07 10.00.00.000000 AM
3 DIKSHA 20 22-MAY-98 25-JUN-07 10.00.00.000000 AM
4 MEHAJ 20 27-OCT-98 29-JUN-07 10.00.00.000000 AM

SQL> update jash3998


2 set pname='DIKSHA.G'
3 where pid=3;

1 row updated.

SQL> select * from jash3998;

PID PNAME PAGE DOB JTIME


---------- ---------- ---------- --------- ---------------------------------------------------------
1 JASH 20 03-SEP-98 23-JUN-07 10.00.00.000000 AM
2 VIKAS 20 19-AUG-98 24-JUN-07 10.00.00.000000 AM
3 DIKSHA.G 20 22-MAY-98 25-JUN-07 10.00.00.000000 AM
4 MEHAJ 20 27-OCT-98 29-JUN-07 10.00.00.000000 AM

SQL> delete from jash3998


2 where pid=4;

1 row deleted.

SQL> select * from jash3998;

PID PNAME PAGE DOB JTIME


---------- ---------- ---------- --------- ---------------------------------------------------------
1 JASH 20 03-SEP-98 23-JUN-07 10.00.00.000000 AM
2 VIKAS 20 19-AUG-98 24-JUN-07 10.00.00.000000 AM
3 DIKSHA.G 20 22-MAY-98 25-JUN-07 10.00.00.000000 AM

CONCLUSION: DDL and DML Commands are executed successfully.

You might also like