0% found this document useful (0 votes)
10 views3 pages

PS02 (2583852)

The document contains 7 examples of using DDL commands like CREATE TABLE, INSERT, and DROP TABLE in MySQL. The examples create and populate tables for pastries, people, employees, jobs, countries, job history, and employees with different column definitions, constraints, and relationships between the tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

PS02 (2583852)

The document contains 7 examples of using DDL commands like CREATE TABLE, INSERT, and DROP TABLE in MySQL. The examples create and populate tables for pastries, people, employees, jobs, countries, job history, and employees with different column definitions, constraints, and relationships between the tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

• problem Statement2: DDL Commands in MySQL EMP ID:2583852

NAME: Vishnu kumar.B

#1. CREATE TABLE Pastries(

Name Varchar(50),

Quantity int);

DESCRIBE Pastries;

DROP TABLE Pastries;

#2. CREATE TABLE People(

First_name VARCHAR(20),

Last_name VARCHAR(20),

Age INT);

INSERT INTO People (first_name,last_name,age) values

(‘Tina’,’Belcher’,13),

(‘Bob’,’Belcher’,42);

INSERT INTO People (first_name,last_name,age) values

(‘Linda’,’Belcher’,45),

(‘Phillip’,’Frond’,38),

(‘Calvin’,’Fischoedor’,70);

#3. CREATE TABLE Empolyees(

Id_number INT AUTO_INCREMENT PRIMARY KEY,


Last_name TEXT NOT NULL,

First_name TEXT NOT NULL,

Middle_name TEXT,

Age INT NOT NULL,

Current_status VARCHAR(50) DEFAULT ‘employed’ NOT NULL );

#4. CREATE TABLE jobs(

job_id INT PRIMARY KEY,

job_title VARCHAR(40) NOT NULL,

min_salary DECIMAL(8,2),

max_salary DECIMAL(8,2) CHECK (max_salary <= 25000) );

#5. CREATE TABLE countries(

country_id INT PRIMARY KEY,

country_name VARCHAR(40) NOT NULL,

region_id INT NOT NULL,

CONSTRAINT chk_country CHECK (country_name IN('Italy','India','China')) );

#6. CREATE TABLE job_history (

employee_id INT NOT NULL,

start_date DATE NOT NULL,

end_date DATE NOT NULL,

job_id INT ,

department_id INT NOT NULL,

PRIMARY KEY (employee_id, start_date),

CONSTRAINT fk_job_history_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id)) ;

#7. CREATE TABLE employees (

employee_id INT NOT NULL PRIMARY KEY,


first_name VARCHAR(20) NOT NULL,

last_name VARCHAR(20) NOT NULL,

job_id INT,

salary DECIMAL(8,2) NOT NULL,

CONSTRAINT fk_employees_job_id FOREIGN KEY (job_id) REFERENCES jobs (job_id) ON DELETE

CASCADE ON UPDATE RESTRICT )

ENGINE=InnoDB

You might also like