数据库操作指令:

样式代码:

  1. // 创建phpedu数据库
  2. create database phpedu collate utf8mb4_unicode_ci;
  3. // 选择默认数据库
  4. use phpedu;
  5. select database();
  6. // 删除phpedu库
  7. drop database phpedu;
  8. // 查看建库语句
  9. show create database phpedu;
  10. // 创建数据表 sjbcz
  11. create table sjbcz (
  12. sid int unsigned auto_increment not null primary key comment 'ID',
  13. name varchar(20) not null comment '姓名',
  14. gender enum('man','girl') not null comment '性别',
  15. email varchar(150) not null comment '邮箱',
  16. birthday date not null comment '出生日',
  17. create_at timestamp not null default current_timestamp comment '创建时间',
  18. update_at timestamp not null default current_timestamp on update current_timestamp comment '更新时间'
  19. ) engine = innodb auto_increment=1 collate = utf8mb4_unicode_ci;
  20. // 删除数据表
  21. drop table sjbcz;
  22. // 查看建表语句
  23. show create table sjbcz;
  24. // 查看表结构
  25. desc sjbcz;
  26. // 查看库中有哪些表?
  27. show tables;
  28. // 修改表
  29. // 增加字段
  30. alter table sjbcz add salary int unsigned not null default 2000 after gender;
  31. // 更新字段定义
  32. alter table sjbcz change salary salary float unsigned not null default 3000 after gender;
  33. // 删除字段
  34. alter table sjbcz drop test;
  35. // 插入数据
  36. insert sjbcz (name, gender, salary, email, birthday)
  37. values('小明同学', 'man', 8800, 'w123@php.cn', '2000-1-2'),
  38. ('小张同学', 'girl', 348800, 'w989@ydsq.cn', '2001-2-23');
  39. // 子查询式插入/数据复制插入
  40. insert sjbcz (name,gender, salary, email,birthday)
  41. (select name,gender, salary, email,birthday from sjbcz);

数据表效果预览:

数据效果预览:

更多相关文章

  1. DDL之数据库--增删改查
  2. Zabbix监控ELK异常日志告警
  3. ELK企业日志平台收集Nginx访问日志
  4. 10 个Linux Awk文本处理经典案例
  5. SQL优化小讲堂(六)——善待数据库从建表开始
  6. 记一次Oracle数据更新经历
  7. 你有一份经典SQL语句大全,请注意查收!!!
  8. 项目中常用的19条MySQL优化,你知道几个?
  9. JAVA开发ORACLE的规范

随机推荐

  1. 汇编语言和c语言之间有什么区别?
  2. 对c语言的了解和认识
  3. c语言double类型默认输出几位小数?
  4. int main和void main的区别
  5. c语言中int是什么意思
  6. c语言中的关键字有哪些?
  7. c语言求余的实现方法
  8. c程序的基本组成是什么
  9. c语言程序怎么注释?
  10. c语言中的函数可不可以单独进行编译?