Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql creates a sql statement for a table

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report