--创建表格

create table  production(

ProductIdvarchar2(10),

ProductNamevarchar2(20),

ProductPricenumber(8,2),

Quantitynumber(10),

Categoryvarchar2(10),

Desperationvarchar2(1000),

Originvarchar2(10)

)

--添加一列

alter table production

add remark varchar2(200);

select * from production

--修改列类型

alter table production

modify remark number(2,2)

--删除一列

alter table production

drop column remark

create table categoryinfo(

CategotyIdvarchar2(10),

CategoryNamevarchar2(30)

);

alter table categoryInfo

DROP COLUMN CategotyId;

alter table categoryinfo

ADD CategoryIdvarchar2(10);

--添加主键约束

alter table  production

ADD CONSTRAINTpk_Productionprimary key(ProductId);

alter table  categoryinfo

ADD CONSTRAINT pk_CategoryInfo primary key(CategoryId);

--删除主键约束

alter table categoryinfo

DROP CONSTRAINT pk_CategoryInfo;

--完整练习

create table productioninfo (

Prod uctIdvarchar2(10),

ProductNamevarchar2(20),

ProductPricenumber(8,2),

Quantitynumber(10),

Categoryvarchar2(10),

Desperationvarchar2(1000),

Originvarchar2(10),

primary key(ProductId),

--添加外键

CONSTRAINT fk_pro FOREIGN KEY(Category) REFERENCES categoryinfo(CategoryId) ON DELETE CASCADE

);

alter table productioninfo

DROP CONSTRAINT fk_pro;

--修改添加外键约束

alter table productioninfo

ADD CONSTRAINT fk_pro FOREIGN KEY (Category) REFERENCES categoryinfo(CategoryId)

ON DELETE CASCADE;

select * from categoryinfo;

select * from production;

alter table production

--创建带有check条件的消费者表

create table custominfo(

CustomIdvarchar2(10),

CustomNamevarchar2(20),

CustomAgenumber(2),

Gendervarchar2(2),

Telvarchar2(11),

Addressvarchar2(100),

CONSTRAINT CHK_AGE

CHECK(CustomAge>=18 and CustomAge<=50)

);

--修改时添加check条件

alter table custominfo

ADD CONSTRAINTS chk_gender CHECK(Gender = '男' or Gender = '女');

--删除约束条件

alter table custominfo

DROP CONSTRAINS chk_gender;

--unique约束唯一约束

--订单信息表

create table orderinfo(

OrderIdvarchar2(10),

CustomIdvarchar2(10),

ProductIdvarchar2(10),

OrderDatevarchar2(10),

OrderQuantitynumber(10),

SendDatevarchar2(10),

CONSTRAINTS UNQ_ORDERID UNIQUE(OrderId)

);

--NOT NULL约束

--管理员信息表

create table managerinfo(

ManagerIdvarchar2(10),

LoginNamevarchar2(10) NOT NULL,

Passwordvarchar2(10) NOT NULL,

Namevarchar2(10),

Telnumber(11)

);

--修改notnull约束

alter table managerinfo

MODIFY LoginName Null;

oracle DDL(数据定义语言)基本语句的更多相关文章

  1. oracle学习笔记(三) DCL 数据控制语言与 DDL 数据定义语言

    DCL 数据控制语言 Data control language 之前说过的授权和收权利语句 grant, revoke DDL 数据定义语言 Data define language create ...

  2. sql 两大类 DDL数据定义语言 和DCL数据控制语言

    SQL分为五大类: DDL:数据定义语言   DCL:数据控制语言     DML:数据的操纵语言  DTL:数据事务语言  DQL:数据查询语言. DDL (date definition lang ...

  3. DDL数据定义语言

    DDL数据定义语言 (一)概述 DDL(Data Definition Language):数据定义语言,用来定义数据库对象,库.表.列等:创建.删除.修改 库,表结构.主要分为操作数据库的DDL和操 ...

  4. Hive 官方手册翻译 -- Hive DDL(数据定义语言)

    Hive DDL(数据定义语言) Confluence Administrator创建, Janaki Lahorani修改于 2018年9月19日 原文链接 https://cwiki.apache ...

  5. mysql DDL数据定义语言

    DDL数据定义语言 本节涉及MySQL关键字:create.alter(rename,add,chang,modify,drop).drop.delete.truncate等. -- 创建表:-- 数 ...

  6. Oracle language types(语言种类) 表的相关操作 DDL数据定义语言

    数据定义语言 Data Definition Language Statements(DDL)数据操纵语言 Data Manipulation Language(DML) Statements事务控制 ...

  7. 【MySQL】DDL数据定义语言的基本用法create、drop和alter(增删改)

    DDL 的基础语法 文章目录 DDL 的基础语法 对数据库进行定义 对数据表进行定义 创建表结构(数据表) 设计工具 修改表结构 小结 参考资料 简单复习一波 SQL必知必会 DDL 的英文全称是 D ...

  8. DDL 数据定义语言

    目录 创建数据库(CREATE) 删除数据库(DROP) 修改数据库(ALTER) 创建数据表(CREATE) 数据表的数据属性 数据类型属性(Type) 其他属性(Null,Key,Default, ...

  9. MySQL之DDL数据定义语言:库、表的管理

    库的管理 常用命令 #创建库 create database if not exists 库名 [ character set 字符集名]; create database if not exists ...

  10. ODPS SQL <for 数据定义语言 DDL>

    数据定义语言:(DDL) 建表语句: CREATE TABLE [IF NOT EXISTS] table_name [(col_name data_type [COMMENT col_comment ...

随机推荐

  1. ERROR 2003 (HY000): Can't connect to MySQL server on 'ip address' (111)的处理办法

    远程连接mysql数据库时可以使用以下指令 mysql -h 192.168.1.104 -u root -p 如果是初次安装mysql,需要将所有/etc/mysql/内的所有配置文件的bind-a ...

  2. linux命令-系统命令

    1.查看Linux磁盘空间大小 df -lh Filesystem 容量 已用 可用 已用% 挂载点 /dev/hda8 11G 6.0G 4.4G 58% / /dev/shm 236M 0 236 ...

  3. 第9章 Shell基础(2)_Bash基本功能

    3. Bash的基本功能 3.1 历史命令与命令补全 (1)历史命令:#history [选项] [历史命令保存文件] ①选项:-c:清空历史命令: -w:把缓存中的历史命令写入文件~/.bash_h ...

  4. 【repost】JavaScript Scoping and Hoisting

    JavaScript Scoping and Hoisting Do you know what value will be alerted if the following is executed ...

  5. React服务端渲染总结

    欢迎吐槽 : ) 本demo地址( 前端库React+mobx+ReactRouter ):https://github.com/Penggggg/react-ssr.本文为笔者自学总结,有错误的地方 ...

  6. Permutations II

    Given a collection of numbers that might contain duplicates, return all possible unique permutations ...

  7. [LeetCode] Binary Watch 二进制表

    A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom ...

  8. [LeetCode] Count of Smaller Numbers After Self 计算后面较小数字的个数

    You are given an integer array nums and you have to return a new counts array. The counts array has ...

  9. NPOI操作EXCEL(六)——矩阵类表头EXCEL模板的解析

    哈哈~~~很高兴还活着.总算加班加点的把最后一类EXCEL模板的解析做完了... 前面几篇文章介绍了博主最近项目中对于复杂excel表头的解析,写得不好,感谢园友们的支持~~~ 今天再简单讲诉一下另一 ...

  10. Extjs 下拉框显示远程数据

    var store = new HT.SyncStore({ baseParams : { itemName : '绩效考核_任务状态' }, url : __ctxPath + '/system/l ...