ORACLE常用傻瓜問題1000問(之三)
2024-08-29 13:30:16
供稿:網(wǎng)友
88. chr()的反函數(shù)是? ascii() select char(65) from dual; select ascii('a') from dual; 89. 字符串的連接 select concat(col1,col2) from table ; select col1||col2 from table ; 90. 怎么把select出來的結(jié)果導(dǎo)到一個(gè)文本文件中? sql>spool c:/abcd.txt; sql>select * from table; sql >spool off; 91. 怎樣估算sql執(zhí)行的i/o數(shù) ? sql>set autotrace on ; sql>select * from table; or sql>select * from v$filestat ; 可以查看io數(shù) 92. 如何在sqlplus下改變字段大小? alter table table_name modify (field_name varchar2(100)); 改大行,改小不行(除非都是空的) 93. 如何查詢某天的數(shù)據(jù)? select * from table_name where trunc(日期字段)=to_date('2003-05-02','yyyy-mm-dd'); 94. sql 語句如何插入全年日期? create table bsyear (d date); insert into bsyear select to_date('20030101','yyyymmdd')+rownum-1 from all_objects where rownum <= to_char(to_date('20031231','yyyymmdd'),'ddd'); 95. 如果修改表名? alter table old_table_name rename to new_table_name; 96. 如何取得命令的返回狀態(tài)值? sqlcode=0 97. 如何知道用戶擁有的權(quán)限? select * from dba_sys_privs ; 98. 從網(wǎng)上下載的oracle9i與市場(chǎng)上賣的標(biāo)準(zhǔn)版有什么區(qū)別? 從功能上說沒有區(qū)別,只不過oracle公司有明文規(guī)定;從網(wǎng)站上下載的oracle產(chǎn)品不得用于 商業(yè)用途,否則侵權(quán)。 99. 怎樣判斷數(shù)據(jù)庫是運(yùn)行在歸檔模式下還是運(yùn)行在非歸檔模式下? 進(jìn)入dbastudio,歷程--〉數(shù)據(jù)庫---〉歸檔查看。 100. sql>startup pfile和ifile,spfiled有什么區(qū)別? pfile就是oracle傳統(tǒng)的初始化參數(shù)文件,文本格式的。 ifile類似于c語言里的include,用于把另一個(gè)文件引入 spfile是9i里新增的并且是默認(rèn)的參數(shù)文件,二進(jìn)制格式 startup后應(yīng)該只可接pfile 101. 如何搜索出前n條記錄? select * from employee where rownum < n order by empno; 102. 如何知道機(jī)器上的oracle支持多少并發(fā)用戶數(shù)? sql>conn internal ; sql>show parameter processes ; 103. db_block_size可以修改嗎? 一般不可以﹐不建議這樣做的。 104. 如何統(tǒng)計(jì)兩個(gè)表的記錄總數(shù)? select (select count(id) from aa)+(select count(id) from bb) 總數(shù) from dual; 105. 怎樣用sql語句實(shí)現(xiàn)查找一列中第n大值? select * from (select t.*,dense_rank() over (order by sal) rank from employee) where rank = n; 106. 如何在給現(xiàn)有的日期加上2年?( select add_months(sysdate,24) from dual; 107. used_ublk為負(fù)值表示什么意思? it is "harmless". 108. connect string是指什么? 應(yīng)該是tnsnames.ora中的服務(wù)名后面的內(nèi)容 109. 怎樣擴(kuò)大redo log的大小? 建立一個(gè)臨時(shí)的redolog組,然后切換日志,刪除以前的日志,建立新的日志。 110. tablespace 是否不能大于4g? 沒有限制. 111. 返回大于等于n的最小整數(shù)值? select ceil(n) from dual; 112. 返回小于等于n的最小整數(shù)值? select floor(n) from dual; 113. 返回當(dāng)前月的最后一天? select last_day(sysdate) from dual; 114. 如何不同用戶間數(shù)據(jù)導(dǎo)入? imp system/manager file=aa.dmp fromuser=user_old touser=user_new rows=y indexes=y ; 115. 如何找數(shù)據(jù)庫表的主鍵字段的名稱? sql>select * from user_constraints where constraint_type='p' and table_name='table_name'; 116. 兩個(gè)結(jié)果集互加的函數(shù)? sql>select * from bsempms_old intersect select * from bsempms_new; sql>select * from bsempms_old union select * from bsempms_new; sql>select * from bsempms_old union all select * from bsempms_new; 117. 兩個(gè)結(jié)果集互減的函數(shù)? sql>select * from bsempms_old minus select * from bsempms_new; 118. 如何配置sequence? 建sequence seq_custid create sequence seq_custid start 1 incrememt by 1; 建表時(shí): create table cust { cust_id smallint not null, ...} insert 時(shí): insert into table cust values( seq_cust.nextval, ...) 日期的各部分的常用的的寫法 119>.取時(shí)間點(diǎn)的年份的寫法: select to_char(sysdate,'yyyy') from dual; 120>.取時(shí)間點(diǎn)的月份的寫法: select to_char(sysdate,'mm') from dual; 121>.取時(shí)間點(diǎn)的日的寫法: select to_char(sysdate,'dd') from dual; 122>.取時(shí)間點(diǎn)的時(shí)的寫法: select to_char(sysdate,'hh24') from dual; 123>.取時(shí)間點(diǎn)的分的寫法: select to_char(sysdate,'mi') from dual; 124>.取時(shí)間點(diǎn)的秒的寫法: select to_char(sysdate,'ss') from dual; 125>.取時(shí)間點(diǎn)的日期的寫法: select trunc(sysdate) from dual; 126>.取時(shí)間點(diǎn)的時(shí)間的寫法: select to_char(sysdate,'hh24:mi:ss') from dual; 127>.日期,時(shí)間形態(tài)變?yōu)樽址螒B(tài) select to_char(sysdate) from dual; 128>.將字符串轉(zhuǎn)換成日期或時(shí)間形態(tài): select to_date('2003/08/01') from dual; 129>.返回參數(shù)的星期幾的寫法: select to_char(sysdate,'d') from dual; 130>.返回參數(shù)一年中的第幾天的寫法: select to_char(sysdate,'ddd') from dual; 131>.返回午夜和參數(shù)中指定的時(shí)間值之間的秒數(shù)的寫法: select to_char(sysdate,'sssss') from dual; 132>.返回參數(shù)中一年的第幾周的寫法: select to_char(sysdate,'ww') from dual; 如有問題歡迎大家一起探討﹗ 待續(xù)……