005-数据库之表操作

创建表

-- 创建学生表,字段要求如下:

-- 注释 ctrl + /

-- 取消注释 ctrl + shift + /

-- 姓名(长度为10), 年龄,身高(保留小数点2位)

primary key:设置主键
auto_increment:设置自动递增

create table students2(
  id int unsigned primary key auto_increment,
  name varchar(10),
  age tinyint unsigned,
  height decimal(5,2)
)

删除表

删除学生表

drop table students
drop table if exists sutdents1

删除并创建新表

drop table if exists students;
  create table students(
  name varchar(10),
  age int
)

给表添加别名

select s.name,s.age from students as s

 

posted @ 2019-12-01 00:09  阿布不学习  阅读(168)  评论(0编辑  收藏  举报