orcal学习笔记

这篇博客详细介绍了Oracle数据库中创建、修改和删除表的操作,包括添加约束、修改字段、删除字段、重命名以及查询数据文件等。还讨论了各种查询语句、约束类型如非空、主键、唯一和检查约束,以及外键约束的创建和管理。
摘要由CSDN通过智能技术生成

创建表
create table test01(
id int not null,
name varchar(8) not null,
gender varchar2(2) not null,
age int not null,
address varchar2(20) default ‘地址不详’ not null,
regdata date
);
修改表
alter table test01 add constraint s_id primary key;

alter table test01 add constraint CK_INFOS_GENDER check(gender=’男’ or gender=’女’)

alter table test01 add constraint CK_INFOS_AGE(age>=0 and age<=50)

alter table 表名 modify 字段名 default 默认值; //更改字段类型

alter table 表名 add 列名 字段类型; //增加字段类型

alter table 表名 drop column 字段名; //删除字段名

alter table 表名 rename column 列名 to 列名 //修改字段名

rename 表名 to 表名 //修改表名


删除表

truncate table 表名 //删除表中的所有数据,速度比delete快很多,截断表

delete from table 条件//

drop table 表名 //删除表

插入语句

insert into 表名(值1,值2) values(值1,值2);

修改语句

update 表名 set 字段=值 [修改条件]

查询语句

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值