五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Oracle創(chuàng)建或查看或刪除用戶,DBA,rownum偽列進(jìn)行分頁,增刪改查語句等【詩書畫唱】

2021-03-03 23:53 作者:詩書畫唱  | 我要投稿

前言:每次寫這種技術(shù)專欄都要花很多小時(shí)且累,所以沒時(shí)間做高創(chuàng)的視頻,同時(shí)閱讀量和點(diǎn)贊或慷慨三連的人很少。但是學(xué)習(xí)為主嘛!學(xué)好一些東西后,創(chuàng)作更多更高創(chuàng)的作品給你們!

點(diǎn)贊或慷慨三連吧!

下面我是用DBA管理員創(chuàng)建表的,如果用sccot的賬號創(chuàng)建表前,可能要先給權(quán)限:


--登錄sys超級管理員賬號執(zhí)行

--創(chuàng)建一個(gè)名為SSHC的賬戶

create user SSHC

--設(shè)置密碼為1

identified by orcl

--設(shè)置默認(rèn)表空間為user

default tablespace users

--設(shè)置臨時(shí)表空間為temp

temporary tablespace temp

--解鎖賬號,允許登錄oracle

account unlock;


--允許SSHC用戶登錄到orcl數(shù)據(jù)庫

grant connect to?SSHC;

--允許SSHC用戶使用存儲空間

grant resource to SSHC;




內(nèi)容概括:

作業(yè)
講義

創(chuàng)建用戶的步驟

oracle中的常用的數(shù)據(jù)類型

lob:存儲視頻和音頻以及大文件,存放大文件

number(10,2)



oracle數(shù)據(jù)庫中的偽列:

rowid:當(dāng)需要對數(shù)據(jù)庫中的數(shù)據(jù)進(jìn)行編輯時(shí),就必須顯示rowid

rownum:使用rownum進(jìn)行分頁查詢


mysql:limit進(jìn)行分頁

oracle:rownum偽列進(jìn)行分頁


以你的名字首字母為賬號創(chuàng)建一個(gè)賬號,密碼自定(授予他dba的權(quán)限)【DBA(數(shù)據(jù)庫管理員)?DBA是數(shù)據(jù)庫管理員認(rèn)證,英文是Database Administrator。 】

oracle登錄身份有三種: 1、normal 普通身份; 2、sysdba 系統(tǒng)管理員身份; 3、sysoper 系統(tǒng)操作員身份。


創(chuàng)建一個(gè)商品信息表(id,name,price,type)和商品類型表(id,name)

--查看用戶或角色所擁有的角色:

select * from dba_role_privs;

Oracle中常用的部分語句個(gè)人總結(jié)

查看Oracle中所有用戶或角色的權(quán)限等等

PLSQL設(shè)置編輯器的字體大小的方法?

oracle 刪除用戶命令和部分命令

查看Oracle中所有用戶的方法

關(guān)于甲骨文公司的擴(kuò)展知識

在商品信息表和商品類型表中輸入數(shù)據(jù)進(jìn)行測試。

關(guān)于外鍵的添加?



關(guān)于外鍵的添加 START


【外鍵的話,是保存副表的內(nèi)容的完整性的。比如副表(我理解我為補(bǔ)充表)

比如類型表,如果是組合查詢時(shí)的下拉框的話,就是查詢類型表。使用了

外鍵把主表的信息表和類型表聯(lián)系起來后,就是

主表的typeid的數(shù)值中只會出現(xiàn)副表中出現(xiàn)的加了主鍵的編號id列

<int類型,有主鍵>出現(xiàn)的數(shù)值,添加數(shù)據(jù)到信息表的時(shí)候,

有一列typeid<int類型,無主鍵>,

防止操作員添加了無type表的id值到typeid列中,那么就是無效的數(shù)據(jù),

加了外鍵后,這種無效的數(shù)據(jù)是添加不到信息表里的。)】





