Home > Database > SQL > What is the core and most commonly used operation of the database?

What is the core and most commonly used operation of the database?

angryTom
Release: 2019-07-30 14:57:34
Original
11553 people have browsed it

What is the core and most commonly used operation of the database?

If you want to know more about databases, you can click: SQL tutorial

The core and most commonly used operation of the database is addition, deletion, modification and query. Below we will introduce to you the specific operation syntax of adding, deleting and checking.

Database

Query database: show databases;

Create database: create database library name;

Delete database: drop database database name

Table

Create table: create table table name (field name data type [attribute] [index] 】)

View table structure: desc table name

View table: show tables

Insert data: insert into table name value()

View creation Table information: show create table table name

View the tables of the specified library: show tables where target library name

field

Add: alter table table name add field name data type [Attribute] [Index]

Insert a field after the specified position: alter table table name add field name data type [Attribute] [Index] after the specified field Name

Insert into the first position: alter table table name add field name data type [Attribute] [Index] first

Delete: alter table table name drop field name

Modification: alter table table name change old field new field data type [Attribute] [Index]

Conditional statement: > < >= <= != and or etc.

Data

Add: insert into table name value()

Delete: delete from table name (use with caution, delete the entire table data)

                                                   :                         machines U in Conditional statement

Operator query: select * from table name where id = 1 1

Select * from table name where id < 100

Logical query: select * from Table name where and condition

# SELECT * from table name where or condition

糊 query: Select * from table name when the name like 'value:%a% data) a% (find data starting with a) %a (find data ending with a)

Sorting and restricted query: select * from table name where order by column name desc Desc: indicates from Sort from big to small asc: Indicates sorting from small to large

     select * form table name limit x,y (Column name) from table name

Count: Count the number of times data in a column or columns in the table is calculated

avg: Average value

Max: Maximum value

     min: Minimum value

   sum: The sum is generally used to calculate the price

   Interval query: select * from table name where field between 0 and 10 Find data between 0 and 10

Group query: select displayed column from table name group by reference column

Select name,count(column) from table name group by name

select name,count( content) from table name group by name having count(content) > 5 Having is filtering on the basis of aggregation

Grouping queries are generally used together with aggregation queries

The above is the detailed content of What is the core and most commonly used operation of the database?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template