Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a1f8cd

Browse files
committed
Add an example of attaching a default value to an updatable view.
This is probably the single most useful thing that ALTER VIEW can do,particularly now that we have auto-updatable views. So show an explicitexample.
1 parent0343a59 commit3a1f8cd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎doc/src/sgml/ref/alter_view.sgml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,19 @@ ALTER VIEW [ IF EXISTS ] <replaceable class="parameter">name</replaceable> RESET
154154
<literal>bar</literal>:
155155
<programlisting>
156156
ALTER VIEW foo RENAME TO bar;
157-
</programlisting></para>
157+
</programlisting>
158+
</para>
159+
160+
<para>
161+
To attach a default column value to an updatable view:
162+
<programlisting>
163+
CREATE TABLE base_table (id int, ts timestamptz);
164+
CREATE VIEW a_view AS SELECT * FROM base_table;
165+
ALTER VIEW a_view ALTER COLUMN ts SET DEFAULT now();
166+
INSERT INTO base_table(id) VALUES(1); -- ts will receive a NULL
167+
INSERT INTO a_view(id) VALUES(2); -- ts will receive the current time
168+
</programlisting>
169+
</para>
158170
</refsect1>
159171

160172
<refsect1>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp