Detailed summary of mysql sql statements to create tables

Detailed summary of mysql sql statements to create tables

mysql create table sql statement

Common SQL statements for creating MySQL tables:

Connection: mysql -h host address -u username -p user password (Note: u and root do not need to have spaces, and the same applies to the others)

Disconnect: exit (Enter)

Create authorization: grant select on database.* to username@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 databases: show databases;

Display data tables: show tables;

Display table structure: describe table name;

Create a library: create database library name;

Delete database: drop database library name;

Use library (select library): use library name;

Create a table: create table table name (field setting list);

Delete table: drop table table name;

Modify the table: alter table t1 rename t2

Query table: select * from table name;

Clear the table: delete from table name;

Backup table: mysqlbinmysqldump -h(ip) -uroot -p(password) databasename tablename > tablename.sql

Restore table: mysqlbinmysql -h(ip) -uroot -p(password) databasename tablename < tablename.sql (delete the original table before the operation)

Add a column: ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT, ADD INDEX (c);

Modify the column: ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE bc CHAR(20);

Delete columns: ALTER TABLE t2 DROP COLUMN c;

Back up the database: mysql\bin\mysqldump -h(ip) -uroot -p(password) databasename > database.sql

Restore database: mysql\bin\mysql -h(ip) -uroot -p(password) databasename < database.sql

Copy the database: 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 is the detailed content of the SQL statement for creating a table in MySQL. The knowledge point is very simple. I hope that the content compiled by 123WORDPRESS.COM can help everyone.

You may also be interested in:
  • How to create a table in mysql and add field comments
  • How to create a table by month in MySQL stored procedure
  • Hibernate4 creates table type=InnDB in MySQL5.1 or above
  • A tutorial on creating tables in MySQL
  • MySQL dynamically creates tables and stores data in tables
  • MYSQL fails to create foreign keys in several situations. Can't create table
  • Solution to the error when connecting to MySQL database in IDEA
  • Django saves pictures to MySQL database and displays them on the front-end page
  • Golang implements the submission and rollback of MySQL database transactions
  • Detailed explanation of the role of the default database after MySQL installation
  • Python3 implements MySQL database connection pool sample code
  • The first step in getting started with MySQL database is to create a table

<<:  Detailed steps to build an NFS file sharing server in Linux

>>:  Detailed explanation of the underlying principle of defineCustomElement added in vue3.2

Recommend

A brief discussion on the specific use of viewport in mobile terminals

Table of contents 1. Basic Concepts 1.1 Two kinds...

Should I use distinct or group by to remove duplicates in MySQL?

Preface About the performance comparison between ...

Analysis and solution of Chinese garbled characters in HTML hyperlinks

A hyperlink URL in Vm needs to be concatenated wit...

Let you understand the deep copy of js

Table of contents js deep copy Data storage metho...

JavaScript implements mouse drag to adjust div size

This article shares the specific code of JavaScri...

How to delete an image in Docker

The command to delete images in docker is docker ...

Detailed tutorial on installing harbor private warehouse using docker compose

Overview What is harbor? The English word means: ...

Some front-end basics (html, css) encountered in practice

1. The div css mouse hand shape is cursor:pointer;...

Detailed steps for installing Harbor, a private Docker repository

The installation of Harbor is pretty simple, but ...

JavaScript implements click toggle function

This article example shares the specific code of ...

Javascript to achieve the drag effect of the login box

This article shares the specific code of Javascri...

Introduction to HTML method of opening link files using hyperlinks

a and href attributes HTML uses <a> to repr...

echars 3D map solution for custom colors of regions

Table of contents question extend Solving the pro...

How to set up vscode remote connection to server docker container

Table of contents Pull the image Run the image (g...