Display Database
Show
Enter the specified database
Use database name
- Create a database
Create database name default character Set=utf8
- Deleting a database
Drop database name
Second, the operation of the database table
- To create a table:
Create Tabale studentinfo (name varchar (not null,sex char(ten) null,age int (5), Phone bigint (one)) Studentinfo The name of the table you created
- Delete a table
drop table name;
- Add Table Data
# add one data at a time Insert into Studentinfo (name,sex,age) VALUES ( " Lai poetry ", " female , " 12 )
# add more than one data at a time Insert into Studentinfo (name,sex,age) VALUES ( " Lai poetry ", " female , " 21 "), (" poetry ", " female , " 22 " ) insert into table name (field name, multiple at, interval) values (specific values multiple at, interval)
- Modify
' Li Poetry ' ' Poems of Small poems '
- Delete
from table name where condition
Simple query of database tables (a simple small example)
- Find all people
from people
- Only the person's name and age are queried
from people
- What are the people aged 20?
from ' - '
- What are the people who look for a 60-year-old?
SELECT * from people where P_age < " Span style= "COLOR: #800000" >60 " Find people ages 60 years old Select * from people where p_age <> " 60 " (recommended, official) Select * from people where p_age! = Span style= "COLOR: #800000" > " 60 " Span style= "COLOR: #000000" > (unconventional) common logical operators <, =, <=, >=, <>,! =
- What are the people over the age of 50 who have a salary greater than 8000?
from people where p_age > 50 | | P_sal < 8000# Note: and is used to connect two conditional representations and meaning #or to connect two conditional representations or meanings
- Find the person surnamed Zhang
from p_name like ' Zhang% ',
SELECT * from Prople wherer p_name like '% sheet% '
# There's a word in the middle #
- Find out which people belong to the Wudang Huashan Songshan
SELECT * fromPeople where P_menpai ='Wudang' orP_menpai ='Huashan' orP_menpai ='Songshan'; Select* fromPeople where P_menpaiinch('Wudang','Huashan','Songshan');#No: not in
- What are the people who inquire about the salary at 5000-8900?
from and P_sal <= 8900 from and 8900;
- Query all people, ask for a sort of reverse wage
from people where p_sal > The ORDER by p_sal ask
- Find the leader of a person aged 21 years
# Select P_learder from people where p_age = ' + ' # SELECR * from people where p_id = ' p003 ' from'+')
MySQL basic operation (emphasis)