Assign 1 DBMS
Assign 1 DBMS
Assignment No. 1
Aim :
Design and develop SQL DDL statements which demonstrates the use of SQL
objects such as Table, View, Index, Sequence, Synonym.
Theory :
DDL Statements
These are the SQL Statements used to define the database structure or
schema.
Ex :
Command Description
CREATE To create objects in database
ALTER To alter the structure of database
DROP To delete objects from database
TRUNCATE To remove all elements from table
RENAME To rename an object
1) CREATE :
Syntax : Create table table_name
(
Col_name datatype;
…
);
2) ALTER :
Syntax : Alter table table_name add( col_name datatype(size), …); Alter
table table_name modify( colname data type (size), … );
Ex :
ALTER TABLE movies DROP rating
3) DROP :
View :
View is simply a subset of table which are stored logically in a database
means a view is a virtual table in a database whose contents are defined by
query.
In the above table if we retrieve data on the basis of salary it will take time
because it is not sorted so,in such cases we can apply index to the column.
Salary Row_Address
30000 R2
35000 R3
55000 R1
Sequence :
Sequence object generates a sequence of numeric values in ascending and
descending order. These values are often used to generate numbers for primary
or unique keys.
Synonym :
In SQL we can provide temporary alternative name to table name or
column name. Synonym are referral to original objects.
Ex :
create Synonym films for movies;
Conclusion :
Thus , In this way we have performed DDL statements which
demonstrates the use of SQL objects such as Table, View, Index, Sequence,
Synonym.