Home > 設定資料 > Viewにカラムを追加するには

Viewにカラムを追加するには

既存のViewにカラムを追加するには
ALTER VIEW
を使うらしい。

まずView作成


CREATE view_table AS
SELECT
table_a.カラム1,
table_a.カラム2,
table_b.カラム3
FROM table_a
LEFT JOIN table_b
ON table_b.id = table_a.id;

作成したViewにカラム4を追加


ALTER VIEW view_table AS
SELECT
table_a.カラム1,
table_a.カラム2,
table_b.カラム3,
table_b.カラム4
FROM table_a
LEFT JOIN table_b
ON table_b.id = table_a.id;

CREATE OR REPLACE VIEW はどういう時に使うんだろ・・・
IF NOT EXISTSみたいな物かな?


CREATE OR REPLACE VIEW view_table AS
SELECT
table_a.カラム1,
table_a.カラム2,
table_b.カラム3,
table_b.カラム4
FROM table_a
LEFT JOIN table_b
ON table_b.id = table_a.id;

Comments:0

Comment Form
Remember personal info

Trackbacks:0

Trackback URL for this entry
http://acoustype.com/archives/540/trackback
Listed below are links to weblogs that reference
Viewにカラムを追加するには from acoustype.com

Home > 設定資料 > Viewにカラムを追加するには

Search
Feeds
Meta

Return to page top