Professional Documents
Culture Documents
CREATE TABLE
ALTER TABLE
DROP TABLE
TRUNCATE TABLE
RENAME TABLE
Creating Tables
o DDL command CREATE TABLE is used to create table.
o Syntax
CREATE TABLE tablename
(
columnname1 type(size),
columnname2 type(size),
………………
columnnameN type(size)
);
o Example
(
rollno int,
name varchar(15),
age int,
city varchar(15)
);
describe student1
Deleting a Table
o DROP TABLE is a DDL command
o Syntax:
o DROP TABLE tablename
DM
FIRST WAY:
1. INSERT INTO tablename(col1,col2…) VALUES(value1,value2,
….valueN);
Here specify name of columns for which value is known
2. Imp. Points
a. The values are separated by comma.
b. Character data or date and time data enclosed in single
inverted commas.
c. The number of values must match with number of columns
specified in insert query
d. The type of values must match with type of column in insert
query.
e. The order of values must match with column order in insert
query.
Second Way
1. Syntax 1 is used and for values that is not know we add NULL
Syntax4: specific to MYSQL. Insert multiple rows at one time and use row()
INSERT INTO tablename VALUES ROW(value1,value2,….valueN) ,
ROW(value1,value2,….valueN),
ROW(value1,value2,….valueN),
ROW(value1,value2,….valueN);
WHERE condition;
4. Retrieval of Data
Based on relational algebra and calculus
SELECT DML command is used
Constraints in ORACLE
Rules , restrictions that we can apply to make sure data is always correct, valid and
accurate.
It is also known as constraints.
We can apply constraints using DDL
CREATE TABLE
ALTER TABLE
Types of Constraints (total 6)
NOT NULL constraints
DEFAULT constraints
States that each column must have atleast one value (can be valid or invalid)
It is compulsory to add a value in column.
DEFAULT constraint
States that if value is missing or not available or not known inlace of NULL insert
some valid value known as default value.