sql基本试题&深信服笔试

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则不存在重复字符串。
给定任意字符串,请帮小强找出其中的最长重复子串

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值