0% found this document useful (0 votes)
0 views4 pages

rdbms lab exercise

The document outlines the procedure for creating a 'student' table in a MySQL database named 'seq_db' with an auto-incrementing ID. It includes steps for inserting records, altering the sequence value, and verifying the table's contents. The process concludes with a successful creation and manipulation of the table and its records.

Uploaded by

Chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views4 pages

rdbms lab exercise

The document outlines the procedure for creating a 'student' table in a MySQL database named 'seq_db' with an auto-incrementing ID. It includes steps for inserting records, altering the sequence value, and verifying the table's contents. The process concludes with a successful creation and manipulation of the table and its records.

Uploaded by

Chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Ex.No.

7 TABLE CREATION WITH SEQUENCES

Statement of problem
create a table named ‘student’ with sequences

Aim
To create a table named ‘student’ with sequences

PROCEDURE:
Create Database
 CREATE DATABASE seq_db;
show the database
 SHOW DATABASES;
Using the database
 USE seq_db;

Create the 'student' table


 CREATE TABLE student (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
age INT NOT NULL,
grade DECIMAL(4,2) NOT NULL
);
 Desc student;

Insert some records into the 'student' table


 INSERT INTO student (name, age, grade) VALUES
('John Doe', 20, 3.75),
('Jane Smith', 22, 4.00),
('Bob Johnson', 19, 3.25);
Selecting the table
 select * from student;
Finding Sequence value
 select last_insert_id( );

Altering the sequence value


 alter table student auto_increment = 200;
Insert records after changing sequence value
 INSERT INTO student (name,age,grade) VALUES
('David', 21, 3.65),
('Arul', 22, 3.00),
('Newton', 20, 3.45);
Verify the table after changing sequence vlaue
 select * from student;

Result
The mysql query to create a table named ‘student’ with sequences has been done
successfully.
Student Table structure:

Displaying Records:

Finding Sequence value


Display records after changing sequence value

You might also like