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

mysql-commands(DCML)

The document provides a comprehensive list of commonly used MySQL commands for creating, modifying, and managing databases and tables. It includes commands for database creation, data retrieval, data manipulation, and table management. Each command is briefly described to facilitate practical use.

Uploaded by

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

mysql-commands(DCML)

The document provides a comprehensive list of commonly used MySQL commands for creating, modifying, and managing databases and tables. It includes commands for database creation, data retrieval, data manipulation, and table management. Each command is briefly described to facilitate practical use.

Uploaded by

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

DECIMAL…

Here are some most commonly used MySQL commands, which can be used to create, modify,
and manage databases and tables during practicals:

1) CREATE DATABASE database_name; -

create a new database.

2) USE database_name; -

select a database to use.

3) SHOW DATABASES; -

show a list of all databases.

4) DROP DATABASE database_name; -

delete a database.

5) CREATE TABLE table_name (column1 datatype, column2 datatype, ...); -

create a new table.

6) DESCRIBE table_name; or SHOW COLUMNS FROM table_name; -

show the structure of a table.

7) ALTER TABLE table_name ADD column_name datatype; -

add a new column to a table.

8) ALTER TABLE table_name MODIFY column_name datatype; -

change the data type of a column.

9) ALTER TABLE table_name DROP column_name; -

delete a column from a table.

10) SELECT * FROM table_name; -

retrieve all data from a table.

11) SELECT column1, column2, ... FROM table_name; -

retrieve specific columns from a table.

12) SELECT * FROM table_name WHERE condition;


- retrieve data that meets a certain condition.

13) INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

- insert new data into a table.

14) UPDATE table_name SET column_name = new_value WHERE condition; -

update existing data in a table.

15) DELETE FROM table_name WHERE condition;

- delete data from a table.

16) TRUNCATE TABLE table_name;

- delete all data from a table.

17) DROP TABLE table_name; - CREATE DATABASE database_name; -

USE database_name; -

18) SHOW DATABASES; -


Shows lists of databases
19) DROP DATABASE database_name
Deletes a database
20) CREATE TABLE table_name (column1 datatype, column2 datatype, ...);

Creates a table in database

21) DESCRIBE table_name; or SHOW COLUMNS FROM table_name; -

22) UPDATE table_name SET column_name = new_value WHERE condition; -

-sets existing column name to a new name

23) DELETE FROM table_name WHERE condition;


-Deletes a table according to the condition given

24) TRUNCATE TABLE table_name;


delete a table.

25) CREATE INDEX index_name ON table_name (column_name); -


create an index on a table.

26) SHOW INDEX FROM table_name;


- show all indexes on a table.

27) SELECT COUNT(*) FROM table_name;


- count the number of rows in a table.

28) SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name;


- count the number of rows for each unique value in a column.

29) SELECT MAX(column_name) FROM table_name;


- find the maximum value in a column.

30) SELECT MIN(column_name) FROM table_name;


- find the minimum value in a column.

31) SELECT AVG(column_name) FROM table_name;


- calculate the average value of a column.

32) SELECT SUM(column_name) FROM table_name; -


calculate the sum of values in a column.

33) SELECT column_name FROM table_name ORDER BY column_name ASC;


- retrieve data in ascending order.

34) SELECT column_name FROM table_name ORDER BY column_name DESC;


- retrieve data in descending order.

35) SELECT column_name FROM table_name LIMIT number_of_rows;


- retrieve a specific number of rows from a table.

36) SELECT column_name FROM table_name LIMIT starting_row, number_of_rows;


- retrieve a specific range of rows from a table.

37) SELECT DISTINCT column_name FROM table_name;


- retrieve unique values from a column.

38) SELECT column1, column2 FROM table1 JOIN table2 ON table1.column_name =


table2.column_name; - retrieve data from two tables based on a common column.
39) SELECT column_name FROM table_name WHERE column_name LIKE 'pattern';
- retrieve data that matches a pattern.

40) SELECT column_name FROM table_name WHERE column_name BETWEEN


value1 AND value2;
- retrieve data

41) ALTER TABLE table_name ADD column_name datatype; -

-add new column to existing table

42) ALTER TABLE table_name MODIFY column_name datatype;

-modify a column of a existing table

43) ALTER TABLE table_name DROP column_name; -


-delete a column from a table

44) SELECT * FROM table_name; -


-select all columns of a table

45) SELECT column1, column2, ... FROM table_name; -


Select the specify columns from the table which is column1 and column2

46) SELECT * FROM table_name WHERE condition;


Select column according to the condition given

47) INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
-helps insert values into the columns.

DECIMAL…
(YOUR SUCCESS IS OUR CONCERN)

You might also like