1. 程式人生 > >建立一個actor表,包含當前實時日期

建立一個actor表,包含當前實時日期

題目描述

建立一個actor表,包含如下列資訊

列表 型別 是否為NULL 含義
actor_id smallint(5) not null 主鍵id
first_name varchar(45) not null 名字
last_name varchar(45) not null 姓氏
last_update timestamp not null 最後更新時間,預設是系統的當前時間

 

解題思路:

mysql版:

create table if not exists actor
(actor_id smallint(5) not null primary key,
 first_name varchar(45) not null,
 last_name varchar(45) not null,
 last_update timestamp not null default CURRENT_TIMESTAMP
);

sqlite版:

create table if not exists actor
(actor_id smallint(5) not null primary key,
 first_name varchar(45) not null,
 last_name varchar(45) not null,
 last_update timestamp not null default (datetime('now','localtime'))
);