• Oracle基本命令大全


     用户:  

    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 connect,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;

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

    添加外键约束:

    alter table 外键表 add constraint FK_名字 foreign key(外键列) references 主键表(列)  

    alter table 外间表 add constraint fk_名字 foreign key (外键列) references 主键表(列)

  • 相关阅读:
    Ganglia Install
    [ZZ]perl一揽子特殊变量
    点滴积累【C#】---C#实现上传word将路径保存到数据库,文件保存到服务器。并且按照名称读取服务器的word
    点滴积累【C#】---C#实现上传照片到物理路径,并且将地址保存到数据库,
    点滴积累【C#】---C#实现上传word以流形式保存到数据库和读取数据库中的word文件。
    点滴积累【C#】---将Excel数据导入到数据库
    点滴积累【C#】---TreeView读取数据库
    DIV内英文或者数字不换行的问题 解决办法
    Rabbitmq中rabbitmqctl的常用命令
    Uploadify参数详解
  • 原文地址:https://www.cnblogs.com/walle2014/p/3664688.html
Copyright © 2020-2023  润新知