Query, add, delete, and modify databases. Mysql does not take a long time to learn. database operations simply add records, search records, delete records, and modify records. We have summarized the following commands to share with you: the connection command: mys does not take long to learn mysql, and database operations simply add records, search records to delete records, and modify records.
Summarize the following commands to share with you:
Connection command: mysql-h [host address]-u [user name]-p [user password]
Create database: create database [database name]
Show all databases: show databases;
Open Database: use [Database name]
Status of the currently selected DATABASE: select database ();
CREATE a data TABLE: create table [TABLE name] ([field name] [field type] ([field requirements]) [field parameters], ......);
Display the data table field: describe table name;
Current database data table structure: show tables;
Change Table
Alter table [TABLE name] add column [field name] DATATYPE
Note: add a column (the syntax of a column is not deleted.
Alter table [TABLE name] add primary key ([field name])
Note: You can change the table definition to set a column as a primary key.
Alter table [TABLE name] drop primary key ([field name])
Delete the definition of the primary key.
Show columns from tablename;
Delete database: drop database [database name];
Delete table: drop table [table name];
Data operations
Add: insert into [table name] VALUES ('','',... ordered data );
Query: SELECT * FROM [table name] WHERE ([condition]);
Create index [INDEX file name] ON [table name] ([field name]);
DELETE: delete from [table name] WHERE ([condition]);
Modify: UPDATE [table name] SET [modification content such as name = 'Mary '] WHERE [condition];
Import external data text:
1. execute external SQL scripts
Run mysql <input. SQL on the current database.
Run the following command on the specified database: mysql [table name] <input. SQL
2. data import command load data local infile "[file name]" into table [table name];
Back up the database: (under dos)
Mysqldump -- opt school> school. bbb
Bytes. Summarize the following commands to share with you: connection command: mys...