【直接創(chuàng)建完整約束的表(寫項(xiàng)目的時(shí)候,一般就是用這種方法建表。

同時(shí)建表的時(shí)候,一般用管理員的身份創(chuàng)建表的時(shí)候,不用授權(quán),但是

普通用戶要。這是為了安全,2個(gè)不同的公司,互相合作時(shí),交互時(shí)授權(quán)后

才能訪問更安全)】



create table spInformation?


(


id number primary key,


name varchar2(30),


price number(9,2),


typeid int


);


create table spType


(id number primary key,


name varchar2(30));



--刪除表

drop table spInformation;

drop table spType;


--加外鍵

【表創(chuàng)建成功后再添加外鍵約束

添加外檢約束 :alter table 從表表名 add constraint?

外鍵約束名稱 foreign key(列名) references 主表名稱(主鍵列名)】

alter table spInformation add constraint

?FK_spInformation foreign key(typeid) references spType(id);

——————————————————————————————————————————————————————


---建基本的表(一般是不會去用這種方法建表的):


create table spInformation?


(


id number,


name varchar2(30),


price number(9,2),


type varchar2(30)


);


create table spType


(id number primary key,


name varchar2(30));


--查詢表


select * from spInformation;?


select * from spType;?




--通過sql語句給商品信息表的id添加主鍵約束

alter table spInformation?

add constraint PK_id primary key(id);

--name添加唯一約束

ALTER TABLE spInformation

ADD CONSTRAINT unique_spInformation

UNIQUE (name)?

--id添加外鍵約束

【表創(chuàng)建成功后再添加外鍵約束

添加外檢約束 :alter table 從表表名 add constraint?

外鍵約束名稱 foreign key(列名) references 主表名稱(主鍵列名)】

alter table spType add constraint

?FK_spInformation foreign key(id) references spInformation(id);

--價(jià)格添加檢查約束(1-99999999元)

Alter table spInformation

Add constraint CK_spInformation check(99999999>price and price>=1)

--在商品信息表和商品類型表中輸入數(shù)據(jù)進(jìn)行測試。

insert into spInformation values(1,'詩書畫唱牌商品',999.99,'名牌類');


insert into spType values(1,'名牌類');

--select * from user_tablespaces ;

--select * from user_tablespaces ;










關(guān)于外鍵的添加 END



講義 START


PLSQL:漂亮SQL,oracle圖形化的管理界面


使用oracle數(shù)據(jù)庫:

打開后臺服務(wù)界面,打開Oracle服務(wù)項(xiàng)

打開PLSQL,登錄數(shù)據(jù)庫


放大字體:工具-首選項(xiàng)-從左邊選中“字體”選項(xiàng)-調(diào)整字體大小

切換賬號:會話-登錄-重新輸入賬號密碼進(jìn)行登錄

mysql:默認(rèn)賬號root

sqlserver:默認(rèn)賬號sa

oracle:默認(rèn)賬號scott,超級管理員賬號sys,system,密碼orcl


oracle數(shù)據(jù)庫中的權(quán)限管理非常嚴(yán)格。


oracle中寫sql語句:文件-新建-SQL WINDOW


創(chuàng)建用戶的步驟

1、使用超級管理員登錄

2、執(zhí)行創(chuàng)建用戶的sql語句


oracle中的常用的數(shù)據(jù)類型:

varchar2:可變長度字符串類型

char:固定長度字符串類型

number:數(shù)值類型

date:日期類型

lob:存儲視頻和音頻以及大文件,存放大文件

number(10,2)


oracle數(shù)據(jù)庫中的偽列:

rowid:當(dāng)需要對數(shù)據(jù)庫中的數(shù)據(jù)進(jìn)行編輯時(shí),就必須顯示rowid

rownum:使用rownum進(jìn)行分頁查詢


mysql:limit進(jìn)行分頁

oracle:rownum偽列進(jìn)行分頁



講義 END



作業(yè) START

1、以你的名字首字母為賬號創(chuàng)建一個(gè)賬號,密碼自定(授予他dba的權(quán)限)【DBA(數(shù)據(jù)庫管理員)?DBA是數(shù)據(jù)庫管理員認(rèn)證,英文是Database Administrator。 】

