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

Summary of related essentials of operating MySQL table

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

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.

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