1. 程式人生 > >plsql最簡單的增刪改查命令

plsql最簡單的增刪改查命令

1 insert
語法: insert into 表名稱 values(值1,值2);
insert into person values('github','c++','java','mysql');
insert into  persion(name,password) values('張三',123);

2 delete
語法: delete from 表名稱 where 列名稱=值
刪除某行
delete from persion where lastname ='zhangsan';
刪除所有行:
delete from table_name
或者
delete * from table_name;

3 updata
語法:updata 表名稱 set 列名稱=新值 where 列名稱=某值
更新某一行中一個列
updata persion set firstname ='lisi' where lastname='zhangsan';
更新某一行的諾幹列
修改地址,並新增新的城市名稱
update persion set address ='zhenghzou',city='nanjing' where lastname='zhangsan';
4 select
語法:select 列名稱 from 表名稱
select * from 表名稱
獲取列名稱為"lastname" 和"firstname"的列內容
select lastname ,firstname from  persion;
獲取表中所有的列名稱
select * from persion
指定條件查詢
select * form persion where id=2;
select連線字串並起別名
select firstname+''+lastname as 名字 from persion
查詢表中所有ID不為1的記錄
select * from persion where not id=1;
帶and多條件查詢,沒有符合條件的記錄,返回為空
帶or的多條件查詢
select * from persion where id or firstname='a1';
select * from persion where id=1 and firstname='a1';
5 order by 排序
select * from persion order by id desc;
select * from persion order by id asc;
6 模糊查詢
% 零或多個字元
select * from persion where firstnam like 'a%';
_ 一個字元
select * from persion where firstname like 'a_';
[] 指定範圍內的任意單個字元
select * from persion where firstname like'a[a-e]';
select * from persion  where firstname like 'a[bcd]';
[^]不屬於指定範圍內的任單個字元
select * from persion where firstname like'a[^bcd]';
select * from persioin  where firstname likt '[bcd]%';
7 between and
select * from  between 1 and 2;