sql - 如何修改postgresql中的类型?

标签 sql postgresql ddl alter

我有一个类型定义为:

CREATE TYPE New_A AS
   (id integer,
    id_new integer,
    arrived date,
    sum numeric);

我想将 arriveddate 类型更改为 timestamp without time zone 类型

我试过:

ALTER TYPE New_A SET arrived TO timestamp without time zone

但它不起作用。它给出:

ERROR: syntax error at or near "arrived"

最佳答案

您可以使用alter attribute 子句:

ALTER TYPE new_a ALTER ATTRIBUTE arrived TYPE timestamp without time zone;

详情请引用the documentation .

关于sql - 如何修改postgresql中的类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33094905/

相关文章:

python - 您需要安装 postgresql-server-dev-X.Y 来构建服务器端扩展或 libpq-dev 来构建客户端应用程序

java - Hibernate DDL表动态创建

sql-server - 添加约束是 DDL 或 DML

sql - 有没有办法根据其中一列值添加表约束?

SQL 选择两个近乎的字段

mysql - SQL 连接查询以返回总和和最近的条目

mysql - 使用mysql如何在字符串中找到字母表的第一次出现

php - 这个 ~* 语法在 sql 查询中的作用是什么?

sql - Postgres 分组并提取具有多个元素的组

sql - 如何生成4位随机数