0% found this document useful (0 votes)
17 views9 pages

Mastering Basic Database Commands

This presentation introduces essential database commands for managing databases and tables, crucial for beginners. It covers commands such as CREATE DATABASE, SHOW DATABASES, USE, CREATE TABLE, DROP TABLE, DROP DATABASE, RENAME TABLE, and RENAME DATABASE, along with their syntax and examples. Mastering these commands is fundamental for effective database management.

Uploaded by

kayal13bhavin
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)
17 views9 pages

Mastering Basic Database Commands

This presentation introduces essential database commands for managing databases and tables, crucial for beginners. It covers commands such as CREATE DATABASE, SHOW DATABASES, USE, CREATE TABLE, DROP TABLE, DROP DATABASE, RENAME TABLE, and RENAME DATABASE, along with their syntax and examples. Mastering these commands is fundamental for effective database management.

Uploaded by

kayal13bhavin
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/ 9

Mastering Basic Database

Commands
Welcome to the world of databases! This presentation covers essential
commands. You will learn to manage databases and tables effectively.
These commands are fundamental for database management. Grasping
these commands is crucial for beginners.

by S.BHAVIN Siva
Creating Databases: The CREATE DATABASE
Command
Purpose Syntax Example

The CREATE DATABASE command The syntax is simple: CREATE To create a database named "Bhavin",
creates a new database. It is the first DATABASE database_name;. Ensure the use: CREATE DATABASE Bhavin;.
step in organizing data. database name is unique.
Listing Databases: The
SHOW DATABASES
Command

Purpose Syntax Examples


Use SHOW The syntax is very Common databases
DATABASES to view simple: SHOW include Bhavin,
existing databases. DATABASES;. It Student, Teacher, and
See what databases displays all databases. Test. These are just
are available on the example databases.
server.
Selecting a Database: The USE database_name
Command
Purpose
1 The USE command selects the active database. It specifies which database to work with.

Syntax
2 The syntax is: USE database_name;. This sets the context for queries.

Example
3 To select the "Bhavin" database, use: USE Bhavin;. Now you can query it.
Creating Tables: The CREATE TABLE Command
Purpose
1
CREATE TABLE defines a new table. Tables store
structured data within a database.
Syntax
2
The syntax is: CREATE TABLE table_name
(column1 (datatype), column2 (datatype));
Example
3
Create a "Student" table: CREATE TABLE
Student(rnoint(6) , Name char(35));
Deleting Tables: The DROP
TABLE Command

1 Purpose 2 Syntax
DROP TABLE removes a The syntax is: DROP TABLE
table. This permanently TABLE_NAME;. Use with
deletes the table and its caution!
data.

3 Example
To delete the "Student" table, use: DROP TABLE Student;
Deleting Databases: The DROP DATABASE
Command

Syntax

2 The syntax is: DROP DATABASE


databasename; Exercise extreme
Purpose
caution!
DROP DATABASE deletes an entire 1
database. This removes all tables
and data.
Example
To delete the "Bhavin" database, use:
3
DROP DATABASE Bhavin;.
Renaming Tables: The RENAME TABLE
Command

Purpose
1
RENAME TABLE changes a table's name. This helps with organization.

Syntax
2
The syntax is: ALTER TABLE table_name RENAME TO new_table_name;.

Example
3 To rename "Student" to "Teacher", use: ALTER TABLE
Student RENAME TO Teacher;.
Renaming Databases: The RENAME DATABASE
Command

Purpose
1 RENAME DATABASE renames a database. This requires special privileges.

Syntax
2 The syntax is: ALTER DATABASE [current_database_name] MODIFY
NAME = [new_database_name];.

Example
3 Rename "Bhavin" to "Bhavin Sivakumar": ALTER DATABASE
[Bhavin] MODIFY NAME = [Bhavin Sivakumar];.

You might also like