oracle函数
--创建数据表空间
create tablespace DBStudy datafile 'D:\DB\oracle\DBStudy.dbf' size 100m;
---给用户附表空间权限
alter user king default tablespace DBStudy ;
grant create session,create table,unlimited tablespace to king;
use DBStudy
create table Student
(
stuNo varchar(12) not null,
stuName varchar(20) not null,
stuSex number(1),
stuBrithday date default sysdate,
stuAddress varchar(20)
)
create table Scourse
(
scourseNo varchar(20) not null,
scourseName varchar(20) not null,
scourseType varchar(20)
)
create table Score
(
stuNo varchar(12) not null,
scourseNo varchar(12) not null,
score number(3,1)
)
select sysdate-1 from dual;
select MONTHS_BETWEEN(sysdate,to_date('2012-01-30','yyyy-mm-dd')) from dual;
select trunc(to_date(sysdate,'yyyy-mm-dd')) from dual;
select trunc(to_date('2012-03-12','yyyy-mm-dd'),'day') from dual;
select last_day(sysdate) from dual
select add_months(sysdate,3) from dual;
select concat('021','51717950')||'转862' from dual;
select instr('wggorkingor','or',2,2) from dual;
select length('king') from dual;
select replace('kwggg','wgg','in') from dual;
select substr('king',2,2) from dual;
select initcap('king') from dual;
---创建用户
CREATE USER UserName identified by UserPassword;
--创建数据表空间
create tablespace DBStudy datafile 'D:\DB\oracle\DBStudy.dbf' size 100m;
---给用户附表空间权限
alter user king default tablespace DBStudy ;
grant create session,create table,unlimited tablespace to king;
--oracle 数据类型
1 oracle有三类数据类型:字母、数字、日期、
字母:char(length)、nchar(length)定长字符,最多存2000字节
varchar2(length)、nvarchar2(length)变长字符,最多存4000字节
大对象:blob、clob、nclob、bfile可以存4gb的大字符数据
数字字符:number(length,[scale])
日期: year、month、day
定位符:rowid返回代表行距的物理位置
rownum(伪列)返回检索行顺序的数字
currval返回序列的当前值
nextval返回序列的下一列值
数据转换:
to_char:执行十字到字符和日期到字符的转换
to_number:字符到数字的转换
to_date:字符到日期的转换