PostgreSQL怎么更改列类型[postgresql教程]
PostgreSQL怎么更改列类型
我们来看一下pg中的语法:
推荐:postgresql教程
highgo=# h autowhere action is one of:
ADD [ COLUMN ] [ IF NOT EXISTS ] column_name data_type [ COLLATE collation ] [ column_constraint [ ... ] ]
DROP [ COLUMN ] [ IF EXISTS ] column_name [ RESTRICT | CASCADE ]
ALTER [ COLUMN ] column_name [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ]
ALTER [ COLUMN ] column_name SET DEFAULT expression
更改列类型demo:
highgo=# alter table p1 alter COLUMN pswd type text ;ALTER TABLE
highgo=# d p1
Table "public.p1"
Column | Type | Collation | Nullable | Default
--------+-----------------------------+-----------+----------+---------
id | integer | | |
pswd | text | | |
time | timestamp without time zone | | |
请注意,假如是不同类型转换的话可能不成功。
推荐学习《Python教程》。
以上是 PostgreSQL怎么更改列类型[postgresql教程] 的全部内容, 来源链接: utcz.com/z/527752.html