oracle操作的点点滴滴

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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值