日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle对substr去重,oracle使用笔记

發布時間:2024/4/20 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle对substr去重,oracle使用笔记 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、scott解鎖

alter user scott identified by tiger;

alter user scott account unlock;

2、導表

@d:/oracle/table.sql;

3、查看表結構

desc table;

4、連接數據

'hello' || 'world'

5、去重

distinct column

6、日期轉換

to_char(date,'yyyy-mm-dd')

7、轉義字符

like '%\_%' escape '\'

8、查詢日期94年的

like '%94'

9、字符函數lower,upper,initcap

initcap('hello world') --Hello World

10、concat連接

concat('hello','world') ?--helloworld

11、substr截取

substr('helloworld',2,4) --ello

12、length長度

length('helloworld') --10

13、instr某字符首次出現的位置

instr('helloworld','w') --6 若沒有返回0

14、rpad,lpad 字符補位

rpad(12000,10,'*') ? --12000*****

lpad(12000,10,'*') ? --*****12000

15、trim 去首位字符

trim('h' from 'hellohello') --ellohello

16、replace替換

replace('hellohello','h','x') --xelloxello

17、數字函數round

round(155.555) -- 156

round(155.555,2) --155.56

round(155.555,-2) --200

18、mod取余

mod(1100,300) --200

19、months_between兩個時間相差多少個月

months_between(date1,date2)

20、add_months 給日期加月

add_months(sysdate,12)

21、next_day 下一個星期幾

next_day(sysdate,1) ?--下一個星期日

22、last_day 月的最后一天

last_day(sysdate)-1 ?本月倒數第二天

23、round 舍入時間

round(sysdate,'hh')

24、to_char

to_char(1234567.89,'L999,999,999,99) --¥1,234,567.89

to_char(1234567.89,'000,000,000,00) --001,234,567.89

25、to_number

to_number('¥1,234,567.89','L999,999,999,99') ?--1234567.89

to_number('001,234,567.89','000,000,000,00) --?1234567.89

26、nvl?將空值轉化

nvl(column,0)

nvl(to_char(number),'ABC')? --如果number是空,顯示ABC

27、nvl2?類似三目

nvl2(column,'A','B') --如果column不為空顯示A,為空顯示B

28、NULLIF

nullif('e1','e2') --如果e1等于e2?返回null?否則返回e1

29、coalesce

coalesce(a,b,c) --如果a為空返回b如果b為空返回c

30、case when then else end

case column when 1 then 1 else 2 end?如果列值等于1顯示1,否則顯示2

31、decode

decode(column,1,1,2,2,3)?如果列值等于1顯示1,如果等于2顯示2否則顯示3

32、truncate,delete

truncate table name? ? --清空表

delete from table? ? --清空表,可以rollback

33、add

alter table name add(email varchar2(10))? ? --添加字段

34、modify

alter table name modify(email varchar2(20) default '12345@qq.com')

35、rename

alter table name rename column email to new_email? ? --改字段名

rename stu1 to stu2 ? ? --改表/對象名

36、constraint

id number(8) constraint tn_id_uk unique? ? --列約束

constraint?tn_id_uk?check(id > 0)? ? -表約束

37、級聯刪除和制空

on delete set null? ? 級聯制空

on delete cascade? ? 級聯刪除

38、權限

grant create view to scott? ? --創建視圖權限

39、視圖

create or replace view

with read only? ? --只讀

40、序列

create sequence empseq

increment by 10 --每次增長10

start with 10? ?--從10開始增長

maxvalue 100? ? --提供最大值

cycle? ? ? ? ? ?--需要循環

nocache? ? ? ? ?--不需要緩存登錄

41、索引

create index emp_id_idx on emp(id)? ? --為id列創建索引

42、同義詞

create synonym e for emp? ? --同義詞

43、創建用戶

create user admin identified by 123

44、權限

grant create session to admin? ? --授予登錄權限

grant create table to admin? ? --建表權限

45、表空間

alter user aojn quota 5M(unlimited) on users

46、角色

create?role?manager? ? --創建角色manager

grant create table,create view to manager? ? --將創建表,創建視圖權限賦予角色

grant manager to admin? ? --將角色賦予用戶

47、分配對象權限

grant select,update on scott.emp to admin? ? --分給admin scott用戶emp表得查看更新權限

revoke select on?scott.emp from admin ?--收回權限

with?grant?option? ? --admin還可以將權限分給別人

總結

以上是生活随笔為你收集整理的oracle对substr去重,oracle使用笔记的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。