初学常用命令(一)

来源:互联网 发布:mac绘画录制软件 编辑:程序博客网 时间:2024/06/05 04:36

序列:

create sequence sequence_name

start  with 1

increment by 1;

序列使用:

insert into table_name [column] values(sequence_name.nextval,值列表)

登录用户:

conn 用户名/密码@orcl

解锁用户:

alter  user user_name account unlock;

密码重置:

alter user user_name ifentified by password;

对用户授予数据操作权限:

grant select on table_name to scott with grant option;

删除权限:

revoke select on table_name from user_name;

事务控制语言:

 UPDATE Result 
             SET studentresult = studentresult + 5 
             WHERE studentresult <= 95;
  
  SAVEPOINT mark1;  标记回滚点
  DELETE FROM result  WHERE id= '002';  
  SAVEPOINT mark2;标记回滚点
  ROLLBACK TO SAVEPOINT mark1;--回到保存点1,撤销删除操作
  COMMIT; 提交事务

排序:

升序:select column from table_name where condition order by;

降序:select column from table_name where condition order by desc;

增加多条记录:

insert into table_name(column) 

select 值列表 from dual union

......

selecr 值列表 from dual;

修改列名数据类型

alter table 表名 modify 列名 数据类型

添加列名
alter table 表名 add 列名 数据类型

重命名列名
alter table 表名 rename column 当前列名 to 新列名

删除列名
alter table 表名 drop column 列名

重命名表明

 alter table 当前表名 rename  to 新表名

添加主键

alter table table_name add constraint 主键名 primary key(column)

删除主键

alter table table_name drop constraint 主键名;

原创粉丝点击