설문조사
PostgreSQL/PPAS 관련 듣고 싶은 교육은


총 게시물 94건, 최근 0 건
   

컬럼 디폴트값의 사용

글쓴이 : PostgresDBA 날짜 : 2012-12-05 (수) 21:40 조회 : 5637
컬럼 디폴트값 사용은 아래과 같습니다. syntax 는 오라클과 동일하네요.

scott@[local]:5432 scottdb#SQL> CREATE TABLE TEST(X INTEGER DEFAULT -1, Y INTEGER);
CREATE TABLE
Time: 287.837 ms
scott@[local]:5432 scottdb#SQL> INSERT INTO TEST(X,Y) VALUES(DEFAULT,100);
INSERT 0 1
Time: 62.379 ms
scott@[local]:5432 scottdb#SQL> INSERT INTO TEST(Y) VALUES(200);
INSERT 0 1
Time: 11.973 ms
scott@[local]:5432 scottdb#SQL> INSERT INTO TEST(X,Y) VALUES(NULL, 300);
INSERT 0 1
Time: 11.605 ms
scott@[local]:5432 scottdb#SQL> SELECT * FROM TEST;
  x   |  y  
------+-----
   -1 | 100
   -1 | 200
 NULL | 300
(3 rows)

Time: 75.948 ms
scott@[local]:5432 scottdb#SQL> 


   

postgresdba.com