CREATE (SQL)
SQLにおけるCREATE文(英: CREATE statement)は、関係データベース管理システム (RDBMS) の管理下にオブジェクトを新しく作…
SQLにおけるCREATE文(英: CREATE statement)は、関係データベース管理システム (RDBMS) の管理下にオブジェクトを新しく作成するデータ定義言語 (DDL) の命令である。
使用しているRDBMSの実装によって、CREATE文で作成することができるオブジェクトの種類は異なる。
ただしほとんどのRDBMSの実装では、表 (テーブル) 、定義域 (ドメイン) 、索引 (インデックス) 、利用者 (ユーザ) 、別名 (シノニム) 、ストアドプロシージャおよびデータベースの作成をサポートしている。
いくつかのRDBMSの実装 (PostgreSQLなど) では、トランザクション内で CREATE 文および他のDDL命令を実行可能であり、そのためロールバックが可能である。
CREATE TABLE 文
おそらく最もよく知られている CREATE 命令は、CREATE TABLE 命令であろう。
基本的な使用方法は次のとおりである。
CREATE [TEMPORARY] TABLE [表名] ( [基底表要素カンマリスト] ) [表パラメータ]
- 基底表要素カンマリスト
- 下記のいずれかで構成された定義のカンマで区切られたリストである。
- 列定義: [列名] [データ型] {NULL | NOT NULL} {列オプション}
- 主キー定義: PRIMARY KEY ( [列カンマリスト] )
- 制約: {CONSTRAINT} [制約定義]
- RDBMS実装固有の記述
いくつかの列をもつ「従業員」という名前の表を作る命令の例を示す。
CREATE TABLE 従業員 (
ID INTEGER PRIMARY KEY,
姓 CHAR(75) not null,
名 CHAR(50) null,
生年月日 DATE null
);
参考文献
- C.J.Date、Hugh Darwen、QUIP LLC (訳)、『標準SQLガイド 改訂第4版』、アスキー、1999年、ISBN 4-7561-2047-4
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.