0% found this document useful (0 votes)
14 views6 pages

DBMS Practical 1

The document outlines the objectives and procedures for executing Data Definition Language (DDL) commands in SQL, including commands for creating, altering, dropping, and truncating tables. It provides specific syntax and examples for each command, as well as exercises for creating and modifying tables. The document concludes with exercises on altering table structures, deleting tables, and renaming tables.

Uploaded by

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

DBMS Practical 1

The document outlines the objectives and procedures for executing Data Definition Language (DDL) commands in SQL, including commands for creating, altering, dropping, and truncating tables. It provides specific syntax and examples for each command, as well as exercises for creating and modifying tables. The document concludes with exercises on altering table structures, deleting tables, and renaming tables.

Uploaded by

jyotisharma5964
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
EXPERIMENT NO: 1 DATA DEFINITION LANGUAGE (DDL) COMMANDS To execute and verify the Data Definition Language commands. OBJECTIVES To understand DDL commands. THEORY The commands used are: ®@ CREATE - It is used to create a table. e ALTER = The structure of a table can be modified by using the ALTER TABLE command. This command is used to add a new column, modify the existing column definition and to include or drop integrity constraint. e DROP - It will delete the table structure provided the table should be empty. @ TRUNCATE - If there is no further use of records stored in a table and the structure has to be retained, and then the records alone can be deleted. # DESC - This is used to view the structure of the table PROCEDURE CREATION OF TABLE: SYNTAX: create table(column! datatype,column2 datatype...); EXAMPLE: SQL>CREATE TABLE Employee ( EmpNo number(5), EName VarChar(15), Job Char(10) , DeptNo number(3)); ALTER TABLE (a) To Add column to existing Table ‘Syntax: alter table table-name add(column-name datatype ); ALTER TABLE Employee ADD (phone_no char (20); (b)To Add Multiple columns to existing Table ‘Syntax: alter table table-name add(column-namel datatype, column-name2 datatype2, eolumn-name3 datatype3); EXAMPLE: alter table Employee add(salary number(7), age(5)); (c) Dropping a Column from a Table ‘Syntax: ALTER TABLE
DROP COLUMN ; EXAMPLE: ALTER TABLE Employee DROP COLUMN phone_no ; (d) Modifying Existing Columns ‘Syntax: ALTER TABLE
MODIFY (());, EXAMPLE: ALTER TABLE Employee MODIFY (EName VarChar(25)); (e) To Rename a column Using alter command we ean rename an existing column Syntax: alter table fable-name rename old-column-name to column-name ; EXAMPLE: alter table Employee rename address to Location; RENAMING TABLES: Syntax: Rename to ; EXAMPLE: rename Employee to Employee 1; TRUNCATE TABLE Syntax: TRUNCATE TABLE
; Example: Truncate table Employee; DESTROYING TABLES: Syntax: DROP TABLE
; Example: DROP TABLE Employee; DESCRIBE TABLES ‘Syntax: DESC
; Example: dese employee: RESULT: The DDL commands have been executed successfully Problems 1 Create the tables described below Table Name : PRODUCT_MASTER Description used to store product information ‘Column name Data type size PRODUCTNO: Varchar2 6 DESCRIPTION Varchar2 5 PROFITPERCENT Warchar2 42 UNITMEASURE Warchar2 10 QTYONHAND Number 8 REORDERLVL Number 8 SELLPRICE Number B2 COSTPRICE Number 82 Table Name : CLIENT_MASTER, Description _: used to store client information Column name Data type size CLIENTNO Varchar2 6 NAME Varchar2 20 ADDRESS1 Varchar2 30 ADDRESS? Varchar2 30 cITY Varchar2: 15 PINCODE Number 8 STATE Varchar2, 15 BALDUE Number 10,2 Table Name : SALESMAN MASTER Description : used to store salesman information working for the company Column name Data type size SALESMANNO- Varchar2: 6 SALESMANNAME Varchar2 20 ADDRESS| Varchar2, 30 ADDRESS2 Varchar2 30 cITY Varchar2 15 PINCODE Number 8 STATE Varchar2 15 Table Name ;: STUDENT Description used to store student information Column name Data type size SNO Number 3 SNAME Varehar2 20 AGE Number 3 SDOB Date SMARKI Number az SMARK2 Number 42 SMARK3 Number a4 2. Exercise on altering the table structure (a) Add a column called ‘telephone’ of data type ‘number’ and size ="10" to the Client _Master table. (b)Change the size of Sellprice column in Produet_Master to 10,2 3. Exercise on deleting the table structure along with the data (a)Destroy the table Client_Master along with its data 4, Exercise on renaming the table (a)Change the name of the Salesman_Master table to sman_mast

You might also like