- 创建数据库
create database students_management;
- 创建表
create table students(id int auto_increment primary key not null, name char(15));
操作表中数据
- 增insert into 表名 value ();
插入一列
insert into students (name) values(“name1”),(“name2”);
插入一行
insert into students value (NULL,”WG”,”女”,”1538488488”);
- 删delete from 表名 where … ;
delete from students where id = 5;
delete from students;
- 改update 表名 set … where …;
update students set tel = “13288097888” where name = “张伟”;
update students set age = 19, name = “张鹏” where tel = “132453453”;
- 查select * from 表名 where … ;
select * from students;
select id, name from students;
//查询名字中带有 "王" 字的所有人信息:
select * from students where name like “%王%”;
insert into students value ();
delete from students where …;
update students set name ww = wg where ..;
select id = 5 from students ;
select * from students where sex = “女”;
创建表后对表的修改
- 添加列
alter table students add birthday after age;
alter table students add address char(60) after age;
- 修改列
修改tel为telphone
alter table students change tel telphone char(8);
- 删除列
alter table students drop birthday;
- 重命名
alter table students rename students_1;
- 删除表
drop table students;