"Zero-Distance Access to mysql" study notes, zero-Distance Access to mysql
1. add, delete, modify, and query data tables (crud ):
For tables:
Add: create table XXXX
Delete: drop table XXXX
Change: alter table XXXX rename to XXXX
Query: select * from XXXX
For rows:
Add: insert into XXXX (xxxx) values (xxxx)
Insert into XXXX set xxxx = xx, xxxx = xx
Delete: delete from XXXX where xxxx
Change: update table set xxxx = xxxx where xxxx = xxxx
Query: select xxxx from XXXX
For columns:
Add: alter table XXXX add xxxx ()
Delete: alter table XXXX drop xxxx
Change: alter table XXXX change xxxx
Alter table XXXX modify xxxx
Check: show columns from XXXX
2. Operators and functions
Character Functions
Concat () select concat ('hha ','-', 'hdf ')
Concat_ws () select concat_ws ('=', 'A', 'B', 'C ')
Format () select format (125060.752, 2)
Lower () select lower ('hiiho ')
Upper () select upper ('fsfds ')
Left () select left ('fsfds ', 2)
Right () select right ('fsfds ', 2)
Length () select length ('fsfds ')
Ltrim () select ltrim ('fsfds ')
Rtrim () select rtrim ('fsfds ')
Trim () select trim ('fsfds ')
Select trim (leading '? 'From' fs? Fds ')
Select trim (trailing '? 'From' fs? Fds ')
Select trim (both '? 'From' fs? Fds ')
Substring () select substring ('fsfds ', 2, 3)
Select substring ('fsfds ', 2)
Like select 'myufsd' like'm %'
Select * from test where first_name like '% 1% %' escape '1'
% Represents any character
_ Represents any character
Replace () select replace ('fsgasgsfa', 's', 'T ')
3. Numeric Operators
Div Integer Division
4. Comparison operations comply with functions
Not between and
Not in
5. time and date functions
Now ()
Curdate ()
Curtime ()
Date_add ()
Datediff ()
Date_format ()
6. Information Functions
Connection_id ()
Datebase ()
Last_insert_id ()
User ()
Version ()
7. Aggregate functions
...
8. encryption functions
Md5 ()
Password ()