LoginSignup
0
0

More than 1 year has passed since last update.

DBIx::Schema::DSLとMySQL型の対比

Posted at

使える型

データ型 MySQLで言うと
tinyint -128から127(0から255)
smallint -32,768から32,767(0から65,535)
integer int型(-2,147,483,648から2,147,483,647(0から4,294,967,295))
bigint -9,223,372,036,854,775,808から9,223,372,036,854,775,807(0から18,446,744,073,709,551,615)
number int型の別名
decimal 固定小数点型
dec decimalの略称
numeric decimalの別名
float 浮動小数点型
double 浮動小数点型
real doubleの別名
bit bit型(2進数)
date date型(YYYY-MM-DD)
datetime datetime型(YYYY-MM-DD HH:MM:SS[.fraction])
timestamp timestamp型(エポック秒)
char  固定長文字列
varchar 可変長文字列
string varchar型の別名
text text型
binary 固定長バイナリバイト文字列
varbinary 可変長バイナリバイト文字列
tinyblob tinyblob型(バイナリデータ型)
blob blob型(バイナリデータ型)
enum enum型
set set型(複数選択項目を格納できる)

emumの書き方

create_table 'テーブル名' => columns {
    emum 'hoge' => ['aaa', 'bbb', 'ccc']
}
0
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
0
0