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

A detailed summary of the sql statement for creating a table by mysql

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

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.

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