Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql creates a sql statement for a table

Shulou Source: shulou.com Published: 2022-06-01 02:37:23 09月26日 Update

This article mainly introduces the sql sentence of mysql creation table, which is very detailed and has certain reference value. Friends who are interested must finish it!

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

These are all the contents of the sql statement that mysql created the table. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Data database statement password user user name host content backup no value interest address field boy partner commonly used datasheet file file name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL vpn Shulou Tech Info Redmi