0% found this document useful (0 votes)
7 views5 pages

DBMS 1

DBMS

Uploaded by

manishverma22011
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)
7 views5 pages

DBMS 1

DBMS

Uploaded by

manishverma22011
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/ 5

PROGRAM NO.

:- 01
Objective :

1) Show Databases :- Show databases lists the databases on the MySQL server host.
Syntax : SHOW DATABASES;
Ex : show databases;
Output :

2) Create database :- This command is used to create a new database in SQL.


Syntax : CREATE DATABASE database_name;
Ex : create database manish;
Output :

3) Drop Database :- This command deletes all user data and log files as well as backup data and restore
database history.
Syntax : DROP DATABASE database_name;
Ex : drop database manish;
Output :

4) Use Database :- This command is used when there are multiple databases in the SQL and user specially
wants to use a particular database.
Syntax : USE database_name;
Ex : use manish;
Output :

5) Create Table :- This command is used to define and create a new table within a relational database.
Syntax : CREATE TABLE table_name(column 1 datatype, column 2 datatype, ….);
Ex : create table people(id int(10) Primary key, name varchar(50) not null, city varchar(10));
Output :

6) Show tables :- This command lists the non-temporary tables in a given database.
Syntax : SHOW TABLES;
Ex : show tables;
Output :

7) Describe Table :- Displays metadata about the columns, indexes and data partitions of tables or views.
Syntax : DESC table_name;
Ex : desc people;
Output :

8) Insert Values :- This command is used to insert new rows into a database table.
Syntax : INSERT INTO table_name(column 1, column 2, ….) VALUES(value 1, value 2, …);
Ex :
Output :

9) Select :- Thid command retrieve data from all columns that object in the FROM clause.
Syntax : SELECT * FROM table_name;
Ex : select * from people;
Output :
10) Alter Table :- This command adds, delete or modifies column in a table.
Syntax : ALTER TABLE table_name ADD new_column datatype;
Ex : alter table people add phone int(10);
Output :

11) Update Table :- This command is used to update existing rows in a table.
Syntax : UPDATE table_name SET [column name = values] [WHERE = Condition];
Ex :
Output :

12) Select Row :- This command select rows by creating a row condition.
Syntax : SELECT * FROM table_name [WHERE Condition];
Ex : select * from people where id=5;
Output :
13) Alter Column Name :- This command used to rename a column name in table.
Syntax : ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;
Ex : alter table people rename column id to pe_id;
Output :

14) Distinct :- This command used to retrieve unique values from a specified column or set of columns in a
database table.
Syntax : SELECT DISTINCT column_name FROM table_name;
Ex : select distinct name from people;
Output :
15) Truncate :- This command used to delete the complete data from the table without deleting the table
structure.
Syntax : TRUNCATE TABLE table_name;
Ex : truncate table emp;
Output :

16) Delete Row :- This command is used to delete a row by creating row condition.
Syntax : DELETE FROM table_name [WHERE Condition];
Ex : delete from people where pe_id=8;
Output :

You might also like