Oracle初探(一)
2015-08-03 17:09
387 查看
Oracle基本操作
--创表 create table stu ( stu_id number, stu_name varchar2(20), stu_age number ); --插入数据 insert into stu values ( 200,'tony',19 ); --伪表 select sysdate from dual; --伪列 select s.*,rowid,rownum from (select * from stu)s; --复制表(有数据) create table copystu select* from sru; --复制表(无数据) create table copystu select * from stu where 1<>1; --查看表结构 desc stu; --增加字段 alter table stu add(stu_date date); alter table stu add(stu_date to_date('2015-02-14','yyy-MM-dd')); --删除字段 alter table stu drop(stu_date); --修改字段 alter table stu modify(stu_age number(20)); --约束 create table stu ( stu_id number(8) primary key, stu_name varchar2(20) not null, stu_Sex varchar2(20) default '男', stu_age number(8) check(stu_age>=0 and stu_age<=100), stu_date date unique ); --表级约束 alter table stu add constant pk_stu_id PRIMARY KEY(stu_id); --外键 create table classtab ( class_id number(8) primary key, class_name varchar2(20) ); create table stutab ( stu_id number(8) primary key, stu_name varchar2(20), class_id number(8) ); --设置外键 alter table stutab add constraint fk_class_id foreign key(class_id) references classtab(class_id);
相关文章推荐
- oracle 创建用户
- oracle exp EXP-00008: 遇到 ORACLE 错误 904
- oracle 删除表找回
- oracle将查询到的数据插入到数据库的表中
- Oracle锁表数据查询及解决方法
- oracle 日期获取
- 数据库之Oracle的使用【入门版,包括常用的Sql语句】
- ORACLE 实用语句大集合
- Oracle 11g 导入,空数据表无法导出问题。
- 数据库之Oracle的下载与安装【入门必修】
- Make sure you have the 32 bits Oracle Client installed.
- Oracle中的CHR()函数与ASCII()函数
- Oracle中的CHR()函数与ASCII()函数
- MySQL实现ORACLE序列(Sequence)的解决方案
- Mysql与Oracle区别
- mybatis执行批量更新batch update 的方法(oracle,mysql)
- ORACLE数据文件大小限制
- How to Modify Public Network Information including VIP in Oracle Clusterware (文档 ID 276434.1)
- Oracle内存数据库Timesten的使用(2)
- Oracle内存数据库Timesten的使用(1)