Oracle SQL基本用法

Oracle SQL基本用法

表操作

  • 创建表 create table tablename (age int,name String ……)

    primary key (xxx,yyy)

    foreign key (xxx) references 表名 (xxx)

  • 删除表 drop table tablename cascade|restricty

修改基本表 ↓ alter table 表名

​ add column <新列名><数据类型>[完整性约束]

​ add 表级完整性约束

​ …

  • 重命名表 alter table 表名 rename to 新表名

  • 增加字段 alter table tablename add (ID int default ‘空’ not null)

  • 修改字段 alter table tablename modify (ID varchar(4))

  • 重命名字段 alter table tablename rename column 列名 to 新列名

  • 删除字段 alter table tablename drop column 字段名

  • 添加主键 alter table tablename add peimary key (col)

  • 删除主键 alter table tablename drop primary key (col)

  • 创建索引 create unique|cluster index idxname on tablename(col)

    create unique index SCno on SC(Sno asc,Cno desc)

    asc:升序

    desc:降序

  • 删除索引 drop index idxname (索引是不能改变的,再更改之前必须删除之前的索引 新建)

  • 修改索引名 alter index 旧索引名 rename to 新索引名

  • 创建模式 create schema 模式名 authorization 用户名

  • 删除模式 drop schema 模式名 cascade|restrict

    cascade和restrict必须选一个

    cascade:将模式下的所有数据库对象一起删除

    restrict:如果模式下有数据库对象,拒绝删除

数据查询

–完整语法描述:

select {
   [distinct | all] column | *}
[into table_name]
from {
   table | views | other select}
[where conditions]
[group by columns]
[having conditions]
[order by columns]
distinct : 去掉重复

字符匹配:

[not] like '匹配串' [escape '换码字符']
%	:	表示任意长度的字符串
_	:	表示单个任意字符
select * from student where Sname like '刘%';
select * from student where Sname like '欧阳_';
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值