Page 56 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 56
Unit 3: Structured Query Language
3.7.4 Delete Command Notes
Delete Rows
The syntax for this command is-
delete from tablename where [search_conditions];
Example: delete from Student where id=1;
This statement is used to delete the row from Student table where the student id is 1.
Task Use update command in existing table.
3.8 DDL Commands for Creating and Altering
Various DDL (Data Definition Language) commands
1. CREATE to create a new table
2. ALTER to modify the structure of the table
3. DROP to delete the table from the database
Create Command
Create Table
This statement is used to create a table. The syntax for this command is create table tablename
(colname1 datatype [constraint], colname2 datatype [constraint]);
Example: create table Student (id number(4) primary key, Name varchar2(20));
It creates the table Student which has two fields id i.e. Student id and Name i.e. the student name.
The number and varchar2 are the data types of id and Name respectively. Field ‘id’ has the size
4 means it can take id up to 4 digits and same for Name, it can take the size upto 20 characters.
And also added the constraint Primary key to the field ‘id’.
Alter Command
Alter Table
This command is used to add, drop columns in a table. The syntax for this command is
alter table
tablename add colname1 datatype [constraint];
alter table tablename drop column colname1;
Example: alter table Student add DOB date
LOVELY PROFESSIONAL UNIVERSITY 49