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

Introduction to Linux environment variables and process address space

Table of contents Linux environment variables and...

Five ways to implement inheritance in js

Borrowing Constructors The basic idea of ​​this t...

Implementing access control and connection restriction based on Nginx

Preface Nginx 's built-in module supports lim...

MySQL transaction isolation level details

serializable serialization (no problem) Transacti...

How to install Solr 8.6.2 in Docker and configure the Chinese word segmenter

1. Environment version Docker version 19.03.12 ce...

JavaScript canvas realizes dynamic point and line effect

This article shares the specific code for JavaScr...

MySQL calculates the number of days, months, and years between two dates

The MySQL built-in date function TIMESTAMPDIFF ca...

Bootstrap FileInput implements image upload function

This article example shares the specific code of ...

JavaScript BOM Explained

Table of contents 1. BOM Introduction 1. JavaScri...

Abbreviation of HTML DOCTYPE

If your DOCTYPE is as follows: Copy code The code ...

How to install elasticsearch and kibana in docker

Elasticsearch is very popular now, and many compa...

MySQL Query Cache Graphical Explanation

Table of contents 1. Principle Overview Query Cac...

Detailed explanation of basic management of KVM virtualization in CentOS7

1. Install kvm virtualization : : : : : : : : : :...

In-depth explanation of the style feature in Vue3 single-file components

Table of contents style scoped style module State...

The latest Linux installation process of tomcat8

Download https://tomcat.apache.org/download-80.cg...