1)sqlplus 帳號(hào)/密碼 yb yb123
2)alter user scott account unlock;
2,瀏覽器登錄isqlplus http://127.0.0.1:5560/isqlplus/
http://v.youku.com/v_show/id_XMzc3Njg0NjQ=.html
3,描述desc
desc emp....dept
4,select * from XXX;
*為表達(dá)式什么的.
5,dual是一個(gè)空表
6,sysdate關(guān)鍵字,用于查看系統(tǒng)時(shí)間;
select sysdate from dual;
7,select ename, sal*12 年薪 from emp;
為sal*12起一個(gè)別名nianxin
select ename, sal*12 "nianxin": from emp;可以保持格式小寫(xiě)
8,select ename||sal from emp;
相當(dāng)于字符串連接 ' ' 單引號(hào)里面是一個(gè)字符串;如果字符串里面就有單引號(hào) 那么兩個(gè)單引號(hào)代表一個(gè)引號(hào)
9,select distinct deptno, job from emp;
去掉depno和job里面重復(fù)的.
select distinct deptno from emp; 去掉重復(fù)的;distinct//清楚的明顯的....
10,select * from emp 回車(chē)完了后面可以接著打
2 where ename = '222'; 選出名字為222的人;
<> <-不等于符號(hào)
select ename, sal from emp where sal between 800 and 1000; // 800 到1000
select ename, sal from emp where sal is not null;
is null代表控制 is not null.......
select ename, sal from emp where sal in('SI', 'SDA', 'SDFAS');取出in里面的東西..
11,select ename, sal from emp where sal>1000 or hiredate = 10;
//or 是或者 and是和 not in 是取反
select ename, sal from emp where not in sal>1000 or hiredate = 10;
12,模糊查詢
select ename from emp where ename like '%ALL%';
//%是通配付一個(gè)或多個(gè) _A% _代表一個(gè)字母
select ename from emp where ename like '%&%%' escape '&';
escape申明'&'是轉(zhuǎn)義字符;轉(zhuǎn)義字符默認(rèn)是\;
13, select *from dept order by deptno desc;按降序排序關(guān)鍵字order by asc是升序默認(rèn)是升序
14,1)sql 函數(shù) lower 轉(zhuǎn)換為小寫(xiě) upper你懂的
select lower(ename) from emp;
2)select substr(ename, 1, 3) from emp;
從第一個(gè)字符開(kāi)始截 一共截取3個(gè)字符
3)select chr(65) from dual;
select ascii('A') from dual;轉(zhuǎn)換ASC...
4)select round(23.554) from dual;四舍五入輸出24
select round(23.554, 2) from dual;輸出23.55四舍五入到小數(shù)點(diǎn)后兩位
5)比較重要
select to_char(sal, '$99,99') from emp;
轉(zhuǎn)換格式必須填9
select to_char(sal, 'L99,99') from emp;
L代表本地貨幣符號(hào)
select to_char(sal, 'L00,00') from emp;
0表示該位上沒(méi)有數(shù)字也顯示為0
select to_char(hiredate, 'YYYY MM DD HH:MI:SS') from emp;
排日期 還有HH24 ..就24小時(shí)進(jìn)制咯
6)select ename, hiredate from emp where hiredate > to_date('1981-2-20 12::45::44', 'YYYY-MM-DD HH24::MI::SS');
to_date把字符串按一定格式轉(zhuǎn)換為日期
7)select sal from emp where sal > to_number('$1.254.00','$9.999.99');
to_number轉(zhuǎn)化為數(shù)字
8)select ename ,sal*12 + nvl(comm,0) from emp;
nvl(comm,0)如果comm是空值,那么就用0 來(lái)替代他
16,組函數(shù) 重點(diǎn)就這個(gè)5個(gè)
select min(sal) from emp;輸出最小值的薪水
select max(sal) from emp;
select avg(sal) from emp;平均
select sum(sal) from emp;
select count(*) from emp;求出有多少條記錄
select count(comm) from emp;說(shuō)明有多個(gè)有津貼 distinct
17,group by
select avg(sal), deptno from emp group by deptno;
分組函數(shù)by按照部門(mén)進(jìn)行分組,要一一對(duì)應(yīng).
select avg(sal), ename from emo group by deptno;
這條是錯(cuò)的,ename 和 deptno不能對(duì)應(yīng)起來(lái)
eg.
每個(gè)部門(mén)的平均薪水
select avg(sal), deptno from emp group by deptno;
18,使用having 對(duì)分組進(jìn)行限制
select avg(sal) avg(sal), deptno from emp group by deptno having avg(sal) > 2000;
having是對(duì)分組進(jìn)行限制, where是對(duì)單條進(jìn)行限制;
19,
select avg(sal)
from emp
where sal > 1200
group by deptno
having avg(sal) > 1500
order by avg(sal) desc;
20,ed回車(chē)可以用記事本來(lái)寫(xiě)語(yǔ)句
21,子查詢 select 里面套select 語(yǔ)句
select ename, sal from emp where sal >(select avg(sal) from emp);
每個(gè)部門(mén)平均sal的薪水等級(jí)
select ename ,grade from emp e join salgrade s on (e.sal between s.losal and s.hisal);
select ename ,grade from emp e, salgrade s where (e.sal between s.losal and s.hisal);
SELECT ENAME , SAL FROM EMP
JOIN (SELECT MAX(SAL) MAX_SAL, DEPTNO FROM EMP GROUP BY DEPTNO) T
ON (EMP.SAL = T.MAX_SAL AND EMP.DEPTNO = T.DEPTNO)
22,1999標(biāo)準(zhǔn) join no
select ename, dname from emp join dept on (emp.deptno = dept.deptno);
連接emp 和 dept兩張表
= select ename, dname from emp , dept where (emp.deptno = dept.deptno);
= select ename ,dname from emp join dept using (deptno);
select ename , dname from emp cross join dept;
交叉連接ename dname找出每種組合
23,外連接
select e1.ename, e2.ename from emp e1 left join emp e2 on (e1.mgr = e2.empno);
會(huì)把左邊那張表沒(méi)產(chǎn)生連接的也打印出來(lái).
右外連接同理
全外連接
select ename, dname from emp e full join dept d on (e.deptno = d.deptno);
24,
求部門(mén)中哪些人的薪水最高
select ename, sal from emp
join (select max(sal) max_sal, deptno from emp group by deptno) t
on (emp.sal = t.max_sal and emp.deptno = t.deptno);
部門(mén)中的平均薪水等級(jí)
select deptno, avg_sal, grade from
(select deptno, avg(sal) avg_sal from emp group by deptno) t
join salgrade s on (t.avg_sal between s.losal and s.hisal)
誰(shuí)的工資最高
select ename, sal from emp where sal = (select max(sal) from emp);
工資位于平均工資之上
哪些人是經(jīng)理人
select ename from emp where empno in(select distinct mgr from emp);
不用組函數(shù)求薪水的最高值
select ename, sal from emp where ename not in( select distinct e1.ename fro
m emp e1 join emp e2 on e1.sal < e2.sal);
平均薪水最高的部門(mén)編號(hào)
改天
平均薪水的等級(jí)最低的部門(mén)名稱
select dname, t1.deptno, grade, avg_sal from
(
select deptno, avg_sal, grade from
(select deptno, avg(sal) avg_sal from emp group by deptno) e
join salgrade s on (e.avg_sal between s.losal and hisal)
) t1
join dept on (t1.deptno = dept.deptno)
where t1.grade =
(
select min(grade) from
(
select deptno, avg_sal, grade from
(select deptno, avg(sal) avg_sal from emp group by deptno) e
join salgrade s on (e.avg_sal between s.losal and hisal)
)
)
/
比普通員工的最高薪水還要高的經(jīng)理人
1)先選出哪些不是經(jīng)理人的最高薪水 select max(sal) from emp
where empno not in (select mgr from emp where mgr is not null)
2)
select ename, sal from emp
where sal >
(
select max(sal) from emp
where empno not in (select mgr from emp where mgr is not null)
)
and empno in (select distinct mgr from emp)
25,創(chuàng)建視圖view 需要權(quán)限
簡(jiǎn)化用creat view v$dept_avg_sal_info as
select deptno, avg_sal, grade from
(select deptno, avg(sal) avg_sal from emp group by deptno) e
join salgrade s on (e.avg_sal between s.losal and hisal)
授權(quán)
conn sys/orcl as sysbda;
grant create table, creat view to scott;
conn scott/tiger
26,
建立新的用戶
登錄超級(jí)管理員 conn sys/orcl as sysdba;
1)刪除用戶drop user scott cascade;
2)創(chuàng)建新用戶
1--backup scott
exp 導(dǎo)出
2--create user
create user username用戶名 identified by password密碼 default tablespace users默認(rèn)空間 quota 10M on users分配10M的空間
3--賦權(quán)限
grant create session登錄, create table建表, create view to username;
3--import data
imp
需要輸入用戶名的地方輸入scott也就是你要導(dǎo)的那個(gè)用戶名
ORA-01950錯(cuò)誤分析 對(duì)表空間無(wú)權(quán)限2009-02-12 21:10ORA-01950錯(cuò)誤分析
1.用戶沒(méi)有resource權(quán)限。
2.在修改了用戶的表空間后,在用戶中創(chuàng)建表時(shí)會(huì)出現(xiàn)以下的錯(cuò)誤:ORA-01950: 表空間'HDNHG'中無(wú)權(quán)限
這個(gè)時(shí)候就要給修改了表空間的用戶重新分配權(quán)限如:grant connect,resource to username;
再切換到該用戶下創(chuàng)建表OK了。。
3.總的來(lái)說(shuō)這個(gè)錯(cuò)誤是由于對(duì)表空間操作的權(quán)限不足造成的,所以這個(gè)時(shí)候就可以檢查出錯(cuò)之前對(duì)于所操作的表空間有哪些權(quán)限可能被revoke了(或者說(shuō)原來(lái)就沒(méi)有g(shù)rant),然后重新賦予相應(yīng)的權(quán)限。
撤銷(xiāo)權(quán)限r(nóng)evoke
更多權(quán)限管理http://www.javaeye.com/topic/431907
27,
create table emp2 as select * from emp;//相當(dāng)于emp2是emp的備份
create v iew xxx as xxx;
insert into dept values(50,'game','sdf');//插入
insert into dept (deptno)values(60);//只插deptno這個(gè)字段
insert into dept select * from dept;
update
update emp2 set sal = sal * 2,ename = ename || 'sb';
delete from emp2 where ename = 'xx';
drop table xxx;
28,rownum
select empno, ename from emp where rownum <= 5;
只能是<= 或者<不能是= >
解決方法用一個(gè)子查詢
select empno,ename from(select rownum r, ename, empno from emp) where r > 5;
求薪水最高的前5名雇員
select ename, sal, rownum r from
(
select ename, sal from emp order by sal desc
)
where rownum <= 5
mysql 下可以用limit
29,create
創(chuàng)建表
create table t (a varchar2(10));
varchar2不定長(zhǎng)
char定長(zhǎng) 區(qū)別只是效率和空間的問(wèn)題
number(8,2) 8位,兩個(gè)小數(shù)點(diǎn)
long用來(lái)存大的文章之類(lèi)
date;
create table stu
(
id number(9) default 1,//設(shè)置一個(gè)默認(rèn)值
name varchar2(20) not null//設(shè)置為非空,必須輸入名字.
);
insert into stu(id) values(1);報(bào)錯(cuò)
30,transaction 事務(wù)
commit;提交事物完成 rollback回不去了;
create table grand exit之類(lèi) 事務(wù)也提交一樣rollback不回去;
非正常斷開(kāi)連接自動(dòng)回滾;
31,constraint
1)非空約束
create table stu
(
id number(9) default 1,//設(shè)置一個(gè)默認(rèn)值
name varchar2(20) constraint stu_name_nn not null
);
//設(shè)置為非空,必須輸入名字.
使用constraint 關(guān)鍵字為限制取一個(gè)名字
2)唯一約束,例如學(xué)號(hào)必須唯一
create table stu
(
id number(9) unique,//設(shè)置一個(gè)默認(rèn)值
name varchar2(20),
date date;
);
學(xué)號(hào)重復(fù)則報(bào)錯(cuò)
create table stu
(
id number(9) unique,//設(shè)置一個(gè)默認(rèn)值
name varchar2(20),
date date,
email varchar2(50),
constraint stu_name_email unique(name, email)
);
組合重復(fù)約束,如果名字和郵件地址都重復(fù)才重復(fù)
3)主鍵約束
create table stu
(
id number(9) unique,
name varchar2(20),
sdate date,
email varchar2(50),
constraint saaa primary key (id)
);
唯一且不能為空
4)外鍵約束 設(shè)計(jì)到兩張表或者一張表的兩個(gè)字段
例如dept這張表里的deptno里面沒(méi)有50這個(gè)部門(mén),那么在emp里面插入數(shù)據(jù)就不能插入50這個(gè)部門(mén)編號(hào)
用法
create table class
(
id number(1) primary key
)
create table stu
(
id number(9) unique,
class number(1) references class(id)//class是表的名字
)
另一種寫(xiě)法,表限制
create table stu
(
id number(9) unique,
class number(1),
contraint sss foreign key(class) references class(id)
)
重要:被references的值必須是主鍵
如果另一張表有值在參考class 則不能刪除class里的這條記錄
5)check
CREATE TABLE Persons
(
Id_P int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CHECK (Id_P>0)
)
Id_P>0咯不解釋
32,
函數(shù)返回表中的記錄數(shù):
SELECT COUNT(*) FROM table_name;
select count(xxx)from tab;--返回制定列的值的數(shù)目
33,alter
修改表結(jié)構(gòu),不是很重要
增加不解釋
alter table stu add(aaa varchar2(22));
刪除
alter table stu drop(aaa);
修改
alter table stu modify(aaa varchar2(33));
刪除添加表的約束條件
刪除
alter table stu drop constraint xxx;
添加
alter table stu add constraint xxx foreign key(class) references class(id);
alter table stu add check(id>0);
之類(lèi)
34,查看數(shù)據(jù)字典表
有一張默認(rèn)的表 user_tables
select table_name from user_tables;
select view_name from user_views;
select constraint_name from user_constraints;
select index_name from user_indexes;
存放數(shù)據(jù)字典表的表 dictionary
35,indexs
建立索引,讀數(shù)據(jù)的時(shí)候更快,修改的時(shí)候會(huì)更慢一點(diǎn).一般不輕易建立索引.
create index idx_stu_email on stu (email);
36,視圖
就是一個(gè)虛表,可以看做是一個(gè)子查詢.可以簡(jiǎn)化查詢和保護(hù)數(shù)據(jù)
create view v$_stu_info as select id, name, class from stu;SS
37,sequence序列 orcle only
創(chuàng)建一個(gè)獨(dú)一無(wú)二自動(dòng)遞增的數(shù)字
create sequence seq;
select seq.nextval from dual;
會(huì)發(fā)現(xiàn)每次運(yùn)行都產(chǎn)生不一樣的數(shù)字,默認(rèn)已經(jīng)包含同步了
38,三范式
1有主鍵 列不可分
2當(dāng)一張表里有多個(gè)主鍵存在時(shí),不能依賴于單獨(dú)的主鍵
不能部分依賴,要依賴于組合的主鍵.不然會(huì)存在數(shù)據(jù)的冗余
3不存在傳遞依賴
一般設(shè)計(jì)良好的數(shù)據(jù)庫(kù)SQL語(yǔ)句寫(xiě)起來(lái)就會(huì)麻煩一些
39,PL_SQL
1-第一個(gè)簡(jiǎn)單的hello world程序
BEGIN
DBMS_OUTPUT.PUT_lINE('HELLO WORLD');
END;
要顯示需要設(shè)置默認(rèn)顯示set serveroutput on;默認(rèn)是關(guān)閉的
2-聲明變量declare
declare
v_name varchar2(20);--約定的v_開(kāi)頭的變量名
begin
v_name := 'name';
dbms_output.put_line('name' || v_name);
end;
3-exception
declare
v_name number := 0;
begin
v_num := 2/v_num;
dbms_output.put_line(v_num);
exception
when others then--相當(dāng)于catch excption了
dbms_output.put_line('error');
end;
3-變量聲明
每行只能聲明一個(gè),不能與數(shù)據(jù)庫(kù)或表重名
變量類(lèi)型
簡(jiǎn)單變量
a number(1);
a binary_integer := 0;--主要用來(lái)計(jì)數(shù)
a number(7,2) := 4000.00;
a date := sysdate;--sysdate系統(tǒng)當(dāng)前時(shí)間
a constant number(3,2) := 3.14;
a boolean := false;--可以取空值,不賦值默認(rèn)為空.不能打印
a varchar2(20) not null := '12345';
%type屬性
declare
v_empno emp.empno%type;
v_empno v_empno%type;
復(fù)合變量
table 相當(dāng)于數(shù)組
declare
type type_table_emp_empno is table of emp.empno%type index by binary_integer;--相當(dāng)于聲明一個(gè)數(shù)組類(lèi)型
v_empnos type_table_emo_empno;
begin
v_empnos(0) := 4444;
v_empnos(-1) := 9999;--下標(biāo)可以為負(fù),這個(gè)有點(diǎn)神
dbms_output.put_line(v_empnos(-1));
end
record 相當(dāng)于類(lèi)
declare
type type_record_dept is record
(
deptno dept.deptno%type,
dname dept.dname%type,
loc dept.loc%typ
);
v_test type_record_dept;
begin
v_test.deptno := 50;
v_test.dname := '11';
v_test.loc := 'cd';
dbms_output.put_line(v_test.deptno || v_test.dname || v_test.loc);
end;
4-PL_SQL語(yǔ)句的不同
----執(zhí)行SQL語(yǔ)句必須且只返回一條記錄.有且只有
select ename,sal into v_name,v_sal from emp where empno = 7369;--必須有into,賦值
dbms_output.put_line....
---excute immediate 關(guān)鍵字
begin
execute immediate 'create table T(te/
st varchar2(20) default ''aa'')';
end;
執(zhí)行DDL語(yǔ)句的時(shí)候要用execute immediate'';單引號(hào)內(nèi)加語(yǔ)句
----IF關(guān)鍵字
declare
v_sal emp.sal%type;
begin
select sal into v_sal from emp where empno = 7369;
if (v_sal < 1200) then
dbms_output.put_line('low');
elsif(v_sal < 2000) then---eslif不是else if
dbms_output.put_line('high');
else
dbms_output.put_line('high very');
end if;
end;
----循環(huán)
loop
declare
i binary_integer := 1;
begin
loop
dbms_output.put_line(i);
i := i ++;
exit when(i > = 10);
end loop;
end;
for
begin
for k in 1..10 loop
dbms_output.put_line(k);
end loop;
for k in reverse 1..10 loop--逆序
dbms_output.put_line(k);
end loop;
end;
5---錯(cuò)誤處理
declare
v_temp number(4);
begin
select empno into v_temp from emp where deptno = 10;
exception
when too_many_rows then
dbms_output.putline('aaa');
when others then
dbms_output.putline('error');
end;
6---游標(biāo)cursor,重點(diǎn) 相當(dāng)于迭代器
declare
cursor c is
select * from emp;
v_emp c%rowtype;--rowtype相當(dāng)與C這是一表的類(lèi)型
begin
open c;
fetch c into v_emp;
dbms_output.put_line(v_emp.ename);
close c;
end;
拿出第一條記錄
declare
cursor c is
select * from emp;
v_emp c%rowtype;--rowtype相當(dāng)與C這是一表的類(lèi)型
begin
open c;
loop
fetch c into v_emp;
exit when(c%notfound)
dbms_output.put_line(v_emp.ename);
endloop;
close c;
end;
循環(huán)拿出每一條記錄
游標(biāo)的4個(gè)屬性
c%isopen是不是打開(kāi)了;
c%notfound最近的一次fetch如果沒(méi)有找到就返回true;
c%found 找到就返回true;
c%rouwcount 當(dāng)前已經(jīng)fetch 到了多少條記錄
for循環(huán)遍歷,有些不一樣.不用open fetch什么的
declare
cursor c is
select * from emp;
begin
for v_emp in c loop
dbms_output.put_line(v_emp.ename);
end loop;
end;
待參數(shù)的游標(biāo)
declare
cursor c(v_deptno emp.deptno%type, v_job emp.job%type)--和形參差不多
is
select ename, sal from emp where deptno = v_deptno and job = v_job;
begin
for v_temp in c(30, 'CLERK') loop
dbms_output.put_line(v_temp.ename);
end loop;
end;
可更新的游標(biāo)
declare
cursor c
is
select * from emp for update;
begin
for v_temp in c loop
if(v_temp.sal < 2000) then
update emp set sal = sal * 2 where current of c;---where current of c就是更新當(dāng)前這個(gè)游標(biāo)
elsif (v_temp.sal = 5000) then
delete from emp where current of c;
end if;
end loop;
--commit;
end;
創(chuàng)建存儲(chǔ)過(guò)程
create or replace procedure p
is
begin
dbms_ouput.put_line('222');
end;
執(zhí)行后會(huì)提示過(guò)程已經(jīng)完成,但是他沒(méi)有執(zhí)行
執(zhí)行方法
1)exec p;
2)
begin
p;
end;
這樣的話可以方便的多次執(zhí)行
帶參數(shù)的存儲(chǔ)過(guò)程
create or replace procedure p
(v_a in number, v_b number, v_ret out number, v_temp in out number)-- 傳入傳出,默認(rèn)是in
is
---變量聲明 無(wú)
begin
if(v_a > v_b) then
v_ret := v_a;
else
v_ret := v_b;
end if;
v_temp := v_temp + 1;
end;
執(zhí)行
declare
v_a number := 3;
v_b number := 4;
v_ret number;---因?yàn)樗莖ut number
v_temp number := 5;
begin
p(v_a, v_b, v_ret, v_temp);
dbms_output.put_line(v_ret);
dbms_output.put_line(v_temp);
end;
show error;
函數(shù)function
create or replace function sal_tex
(v_sal number)--形參
return number
is
begin
if(v_sal < 2000) then
return 0.10;
else
return 0.20;
end if;
end;
這個(gè)不是很重要
觸發(fā)器
create table emp2_log
(
uname varchar2(20),
ation varchar2(10),
atime date
);
創(chuàng)建一個(gè)觸發(fā)器
create or replace trigger trig
after insert or delete or update on emp2 for each row---或者把a(bǔ)fter改成俄海關(guān)before 如果加上for each row 會(huì)產(chǎn)生多條記錄.每更新一條記錄就觸發(fā)一次,而不是每次操作觸發(fā)一次
begin
if inserting then
insert into emp2_log values(USER, 'i', sysdate);--USER關(guān)鍵字當(dāng)前的用戶
elsif updating then
insert into emp2_log valuse(USER, 'u', sysdate);
elsif deleting then
insert into emp2_log valuse(USER, 'd', sysdate);
end if;
end;
觸發(fā)器的另類(lèi)使用
create or replace trigger trig
after update on dept
for each row
begin
update emp2 set deptno = :NEW.deptno where deptno = :OLD.deptno;
end;
這樣的話就可以修改emp2里面被參考的值了
樹(shù)狀結(jié)構(gòu)的展示recursion
create table article
(
id number primary key,
cont varchar2(4000),
pid number,--pried
isleaf number(1),---0代表非葉子節(jié)點(diǎn), 1代表葉子節(jié)點(diǎn)
alevel number(2)---級(jí)別
);
id l al
insert into article values (1, '大象大戰(zhàn)螞蟻', 0, 0, 0);
insert into article values (2, '大象被打趴下了', 1, 0, 1);---pid就是他的父ID
insert into article values (3, '螞蟻也不好過(guò)', 2, 1, 2);---說(shuō)明他是最后一個(gè)了
insert into article values (4, '瞎說(shuō)', 2, 0, 2);
insert into article values (5, '沒(méi)有瞎說(shuō)', 4, 1, 3);
insert into article values (6, '怎么可能', 1, 0, 1);
insert into article values (7, '怎么沒(méi)有可能', 6, 1, 2);
insert into article values (7, '可能性是很大的', 6, 1, 2);
insert into article values (8, '大象進(jìn)醫(yī)院了', 2, 0, 2);
insert into article values (9, '護(hù)士是螞蟻', 9, 1, 3);
螞蟻大戰(zhàn)大象
大象被打趴下了
螞蟻也不好過(guò)
瞎說(shuō)
只需要在Oracle官方網(wǎng)站下載一個(gè)叫Instant Client Package的軟件就可以了,這個(gè)軟件不需要安裝,只要解壓就可以用了,很方便,就算重裝了系統(tǒng)還是可以用的。
下載地址:
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html
解壓到一個(gè)目錄中即可,例如c:\oracleclient
2. 配置操作系統(tǒng)環(huán)境變量
NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
TNS_ADMIN=C:\oracleclient\NETWORK\ADMIN
3. 配置連接Oracle的配置。tnsnames.ora文件到目錄C:\oracleclient。可以從oracle服務(wù)器拷貝一個(gè)過(guò)來(lái)。
4. 安裝PLSQL Developer
5. 配置PLSQL Developer(第一次可以不用登錄直接進(jìn)到PLSQL Developer)
Tools --> Preferences--> Connections,
Oracle Home內(nèi)容為 C:\oracleclient
OCI library內(nèi)容為 C:\oracleclient\oci.dll
重新啟動(dòng)PLSQLDeveloper
完畢
觸發(fā)器 自動(dòng)遞增
001.創(chuàng)建唯一索引控制 ID ACCOUNT什么的兩個(gè)唯一
創(chuàng)建主鍵:
alter table T add primary key (V)
T是表名,V是列名
創(chuàng)建索引:
create index F2009100000NMINFOSYS_XIANG on f2009100000nminfo( SYS_XIANG );
創(chuàng)建一般索引,索引名為表名+列名
create unique index F2009100000NMINFOSYS_ZDM on f2009100000nminfo( SYS_ZDM );
創(chuàng)建唯一索引
create BITMAP index F2009100000NMINFOSYS_XIANG on f2009100000nminfo( SYS_XIANG );
創(chuàng)建位圖索引
完整語(yǔ)法如下:
CREATE (UNIQUE|BITMAP) INDEX [用戶名.]索引名 ON [用戶名.]表名 (列名 [ ASC | DESC], [列名 [ ASC | DESC]]...)
[ TABLESPACE 表空間名 ]
[ PCTFREE 正整型數(shù) ]
[ INITRANS 正整型數(shù) ]
[ MAXTRANS 正整型數(shù) ]
[ 存儲(chǔ)子句 ]
[ LOGGING | NOLOGGING ]
[ NOSORT ]