这里写目录标题
SQL33 创建一个actor表,包含如下列信息
描述
创建一个actor表,包含如下列信息
列表 类型 是否为NULL 含义
actor_id smallint(5) not null 主键id
first_name varchar(45) not null 名字
last_name varchar(45) not null 姓氏
last_update date not null 日期
create table if not exists actor(
actor_id smllint(5) not null primary key,
first_name varchar(45) not null,
last_name varchar(45) not null,
last_update date not null default(datetime('now','localtime'))
)
SQL36 创建一个actor_name表
create table if not exists actor_name(
first_name varchar(45) not null,
last_name varchar(45) not null); -- 创建表
insert into actor_name
select first_name,last_name
from actor;
SQL37 对first_name创建唯一索引uniq_idx_firstname
对first_name创建唯一索引uniq_idx_firstname,对last_name创建普通索引idx_lastname
alter table actor add unique index uniq_idx_firstname(first_name);
alter table actor add index idx_lastname(last_name);
SQL38 针对actor表创建视图actor_name_view
针对actor表创建视图actor_name_view,只包含first_name以及last_name两列,并对这两列重新命名,first_name为first_name_v,last_name修改为last_name_v:
CREATE VIEW actor_name_view
AS
SELECT first_name AS first_name_v, last_name AS last_name_v
FROM actor;
SQL40 在last_update后面新增加一列名字为create_date
现在在last_update后面新增加一列名字为create_date, 类型为datetime, NOT NULL,默认值为’2020-10-01 00:00:00’
alter table actor add create_date datetime not null DEFAULT '2020-10-01 00:00:00';
寻找最长重复字符串
一个重复字符串是由两个相同的字符串首尾拼接而成,例如abcabc便是长度为6的一个重复字符串,而abcba则不存在重复字符串。
给定任意字符串,请帮小强找出其中的最长重复子串