加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle系列(三)表操作基础

发布时间:2020-12-12 13:30:44 所属栏目:百科 来源:网络整理
导读:支持的数据类型: 字符型 char 定长 最大2000 varchar2() 变长 最大4000 clob 字符型大对象 最大4G 数字型 number范围 -10的38次方到10的+38次方; number(5,2) 一个小数,有效位5个,小数点后2个数字 number(5) 表示一个5位的整数 日期类型 date timestamp 二进

支持的数据类型:

字符型
char 定长 最大2000
varchar2() 变长 最大4000
clob 字符型大对象 最大4G

数字型
number范围 -10的38次方到10的+38次方;
number(5,2) 一个小数,有效位5个,小数点后2个数字
number(5) 表示一个5位的整数

日期类型
date
timestamp

二进制数据
blob 保密性较高,存入数据库/其他情况,保持在文件服务器,数据库只存文件路径

建表:

create table student(
stuId varchar2(10),
age number(2),
birthday date
)

--添加一个字段
alter table student add(name varchar2(10));
--修改字段长度
alter table student modify (name varchar2(20));

null值:is null,is not null
select * from student t where t.name is not null;

savepoint 保存点的使用

SQL> savepoint firstPoint;
Savepoint created

delete from student;

rollback to firstPoint;

drop from student;
delete from student where age>10;
truncate table student;--删除所有记录,表结构还在,不写日志,速度极快

简单查询:

列别名,函数nvl
select t.age "年龄",nvl( t.age,0) "年龄为null显示0",t.rowid from STUDENT t;
字符串连接:||
select t.name||‘-‘|| t.age from student t;

like操作符:%:任意0到多个字符_:单个任意字符

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读