码迷,mamicode.com
首页 > 数据库 > 详细

oracle系列(三)表操作基础

时间:2018-07-12 01:04:39      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:clob   --   ble   int   add   trunc   结构   使用   文件路径   

支持的数据类型:

字符型
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到多个字符
_:单个任意字符

 

oracle系列(三)表操作基础

标签:clob   --   ble   int   add   trunc   结构   使用   文件路径   

原文地址:https://www.cnblogs.com/ICE_Inspire/p/9297406.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!