当前位置:Gxlcms > 数据库问题 > ORACLE 操作

ORACLE 操作

时间:2021-07-01 10:21:17 帮助过:2人阅读

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 主键表(列)

ORACLE 操作

标签:

人气教程排行