DBMS_lab[1]
DBMS_lab[1]
3. Performance Enhancement:
o Improve query execution speed through proper indexing and data retrieval
methods.
o Help the DBMS understand how to process and display the stored data.
o Define the permissible operations (e.g., arithmetic on numbers, concatenation
on strings).
1
Database Management Systems Lab Rohit Kumar
BTCS 505-18 2224525
o Examples: DATE, TIME, TIMESTAMP, DATETIME.
4. Binary Data Types:
Show Database :- The SHOW DATABASES statement in MySQL is used to display all
databases that exist on the MySQL server to which the user is connected. It provides a list of
all databases that the user has access to, based on their permissions.
Use Database :- The USE statement in MySQL is used to select a particular database to work
with. After executing the USE command, all subsequent SQL queries will apply to the
2
Database Management Systems Lab Rohit Kumar
BTCS 505-18 2224525
selected database unless another database is explicitly specified. It essentially sets the default
database for the current session.
Insertion :- The INSERT statement in MySQL is used to add new rows (records) to a table.
You can insert a single row or multiple rows at once. The values provided in the INSERT
statement must match the order and data types of the columns in the table.
3
Database Management Systems Lab Rohit Kumar
BTCS 505-18 2224525
insert into allstudent values(103,"Rohan Raj","darbhanga","CSE",22,'2001-10-4');
insert into allstudent values(104,"Ritesh Kumar","Supaul","CSE",20,'2004-11-9');
Select Statement :- The SELECT statement in MySQL is used to retrieve data from one or
more tables in a database. The result is stored in a result table (called the result set). The
SELECT statement can be customized to fetch specific columns, filter rows, sort data, group
results, and much more.
Conditional Retrieval of Rows :- Conditional retrieval of rows in MySQL is done using the
WHERE clause in the SELECT, UPDATE, or DELETE statements. The WHERE clause
filters the rows based on specific conditions or criteria. It retrieves only the rows that meet
the condition(s) specified. You can use a variety of operators and functions to define
conditions, such as comparison operators, logical operators, pattern matching, and more.
4
Database Management Systems Lab Rohit Kumar
BTCS 505-18 2224525
Alter Statement :- The ALTER statement in MySQL is used to modify an existing table's
structure. It allows you to add, delete, or modify columns, as well as change other table
properties like indexes, constraints, and even rename the table itself. The ALTER statement is
essential for maintaining the flexibility of a database as the data model evolves over time.
Drop Statement :- The DROP statement in MySQL is used to delete database objects such as
tables, databases, indexes, or views. Once an object is dropped, it is permanently removed
from the database, including all of its data and associated metadata. The DROP statement is a
powerful command and should be used with caution, as it cannot be rolled back unless you
have a backup.
Syntax :- alter table table_name drop column_name ;
Example:-
alter table student_detail drop CGPA;
describe ;
5
Database Management Systems Lab Rohit Kumar
BTCS 505-18 2224525
Drop table student_details;
show tables;
Rename :- The RENAME statement in MySQL is used to change the name of a table or a
column. It allows you to update the names of these database objects without having to
recreate them. This can be useful for correcting naming errors, improving naming
conventions, or simply renaming objects to better reflect their purpose.
Syntax :- alter table table_name rename column old_column_name to new_column_name;
Example :-
alter table student_details rename column class to department;
describe student_details;
6
Database Management Systems Lab Rohit Kumar
BTCS 505-18 2224525
Truncate Statement :- The TRUNCATE statement in MySQL is used to quickly remove all
rows from a table, effectively emptying the table while retaining its structure (schema) for
future use. Unlike the DELETE statement, which removes rows one at a time and can be
slower, TRUNCATE is a more efficient way to clear out large amounts of data. It does not
generate individual row delete operations and typically executes faster.
Syntax :- truncate table student_details;
Example :-
truncate table student_details;
select*from student_details;