oracle操作的点点滴滴

来源:互联网 发布:微商城数据统计 编辑:程序博客网 时间:2024/06/09 23:10
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 Connected as haha@ORCLSQL> show user;User is hahaSQL> connt haha/123456;connt haha/123456ORA-00900: 无效 SQL 语句SQL> connt user haha/123456;connt user haha/123456ORA-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 123456ORA-01031: 权限不足SQL> conn system/123456;Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 Connected as systemSQL> create user zz identified by 123456;User createdSQL> conn zz/123456;SQL> show user;User is "system"SQL> conn zz/123456;SQL>--为新创建的用户加连接权限和资源权限SQL> grant connect,resource to zz;grant connect,resouret to zzORA-01919: 角色 'RESOURET' 不存在SQL> grant connect,resourece to zz;grant connect,resourece to zzORA-01919: 角色 'RESOURECE' 不存在SQL> grant connect,resource to zz;Grant succeededSQL> conn zz/123456;Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 Connected as zzSQL> edSQL> SQL> create table db  2  (  3         id number primary key,  4         d_name varchar(20)  5  )  6  /Table createdSQL> insert into db values(10,'hhhh');1 row insertedSQL> commit;Commit completeSQL> select *from db;        ID D_NAME---------- --------------------        10 hhhhSQL> select *from db;        ID D_NAME---------- --------------------        10 hhhhSQL> select *from db;        ID D_NAME---------- --------------------        10 hhhhSQL> select *from db;        ID D_NAME---------- --------------------        11 hahhaa        10 hhhhSQL> select *from db;        ID D_NAME---------- --------------------        11 hahhaa        10 hhhh        12 vvvvvvvvvSQL> select *from db;        ID D_NAME---------- --------------------        10 hhhh        12 vvvvvvvvvSQL> select *from db;        ID D_NAME---------- --------------------        10 我爱你        12 vvvvvvvvvSQL> //解锁alter user scott account unlock;//对数据库的表进行外键约束SQL> create table userinfo  2  (  3         id integer primary key,  4         u_name varchar(20)  5  )  6  /Table createdSQL> create table u_class  2    (  3    id integer primary key,  4    content varchar(50),  5    u_id integer  6  )  7  /Table createdSQL> insert into userinfo values(1,'aaa');1 row insertedSQL> insert into u_class values(2,'zzz',1);1 row insertedSQL>--添加外键约束;SQL> alter table u_class add foreign key (u_id) references userinfo(id);Table alteredSQL> delete from userinfo where id=1;delete from userinfo where id=1ORA-02292: 违反完整约束条件 (SA.SYS_C0011126) - 已找到子记录SQL> delete from u_class where id=2;1 row deletedSQL> delete from userinfo where id=1;1 row deletedSQL> --查看oracle中的所有的用户;SQL> select *from dba_users;USERNAME------------------------------MGMT_VIEWSYSSYSTEMDBSNMPSYSMANSTUSCOTTSAOUTLNFLOWS_FILESMDSYSORDSYSEXFSYSWMSYSAPPQOSSYSAPEX_030200OWBSYS_AUDITORDDATACTXSYSANONYMOUSUSERNAME------------------------------XDBORDPLUGINSOWBSYSSI_INFORMTN_SCHEMAOLAPSYSORACLE_OCMXS$NULLBIPMMDDATAIXSHDIPOEAPEX_PUBLIC_USERHRSPATIAL_CSW_ADMIN_USRSPATIAL_WFS_ADMIN_USR38 rows selectedSQL> --查看当前用户下的所有表;SQL> select *from user_tables;TABLE_NAME------------------------------SELLERCOMMODITYORDERITEMCUSTOMERORDERFORMSQL>

0 0
原创粉丝点击