1、创建数据库
create database if not exists db_name;
2、使用数据库
use db_name;
3、删除数据库
drop database db_name;
4、创建表 例如创建学生信息表
create table student_info
(
stu_id smallint unsigned not null auto_increment,
stu_name varchar(30) not null,
stu_sex char(2) not null,
stu_age int not null,
stu_address varchar(100),
primary key(stu_id)
);
5、修改表 例如增加入学日期
alter table student_info add stu_entrance data;
6、删除表
drop table if exists student_info;
7、插入
insert into student_info(stu_id,stu_name,stu_sex,stu_age) values(100,'aa','m',18)
8、更新
update student_info set stu_age=22 where stu_id=100;
9、删除
delete from student_info where stu_id=100;
10、查询
select * from student_info;
select stu_id,stu_name from student_info;
select stu_age from student_info where stu_age>20;
create database if not exists db_name;
2、使用数据库
use db_name;
3、删除数据库
drop database db_name;
4、创建表 例如创建学生信息表
create table student_info
(
stu_id smallint unsigned not null auto_increment,
stu_name varchar(30) not null,
stu_sex char(2) not null,
stu_age int not null,
stu_address varchar(100),
primary key(stu_id)
);
5、修改表 例如增加入学日期
alter table student_info add stu_entrance data;
6、删除表
drop table if exists student_info;
7、插入
insert into student_info(stu_id,stu_name,stu_sex,stu_age) values(100,'aa','m',18)
8、更新
update student_info set stu_age=22 where stu_id=100;
9、删除
delete from student_info where stu_id=100;
10、查询
select * from student_info;
select stu_id,stu_name from student_info;
select stu_age from student_info where stu_age>20;