ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • VIEW
    postgresql 2023. 7. 28. 18:03
    • VIEW 는 데이터를 물리적으로 저장하지 않고, SQL 을 저장함.
    • 자주 사용하는 SQL 을 매번 작성해 실행하기 귀찮으니 VIEW 로 만들어 사용함.
    select first_name, last_name, address 
    from customer join address
    on customer.address_id = address.address_id 
    
    -- view 생성
    create view customer_info as
    select first_name, last_name, address 
    from customer join address
    on customer.address_id = address.address_id 
    
    -- view 조회
    select * from customer_info
    
    -- view 수정
    create or replace view customer_info as
    select first_name, last_name, address, district 
    from customer join address
    on customer.address_id = address.address_id 
    
    -- view 이름 변경
    alter view customer_info rename to c_info
    
    -- view 삭제
    drop view c_info

    'postgresql' 카테고리의 다른 글

    CHECK constraint (when create table)  (0) 2023.07.28
    Timestamp and Extract  (0) 2023.07.28
    like / ilike / as  (0) 2023.07.27
    외부 데이터 import 하기  (0) 2023.07.27
    PostgreSQL 소개  (0) 2023.07.27

    댓글

Designed by Tistory.