Get the App
SLTechnology News&Howtos  ›  Database  › 

Summary of related essentials of operating MySQL table

Shulou Source: shulou.com Published: 2022-06-01 17:22:44 09月10日 Update

The following is about the essentials of manipulating MySQL tables. The secret of the text lies in being close to the topic. So, no gossip, let's read the following directly, I believe you will benefit from reading this article related to the operation of the MySQL table.

Edit instructions using the editor

Edit

Create a tabl

Create table table name (

Field 1, type [width] constraint)

= in the same table, the field name cannot be the same

= = width and constraints are optional

Field name and type are required

View tabl

Show tables

Desc ; view table structure

Show create table

Show table status like ''\ G

Modify the table:

Alter modifies table name, modifies field name, modifies field data type, modifies field modifier

Insert insert data

Delete delete data

Update updates data

Modify table name

Rename table to xixi

Alter table hh rename xixi

Add a new field

Alter table T1 add math int (10)

Alter table T1 add (chinese int (10)), english int (10))

Modify the field database type. The modifier alter can only change the database type, not the name.

Alter table T1 modify chinese int (5) not null

Modify name, data type, modifier

Alter table T1 change chinese china int (6)

First after

Alter table T1 change english en int (6) after id

Alter table T1 modify en int (6) first

Delete a field

Alter table t1 drop en

Insert data (add record)

Strings must be enclosed in quotation marks

Mysql > insert into T1 (id,name,math,china) values (1, "wing", 80 ~ 90)

Mysql > insert into T1 (id,name,math,china) values (2, "king", 70100), (3, "tom", 50 and 70)

Mysql > insert into T1 values (4, "xiaosan", 50100)

Mysql > insert into T1 (id,math) values (5Jing 70)

Mysql > insert into T1 set id=6,math=65

Update record

Mysql > update T1 set name= "lili" where id=5

Delete record

Mysql > delete from T1 where id=6

Mysql > delete from T1; / / Delete all records

Table replication: key is not replicated: primary key, foreign key, and index

Copy a table

Mysql > create table T10 (select * from T3)

Mysql > create table T10 (select id,name from T3)

Copy table structure

Mysql > create table T4 (select * from T3 where 54th)

Mysql > create table T4 (select id,name from T3 where 554)

Copy record

Mysql > insert into T3 select * from T10 where id=9

Delete tabl

Mysql > drop table T1

Delete Library

Mysql > drop database gnu

For the above operation of the MySQL table related to the relevant content, is there anything you do not understand? Or if you want to know more about it, you can continue to follow our industry information section.

Tags: Field data type name meaning width database condition structure update same following subject content place secret character string quotation mark instruction Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple Shulou Technology Redmi Shulou Information