oracle操作的點點滴滴

2021-07-25 11:14:17 字數 4296 閱讀 9559

connected to oracle database 11g enterprise edition release 11.2.0.1.0 

connected as haha@orcl

sql> show user;

user is haha

sql> connt haha/123456;

connt haha/123456

ora-00900: 無效 sql 語句

sql> connt user haha/123456;

connt user haha/123456

ora-00900: 無效 sql 語句

sql> conn user haha/123456;

sql>

sql> conn user haha/123456;

sql> create user zz identified by 123456;

create user zz identified by 123456

ora-01031: 許可權不足

sql> conn system/123456;

connected to oracle database 11g enterprise edition release 11.2.0.1.0

connected as system

sql> create user zz identified by 123456;

user created

sql> conn zz/123456;

sql> show user;

user is "system"

sql> conn zz/123456;

sql>--為新建立的使用者加連線許可權和資源許可權

sql> grant connect,resource to zz;

grant connect,resouret to zz

ora-01919: 角色 'resouret' 不存在

sql> grant connect,resourece to zz;

grant connect,resourece to zz

ora-01919: 角色 'resourece' 不存在

sql> grant connect,resource to zz;

grant succeeded

sql> conn zz/123456;

connected to oracle database 11g enterprise edition release 11.2.0.1.0

connected as zz

sql> ed

sql>

sql> create table db

2 (

3 id number primary key,

4 d_name varchar(20)

5 )

6 /

table created

sql> insert into db values(10,'hhhh');

1 row inserted

sql> commit;

commit complete

sql> select *from db;

id d_name

---------- --------------------

10 hhhh

sql> select *from db;

id d_name

---------- --------------------

10 hhhh

sql> select *from db;

id d_name

---------- --------------------

10 hhhh

sql> select *from db;

id d_name

---------- --------------------

11 hahhaa

10 hhhh

sql> select *from db;

id d_name

---------- --------------------

11 hahhaa

10 hhhh

12 vvvvvvvvv

sql> select *from db;

id d_name

---------- --------------------

10 hhhh

12 vvvvvvvvv

sql> select *from db;

id d_name

---------- --------------------

10 我愛你

12 vvvvvvvvv

sql>

//解鎖

alter user scott account unlock;

//對資料庫的表進行外來鍵約束

sql> create table userinfo

2 (

3 id integer primary key,

4 u_name varchar(20)

5 )

6 /

table created

sql> create table u_class

2 (

3 id integer primary key,

4 content varchar(50),

5 u_id integer

6 )

7 /

table created

sql> insert into userinfo values(1,'aaa');

1 row inserted

sql> insert into u_class values(2,'zzz',1);

1 row inserted

sql>--新增外來鍵約束;

sql> alter table u_class add foreign key (u_id) references userinfo(id);

table altered

sql> delete from userinfo where id=1;

delete from userinfo where id=1

ora-02292: 違反完整約束條件 (sa.sys_c0011126) - 已找到子記錄

sql> delete from u_class where id=2;

1 row deleted

sql> delete from userinfo where id=1;

1 row deleted

sql> --檢視oracle中的所有的使用者;

sql> select *from dba_users;

username

------------------------------

mgmt_view

syssystem

dbsnmp

sysman

stuscott

saoutln

flows_files

mdsys

ordsys

exfsys

wmsys

apex_030200

owbsys_audit

orddata

ctxsys

anonymous

username

------------------------------

xdbordplugins

owbsys

si_informtn_schema

olapsys

oracle_ocm

xs$null

bipm

mddata

ixsh

dipoe

apex_public_user

hrspatial_csw_admin_usr

spatial_wfs_admin_usr

38 rows selected

sql> --檢視當前使用者下的所有表;

sql> select *from user_tables;

table_name

------------------------------

seller

commodity

orderitem

customer

orderform

sql>

acm 點點滴滴

qsort排序方法 六種qsort排序方法 本文中排序都是採用的從小到大排序 一 對int型別陣列排序 int num 100 sample int cmp const void a const void b qsort num,100,sizeof num 0 cmp 二 對char型別陣列排序 ...

sizeof 點點滴滴

1.靜態變數是存放在全域性資料區中的,sizeof計算棧中分配的大小,所以類或結構體中的靜態變數時不會計算在sizeof內的!2.sizeof和strlen的區別 1 sizeof操作符的結果型別是size t,它在標頭檔案中的typedef為unsigned int型別。該型別保證能容納實現所建立...

Elastic search點點滴滴

在打造集中化日誌那篇中,稍微提了下elastic search。elk打造集中化日誌 elastic search是elk的核心,寫的時候重點也放在它上面,不過還是覺得深度挖掘得不是太夠,所以決定再另寫一篇重點介紹下elastic search。正如elastic的本義一樣,es就是為擴充套件而生,...