To perfect the use MySql database? You need to know these knowledge!

Summary:

1) MySql is a standard language for relational database manipulation and retrieval of
2) in the 1970s, developed by IBM, currently used in all databases

Category 2:
1) Data Query Language (DQL): select statement including, for retrieving from the table (query)
2) Data Manipulation Language (the DML): including insert (insert), update (update), delete CRUD (deleted), the data for
3) transaction language (TPL): including commit (commit) and rollback (rollback), user data commit and rollback
4) data control language (DCL): including grant (authorization) and revoke (withdraw authorization) for rights management
5) data Definition language (DDL): including create (create), drop (delete), alter (modify) for managing database objects
3.sql writing rules statements:
1) case-insensitive
2) can be written in a single line, multiple lines can be written, it is recommended to write multiple lines, enhance code readability

Third, the simple query
1.select * from table
1) statement: a complete sql command
2) clause: part sql statement, usually by keyword together with other syntax elements constitute
3) Keywords: sql language reserved string, such as: sELECT, from
2. select column
1) Search column: *
2) selection column: sELECT DNAME, DEPTNO from Dept
3. arithmetic operators: + - * /

4. Note:
1) - annotation content (navicatformysql: Ctrl + /)
2) annotation content #
3) / multi-line comments /
5. null: null
1) is a valid null value, unassigned, unknown or not with the value (indeterminate value)
2) different from zero or null spaces
3) the result of any arithmetic containing null values are null values
6. the column aliases
to display the title 1) to rename column
2) column alias method:
a) a column ranked alias
b) as the column name column alias
3) contains spaces alias use double quotation enclose the alias if the column
7. eliminate duplicate rows: DISTINCT
the SELECT DEPTNO the DISTINCT, Job from EMP

Fourth, the query restriction data line
1. syntax rules
1) where clause returned records defining
2) from the where clause clause of
listing 3) select column names
from table
where conditions
2. The comparison operators:
1) = equal to
> = Greater than or equal to
> Greater than
<less than
<= less than or equal
<> not equal to
2) a data string to be used in single quotes (double quotes may be), the default is case-insensitive
3) date data using the single quotes up, the date format is compliant with the requirements ( '1982-01-05', '1982/01/05')
3. special comparison operator
1) between ... and ...: determining a range between the two values (comprising comparison value)
2) in (list): determining a set of
example: SELECT * from EMP WHERE DEPTNO in (10,30)
. 3) like: Fuzzy query
a) use wildcards to replace information unknown
b)%: alternative characters may be of any length (0 to any number)
C) _: a character can replace any
4) is null: empty judgment
4. logical operators: and, or, Not
and (and): condition 1 and condition 2, condition 1 and condition 2 We are set up, the whole condition was established
or (or): Condition 1 or Condition 2, conditions 1 and 2 has a set up, on the whole condition is satisfied (correct)
Not (non): Not conditions, taking the opposite of the condition

The priority calculation highest bracket symbol

V. sorting
1. Syntax:
Order by column name {| expression | alias} [ASC | desc]
2.asc: Ascending (small to large), the default value, desc: descending order (descending order)
3.order by column 1, column 2, said: first sorted according to the column 1, if the value of the same column 1, row 2 in accordance with the sort
4. execution order: SELECT from WHERE order by
5.mysql in, null minimum
6 can follow select the sort order of the column numbers starting from sequence number 1
7. Note: sorted column select may not be present after

Mysql there are a lot of knowledge! These are very basic, if wrong, please point out, the next will continue to update!

Published an original article · won praise 1 · views 334

Guess you like

Origin blog.csdn.net/weixin_46318007/article/details/104284599