A detailed summary of the sql statement for creating a table by mysql
Mysql creates a sql statement for a table
SQL statements are commonly used in mysql table creation:
Connection: mysql-h host address-u user name-p user password (note: U and root can not add spaces, others are the same)
Disconnect: exit (enter)
Create authorization: grant select on database. * to user name @ login host identified by\ "password\"
Change password: mysqladmin-u username-p old password password new password
Delete authorization: revoke select,insert,update,delete om *. * from test2@localhost
Show database: show databases
Display data sheet: show tables
Show table structure: describe table name
Create Library: create database Library name
Delete library: drop database library name
Use Library (selected Library): use Library name
Create table: create table table name (list of field settings)
Delete table: drop table table name
Modify the table: alter table T1 rename T2
Query table: select * from table name
Empty table: delete from table name
Backup table: mysqlbinmysqldump-h (ip)-uroot-p (password) databasename tablename > tablename.sql
Recovery table: mysqlbinmysql-h (ip)-uroot-p (password) databasename tablename
< tablename.sql(操作前先把原来表删除) 增加列:ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT,ADD INDEX (c); 修改列:ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20); 删除列:ALTER TABLE t2 DROP COLUMN c; 备份数据库:mysql\bin\mysqldump -h(ip) -uroot -p(password) databasename >Database.sql
Restore the database: mysql\ bin\ mysql-h (ip)-uroot-p (password) databasename
< database.sql 复制数据库:mysql\bin\mysqldump --all-databases >All-databases.sql
Repair the database: mysqlcheck-A-o-uroot-p54safer
Text data import: load data local infile\ "File name\" into table table name
Data import and export: mysql\ bin\ mysqlimport database tables.txt
The above are the details of the sql statement of mysql to create the table, the knowledge point is very simple, I hope the content can help you.