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

Basic commands commonly used in database-- add, delete, change, check, sort

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Basic commands commonly used in databases:

Show databases; # View the database

Use + database name; # enter the database

Show tables; # View tables in the corresponding database

Select * from info; # View the data in the info table, * representing all the data

Select field from table; # View the specified data, view from the table

Create a database

Create database school; # create a school database

Create tables: be sure to enter the database

For example:

Create table info (id int not null primary key auto_increment,name char (10) not null,score decimal (5jue 2), hobby int (2))

# create a data table named info with attributes of the table (id type int cannot be empty null is the primary key self-increment column, name char (string length is 10) is not null null, maximum score is 5 digits including two decimal places, hobby type is int (2 bytes))

PS details:

Create a table (properties of the table)

Not null: not null

Primary key: primary key

Auto_increment: self-increment column

Char: fixed length string type

Note: M is the maximum number of bytes that can be stored. The maximum number of characters stored is limited by specifying m. Char (20) and varchar (20) can only store up to 20 characters, and characters exceeding it will be truncated. M must be less than the maximum number of characters allowed for this type.

Decimal (5d2): fixed-point precision and decimal places. [maximum 5 digits, including two decimal places]

5 is (significant digits: the total number of maximum decimal digits that can be stored, including the left and right sides of the decimal point. The number of significant digits must be a value between 1 and 38. )

2 is (decimal place: the maximum number of decimal places that can be stored on the right side of the decimal point. The number of decimal places must be from 0 to 4. The number of decimal places can be specified only if the number of significant digits is specified. The default number of decimal places is 0; therefore, 0

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