首页 小组 文章 相册 留言本 用户 搜索 我的社区 在线学堂 商城 购物车 支付钱包

[分享]第二章 修改表、删除表和清空表

2024-03-15 16:57:42
0
418

CREATE DATABASE schooldb;

SELECT DATABASE();

use schooldb;

CREATE TABLE stu_1(
id int,
name VARCHAR(10),
age int,
gender VARCHAR (10)
);

DESC stu_1;

show CREATE TABLE stu_1;

ALTER TABLE stu_1
MODIFY name VARCHAR(20);

ALTER TABLE stu_1
MODIFY age int DEFAULT 18;

ALTER TABLE stu_1
CHANGE name xingming VARCHAR(15);

DESC stu_1;

ALTER TABLE stu_1
DROP COLUMN age;

RENAME TABLE stu_1
TO stu_5201314;

ALTER TABLE stu_1
RENAME stu_886;

DROP TABLE IF EXISTS stu_5201314;

SELECT * from stu_1;

TRUNCATE TABLE stu_1;

set autocommit = FALSE;

DELETE from stu_1;

ROLLBACK;

COMMIT;

评论
意见反馈