// 创建phpedu数据库create database phpedu collate utf8mb4_unicode_ci;// 选择默认数据库use phpedu;select database();// 删除phpedu库drop database phpedu;// 查看建库语句show create database phpedu;// 创建数据表 sjbczcreate table sjbcz (sid int unsigned auto_increment not null primary key comment 'ID',name varchar(20) not null comment '姓名',gender enum('man','girl') not null comment '性别',email varchar(150) not null comment '邮箱',birthday date not null comment '出生日',create_at timestamp not null default current_timestamp comment '创建时间',update_at timestamp not null default current_timestamp on update current_timestamp comment '更新时间') engine = innodb auto_increment=1 collate = utf8mb4_unicode_ci;// 删除数据表drop table sjbcz;// 查看建表语句show create table sjbcz;// 查看表结构desc sjbcz;// 查看库中有哪些表?show tables;// 修改表// 增加字段alter table sjbcz add salary int unsigned not null default 2000 after gender;// 更新字段定义alter table sjbcz change salary salary float unsigned not null default 3000 after gender;// 删除字段alter table sjbcz drop test;// 插入数据insert sjbcz (name, gender, salary, email, birthday)values('小明同学', 'man', 8800, 'w123@php.cn', '2000-1-2'),('小张同学', 'girl', 348800, 'w989@ydsq.cn', '2001-2-23');// 子查询式插入/数据复制插入insert sjbcz (name,gender, salary, email,birthday)(select name,gender, salary, email,birthday from sjbcz);


Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号