Create Database, - Create Table, - Alter Table, - Create Table With Constraint - Primary Key - Foreign Key - Date Time - Time Stamp
Create Database, - Create Table, - Alter Table, - Create Table With Constraint - Primary Key - Foreign Key - Date Time - Time Stamp
• Create Database,
• Create Table,
• Alter Table,
• Create Table with constraint
• Primary key
• Foreign key
• Date time
• Time stamp
Create database
ADD PRIMARY KEY (ID);
ADD PRIMARY KEY (bktypeid);
Constraint – Not Null
• The NOT NULL constraint enforces a column
to NOT accept NULL values.
publishername …… NOT NULL,
……..
);
Create table dept and
alter with constraints ( Not Null )
ALTER TABLE dept
MODIFY deptdesc varchar(10) NOT NULL;
Create Table
Publisher
Dept
Foreign key in Table
• A FOREIGN KEY is a field (or collection of
fields) in one table, that refers to the
PRIMARY KEY in another table.
Allotment
Book
Book_request
datetime & timestamp
• MySQL comes with the following data types for
storing a date or a date/time value in the database:
• Method 2:
INSERT INTO table_name
VALUES (value1, value2, value3, ...);