0
45
5
1
View
Articles
Name
¼Õº´¸ñ
(2002-05-08 00:10:02, Hit : 13836, Vote : 1716)
Homepage
http://www.itmembers.net
Subject
DDL(Data Definition Language) - CREATE TABLE(ù»)
Áö³ ½Ã°£¿¡ ÀÌ¾î ¹Ù·Î ½Ç½ÀÀ¸·Î ³Ñ¾î°©´Ï´Ù.
¾Æ·¡¿Í °°Àº ±¸Á¶ÀÇ C_DEPT Å×À̺íÀ» ¸¸µé·Á°í ÇÕ´Ï´Ù.
Áö³ ½Ã°£¿¡ ´Ù·é CREATE ¹®ÀÇ Çü½ÄÀ» ÂüÁ¶Çؼ Çѹø ¸¸µé¾î º¾½Ã´Ù.
»ùÇà µ¥ÀÌÅÍ´Â 38°¿¡¼ ´Ù·é INSERT ¹®À» ÂüÁ¶Çؼ Á÷Á¢ Çغ¸½Ã°í, À̹ø ½Ã°£¿¡´Â CREATE ¹®¸¸ ÇÔ²² Çϱâ·Î ÇÏÁÒ.
¾Æ·¡ ºó °÷À» ¸¶¿ì½º·Î µå·¡±×Çϸé À§¿Í °°Àº Å×À̺íÀ» ¸¸µå´Â CREATE ¹®ÀÌ ÀÖ½À´Ï´Ù. ¸ÕÀú °õ°õÀÌ »ý°¢ÇØ º¸½Ã°í È®ÀÎÇØ º¸½Ã±â ¹Ù¶ø´Ï´Ù.
CREATE TABLE C_DEPT
( DEPT_NO NUMBER(2) PRIMARY KEY,
DEPT_NAME VARCHAR2(30) NOT NULL );
¸¶Âù°¡Áö·Î ¾Æ·¡¿Í °°Àº ±¸Á¶ÀÇ Å×À̺íÀ» ¸¸µé·Á°í ÇÕ´Ï´Ù.
Àß »ý°¢ÇØ º¸½Ã°í ¾Æ·¡ ºó°÷À» µå·¡±×Çؼ È®ÀÎÇϽñ⠹ٶø´Ï´Ù.
CREATE TABLE C_EMP
(EMP_NUM CHAR(5),
EMP_NAME VARCHAR2(30) NOT NULL,
HIRE_DATE DATE DEFAULT SYSDATE NOT NULL,
RETIRE_DATE DATE,
DEPT_NO NUMBER(2),
CONSTRAINT PK_EMPNUM PRIMARY KEY(EMP_NUM),
CONSTRAINT FK_DEPTNO FOREIGN KEY(DEPT_NO)
REFERENCES C_DEPT(DEPT_NO) );
À§¿¡¼ ½Ç½ÀÇÑ µÎ °¡Áö ¹æ¹ýÀº ¾à°£ÀÇ Â÷ÀÌ°¡ ÀÖ½À´Ï´Ù.
¸ÕÀú ½Ç½ÀÇÑ C_DEPTÀÇ °æ¿ì, Ä÷³º°·Î CONSTRAINT¸¦ ÁöÁ¤ÇÏ¿´½À´Ï´Ù. ÀÌ·² °æ¿ì º°µµ·Î CONSTRAINT ÀýÀ» ¸í½ÃÇÏÁö ¾Ê¾Æµµ µË´Ï´Ù.
¹Ý¸é C_EMP Å×À̺íÀº º°µµÀÇ CONSTRAINT ÀýÀ» »ç¿ëÇÏ¿© CONSTRAINT¸¦ ÁöÁ¤ÇÏ¿´½À´Ï´Ù.
¾î´À °ÍÀÌ ´õ ÆíÇÑ ¹æ¹ýÀÎÁö´Â »ç¿ëÀÚÀÇ ¸òÀÔ´Ï´Ù.
ÀÌ»ó µ¿ÁÖ ¾Æºü ¼Õº´¸ñÀ̾ú½À´Ï´Ù.
Prev
DDL(Data Definition Language) - ALTER TABLE
¼Õº´¸ñ
Next
DDL(Data Definition Language) - CREATE TABLE(ß¾)
¼Õº´¸ñ
Copyright 1999-2024
Zeroboard
/ skin by
Zetyx