create database video_db();
select database();
use video_db();
show databases;
show tables;
%%创建视频类型表
create table tb_type
(
id int not null primary key,
typeId int not null unique,
typename varchar(12)
)
%%创建视频表
create table tb_video
(
id varchar(18) primary key,
typeId int not null,
title varchar(18) not null,
url varchar(18) not null,
description text,
createTime date not null,
CONSTRAINT tb_video_fk_typeId FOREIGN KEY (typeId) REFERENCES tb_type
(typeId)
)
%%创建管理员表
create table tb_admin
(
userId varchar(14) not null primary key,
pwd varchar(32) not null,
lev int default 0
)
describe tb_video;
describe tb_admin;
describe tb_type;
LOAD DATA INFILE "D:/data.txt"
INTO TABLE tb_admin
FIELDS TERMINATED BY ',';
alter table tb_video modify url varchar(300),
modify title varchar(100);
mysql使用手记,适合初学者
最新推荐文章于 2025-05-18 14:51:39 发布
本文介绍了如何使用SQL语句创建并管理一个视频相关的数据库。包括创建数据库、建立视频类型表、视频表及管理员表等步骤,并展示了如何导入数据文件及调整表结构。
8216

被折叠的 条评论
为什么被折叠?



