oracle之alter学习笔记

陆陆续续的需要接触到一些DML,DDL发现除了一些简单的crud,其他语法一概模糊。话点时间

记录下来,不用每次都百度。

首先我们创建一张表 

1 create table alter_test2 as select * from  user_role_privs

OK,我突然不觉得这个表名很2,打算给表改个名字

alter table alter_test2 rename to alter_test

接着,发现表需要额外增加一个字段 add_col

alter table alter_test add (add_col varchar2(20))

发现新增的add_col 字符类型不对 而且我希望他是不能为空的

alter table alter_test modify (add_col number(2) not null)

这里有可能会报错,因为既然是非空的就以为着该列的所有字段都必须是有值的

 继续,我心血来潮,想给新增的字段改变名字

alter table alter_test rename column add_col to add_col_new

好了,最后又改变主意了,不想要这个字段了 ,删除之

alter table alter_test drop column add_col_new

alter User username identified by   'new password'  修改用户密码的语法

先如此吧,后续把其他的DDL的用户补充进来,然后是补充DML,DTL,乃至sql用户plsql语法。。

付一篇关于几种类型语法的简单介绍

http://www.cnblogs.com/gnielee/archive/2009/07/31/1535621.html

原文地址:https://www.cnblogs.com/draem0507/p/2748005.html