CREATE TABLE 資料表名稱 (欄位 欄位類別);
PostgreSQL 實際撰寫SQL有點不相同
PostgreSQL
CREATE TABLE IF NOT EXISTS scores (
id serial PRIMARY KEY,
grade INT NOT NULL,
name VARCHAR(50) NOT NULL,
score INT NOT NULL,
PRIMARY KEY (id),
);
MySQL
以下建立一個年級、姓名、分數資料表
CREATE TABLE IF NOT EXISTS `scores`(
`id` INT UNSIGNED AUTO_INCREMENT,
`grade` INT NOT NULL,
`name` VARCHAR(50) NOT NULL,
`score` INT NOT NULL,
PRIMARY KEY ( `id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;