- inserting data (sql data type): The key values and key insert into
- Method 1: correspondence, a corresponding one of attribute data
insert into t_user(id,username,password,addr,age,score,sex,birthday)
values
(1, 'ha', '12345', 'Henan', 22,99.5, 'M', SYSDATE)
- in this case you can customize which fields (attributes) are not inserted into, for example the following birthday
insert into t_user(id,username,password,addr,age,score,sex)
values
(2, 'la la la', '56789', 'Guizhou', 22,100.0, 'F')
- Method 2: Do not write to insert a field, but this corresponds to the following values of the following fields must be all the fields, indispensable
insert into t_user
values
(3, 'peaches', '56789', 'Guizhou', 22,100.0, 'F', SYSDATE)
insert into t_user
values
(5 'iron Qin', '78945', 'Chinese state', 66, 60, 'M', sysdate)
********************************************************************
- View Data select
--1: View and select data from all keywords, as well as middle *, * represents all fields in a data stripe
- Because t_user following behind with no selector, so the range is to find all the pieces of data
select * from t_user
--2: Find with filter
- (1) find the "id" field of each data
select id from t_user
- (2) Find "id" field of each data, and the "id" to "No."
select 'id='||id 编号 from t_user
- (3) Find "username" and "addr" field of each data (intermediate comma-separated)
select username, addr from t_user
- (4) Find "username" and "addr" field of each data (intermediate comma-separated), and the read address addr name to username
select username name, aDdr address from t_user
- (5) Find all performance data is greater than 80 "username"
select username 姓名 from t_user where score>80
******************************************************************
--change the data
- the name of a peach addr field data changed to Henan
update t_user set addr = 'Henan' where username = 'peaches'
- ha will be the name of the field data to addr Guizhou, age field to 18: modifying a plurality of fields, using an intermediate comma
update t_user set addr = 'Guizhou', age = '18 'where username =' ha '
- all addr field is not Beijing's score field data changed to 88
- Note the use of! =
update t_user set score='99' WHERE addr !='北京'
- <> and! = Role as
update t_user set score='99' WHERE addr <>'北京'
- The results addr field data between the 50-70 "Beijing": a plurality of filter conditions and used between keywords in the connection (and diversity selector)
update t_user set addr='北京' WHERE score>=50 and score<=70
- Note below between keywords and> = and <= equivalent composition
update t_user set age='55' where score between 50 and 70
- the age of 18 or 55 passwords are changed to 00000
update t_user set password='0000' where age='18' or age='55'
- the age of 18 or 55 passwords are changed to 11111: through in keyword
update t_user set password='11111' WHERE age in(18,55)
- will address Henan passwords are changed or Beijing 2222: The in keyword here note the string in quotes
update t_user set password = '2222' WHERE addr in ( 'Henan', 'Beijing')
- all surnamed Ha address to Beijing: The combination of keywords like%:% a: to a end; a%: beginning with a;% a%: contains a
--note! ! ! % Write inside quotation marks
update t_user set addr='北京' where username like '哈%'
- the birthday sysdate field to field is null data birthday
- Note the use of the keyword to determine whether is empty, and only use is to determine whether the keyword is null, null otherwise remind missing keywords
update t_user set birthday= sysdate WHERE birthday is null
- all the age field is not empty data fields plus age 1:
- Note the use of the keyword is not whether a judge is empty
update t_user set age= age+1 WHERE age is not null
*******************************************************************
--delete data:
--1: Delete all data
delete from t_user
--2: delete the name of the data field is ha ha ha
- Note from between dlelte and can not add a keyword parameter
delete from t_user where username='哈哈哈'