數(shù)據(jù)行操作的相關SQL語句(指令)如下:
-
新增數(shù)據(jù)
insert into 表名 (列名,列名,列名) values(對應列的值,對應列的值,對應列的值);insert into tb1(name,password) values('武沛齊','123123'); insert into tb1(name,password) values('武沛齊','123123'),('alex','123'); insert into tb1 values('武沛齊','123123'),('alex','123'); -- 如果表中只有2列 -
刪除數(shù)據(jù)
delete from 表名; delete from 表名 where 條件;delete from tb1; delete from tb1 where name="wupeiqi"; delete from tb1 where name="wupeiqi" and password="123"; delete from tb1 where id>9; -
修改數(shù)據(jù)
update 表名 set 列名=值; update 表名 set 列名=值 where 條件;update tb1 set name="wupeiqi"; update tb1 set name="wupeiqi" where id=1; update tb1 set age=age+1; -- 整型 update tb1 set age=age+1 where id=2; update L3 set name=concat(name,"db"); update L3 set name=concat(name,"123") where id=2; -- concat一個函數(shù),可以拼接字符串 -
查詢數(shù)據(jù)
select * from 表名; select 列名,列名,列名 from 表名; select 列名,列名 as 別名,列名 from 表名; select * from 表名 where 條件;select * from tb1; select id,name,age from tb1; select id,name as N,age, from tb1; select id,name as N,age, 111 from tb1; select * from tb1 where id = 1; select * from tb1 where id > 1; select * from tb1 where id != 1; select * from tb1 where name="wupeiqi" and password="123";