数据库中alter的用法的用法你知道吗?下面小编就跟你们详细介绍下数据库中alter的用法的用法,希望对你们有用。

数据库中alter的用法的用法如下:

To add a column to an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name

ADD column_name column-definition;

For example:

ALTER TABLE supplier

ADD supplier_name varchar2(50);

This will add a column called supplier_name to the supplier table.

Syntax #2

To add multiple columns to an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name

ADD ( column_1 column-definition,

column_2 column-definition,

...

column_n column_definition );

For example:

ALTER TABLE supplier

ADD ( supplier_name varchar2(50),

city varchar2(45) );

This will add two columns (supplier_name and city) to the supplier table.

Modifying column(s) in a table

Syntax #1

To modify a column in an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name

MODIFY column_name column_type;

For example:

ALTER TABLE supplier

MODIFY supplier_name   varchar2(100)     not null;

This will modify the column called supplier_name to be a data type of varchar2(100) and force the column to not allow null values.

Syntax #2

To modify multiple columns in an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name

MODIFY ( column_1 column_type,

column_2 column_type,

...

column_n column_type );

For example:

ALTER TABLE supplier

MODIFY ( supplier_name varchar2(100) not null,

city varchar2(75)   );

This will modify both the supplier_name and city columns.

Drop column(s) in a table

Syntax #1

To drop a column in an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name

DROP COLUMN column_name;

For example:

ALTER TABLE supplier

DROP COLUMN supplier_name;

This will drop the column called supplier_name from the table called supplier.

Rename column(s) in a table

(NEW in Oracle 9i Release 2)

Syntax #1

Starting in Oracle 9i Release 2, you can now rename a column.

To rename a column in an existing table, the ALTER TABLE syntax is:

ALTER TABLE table_name

RENAME COLUMN old_name to new_name;

For example:

ALTER TABLE supplier

RENAME COLUMN supplier_name to sname;

This will rename the column called supplier_name to sname.

oracle数据库alter的用法,数据库中alter的用法相关推荐

  1. mysql中去重的用法_mysql中去重 distinct 用法

    在使用MySQL时,有时需要查询出某个字段不重复的记录,这时可以使用mysql提供的distinct这个关键字来过滤重复的记录,但是实际中我们往往用distinct来返回不重复字段的条数(count( ...

  2. mysql中change用法,mysql 中alter的用法以及一些步骤

    mysql 中alter的用法以及一些方法 在用到alter的时间,查到了这个文章,就copy下来了,详细进入下面链接: MySQL之alter语句用法总结 1:删除列 ALTER TABLE [表名 ...

  3. mysql数据库 or的用法_MySQL中or语句用法示例

    1.mysql中or语法的使用,在mysql语法中or使用注意点. 项目遇到坑,遍历发放奖励数据查询错误!!! $sql = 'SELECT * FROM `vvt_spread_doubleegg_ ...

  4. java decode函数用法_Oracle 中 decode 函数用法

    含义解释: decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) 该函数的含义如下: IF 条件=值1 THEN RETURN(翻译值1) ELSIF 条件=值2 THE ...

  5. python中enumerate在for循环中用法_python中enumerate的用法实例解析

    在python中enumerate的用法多用于在for循环中得到计数,本文即以实例形式向大家展现python中enumerate的用法.具体如下: enumerate参数为可遍历的变量,如 字符串,列 ...

  6. python 字典定义日志用法_python中字典(Dictionary)用法实例详解

    本文实例讲述了python中字典(Dictionary)用法.分享给大家供大家参考.具体分析如下: 字典(Dictionary)是一种映射结构的数据类型,由无序的"键-值对"组成. ...

  7. java中throws用法_java中throws实例用法详解

    在程序出现异常时,会有一个抛出异常的throw出现,这里我们要跟今天所讲的throws区分开.throws的作用是声明抛出,在名称上也跟throw有所不同.下面我们就throws对策概念.语法.实例带 ...

  8. pythonappend用法_python中append实例用法总结

    append()函数 描述:在列表ls最后(末尾)添加一个元素object 语法:ls.append(object) -> None 无返回值 例: a=[1,2,3] a.append(5) ...

  9. python中max函数用法_Python中max函数用法实例分析

    Python中max函数用法实例分析 更新时间:2015年07月17日 15:45:09 作者:优雅先生 这篇文章主要介绍了Python中max函数用法,实例分析了Python中max函数的功能与使用 ...

  10. php中sisson用法,thinkPHP中session()方法用法详解

    本文实例讲述了thinkPHP中session()方法用法.分享给大家供大家参考,具体如下: 系统提供了Session管理和操作的完善支持,全部操作可以通过一个内置的session函数完成. 用法 s ...

最新文章

  1. SAP Spartacus的一个问题 - CheckoutStepsSetGuard无法import
  2. www.cnblog.org无法访问了
  3. linux input输入子系统分析《三》:S3C2440的触摸屏驱动实例
  4. 华为公开“一种芯片堆叠封装及终端设备”专利
  5. python模板引擎传迭代器_python之路 模块,序列化,迭代器,生成器
  6. verilog系统任务之$random
  7. python线程池的使用
  8. sklearn.preprocessing.StandScaler
  9. 数字信号处理-希尔伯特变换
  10. Verilog设计遇到了Congestion问题怎么办?
  11. 安卓分析工具GameGurdian使用说明
  12. 联发科希望P40和P70救命,能如愿么?
  13. c# record的使用场景
  14. 如何理解「异或(XOR)」运算在计算机科学中的重要性
  15. 解忧杂货店—你的问题,我来解答
  16. Windows 10 配置OpenGL ES 3.0 环境
  17. 【23M1W1】菊厂入职前的一些小复习
  18. a survey of transformer 学习笔记
  19. 志汇商城-同城门户小程序,同城服务小程序
  20. html 注音标签,html标签整理

热门文章

  1. Switch Transformer模型解读-Introduction
  2. 如何让全屏游戏的文本编辑框支持IME和TSF输入法
  3. Android数据库升级,android开发艺术探索pdf百度网盘
  4. html中加入emjio表情,jqueryemoji表情插件
  5. a标签的href属性 download属性
  6. 一文吃透 VS Code+Git 操作(vs code中git的相关配置与使用)
  7. 微信支付 发起商家转账API 2022年v3 transfer batches
  8. 计算机原理 · 全加器
  9. linux设置 wps 窗口颜色设置,WPS文字办公—修改默认字体颜色的方法
  10. 分类模型的评价指标--混淆矩阵,ROC,AUC,KS,Lift,Gain