DATABASE MANAGEMENT SYSTEMS
CREATE TABLE STATEMENT
CREATE TABLE STATEMENT
Naming Rules and Conventions
➢ SQL is a case insensitive language
➢ The table name must be unique within the database you create it in
➢ The name also cannot be one of the Oracle or SQL reserved words (i.e. SELECT, INTO, VALUES
etc.). You can use reserved words only if you enclose them in double quotes
➢ The first character of an identifier (table/column) name should begin with a letter between A
and Z (or a and z)
➢ The remaining characters can be letters (A to Z or a to z) or numeric digits (0 to 9) or the
symbols: the dollar sign ($), the underscore sign (_) and the pound sign or number sign(#)
➢ It is possible to have an identifier name that is only one character long
➢ White spaces, hyphens (-) and special characters (other than mentioned above) are not
allowed in an identifier’s name
➢ Must not duplicate the name of another object owned by the same user/schema/database
CREATE TABLE STATEMENT
Valid/invalid names
STUDENT
MAJOR$CODE
1200PROJECT
ROBUST_REG_STUDENT_TABLE
#ROBUST_REG_STUDENT_TABLE
STUDENT_COURSE_REGISTRATION_TABLE
MAJOR CODE
CREATE
PROJECT******1200
CREATE TABLE STATEMENT
Data Types
➢ INTEGER or INT
➢ FLOAT
➢ DECIMAL or NUMERIC or NUMBER
➢ CHAR or CHARACTER
➢ VARCHAR
➢ CLOB
➢ BLOB
➢ TRUE/FALSE/UNKNOWN
➢ DATE
➢ TIME
CREATE TABLE STATEMENT
General syntax (सामान्य ससिंटैक्स)
CREATE TABLE STATEMENT
General syntax while creating a child table (चाइल्ड टे बल बनाते समय सामान्य ससिंटैक्स)
Reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT
CREATE TABLE STATEMENT
CASCADE – ON DELETE CASCADE | ON UPDATE CASCADE
➢ Delete or update the row from the parent table and automatically delete or update the
matching rows in the child table.
RESTRICT or NO ACTION – ON DELETE RESTRICT | ON UPDATE RESTRICT
ON DELETE NO ACTION | ON UPDATE NO ACTION
➢ Rejects the delete or update operation for the parent table if there is a related foreign key
value in the referenced table
SET DEFAULT – ON DELETE SET DEFAULT | ON UPDATE SET DEFAULT
➢ provide a DEFAULT value for the column
SET NULL - ON DELETE SET NULL | ON UPDATE SET NULL
➢ Delete or update the row from the parent table and set the foreign key column or columns
in the child table to NULL
CREATE TABLE STATEMENT
Creating a table and viewing a table’s structure
CREATE TABLE STATEMENT
CREATE TABLE STATEMENT
CREATE TABLE STATEMENT
Q1. The Cascade delete option used for what?
A. is used to make sure that all the related records will be deleted automatically when the record
from parent table is deleted
B. it will repeat the currently delete operation to all the records of current table
C. is used to remove all the records of all tables in a database
D. both A and B
CREATE TABLE STATEMENT
Q2. What is the role of “CONSTRAINS” in defining a table in Mysql?
A. Declaring primary key
B. Declaring Foreign Key
C. Restrictions on columns
D. All of the mentioned
CREATE TABLE STATEMENT
Q3. Which command is used to see the table’s structure?
A. DESC table_name;
B. DESC table_name
C. DESC
D. None of the mentioned
CREATE TABLE STATEMENT
Q4. What is the meaning of “REFERENCES” in table definition?
A. Primary key
B. NULL
C. Foreign Key
D. A ”foreign Key” belong to this particular table
CREATE TABLE STATEMENT
Q5. Tables are created by _____.
A. Naming them
B. Defining their Columns
C. Specifying the Data types
D. All of the above