ORACLE 操作

sqlplus
用户:
    scott/tiger
    sys as sysdba 空密码
转换用户登录:
    connect 用户/密码
    connect sys as sysdba   权限
用户解锁:
    alter user scott account unlock;

-------------------------------------
表:
 创建表语法:
    create table 表名
    (
        列名 类型 约束 是否为空,
        ......
        列名 类型 约束 是否为空
    );
查看表结构: desc 表名
提交:commit;
  修改命令:alter table
    1、添加约束
        alter table 表名 add constraint 约束名 约束类型
    2、删除约束
        alter table 表名 drop constraint 约束名
    3、修改列
        alter table 表名 modify(列名 类型 约束 是否为空)
    4、添加列
        alter table 表名 add(列名 类型 约束 是否为空)
    5、删除列
        alter table 表名 drop column 列名
    6、修改列名
        alter table 表名 rename column 列名 to 新列名
    7、修改表名
        alter table 表名 rename to 新表名。
添加多行:
    1、把源表中的数据添加到新表(已存在)
        insert into 新表名(列名)
        select 列名
        from 源表名
    2、把现有表中的数据创建到新表中(一定不能存在新表)
      create table 新表 as selelct 列名 from 源表名 where (不要数据--where 1=2)

--------------------------
序列:
    语法:
        create sequence 序列名;
    伪列:nextval,currval;
        查看序列的当前值:select 序列名.currval from dual;
        查看序列的下一个值:select 序列名.nextval from dual;
修改:
    alter sequence 序列名
删除:
    drop sequence 序列名
--------------------------------------------
创建用户:
    create user 用户名 identified by 密码。
1、分配会话权限(授权)
    grant create session to 用户名。
2、分配资源权限
    grant resource to 用户名。
  取消:
    revoke resource from 用户名
    grant命令用于为用户分配权限或角色,而revoke命令用于为用户撤销权限或角色

---------------------
访问其他用户的表。
在其他用户登录的情况下授权:
    grant select,insert,update,delete on 表名 to 用户名。
查看用户的表:
    select table_name from user_tables;
--------------------
伪列:
    select rownum,表名.* from 表名 where rownum
-----------------------------------
清屏:clear scr;
--------------------------
D:\app\Myra\product\11.1.0\db_1\NETWORK\ADMIN   //
D:\app\Myra\product\11.1.0\db_1\jdbc\lib    //jar包路径

添加外键约束:
    alter table 外键表 add constraint FK_名字 foreign key(外键列) references 主键表(列)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值