Score
0
Watch 44 Star 256 Fork 69

xuthus / 数据库SQL实战SQLMIT

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
40.在last_update后面新增加一列名字为create_date.md 707 Bytes
Copy Edit Web IDE Raw Blame History
xuthus authored 2019-08-12 23:23 . add:all

在last_update后面新增加一列名字为create_date

题目描述

存在actor表,包含如下列信息:

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')));

现在在last_update后面新增加一列名字为create_date, 类型为datetime, NOT NULL,默认值为'0000-00-00 00:00:00'

答案

alter table actor add column create_date datetime not null default '0000-00-00 00:00:00'

题解

MySQL语法:

alter table actor add column create_date datetime not null after last_name;

Comment ( 0 )

Sign in for post a comment