oracle登錄身份有三種: 1、normal 普通身份; 2、sysdba 系統(tǒng)管理員身份; 3、sysoper 系統(tǒng)操作員身份。


首先想創(chuàng)建一個(gè)新用戶,一般用SYSDBA的類型的權(quán)限的用戶

之后點(diǎn)“新建”,“SQL Windows”。







以你的名字首字母為賬號創(chuàng)建一個(gè)賬號,密碼自定(授予他dba的權(quán)限) START



create user X identified by sshcPwd;


grant connect,resource,dba to X;



以你的名字首字母為賬號創(chuàng)建一個(gè)賬號,密碼自定(授予他dba的權(quán)限) END


--查看數(shù)據(jù)庫里面所有用戶:


select * from dba_users;




--用戶及用戶下面所有表的刪除:


drop user? ?X cascade;


--查看用戶或角色所擁有的角色或權(quán)限:

select * from dba_role_privs;

創(chuàng)建管理員X成功!




2、創(chuàng)建一個(gè)商品信息表(id,name,price,type)和商品類型表(id,name)



create table spInformation?


(


id number,


name varchar2(30),


price number(9,2),


type varchar2(30)


);






create table spType


(


id number,


name varchar2(30)


);


--查看用戶或角色所擁有的角色:

select * from dba_role_privs;

--查看哪些用戶有sysdba或sysoper系統(tǒng)權(quán)限(查詢時(shí)需要相應(yīng)權(quán)限)

select * from V$PWFILE_USERS


--創(chuàng)建一個(gè)商品信息表(id,name,price,type)和商品類型表(id,name)


create table spInformation?

(

id number primary key,

name varchar2(30),

price number(9,2),

type varchar2(30)

)



create table spType

(

id number primary key,

name varchar2(30)

)


--查詢表

select * from spInformation;?

select * from spType;?

--笛卡爾積:將多個(gè)表的數(shù)據(jù)進(jìn)行一一對應(yīng),所得的結(jié)果為多表的笛卡爾積

select * from spInformation,spType;

--多表查詢

select * from spInformation,spType where spInformation.name=spType.name


--刪除表

drop table spInformation


--number型的相關(guān)知識?


oracle中不管什么數(shù)字(正常數(shù)字,不包括0000001這樣的),都可以用number來存,

只是后面的參數(shù)略有不同,你說的小數(shù),可以用number(n,2)來保存就可以了。


還是number型。

參考以下定義:

number ( precision, scale)

? ? precision表示數(shù)字中的有效位。如果沒有指定precision的話,oracle將使用38作為精度。

? ? scale表示數(shù)字小數(shù)點(diǎn)右邊的位數(shù),scale默認(rèn)設(shè)置為0.? 如果把scale設(shè)成負(fù)數(shù),

? ? oracle將把該數(shù)字取舍到小數(shù)點(diǎn)左邊的指定位數(shù)。

--查看用戶或角色所擁有的角色:

select * from dba_role_privs;

--查看哪些用戶有sysdba或sysoper系統(tǒng)權(quán)限(查詢時(shí)需要相應(yīng)權(quán)限)

select * from V$PWFILE_USERS


--創(chuàng)建一個(gè)商品信息表(id,name,price,type)和商品類型表(id,name)


create table spInformation?

(

id number,

name varchar2(30),

price number(9,2),

type varchar2(30)

);



create table spType

(

id number,

name varchar2(30)

);



--通過sql語句給商品信息表的id添加主鍵約束,name添加唯一約束,

--type添加外鍵約束,價(jià)格添加檢查約束(1-99999999元)

alter table spInformation?

add constraint PK_id primary key(id);?




--查詢表

select * from spInformation;?

select * from spType;?

--笛卡爾積:將多個(gè)表的數(shù)據(jù)進(jìn)行一一對應(yīng),所得的結(jié)果為多表的笛卡爾積

select * from spInformation,spType;

--多表查詢

select * from spInformation,spType where spInformation.name=spType.name


--刪除表

drop table spInformation;

drop table spType;

--number型的相關(guān)知識?


oracle中不管什么數(shù)字(正常數(shù)字,不包括0000001這樣的),都可以用number來存,

