Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
90903069
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
90903069
编写于
5月 26, 2003
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add item for changing a column's data type.
上级
6923ea2b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
9 deletion
+31
-9
doc/FAQ
doc/FAQ
+16
-5
doc/src/FAQ/FAQ.html
doc/src/FAQ/FAQ.html
+15
-4
未找到文件。
doc/FAQ
浏览文件 @
90903069
Frequently Asked Questions (FAQ) for PostgreSQL
Last updated:
Tue Apr 22 14:02:41
EDT 2003
Last updated:
Mon May 26 15:25:04
EDT 2003
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
...
...
@@ -60,7 +60,8 @@
4.1) What is the difference between binary cursors and normal cursors?
4.2) How do I SELECT only the first few rows of a query?
4.3) How do I get a list of tables or other things I can see in psql?
4.4) How do you remove a column from a table?
4.4) How do you remove a column from a table, or change it's data
type?
4.5) What is the maximum size for a row, a table, and a database?
4.6) How much database disk space is required to store data from a
typical text file?
...
...
@@ -644,10 +645,10 @@
the -E option so it will print out the queries it uses to execute the
commands you give.
4.4) How do you remove a column from a table?
4.4) How do you remove a column from a table
, or change its data type
?
This functionality was added in release 7.3 with ALTER TABLE DROP
COLUMN. In earlier versions, you can do this:
DROP COLUMN functionality was added in release 7.3 with ALTER TABLE
DROP
COLUMN. In earlier versions, you can do this:
BEGIN;
LOCK TABLE old_table;
SELECT ... -- select all columns but the one you want to remove
...
...
@@ -657,6 +658,16 @@
ALTER TABLE new_table RENAME TO old_table;
COMMIT;
To change the data type of a column, do this:
BEGIN;
ALTER TABLE tab ADD COLUMN new_col new_data_type;
UPDATE tab SET new_col = CAST(old_col AS new_data_type);
ALTER TABLE DROP COLUMN old_col;
COMMIT;
You might then want to do VACUUM FULL tab to reclaim the disk space
used by the expired rows.
4.5) What is the maximum size for a row, a table, and a database?
These are the limits:
...
...
doc/src/FAQ/FAQ.html
浏览文件 @
90903069
...
...
@@ -10,7 +10,7 @@
alink=
"#0000ff"
>
<H1>
Frequently Asked Questions (FAQ) for PostgreSQL
</H1>
<P>
Last updated:
Tue Apr 22 14:02:41
EDT 2003
</P>
<P>
Last updated:
Mon May 26 15:25:04
EDT 2003
</P>
<P>
Current maintainer: Bruce Momjian (
<A
href=
"mailto:pgman@candle.pha.pa.us"
>
pgman@candle.pha.pa.us
</A>
)
<BR>
...
...
@@ -87,7 +87,7 @@
<A
href=
"#4.3"
>
4.3
</A>
) How do I get a list of tables or other
things I can see in
<I>
psql
</I>
?
<BR>
<A
href=
"#4.4"
>
4.4
</A>
) How do you remove a column from a
table?
<BR>
table
, or change it's data type
?
<BR>
<A
href=
"#4.5"
>
4.5
</A>
) What is the maximum size for a row, a
table, and a database?
<BR>
<A
href=
"#4.6"
>
4.6
</A>
) How much database disk space is required
...
...
@@ -822,9 +822,9 @@
execute the commands you give.
</P>
<H4><A
name=
"4.4"
>
4.4
</A>
) How do you remove a column from a
table?
</H4>
table
, or change its data type
?
</H4>
<P>
This
functionality was added in release 7.3 with
<P>
<SMALL>
DROP COLUMN
</SMALL>
functionality was added in release 7.3 with
<SMALL>
ALTER TABLE DROP COLUMN
</SMALL>
. In earlier versions,
you can do this:
</P>
<PRE>
...
...
@@ -838,6 +838,17 @@
COMMIT;
</PRE>
<P>
To change the data type of a column, do this:
</P>
<PRE>
BEGIN;
ALTER TABLE tab ADD COLUMN new_col
<i>
new_data_type
</i>
;
UPDATE tab SET new_col = CAST(old_col AS
<i>
new_data_type
</i>
);
ALTER TABLE DROP COLUMN old_col;
COMMIT;
</PRE>
<P>
You might then want to do
<I>
VACUUM FULL tab
</I>
to reclaim the
disk space used by the expired rows.
</P>
<H4><A
name=
"4.5"
>
4.5
</A>
) What is the maximum size for a row, a
table, and a database?
</H4>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录