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

Mysql code building table

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

* * query class *

Use library name-enter the library and use the

Show databases;-query all library names

Select*from Table name-finds all items with the specified table name

Desc table name;-query all column names of the table

Show tables;-query all tables

* * end of query class *

* * create or delete database classes *

Create database database name default charset='utf8';-build a database

Dorp database database name;-Delete a database

Delete table name;-Delete a table

Alter table table name drop column name-deletes a column name from the specified table

Alter table table name add column name type (e.g. varchar) set the number of digits [(e.g. 10)] set properties (such as primary key)-add a column name to the specified table-

* * end of building or deleting database classes *

* * start setting property sheet *

* *

* U: unique (Unique) P: primary key (Primary key) N: non-empty (Not Null) C: (check) *

* *

* D: (add a value after Default) F: (foreign key) (text: choose CHAR or VARCHAR) *

* * set the end of the property sheet *

-- start to build the table--

Create table table name (

Column name (self-defined) type (text type: varchar) [set number of digits (set by yourself)] [set setting properties ()]

Column name (self-defined) type (integer type: int) [set number of digits (set by yourself)] [set property ()]

Column name (self-defined) type (integer type: tinyint) [set number of digits (set by yourself)] [set property ()]

Column name (self-defined) type (decimal type: float) [set number of digits (set by yourself)] [set property ()]

Column name (self-defined) type (decimal type: double) [set number of digits (set by yourself)] [set property ()]

Column name (self-defined) type (decimal type: declmal (mfocus n) [set number of digits (set by yourself)] [set property ()]

-Special

-m represents the number of digits of this number

-n indicates how many places there are after the decimal point.

Column name (self-defined) type (string type char (m)) [set number of digits (set by yourself)] [set property ()]

-m indicates how many characters you set the length, up to 255 characters.

Column name (self-defined) type (string type varchar (m)) [set number of digits (set by yourself)] [set property ()]

-- m indicates that there is no limit to how many characters you set the length.

Column name (self-defined) type (date type date) [set date (set by yourself, such as 1000-1-1)] [set property ()]

Column name (self-defined) type (time type time) [set time (such as 00:00:00)] [set property ()]

Column name (self-defined) type (date-time type datetime) [set date-time (set by yourself, for example, 100,100,100: 00:00)]

[set properties ()]

)

-- end of table creation--

*

* assign values to the columns in the table *

* *

* insert into table name (column name 1, column 2, column name 3.) values (column name 1 value, column name 2 value, column name 3 value,...); *

* *

* Insert into table name values (column name 1 value, column name 2 value, column name 3 value);

* *

* the values of all the column names of this table must be written in the following values *

*

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