只是后面的參數(shù)略有不同,你說的小數(shù),可以用number(n,2)來保存就可以了。


還是number型。

參考以下定義:

number ( precision, scale)

? ? precision表示數(shù)字中的有效位。如果沒有指定precision的話,oracle將使用38作為精度。

? ? scale表示數(shù)字小數(shù)點(diǎn)右邊的位數(shù),scale默認(rèn)設(shè)置為0.? 如果把scale設(shè)成負(fù)數(shù),

? ? oracle將把該數(shù)字取舍到小數(shù)點(diǎn)左邊的指定位數(shù)。

? ??

? ??

? ? --表創(chuàng)建后,添加主鍵約束?

語法:?

alter table 表名?

add constraint 主鍵名稱(一般主鍵名稱為”PK_”開頭) primary key(要設(shè)為主鍵的列名);?

例:?

alter table T_Grade?

add constraint pk_gradeId primary key (gradeId);





3、通過sql語句給商品信息表的id添加主鍵約束,name添加唯一約束,type添加外鍵約束,價(jià)格添加檢查約束(1-99999999元)


--通過sql語句給商品信息表的id添加主鍵約束


alter table spInformation?


add constraint PK_id primary key(id);




--name添加唯一約束

ALTER TABLE spInformation

ADD CONSTRAINT unique_spInformation

UNIQUE (name)?

--id添加外鍵約束


【表創(chuàng)建成功后再添加外鍵約束


添加外檢約束 :alter table 從表表名 add constraint?

外鍵約束名稱 foreign key(列名) references 主表名稱(主鍵列名)】



alter table spType add constraint

?FK_spInformation foreign key(id) references spInformation(id);


--價(jià)格添加檢查約束(1-99999999元)


Alter table spInformation

Add constraint CK_spInformation check(99999999>price and price>=1)



4、在商品信息表和商品類型表中輸入數(shù)據(jù)進(jìn)行測試。


--在商品信息表和商品類型表中輸入數(shù)據(jù)進(jìn)行測試。


insert into spInformation values(1,'詩書畫唱牌商品',999.99,'名牌類');


insert into spType values(1,'名牌類');





作業(yè) END


關(guān)于甲骨文公司的擴(kuò)展知識 START

https://wenwen.sogou.com/z/q829455879.htm

關(guān)于甲骨文公司的擴(kuò)展知識 END



查看Oracle中所有用戶的方法 START

https://zhidao.baidu.com/question/432789002177092324



方法如下:


輸入select * from dba_users; 即可。


常用語句:


一,查看數(shù)據(jù)庫里面bai所有用戶:


select * from dba_users;?

前提是你是有dba權(quán)限的帳號,如sys,system。


二,查看你能管理的所有用戶:


select * from all_users;??


三,查看當(dāng)前用戶信息 :


select * from user_users;?




擴(kuò)展資料:


Oracle數(shù)據(jù)庫最新版本為Oracle Database 12c。Oracle數(shù)據(jù)庫12c引入了一個(gè)新的多承租方架構(gòu),使用該架構(gòu)可輕松部署和管理數(shù)據(jù)庫云。


此外,一些創(chuàng)新特性可最大限度地提高資源使用率和靈活性,如Oracle Multitenant可快速整合多個(gè)數(shù)據(jù)庫,而Automatic Data Optimization和Heat Map能以更高的密度壓縮數(shù)據(jù)和對數(shù)據(jù)分層。


這些獨(dú)一無二的技術(shù)進(jìn)步再加上在可用性、安全性和大數(shù)據(jù)支持方面的主要增強(qiáng),使得Oracle數(shù)據(jù)庫12c 成為私有云和公有云部署的理想平臺。


Oracle數(shù)據(jù)庫具有完整的數(shù)據(jù)管理功能:?


1)數(shù)據(jù)的大量性


2)數(shù)據(jù)的保存的持久性


3)數(shù)據(jù)的共享性


4)數(shù)據(jù)的可靠性


查看Oracle中所有用戶的方法 END

oracle 刪除用戶命令和部分命令 START

