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
SYS
SYSTEM
DBSNMP
SYSMAN
STU
SCOTT
SA
OUTLN
FLOWS_FILES
MDSYS
ORDSYS
EXFSYS
WMSYS
APPQOSSYS
APEX_030200
OWBSYS_AUDIT
ORDDATA
CTXSYS
ANONYMOUS
USERNAME
------------------------------
XDB
ORDPLUGINS
OWBSYS
SI_INFORMTN_SCHEMA
OLAPSYS
ORACLE_OCM
XS$NULL
BI
PM
MDDATA
IX
SH
DIP
OE
APEX_PUBLIC_USER
HR
SPATIAL_CSW_ADMIN_USR
SPATIAL_WFS_ADMIN_USR
38 rows selected
SQL> --查看当前用户下的所有表;
SQL> select *from user_tables;
TABLE_NAME
------------------------------
SELLER
COMMODITY
ORDERITEM
CUSTOMER
ORDERFORM
SQL>
oracle操作的点点滴滴
最新推荐文章于 2021-04-06 06:41:50 发布