행을 구분하는 번호는 AUTO_INCREMENT가 매깁니다.
앱이 읽는 표는 InnoDB로 만든다. 문자 집합은 utf8mb4다. 이름이 utf8인 옛 문자 집합은 글자 일부를 담지 못한다.
create table posts (
id bigint not null auto_increment,
title varchar(200) not null,
body text,
created_at datetime not null default current_timestamp,
primary key (id)
) engine=InnoDB default charset=utf8mb4;
auto_increment는 행을 넣을 때 id를 1, 2, 3으로 채운다. Postgres의 generated always as identity와 같은 역할이다. 표 설계의 기본 키 개념은 PostgreSQL · 테이블·키와 같다.
예약어와 겹치는 이름은 백틱으로 감싼다. Postgres가 식별자에 큰따옴표를 쓰는 자리와 같다. 기본 모드에서 MariaDB의 큰따옴표는 문자열이다.
show tables;
describe posts;
boolean으로 적어도 저장은 tinyint(1)이다. 0과 1로 읽고, 참·거짓 리터럴에만 기대지 않는다.