DB/SQL/ɽκ

Top/DB/SQL/ɽκ

̿̾§

ɽ̾ޤ̾ȤƻȤʸξϰʲ̤ꡣ

  • ʸdzϤ뤳
  • 1 ʸ 30 ʸǤ뤳
  • [A-Za-z0-9_$#] ʤ뤳
  • Ʊ桼νͭ¾Υ֥Ȥ̾Ƚʣʤ
  • ͽǤʤ

ɽκ

  • ˡ
  • ­
    • ۤɽѥäƺȤϡ̾ʾǤ fuga, piyo ʬˤϤʤƤ⤤
      • ʤˤ硢hoge ɽˤ bar baz 󤬤Ǥ
    • ۤɽѥäƤȤϡȤ˻äƤ
    • ۤɽѥäƤƤ⡢NOT NULL ʳŬѤʤ
    • initial ϽƥȤΥλꡣɽΰΥƥȴ autoallocate ξϡinitial ͤ˺ŬʥƥȥɬפʸĿưdzƤ롣uniform size ξ uniform size ǻꤷñ̤ initial θĿưdzƤ
    • next ɲädzƤƤƥȥλꡣinitial Ʊ͡ɽΰΥƥȴˤäƳƤѤ

ǡ

μʥǡϰʲ̤ꡣ

  • ǡ
    ǡ
    varchar2(<size>)Ĺʸ
    char(<size>)Ĺʸ
    number(<precision>, <size>)ʲ<size> ޥʥˤȴݤ롣<size> ϻꤷʤƤɤ
    dateդȻ
    longĹʸ
    timestamp [with [local] timezone]ôޤ฽߻
    interval year to monthδֳ֤¸ʤ褯狼ġġ

ץ

DEFAULT ץ

Υǥեͤꤹ

  • ˡ
    create table hoge
        ( fuga number(1)  default 0,
          piyo varchar(3) default 'foo');
    

̾ɬܤǤϤʤɤ⡢ѾĤۤɤ

ʤʤ顢̾ϱѾ塢ޤѾ塢ʹ֤ܤ˿ǻȤ뤳Ȥ¿顣

PRIMARY KEY UNIQUE 줿ˤ̾Ʊ̾ΰպ뤳Ȥ顢ƥˤ̿̾ǤȽ˷礱롣뤤ϡ̵̾ͭڤؤݡSQL*Loader ʤɤɤ߹Ȥʤɡˤˤ⡢ƥˤ̿̾Ǥ̾λȤ˼֤롣

PRIMARY KEY

祭Ǥ롣NULL ͤϵʤNOT NULL 󤬼ưղäˡ

٥롢ޤɽ٥ǽʣ祭ɽ٥Τߡ

  • ˡ

UNIQUE

󤬰դǤ뤳Ȥݾڤ롣NULL ϤϵĤ롣

٥롢ޤɽ٥ǽʣեɽ٥Τߡ

  • ˡ
  • ­
    • ʣեǤ NULL ϵĤ롣Ȥоܤǡʲξ֤ˤʤäƤȿˤϤʤʤ
      fugapiyo
      1null
      2null
      null1
      nullnull
      nullnull

NOT NULL

NULL γǼĤʤ

٥Τߤǽ

  • ˡ

FOREIGN KEY

󤬳Ǥ롣

٥롢ޤɽ٥ǽʣ糰ɽ٥Τߡ

  • ˡ
  • ­
    • ¾ΥץȤưʲʻǽ
      ץ
      on delete cascadeιԤȻȸιԤ
      on delete set nullιԤȻȸιԤ NULL ˤ
    • 嵭ץꤷʤϡ˻ȸιԤʤ¤ꡢιԤϺǤʤʤʥơ֥뤴Ȥäʤ
    • ϰդǤɬפPRIMARY KEY ⤷ UNIQUE

CHECK

˳Ǽͤ¤롣

  • ˡ

ɽѹ

¸ɽѹ롣

  • ˡ
  • ­
    • ѹ˰ڤ̷⤬ʤ˸¤ѹǤ
      • ȤСǤ 123 ǼƤ number(3) number(1) ˤѹϤǤʤ
      • number(3) 󤬤٤ NULL äꡢ1 οäƤʤ֤Ǥ number(1) ˤѹǤ

ɽκ

  • ˡ
    drop table hoge;
    
  • ­
    • DDL ʸʤΤǡαΥȥ󥶥ޤƼưǥߥåȤʥХåǤʤ
    • ӥ塼ȥΥ˥ϻĤ뤬̵ˤʤ

ɽγǧ

SQL*Plus ΥޥɤʤΤѤ SQL ǤϤʤ

¹Ԥ˸¤ɬפʤȤ¤ʤƤ desc ϤǤ롣

  • ˡ
    desc <tablename>
    

Last-modified: 2011-11-07 () 14:31:49