SQL All Commands
Here is a list of common MySQL commands, categorized by their usage. This covers creating, managing, and interacting with databases and tables.
1. Database Commands
Create a new database:
Select a database to use:
Show all databases:
Delete a database:
2. Table Commands
Create a new table:
Show all tables in the selected database:
Show table structure (schema):
Rename a table:
Drop a table:
Add a column to a table:
Modify a column in a table:
Drop a column from a table:
3. Data Manipulation Commands
Insert data into a table:
Insert multiple rows:
Select data from a table:
Select all data from a table:
Update data in a table:
Delete data from a table:
4. Index Commands
Create an index:
Drop an index:
5. Constraints
Add a primary key constraint:
Add a foreign key constraint:
Drop a constraint:
6. Joins
Inner Join:
Left Join:
Right Join:
7. Aggregate Functions
Count rows:
Sum a column:
Average a column:
Max value in a column:
Min value in a column:
8. User Management
Create a new user:
Grant privileges to a user:
Revoke privileges from a user:
Show all users:
Delete a user:
9. Backup and Restore
Backup a database (from the command line):
Restore a database (from the command line):
10. Miscellaneous
Show current user:
Show current date and time:
Show server status:
This is a broad overview of common MySQL commands that you'll frequently use in database operations.
Comments
Post a Comment