好文推薦:https://blog.csdn.net/yang_road/article/details/2305045



SQLPLUS 環(huán)境下

? ?① 用戶及用戶下面所有表的刪除

? ?drop user? username cascade;

? ?② 創(chuàng)建用戶

? ?create user username identified by password ;

? ?修改密碼

? ?alter user system identified by [password]

? ?③ 分配表空間

? ? alter user username default tablespace? 表領(lǐng)空間 quota unlimited on 表領(lǐng)空間 ;

? ? 創(chuàng)建表空間

? ? CREATE TABLESPACE "ts"?

? ? LOGGING?

? ? DATAFILE 'E:/ORACLE/ORADATA/TEST/ts.ora' SIZE 50M?

? ? EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT? AUTO

? ?④ 權(quán)限賦予

? ? grant create session to username ;

? ? (create session :連接數(shù)據(jù)庫的權(quán)限 )




oracle 刪除用戶命令和部分命令 END



PLSQL設(shè)置編輯器的字體大小的方法 START



很多時(shí)候,會搜索,會嘗試,會思考才是更重要的技能。




菜單欄—工具—首選項(xiàng)—用戶界面(左邊列表)—字體—編輯器(點(diǎn)擊選擇調(diào)整)。 其他的字體也可以在那里設(shè)置。

PLSQL設(shè)置編輯器的字體大小的方法 END



查看Oracle中所有用戶或角色的權(quán)限等等 START



推薦好文:https://mp.weixin.qq.com/s?src=11&timestamp=1614779792&ver=2924&signature=VwdW8RzALXGOkhAckOM3FD489ej5dpgY9INVTEngMTyVqXWlLKCpvWsESBGOvC-x3vREfL95fDefakUlrTQpDPBhTs4iPq-XgNNWzU*VZJ-zL98FgTrs3CWuNqttsjpR&new=1



1.查看所有用戶:

select * from dba_users;

select * from all_users;

select * from user_users;


2.查看用戶或角色系統(tǒng)權(quán)限(直接賦值給用戶或角色的系統(tǒng)權(quán)限):

select * from dba_sys_privs;

select * from user_sys_privs;


3.查看角色(只能查看登陸用戶擁有的角色)所包含的權(quán)限

sql>select * from role_sys_privs;


4.查看用戶對象權(quán)限:

select * from dba_tab_privs;

select * from all_tab_privs;

select * from user_tab_privs;


5.查看所有角色:

select * from dba_roles;


6.查看用戶或角色所擁有的角色:

select * from dba_role_privs;

select * from user_role_privs;


7.查看哪些用戶有sysdba或sysoper系統(tǒng)權(quán)限(查詢時(shí)需要相應(yīng)權(quán)限)

select * from V$PWFILE_USERS


比如我要查看用戶 wzsb的擁有的權(quán)限:

SQL> select * from dba_sys_privs where grantee='WZSB';

比如我要查看用戶 wzsb的擁有的角色:

SQL> select * from dba_role_privs where grantee='WZSB';

查看一個(gè)用戶所有的權(quán)限及角色

select privilege from dba_sys_privs where grantee='WZSB'

union

select privilege from dba_sys_privs where grantee in?

(select granted_role from dba_role_privs where grantee='WZSB' );




select * from dba_role_privs;



查看Oracle中所有用戶或角色的權(quán)限等等 END




Oracle中常用的部分語句個(gè)人總結(jié) START


create table spInformation?


(


id number,


name varchar2(30),


price number(9,2),


type varchar2(30)


);


create table spType


(id number,


name varchar2(30));


--查詢表


select * from spInformation;?


select * from spType;?




--通過sql語句給商品信息表的id添加主鍵約束

alter table spInformation?

add constraint PK_id primary key(id);

--name添加唯一約束

ALTER TABLE spInformation

ADD CONSTRAINT unique_spInformation

UNIQUE (name)?

--id添加外鍵約束

【表創(chuàng)建成功后再添加外鍵約束

添加外檢約束 :alter table 從表表名 add constraint?

外鍵約束名稱 foreign key(列名) references 主表名稱(主鍵列名)】

