라라벨 DB 컬럼 종류

라라벨 DB 컬럼 종류
라라벨 스키마 빌더의 컬럼 유형

1 목록[ | ]

명령어 자료형 비고
$table->bigIncrements('id'); BIGINT 자동증가, 주키
$table->bigInteger('votes'); BIGINT
$table->binary('data'); BLOB
$table->boolean('confirmed'); BOOLEAN
$table->char('name', 4); CHAR 길이 지정
$table->date('created_at'); DATE
$table->dateTime('created_at'); DATETIME
$table->decimal('amount', 5, 2); DECIMAL
$table->double('column', 15, 8); DOUBLE
$table->enum('choices', array('foo', 'bar')); ENUM
$table->float('amount'); FLOAT
$table->increments('id'); INT 자동증가, 주키
$table->integer('votes'); INT
$table->longText('description'); LONGTEXT
$table->mediumInteger('numbers'); MEDIUMINT
$table->mediumText('description'); MEDIUMTEXT
$table->morphs('taggable'); 컬럼 2개 INTEGER taggable_id, STRING taggable_type
$table->nullableTimestamps(); TIMESTAMP NULL가능
$table->smallInteger('votes'); SMALLINT
$table->tinyInteger('numbers'); TINYINT
$table->softDeletes(); TIMESTAMP deleted_at 컬럼, 기본값 NULL, 소프트 삭제
$table->string('email'); VARCHAR 길이 255[1]
$table->string('name', 100); VARCHAR 길이지정
$table->text('description'); TEXT
$table->time('sunrise'); TIME
$table->timestamp('added_on'); TIMESTAMP
$table->timestamps(); 컬럼 2개 TIMESTAMP created_at, updated_at
$table->rememberToken(); VARCHAR remember_token 컬럼, 길이 100, NULL 가능
->nullable() - NULL 가능
->default($value) - 기본값 지정
->unsigned() - INTEGER를 부호없음(UNSIGNED)으로 지정

2 같이 보기[ | ]

3 참고[ | ]

  1. collation은 테이블 설정에 따르는 듯. 특별한 일이 없다면 utf8_unicode_ci 일 듯
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}