This commit is contained in:
vipg
2025-11-18 11:53:08 +08:00
parent 74e87033ed
commit 53e55c1123
3 changed files with 23 additions and 5 deletions

View File

@@ -69,6 +69,12 @@ BEGIN
WHERE table_name = 'user_info_view'
) INTO view_exists;
-- 若视图存在,先删除(避免字段名冲突)
IF view_exists THEN
DROP VIEW user_info_view;
RAISE NOTICE '已删除旧视图 user_info_view';
END IF;
-- 创建或更新视图
CREATE OR REPLACE VIEW user_info_view AS
SELECT
@@ -85,9 +91,9 @@ BEGIN
WHERE
u.deleted = FALSE;
-- 根据视图是否已存在输出不同提示
-- 根据视图是否已存在输出不同提示
IF view_exists THEN
RAISE NOTICE '视图 user_info_view 已更新';
RAISE NOTICE '视图 user_info_view 已更新(删除旧视图后重建)';
ELSE
RAISE NOTICE '视图 user_info_view 已创建';
END IF;

View File

@@ -69,6 +69,12 @@ BEGIN
WHERE table_name = 'country_info_view'
) INTO view_exists;
-- 若视图存在,先删除(避免字段名冲突)
IF view_exists THEN
DROP VIEW country_info_view;
RAISE NOTICE '已删除旧视图 country_info_view';
END IF;
-- 创建或更新视图
CREATE OR REPLACE VIEW country_info_view AS
SELECT
@@ -87,7 +93,7 @@ BEGIN
-- 根据视图是否已存在输出不同提示
IF view_exists THEN
RAISE NOTICE '视图 country_info_view 已更新';
RAISE NOTICE '视图 country_info_view 已更新(删除旧视图后重建)';
ELSE
RAISE NOTICE '视图 country_info_view 已创建';
END IF;

View File

@@ -69,6 +69,12 @@ BEGIN
WHERE table_name = 'currency_info_view'
) INTO view_exists;
-- 若视图存在,先删除(避免字段名冲突)
IF view_exists THEN
DROP VIEW currency_info_view;
RAISE NOTICE '已删除旧视图 currency_info_view';
END IF;
-- 创建或更新视图
CREATE OR REPLACE VIEW currency_info_view AS
SELECT
@@ -87,11 +93,11 @@ BEGIN
-- 根据视图是否已存在输出不同提示
IF view_exists THEN
RAISE NOTICE '视图 currency_info_view 已更新';
RAISE NOTICE '视图 currency_info_view 已更新(删除旧视图后重建)';
ELSE
RAISE NOTICE '视图 currency_info_view 已创建';
END IF;
EXCEPTION
WHEN OTHERS THEN
RAISE NOTICE '处理视图时发生错误: %', SQLERRM;
END $$;
END $$;