alter table spType add constraint

?FK_spInformation foreign key(id) references spInformation(id);

--價(jià)格添加檢查約束(1-99999999元)

Alter table spInformation

Add constraint CK_spInformation check(99999999>price and price>=1)

--在商品信息表和商品類型表中輸入數(shù)據(jù)進(jìn)行測試。

insert into spInformation values(1,'詩書畫唱牌商品',999.99,'名牌類');


insert into spType values(1,'名牌類');

--select * from user_tablespaces ;

--select * from user_tablespaces ;






Oracle中常用的部分語句個(gè)人總結(jié) END

SQL語句代碼增刪改查例子 START


--登錄sys超級管理員賬號執(zhí)行

--創(chuàng)建一個(gè)名為J190802的賬戶

create user j190802

--設(shè)置密碼為1

identified by orcl

--設(shè)置默認(rèn)表空間為user

default tablespace users

--設(shè)置臨時(shí)表空間為temp

temporary tablespace temp

--解鎖賬號,允許登錄oracle

account unlock;


--允許j190802用戶登錄到orcl數(shù)據(jù)庫

grant connect to j190802;

--允許j190802用戶使用存儲空間

grant resource to j190802;


--登錄j190802賬號執(zhí)行代碼

--創(chuàng)建一個(gè)表

create table userinfo(

? ? id number primary key,

? ? act varchar2(30) not null,

? ? pwd varchar2(30) not null,

? ? birth date

);

--新增語句

insert into userinfo values(2,'小明',789,sysdate);

--修改語句

update userinfo set pwd = 888 where id = 1;

--刪除

delete from userinfo where id = 2;


select * from userinfo;

--顯示rowid

select t.*,t.rowid from userinfo t;

--顯示rownum

select rownum,t.* from userinfo t;


--創(chuàng)建學(xué)生表

create table stu(

? ?stuno number,

? ?stuname varchar2(20),

? ?address varchar2(30)

);

--給學(xué)生表添加一個(gè)sex屬性

alter table stu add sex char(2);

--刪除表:delete和drop

--刪除stu表中的所有數(shù)據(jù)

--delete from stu;

--將stu表結(jié)構(gòu)都刪除了

--drop table stu;

--給stu表的stuno添加一個(gè)主鍵約束

alter table stu?

add constraint pk_stu

primary key(stuno);


create table product(

? ? id number primary key,

? ? pname varchar2(30) not null,

? ? price number(10,2),

? ? ptype number

);

create table protype(

? ? id number primary key,

? ? tname varchar2(30) not null

);

--添加外鍵約束

alter table product?

add constraint fk_product

foreign key(ptype)

references protype(id);


insert into protype values(1,'書籍');

insert into protype values(2,'家電');

insert into protype values(3,'食品');

insert into product values(1,'德芙巧克力',8.5,3);

insert into product values(2,'java實(shí)踐',44.8,1);


--stu表中的stuname不能為空

alter table stu

modify stuname not null;


--Product表中的price必須在1到1000之間

alter table product

add constraint ck_price?

check(price between 1 and 1000);

--報(bào)錯(cuò),價(jià)格超過1000了

--insert into product values(3,'電冰箱',3200,2);




SQL語句代碼增刪改查例子 END




Oracle創(chuàng)建或查看或刪除用戶,DBA,rownum偽列進(jìn)行分頁,增刪改查語句等【詩書畫唱】的評論 (共 條)

分享到微博請遵守國家法律
长阳| 九龙城区| 岳池县| 全椒县| 江华| 宁阳县| 新兴县| 新河县| 含山县| 宁都县| 平原县| 香格里拉县| 平遥县| 乡城县| 金川县| 浏阳市| 内黄县| 北海市| 汉川市| 枣阳市| 延庆县| 乐安县| 华亭县| 辛集市| 双流县| 吉木乃县| 茶陵县| 临桂县| 丰顺县| 永泰县| 龙南县| 化州市| 奉节县| 云安县| 无为县| 长葛市| 吴川市| 大竹县| 万全县| 乐业县| 乌兰察布市|