2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SQLの基礎

2
Last updated at Posted at 2022-12-12

こんにちは!
今OracleSilver SQLを勉強しているので、アウトプットとして、SQLの構文を書いていきたいと思います!

CREATE TABLE文

書式
CREATE TABLE `表名`
    ( `列名1` `データ型`,
      `列名2` `データ型`,
       `…`    );
  • それぞれの列でデータ型を指定する必要がある。
  • 1つの表の列数は最大1000
例
CREATE TABLE `社員表`
    (`社員番号` NUMBER,
     `名前` VARCHAR2(10),
     `性別` CHAR(2),
     `住所` VARCHAR2(100));

結果

社員番号 名前 性別 住所

基本のデータ型

データ型 格納できるデータ
NUMBER 整数又は小数
CHAR(n) nバイト格納できる固定長の文字列 (nは4000まで)
VARCHAR2(n) nバイト格納できる可変長の文字列
DATE 日付と時刻
  • 固定長
    指定した文字数より格納した文字が少ないなら、足りない分を空白で埋める
  • 可変長
    指定した文字数に満たなくとも空白は入らない
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?