[ Programing ]/Database
[MySQL] View Table 삭제&생성
Mister_Q
2023. 11. 16. 16:12
/* VIEW : 가상 테이블 (데이터 딕셔너리 테이블에 SQL문만 저장되 디스크 공간 할당 없음.) */
-- 기존 뷰-테이블 삭제, 만약 없다면 생성.
DROP VIEW IF EXISTS `v_object_info`;
CREATE TABLE `v_object_info` (
`object_id` INT(11) NOT NULL COMMENT ' ObjectSequence',
`object_name` VARCHAR(128) NOT NULL COLLATE 'utf8mb4_general_ci',
`param` BIGINT(20) NOT NULL DEFAULT '0',
`reg_date` DATETIME NOT NULL
) ENGINE = MyISAM;
-- 뷰-테이블 삭제
DROP VIEW IF EXISTS `v_object_info`;
DROP TABLE IF EXISTS `v_object_info`;
-- 뷰 알고리즘(Query) 생성
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `v_object_info` AS SELECT `object_id`, `object_name`, `param`, `reg_date` FROM v_object_info;