Professional Documents
Culture Documents
Components of SQL: Assignment - 2
Components of SQL: Assignment - 2
Components of SQL
SQL has 4 major components
DDL (Data Definition Language)
DML (Data Manipulation Language)
DCL(Data Control Language)
DQL (Data Query Language)
If a table name should exceed 30 characters, reduce the size of the table name in
this order:
From the left of the table name, remove vowels from each word in the table
name except for the first vowel of each word.
If a column name should exceed 30 characters, reduce the size of the column name
in this order:
From the left of the column name, remove vowels from each word in the table
name except for the first vowel of each word.
SYNTAX
CREATE TABLE table_name(column1 datatype,column2 datatype,
column3 datatype, ..... columnN datatype );
Example
CREATE TABLE STUDENTS
(
REGNO CHAR(4),
FIRST_NAME VARCHAR2(15),
LAST_NAME VARCHAR2(15),
DOB DATE,
BRANCH VARCHAR2(3),
SUBJECT VARCHAR2(3),
MARK NUMBER(3)
);
DISPLAY THE STRUCTURE OF TABLE
SYNTAX
DESC <TABLENAME>
Example
DESC STUDENTS
ALTER COMMAND:
Alter table command is used to alter the structure of the table Operation performed with
table.
ASSIGNMENT -2
Drop column
SYNTAX
ALTER TABLE table_name DROP COLUMN <COLUMN NAME>;
Example
Alter table employee drop column Branch;
Rename column
SYNTAX
Alter tablename rename column <column_name_old> to <column_name_new>;
Example
Alter table student rename column address to address1;
RENAME COMMAND
The rename command is used to rename the existing table from the database.
SYNTAX
Rename mytable to newtable;
Example
Rename Student to Student_Details
ASSIGNMENT -2
DROP COMMAND
The command is used to delete the table and its description.
SYNTAX
Drop table tablename;
Example
Drop table Student_Details;
TRUNCATE COMMAND
The command is used to delete the table and its description with its memory.
SYNTAX
Truncate table tablename;
Example
Truncate table Student_Details;
COMMENT COMMAND
The command is used to add comment to the data dictionary.
SYNTAX
--single line comment
Example
-- alter table can be possible with rename and delete any specific column
SYNTAX
/* multi line comment
any other comment*/
ASSIGNMENT -2
ASSIGNMENT -2
ASSIGNMENT -2