0% found this document useful (0 votes)
6 views

My SQL

The document discusses 20 MySQL commands with outputs and examples. It covers creating and dropping databases and tables, selecting, inserting, updating, and deleting data, renaming columns, counting rows, and performing calculations on columns.

Uploaded by

gudguy77
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

My SQL

The document discusses 20 MySQL commands with outputs and examples. It covers creating and dropping databases and tables, selecting, inserting, updating, and deleting data, renaming columns, counting rows, and performing calculations on columns.

Uploaded by

gudguy77
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

MY SQL

20 COMMANDS WITH OUTPUTS

1) Create a Database:
CREATE DATABASE `Abdul Rafay and Co.`;
2) Show Databases:
SHOW DATABASES;

3) Use a Database:
Use Abdul Rafay and Co. ;

4) Show Tables:
show tables ;
Currently No tables are there
5) Create a Table:

6) Describe a Table:
DESCRIBE MyEmployeesInfo;

7) Insert Data into a Table:

8) Select Data from a Table:


Select * from MyEmployeeInfo ;
9) Selecting a column from the table :
Select Name from MyEmployeeInfo ;

10) Updating Data in a Table:

11) Delete Data from a Table:


DELETE FROM MyEmployeesInfo WHERE EMPNO = 100;
12) Drop a database :
drop database abdulrafay ;
13) Selecting distinct record:
SELECT DISTINCT DEPARTMENT_ID
FROM MyEmployeesInfo;

14) Renaming a Column in a Table:


ALTER TABLE MyEmployeesInfo RENAME COLUMN SALARY TO SAL;

15) Count Rows in a Table:


SELECT COUNT(*) AS TotalRows FROM MyEmployeesInfo;

16) To display record in Upper Case :


SELECT UCASE(NAME) FROM MyEmployeesInfo;
17) To display record starting with a
particular letter
SELECT * FROM MyEmployeesInfo WHERE NAME LIKE 'H%';
18) TO DISPLAY THE ANNUAL SALARY
(SALARY*12):

19) To display the sum of any column:

20) To drop a table


DROP TABLE MyEmployeesInfo;

You might also like