oracle中的对象创建及删除语句【原创】
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中的对象创建及删除语句【原创】的更多相关文章
- Oracle中dblink的创建与删除
查询数据库中有哪些dblink连接 select * from dba_objects where object_type='DATABASE LINK'; 删除公有的EMIS_PRODUCTOIN连 ...
- Oracle获取数据库中的对象创建语句
使用dbms_metadata.get_ddl()函数可以做到. 实验环境:Oracle 11.2.0.4 以获取jingyu用户下的T1表为例: SQL> conn jingyu/jingyu ...
- Unity3D 中的面向对象设计 {游戏对象(创建、删除、获取),以及添加修改组件}
一.创建游戏对象 游戏对象分三种:(1) 将物体模型等资源由Project工程面板拖拽到Hierarchy层次面板中 (2) 由GameObject菜单创建Unity自带的游戏对象,如Cube.Cam ...
- Oracle表空间的创建与删除
ORACLE中,表空间是数据管理的基本方法,所有用户的对象要存放在表空间中,也就是用户有空间的使用权,才能创建用户对象.否则是不充许创建对象,因为就是想创建对象,如表,索引等,也没有地方存放,Orac ...
- 【JOB】Oracle中JOB的创建方法以及一个细节的探究
在Oracle中可以使用JOB来实现一些任务的自动化执行,类似于UNIX操作系统crontab命令的功能.简单演示一下,供参考. 1.创建表T,包含一个X字段,定义为日期类型,方便后面的定时任务测试. ...
- 使用PL/SQL能查询oracle中数据,在for update 语句中一直卡住
原因:在oracle中,执行了update或者insert语句后,都会要求commit,如果不commit却强制关闭连接,oracle就会将这条提交的记录锁住.下次就不能执行增删操作. 解决:1.查询 ...
- js中函数对象创建的总结
在JavaScript的函数对象创建方法中,可以分为三种情况: 1:第一种是使用function语句定义函数 <script type="text/javascript"&g ...
- 使用API接口在zabbix系统中登陆、创建、删除agent
一.API的介绍 API(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力 ...
- 批量导出oracle中的对象
背景 Oracle数据库中有table,view,procedure,function,package,type等对象,需要将这些对象导出到不同的文件中.常用的方法有3种:1. 通过开发工具直接导出. ...
随机推荐
- 温馨小程序前端布局Flex
伸缩容器支持的属性有: 1,display 2,flex-direction 3,flex-wrap 4,flex-flow 5,justify-content 6,align-items 7,ali ...
- Codeforces 987 F - AND Graph
F - AND Graph 思路: 首先,x & (~x) == 0 其次,~x 的 子集 y = ((~x) ^ (1<<k)), 0<= k < n(如果k这一位是 ...
- Codeforces 377A - Maze
A. Maze 题目链接:http://codeforces.com/contest/377/problem/A time limit per test 2 seconds memory limit ...
- Notepad++安装json插件
安装 : 1.下载插件压缩包并解压出dll:NPPJSONViewer.dll(64位) 下载地址:https://pan.baidu.com/s/1JeBzrovb-GHRo14vO-AnJA 提 ...
- FetchType.LAZY和FetchType.EAGER什么区别
1.FetchType.LAZY:懒加载,加载一个实体时,定义懒加载的属性不会马上从数据库中加载. 2.FetchType.EAGER:急加载,加载一个实体时,定义急加载的属性会立即从数据库中加载. ...
- LeetCode--006--Z字型变换(java)
将一个给定字符串根据给定的行数,以从上往下.从左到右进行 Z 字形排列. 比如输入字符串为 "LEETCODEISHIRING" 行数为 3 时,排列如下: L C I R E T ...
- 20180518VSTO多簿单表汇总外接程序按钮
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsof ...
- linux bash基本特性
一.bash 基础特性 (1)命令历史的功能 history: 环境变量 HISTSIZE:命令历史记录的条数 HISTFILE: ~/.bash_history 每个用户都有自己独立的命令历史文件 ...
- POJ No.2386 Lake Counting
题目链接:http://poj.org/problem?id=2386 分析:八联通的则为水洼,我们则需遍历一个单位附近的八个单位并将它们都改成'.',但附近单位可能仍连接着有'W'的区域,这种情况下 ...
- (CCPC-Final 2018)K - Mr. Panda and Kakin
题意:x是\([1e5,1e9]\)的随机数,p是小于x的最大素数,q是大于等于x的最小素数,\(n=pq\),\(c=f^{2^{30}+3}\mod{n}\),给n和c求f 题解:rsa解密,首先 ...