테이블을 생성하고 난 후

Primary Key 를 추가하고

Sequence 생성하기

 

-- 테이블 생성: my_tbl 
CREATE TABLE my_tbl (
  ID              NUMBER(2)       NOT NULL,
  CONTENT VARCHAR2(60)  NOT NULL,
);


-- Primary Key 생성: my_tbl_pk
ALTER TABLE my_tbl 
ADD CONSTRAINT my_tbl_pk PRIMARY KEY (ID);

 

-- Sequence 생성: 

CREATE SEQUENCE my_tbl_seq
INCREMENT BY 1
START WITH 1 ORDER;

 

 

-- Oracle SQL Developer에서 테이블 SQL 확인 
  CREATE TABLE "LIVE01"."MY_TBL
   ( "ID" NUMBER(2,0) NOT NULL ENABLE, 
"CONTENT" VARCHAR2(15 BYTE) NOT NULL ENABLE, 
 CONSTRAINT "MY_TBL_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS NOCOMPRESS LOGGING
  TABLESPACE "USERS"  ENABLE
   ) SEGMENT CREATION DEFERRED 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  TABLESPACE "USERS" ;
 

 

 출처

Primary Key 추가, Sequence 생성

 

Oracle 11g Release 2

  Database 2 Day Developer's Guide

    4. Creating and Managing Schema Objects

https://docs.oracle.com/cd/E11882_01/appdev.112/e10766/tdddg_objects.htm#TDDDG32100

 

728x90

+ Recent posts