Professional Documents
Culture Documents
Assignment 6 1 Solution
Assignment 6 1 Solution
Assignment 6 1 Solution
Solution:
■ Create the table
CREATE TABLE student1 (
Student_id INT PRIMARY KEY,
student_name VARCHAR(255),
student_age INT,
student_std VARCHAR(10)
);
■ DDL Commands:
1. Alter Table:
ALTER TABLE student1
ADD student_email VARCHAR(255);
2. DROP table:
DROP TABLE student1;
3. Truncate Command:
4. RENAME Command:
ALTER TABLE student1
RENAME TO student_data;
■ DML Commands:
1. Insert Data:
INSERT INTO student1 (Student_id, student_name, student_age,
student_std, student_email) VALUES (6, 'Grace Lee', 17, '11th',
'grace@example.com');
2. Update Data:
UPDATE student1
SET student_age = 20
WHERE Student_id = 3;
3. Delete Data:
4. Select Data:
Select * from student1;
___________________________________________________________________
___________________
Q2. Table name customer1:( Perform TCL command)
Columns : c_id, c_name, c_age, c_billamount
5 rows data:
Solution:
■ Create the table
CREATE TABLE customer1 (
c_id INT PRIMARY KEY,
c_name VARCHAR(255),
c_age INT,
c_billamount DECIMAL(10, 2));
___________________________________________________________________
___________________
Solution:
1. Create the table with a primary key
CREATE TABLE student_details (
Student_id INT PRIMARY KEY,
student_name VARCHAR(255),
student_age INT,
student_std VARCHAR(10)
);
2. Insert 5 rows of data
INSERT INTO student_details (Student_id, student_name,
student_age, student_std)VALUES
(1, 'John Doe', 18, '12th'),
(2, 'Jane Smith', 17, '11th'),
(3, 'Bob Johnson', 19, '12th'),
(4, 'Alice Brown', 16, '10th'),
(5, 'Eva Davis', 18, '11th');
___________________________________________________________________
__________________
Solution:
1. Create the city_info table
CREATE TABLE city_info (
city_id INT PRIMARY KEY,
student_city VARCHAR(255)
);