Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
90903069
Commit
90903069
authored
22 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Add item for changing a column's data type.
parent
6923ea2b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/FAQ
+16
-5
16 additions, 5 deletions
doc/FAQ
doc/src/FAQ/FAQ.html
+15
-4
15 additions, 4 deletions
doc/src/FAQ/FAQ.html
with
31 additions
and
9 deletions
doc/FAQ
+
16
−
5
View file @
90903069
Frequently Asked Questions (FAQ) for PostgreSQL
Last updated:
Tue Apr
2
2
1
4:02:41
EDT 2003
Last updated:
Mon May
2
6
1
5: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:
...
...
This diff is collapsed.
Click to expand it.
doc/src/FAQ/FAQ.html
+
15
−
4
View file @
90903069
...
...
@@ -10,7 +10,7 @@
alink=
"#0000ff"
>
<H1>
Frequently Asked Questions (FAQ) for PostgreSQL
</H1>
<P>
Last updated:
Tue Apr
2
2
1
4:02:41
EDT 2003
</P>
<P>
Last updated:
Mon May
2
6
1
5: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>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment