MySQL数据库基本操作
时间:2021-07-01 10:21:17
帮助过:2人阅读
create database if not exists `HA`;
use HA;
create table if not exists student (id
int, name
char(
40), age
int);
show create table student \G;
desc student;
create table student2 (id
int(
20), name
char(
40), age
int) ENGINE
=InnoDB
DEFAULT CHARSET
=utf8;
show columns from student2;
drop table student2;
alter table student rename students;
show tables;
alter table students modify id
int(
10);
show fields from students;
alter table students modify id
int(
20)
primary key;
show fields from students;
alter table students change name stname
char(
20);
desc students;
alter table students
add sex enum(
‘M‘,
‘W‘);
desc students;
alter table students
add uid
int(
10) first;
desc students;
alter table students
add address
char(
50) after age;
desc students;
alter table students
drop address;
insert into students
values(
1,
1,
‘liqiang‘,
22,
‘M‘);
insert into students(uid,id)
values(
2,
2);
select * from students;
select uid,id
from students;
select * from HA.students \G;
show tables;
drop table if exists students;
show tables;
show databases;
drop database if exists `HA`;
show databases;
MySQL数据库基本操作
标签: