Doris 修改字段,如何书写可重复执行脚本 #40517
Unanswered
XinSuiNian
asked this question in
Q&A
Replies: 1 comment
-
建议英文提问,如使用中文提问,可以去ask.selectdb.com中文技术论坛。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
我有如下这么几类修改字段的ddl语句 :新增字段、修改字段名和修改字段类型
`ALTER TABLE test_read_data ADD COLUMN aaabbb INT DEFAULT "0" ;
ALTER TABLE test_read_data RENAME COLUMN aaabbb cccddd;
ALTER table test_read_data modify COLUMN cccddd varchar(200) DEFAULT '0' ;`
但是这种语句,执行过一次后,再次执行,就会报错。如何修改成可重复多次执行,如:在新增字段前要判断表是否存在,字段是否存在,然后在执行语句。就是类似这种:
ALTER TABLE if exists test_read_data ADD COLUMN if not exists aaabbb INT DEFAULT "0" ;
但是这种语句,Doris 并不能兼容,在Doris中执行会报错,有什么其他的方式可以替代?
Beta Was this translation helpful? Give feedback.
All reactions