oracle对象

1.表

a)创建表1

create table students(
id number(10),
stuno number(10) ,
sex varchar2(2),
age int,
classno varchar2(4) ,
regdate date default sysdate
);

b)创建表2

create table student_2
as select * from students;

修改表:

为表增加列(字段)

alter table students add (province varchar2(10));

为表删除列

alter table students drop column province;

修改列

alter table students  modify classno varchar2(6);

重命名表:

alter talbe students rename to students_new;

删除表:

drop table students;//仅删除表
drop table students cascade constraints;//删除表和这个表的视图、约束或触发器

约束:既可以在create table语句进行,也可以在alter table 中进行

非空约束:

1)在create table中:

create table students(
id number(10),
stuno number(10) not null,
sex varchar2(2),
age int,
classno varchar2(4) not null,
regdate date default sysdate
);

2)在alter table中

alter table students modify stuno not null;

主键约束(已经包含非空约束):

增加

1)在create table中:

create table students(
id number(10) primary key,
stuno number(10) not null,
sex varchar2(2),
age int,
classno varchar2(4) not null,
regdate date default sysdate
);

2)在alter table中

alter table students add primary key(id);
alter table students add constraint Students_PK primary key(id);

删除

alter table students drop constraint Students_PK;

外键约束:

1)在create table中:

create table students(
id number(10) primary key,
stuno number(10) not null,
sex varchar2(2),
age int,
classno varchar2(4) not null,
regdate date default sysdate,
classid number(4),
constraint Students_FK foreign key(classid) references class(classid)
);

2)在alter table中:

alter table students add constraint Students_FK foreign key(classid) references class(classid);

索引对象:

B树(Btree)索引;

create index students_stuno_index on students(stuno);

位图索引:

create bitmap index students_sex_index on students(sex);

删除索引:

drop index stuents_stuno_index;

视图对象:

创建视图:

create or replace view students_view as
select id,stuno,sex from students;

创建只读视图:

create or replace view students_view as
select id,stuno,sex from students with read only;

删除视图:

drop view students_view;

序列:

创建序列:

create sequence students_seq
maxvalue 99999
start with 9000
increment by 100
cache 50;

使用序列:

insert into students(id) values(students_seq.nextval);

删除序列:

drop sequence students_seq;

oracle中的对象创建及删除语句【原创】的更多相关文章

  1. Oracle中dblink的创建与删除

    查询数据库中有哪些dblink连接 select * from dba_objects where object_type='DATABASE LINK'; 删除公有的EMIS_PRODUCTOIN连 ...

  2. Oracle获取数据库中的对象创建语句

    使用dbms_metadata.get_ddl()函数可以做到. 实验环境:Oracle 11.2.0.4 以获取jingyu用户下的T1表为例: SQL> conn jingyu/jingyu ...

  3. Unity3D 中的面向对象设计 {游戏对象(创建、删除、获取),以及添加修改组件}

    一.创建游戏对象 游戏对象分三种:(1) 将物体模型等资源由Project工程面板拖拽到Hierarchy层次面板中 (2) 由GameObject菜单创建Unity自带的游戏对象,如Cube.Cam ...

  4. Oracle表空间的创建与删除

    ORACLE中,表空间是数据管理的基本方法,所有用户的对象要存放在表空间中,也就是用户有空间的使用权,才能创建用户对象.否则是不充许创建对象,因为就是想创建对象,如表,索引等,也没有地方存放,Orac ...

  5. 【JOB】Oracle中JOB的创建方法以及一个细节的探究

    在Oracle中可以使用JOB来实现一些任务的自动化执行,类似于UNIX操作系统crontab命令的功能.简单演示一下,供参考. 1.创建表T,包含一个X字段,定义为日期类型,方便后面的定时任务测试. ...

  6. 使用PL/SQL能查询oracle中数据,在for update 语句中一直卡住

    原因:在oracle中,执行了update或者insert语句后,都会要求commit,如果不commit却强制关闭连接,oracle就会将这条提交的记录锁住.下次就不能执行增删操作. 解决:1.查询 ...

  7. js中函数对象创建的总结

    在JavaScript的函数对象创建方法中,可以分为三种情况: 1:第一种是使用function语句定义函数 <script type="text/javascript"&g ...

  8. 使用API接口在zabbix系统中登陆、创建、删除agent

    一.API的介绍 API(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力 ...

  9. 批量导出oracle中的对象

    背景 Oracle数据库中有table,view,procedure,function,package,type等对象,需要将这些对象导出到不同的文件中.常用的方法有3种:1. 通过开发工具直接导出. ...

随机推荐

  1. DOCTYPE的作用以及标准模式和兼容模式的区别

    <!doctype>声明必须处于HTML文档的头部,在<html>标签之前,告知浏览器的解析器用什么文档标准解析这个文档.DOCTYPE不存在或格式不正确会导致文档以兼容模式呈 ...

  2. 2018-2019 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)

    2018-2019 ACM-ICPC Pacific Northwest Regional Contest (Div. 1) 思路: A Exam 思路:水题 代码: #include<bits ...

  3. selenium Grid2 分布式自动化测试环境搭建

    一.Selenium Server 环境配置 1.selenium grid的组成与作用:由一个集线器hub和多个客户机node组成,如果你的程序需要在不用的浏览器,不同的操作系统上测试,而且比较多的 ...

  4. Unity中sharedMaterials 和 materials

    sharedMaterials 和 materials: 这两个属性用法是一样的,但是从效率上来说最好用sharedMaterial,它是共享材质,无论如何操作材质的属性(如更换颜色或者更换shade ...

  5. C# 递归缩小图片

    需求:图片太大,上传到服务器会非常占用服务器空间,而系统又不要求高清图片,于是就通过递归的方式让图片每次减少10%的大小,当图片大小小于100k的时候就保存在本地,核心代码如下: class Prog ...

  6. python中socket模块详解

    socket模块简介 网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个socket.socket通常被叫做"套接字",用于描述IP地址和端口,是一个通信 ...

  7. 解决Android Studio卡在Gradle:Resolve dependecies 'app:_debugCompile'问题

    转载: http://blog.csdn.net/callzjy/article/details/53662073 该死的破墙,我被恶心了一个晚上. 做墙的技术员,TMD的能不能上点心,至少把技术网站 ...

  8. linux常用命令及系统常见符号

    常用命令 1.start x 进入界面 2.shutdown -h now 立刻关机 shutdown -r now 立刻重新启动 reboot 立刻重新启动 3.su root 切换成超级管理员 4 ...

  9. ubuntu下常用命令

    目录 一.查找命令 二.打开相应文件 三.查看系统资源占用 四.Ubantu解压文件 五.虚拟机ubuntu server 14.0 根目录扩容 七.ubuntu 关机,重启,注销命令 1 关机命令 ...

  10. Two Melodies CodeForces - 813D (DP,技巧)

    https://codeforces.com/problemset/problem/813/D dp[i][j] = 一条链以i结尾, 另一条链以j结尾的最大值 关键要保证转移时两条链不能相交 #in ...