Chapter-13-Table Creation and Data Manipulation Commands - NOTES
Chapter-13-Table Creation and Data Manipulation Commands - NOTES
1. What are different divisions of SQL and commands? Give examples of commands in each
division.
2. What is foreign key? How do your define a foreign key in your table?
3. How is FOREIGN KEY commands different from PRIMARY KEY command?
6. What are table constraints? What are column constraints? How are these are
different?
7. What is default value? How do you define it? What is the default value of column for
which no default is define?
Default values, in the context of databases, are preset values defined for a column type. Default values are
used when many records hold similar data.
The DEFAULT constraint is used to set a default value for a column. The default value will be added to all new
records, if no other value is specified.
If you specify no default value for a column, the default is NULL unless you place a NOT NULL constraint on the
column.
8. Differentiate between
a. DROP TABLE DROP DATABASE
b. DROP TABLE DROP clause of ALTER TABLE
Q1. Insert all those records of TABLE Accounts into TABLE Pending WHERE amt_outstanding is more
than 10000.Query if you have already CREATEd TABLE Pending :-
UPDATE Empl
SET comm = comm + 500
WHERE hiredate between “1982-01-01” and “1982-12-31” ;
4. Allocate the department situated in BOSTON to employee with employee number 7500 (TABLEs EMPL,
Dept).
TABLE ----
update Empl
set grade = 1
where sal between 700 and 1500 ;
update Empl
set grade = 2
where sal between 1500 and 2200 ;
update Empl
set grade = 3
where sal between 2200 and 3000 ;
update Empl
set grade = 4
where sal = 3000 ;
10. Add a constraint (NN-Grade) in table Empl that declares column Grade not null.
11. Insert a record of your choice in table Empl. Make sure not to enter Grade.
Insert into Empl(empno , ename , job , mgr , hiredate ,sal ,comm , deptno ) values( 8935, “Path wala ”,
“SALESMAN”,8862 , “1993-06-25” ,1000 , 110.00, 10 )
NOTE:- It will return error because we did not enter Grade. grade should have a value
12. Modify the definition of column Grade. Increase its size to 2.
Insert into Customer values ( 1234, “Path wala ”, “india”, “up” , 211001 , 1234567890) ;
Insert into Customer values ( 1597, “Portal express”, “india”, “hp” , 245901 , 2468135790) ;
22. Drop the column CustomerlncomeGroup from table Customer.