Get the App
SLTechnology News&Howtos  ›  Database  › 

Common sentences of mysql and mysqldb

Shulou Source: shulou.com Published: 2022-06-01 18:27:09 09月30日 Update

Today, the editor will bring you an article that introduces the common sentences of mysql and mysqldb. The editor thinks it is very practical, so I will share it for you as a reference. Let's follow the editor and have a look.

Create database if not exists hidb; # create a library if the library does not exist

Show warnings; # View the most recent db alarm

Alter database hidb character set 'utf-8'; # sets the database character set

Drop database testdb; # deleting a library

Show databases like'% db'; # queries database information ending in db

Help show databases; # help

Create table tbl2 (id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE KEY,name VARCHAR (60) NOT NULL); # create a table structure

Create table tbl2 (id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR (60) NOT NULL,UNIQUE KEY (id,name)); # create table structure

Help desc; # help

Describe city; # query table structure

DESC tbl2; # query table structure

Show engines; # View supported engines

Show table status; # View all table status information

Show table status like 'tablename'\ G; # View single table status information

Show table status where name like 'table'; # View tables that start with table

Show table status where Engine='MyISAM'; # query engine is the table status of MyISAM

Alter table tbl3 ADD gender ENUM ('Fleming recently added M'); # modify the table structure and add enumerated fields

Alter table tbl3 CHANGE id stuid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY; # modify the field name id to stuid

Alter table tbl3 ADD INDEX (name); # create index

Show INDEXES from tbl3; # View all indexes in the table

Alter table tbl3 drop index id; # Delete the index of the id field

Alter table tbl3 drop primary key id; # Delete the primary key of the id field

Create table tbl4 like mysql.user; # create the tbl4 table and copy the table structure from mysql.user

Create table tbl5 select host,user,passwd from mysql.user; # queries the fields and contents of the mysql.user table and puts them in the newly created table

Create index indexname on tabl5 (id); # create index

These are the details of the commonly used sentences in mysql and mysqldb. Have you gained anything after reading them? If you want to know more about it, you are welcome to follow the industry information!

Tags: Structure fields queries indexes information content status commonly used statements engines data databases query tables help practical for this characters character sets that is the beginning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi vpn OPPO Reno Shulou Information NVidia