select /*+ parallel(a,4)*/ col1 from tab;

成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站設(shè)計(jì)制作、網(wǎng)站建設(shè)、青原網(wǎng)絡(luò)推廣、微信平臺(tái)小程序開發(fā)、青原網(wǎng)絡(luò)營銷、青原企業(yè)策劃、青原品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供青原建站搭建服務(wù),24小時(shí)服務(wù)熱線:18982081108,官方網(wǎng)址:chinadenli.net
表示查詢表tab的字段col1,4個(gè)進(jìn)程并行查詢,前提是必須要有4個(gè)CPU才有效,否則性能會(huì)比不加并發(fā)還低
存儲(chǔ)過程(procedure):是一個(gè)命名了的語句塊,可以有0個(gè)或多個(gè)參數(shù)
語法:
create or replace procedure HelloWorld
as
begin
dbms_output.put_line('HelloWorld');
end;
調(diào)用存儲(chǔ)過程
* 命令調(diào)用 exec helloworld
* 語句塊調(diào)用
begin
helloworld;
end;
/
DELETE:
create or replace procedure del_emp01
is
begin
delete from emp01 where empno=7369;
end;
exec del_emp01;
create or replace procedure del_emp01(v_empno in emp01.empno%type)
is
begin
delete from emp01 wherer empno=v_empno;
end;
exec del_emp01(7521);
INSERT
create or replace procedure ins_emp01
(v_empno emp01.empno%type,v_ename emp01.ename%type)
as
begin
insert into emp01(empno,ename) values(v_empno,v_ename);
end;
exec ins_emp01(1000,'李四');
UPDATE
create or replace procedure upd_emp01
(v_empno emp01.empno%type,v_ename emp01.ename%type)
as
begin
update emp01 set ename=v_ename where empno=v_empno;
end;
exec upd_emp01(1000,'張三');
SELECT
create or replace procedure sel_emp01
(v_empno emp01.empno%type,v_emp01_data out emp01%rowtype)
as
begin
select * into v_emp01_data from emp where empno=v_empno;
end;
帶有輸出參數(shù)的存儲(chǔ)過程不能使用命令直接調(diào)用
只能由語句塊或程序調(diào)用(JAVA) ****************************************************************
declare
v_emp_data emp01%rowtype;
begin
sel_emp01(7499,v_emp_data);
dbms_output.put_line(v_emp_data.ename||' '||v_emp_data.sal);
end;
調(diào)用:
declare
v_emp_data emp01%rowtype;
begin
sel_emp01(7499,v_emp_data);
dbms_output.put_line(v_emp_data.ename||' '||v_emp_data.sal);
end;
使用scott用戶登錄
統(tǒng)計(jì)某個(gè)部門的員工的工資總和,員工的人數(shù),平均工資,創(chuàng)建存儲(chǔ)過程
create or replace procedure deptcount
(v_deptno emp.deptno%type,v_sal_sum out number,v_recordes out number,v_avg_sal out number,errorMsg out varchar2)
is
begin
select sum(sal) into v_sal_sum from emp group by deptno having deptno=v_deptno;
select count(*) into v_recordes from emp group by deptno having deptno=v_deptno;
select avg(sal) into v_avg_sal from emp group by deptno having deptno=v_deptno;
exception
when no_data_found then
errorMsg:='沒有該部門';
end;
調(diào)用:
declare
v_sal_sum number;
v_recordes number;
v_avg_sal number(8,2);
v_errormsg varchar2(20);
begin
deptcount(90,v_sal_sum,v_recordes,v_avg_sal,v_errormsg);
dbms_output.put_line(v_sal_sum||' '||v_recordes||' '||v_avg_sal);
dbms_output.put_line(v_errormsg);
end;
//輸出參數(shù)
create or replace procedure my_pro(v_num in number,v_result out number)
is
v_temp number;
begin
v_temp:=0;
for i in 1..v_num
loop
v_temp:=v_temp+i;
end loop;
v_result:=v_temp;
end;
declare
v_recieve number;
begin
my_pro(100,v_recieve);
dbms_output.put_line(v_recieve);
end;
//既是輸入?yún)?shù)又是輸出參數(shù)
create or replace procedure my_pro1(v_i in out number)
is
v_j number;
begin
v_j:=30;
v_i:=v_i*v_j;
end;
declare
v_t number;
begin
v_t:=20;
my_pro1(v_t);
dbms_output.put_line(v_t);
end;
if r.speed = 0 and r.m=3 then
很明白了吧 分都沒郁悶 9幾的人真小氣
1.create user username identified by password;//建用戶名和密碼oracle ,oracle
2.grant connect,resource,dba to username;//授權(quán) grant connect,resource,dba,sysdba to username;
3.connect username/password//進(jìn)入。
4.select table_name,column_name from user_tab_columns where table_name='TABLE_NAME';//查詢表中的表名,字段名等等。 最后的table_name要大寫。
5. 如何執(zhí)行腳本SQL文件? SQL@PATH/filename.sql;
7.查詢用戶下的所有表 select distinct table_name from user_tab_columns; ===僅顯示一列表名。
8.如何搜索出前N條記錄?
select * from tablename where rownumn;--足矣。(--是注釋用的標(biāo)記)
9.查找用戶下的所有表:select * from tab; --查詢?cè)撚脩粝碌乃斜砑耙晥D(顯示表名tname, 類型tabname和clusterid)
2、顯示當(dāng)前連接用戶
SQL show user –不能用在sql窗口 只能用在command命令窗口。
3、查看系統(tǒng)擁有哪些用戶
SQL select * from all_users;
4、新建用戶并授權(quán)
SQL create user a identified by a;(默認(rèn)建在SYSTEM表空間下)
SQL grant connect,resource to a;
5、連接到新用戶
SQL conn a/a –或者是connect a/a
6、查詢當(dāng)前用戶下所有對(duì)象
SQL select * from tab; --table或是view
7、建立第一個(gè)表
SQL create table a(a number);
8、查詢表結(jié)構(gòu)
SQL desc a
9、插入新記錄
SQL insert into a values(1);
10、查詢記錄
SQL select * from a;
11、更改記錄
SQL update a set a=2;
12、刪除記錄
SQL delete from a;
13、回滾
SQL roll;
SQL rollback;
14、提交
SQL commit;
select * from
(select t.*,dense_rank() over (order by cardkind) rank from cardkind t)
where rank = 2;
46. 如何在字符串里加回車?
select 'Welcome to visit'||chr(10)||'' from dual ; --‘||chr(10)||’作為換行符
53. 如何使select語句使查詢結(jié)果自動(dòng)生成序號(hào)?
select rownum COL from table; --主要就是oracle中引入了rownum
54. 如何知道數(shù)據(jù)褲中某個(gè)表所在的tablespace?
select tablespace_name from user_tables where table_name='TEST'; --table_name名稱要大寫。
select * from user_tables中有個(gè)字段TABLESPACE_NAME,(oracle);
select * from dba_segments where …;
55. 怎么可以快速做一個(gè)和原表一樣的備份表?
create table new_table as (select * from old_table);
59. 請(qǐng)問如何修改一張表的主鍵?
alter table aaa drop constraint aaa_key ;
alter table aaa add constraint aaa_key primary key(a1,b1) ;
60. 改變數(shù)據(jù)文件的大小?
用 ALTER DATABASE .... DATAFILE .... ;
手工改變數(shù)據(jù)文件的大小,對(duì)于原來的 數(shù)據(jù)文件有沒有損害。
61. 怎樣查看ORACLE中有哪些程序在運(yùn)行之中?
查看v$session表
62. 怎么可以看到數(shù)據(jù)庫有多少個(gè)tablespace?
select * from dba_tablespaces;
Oracle存儲(chǔ)過程基本語法: CREATE OR REPLACE PROCEDURE 存儲(chǔ)過程名 IS BEGIN NULL; END;解釋: 行1: CREATE OR REPLACE PROCEDURE 是一個(gè)SQL語句通知Oracle數(shù)據(jù)庫去創(chuàng)建一個(gè)叫做skeleton存儲(chǔ)過程, 如果存在就覆蓋它; 行2: IS關(guān)鍵詞表明后面將跟...
你把批量執(zhí)行sql語句和存儲(chǔ)過程,否放入一個(gè)大的存儲(chǔ)過程里,然后在這個(gè)大的存儲(chǔ)過程中提交事務(wù),就所有的都會(huì)納入事務(wù)管理當(dāng)中。
網(wǎng)頁標(biāo)題:oracle并且怎么寫 oracle且語句
網(wǎng)站URL:http://chinadenli.net/article46/hjoihg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、網(wǎng)站導(dǎo)航、虛擬主機(jī)、服務(wù)器托管、做網(wǎng)站、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)