oracle构造添加字段的SQL语句

oracle构造添加字段的SQL语句,第1张

用ORACLE数据库 在其中一个表最后添加了两个字段

alter   table   your_table   add   (column    col_type clumn    col_type )

your_table   :表名

column /column    字段名

col_type /col_type    字段类型

建议用过程实现添加字段 屏蔽掉字段已经存在所造成的错误 另外 一次添加一个字段会更好一些

declare

vstr_sql   varchar ( ):= alter   table   your_table   add   (column    col_type clumn    col_type )

begin

execute   immediate   vstr_sql

end

/

select   column_name data_type   from   ALL_TAB_COLUMNS   where   TABLE_NAME= XX

可以查XX表列名

你可以先查出所有的列 判断是否已有 没有就添加

lishixinzhi/Article/program/Oracle/201311/16876

"随时改变的值"这里有歧义啊,如果你是整列都是一个值可以采用楼上两位的方法,如果第一行是good第二行是doog那得有个数据来源,或者union all 并表

select id ,'good' from table a --where 

union all

selece id ,'doog' from table a --where


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11407876.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存