--Oracle查询当前版本
select * from v$version;
----------Oracle 查询服务器端编码----------
select * from v$nls_parameters where parameter='NLS_CHARACTERSET';

----------Oracle 查询当前时间的三种方式----------
select sysdate from dual;
--2016/8/5 21:47:44
select current_date from dual;
--2016/8/5 21:48:42
select SYSTIMESTAMP from dual;
--05-8月 -16 09.48.23.880000 下午 +08:00

DESC STUINFO;
select name from v$database;
select * from v$database;

select * from user_tables;
select * from user_tablespaces;
select index_name from user_indexes;
select database from user_datapump_jobs;
/*创建学生信息表*/
CREATE table stuInfo(
stuName varchar2(20) NOT NULL,
stuNo char(6) NOT NULL,
stuAge number(3,0) default 0,
stuID numeric(18,0),
stuSeat NUMERIC(2,0)
)

--创建学员成绩表
create table stuMarks
(
examNO CHAR(7) NOT NULL,
stuNo CHAR(6) NOT NULl,
writtenExam NUMERIC(3,0),
labExam numeric(3,0)
);
--删除约束
alter table stuinfo
drop constraint id;

--增加主键约束
alter table stuinfo
add constraint pk_stuno primary key (stuno);

alter table stumarks
add constraint pk_examno primary key (examno);
--添加唯一约束
alter table stuinfo
add constraint UQ_STUID UNIQUE (STUID);
--添加检查约束check
alter table stuinfo
add constraint ck_stuage check(stuAge between 15 and 40);
--添加外键索引
alter table stumarks
add constraint fk_stuno foreign key(stuno) references stuinfo(stuno);

--查看表空间
select * from user_tablespaces

--修改字段的类型
alter table stuinfo modify (stuAddress number(20));
--查询出用户所有表的索引
select * from user_indexes

--修改列名
alter table stuinfo rename column stuAdress to stuAddress;

--修改表名
ALTER TABLE username.TEST1 RENAME TO stuinfo

05-08 08:14