首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SQL脚本看不到数据库

问SQL脚本看不到数据库
EN

Stack Overflow用户
提问于 2021-08-13 11:13:34
回答 1查看 26关注 0票数 0

我想在我的桌子上改几个名字。我使用的是Flyway,所以我使用的是迁移。我想更改表中的名称,但脚本看不到该表。数据库已停靠。

我想要改变这一点:

代码语言:javascript
复制
 create table if not exists document_entity
 (
    document_id varchar
    constraint document_entity_document_id
    not null primary key,
    document_file varchar not null
 );

如下所示:

代码语言:javascript
复制
 alter table document_entity
   rename to documents;
 alter table document_entity
   rename column document_id to id;
 alter table document_entity
   rename column document_file to file;

我也必须从第一个表中更改关系,但不知道如何编写此表。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-13 13:33:39

您在第一个查询中修改了document_entity的表名。第二个和第三个查询不能改变document_entity,而必须改变文档,因为documents_entity已经不存在了。

代码语言:javascript
复制
alter table document_entity rename to documents; 
alter table documents rename column document_id to id; 
alter table documents rename column document_file to file;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68771305

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档