黑马程序员技术交流社区

标题: mysql [打印本页]

作者: liujian5461267    时间: 2016-5-13 10:37
标题: mysql
. 运行 C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld-nt --skip-grant-tables 启动mysql,关闭权限的检查
4. 运行 C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqladmin -u root flush-privileges password "newpassword" 重设root密码

C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.1/Data
创建表
create table if not exists my_student(
name varchar(10),
gender varchar(10),
number int
)charset utf8;

create table my_class(
name varchar(10),
room varchar(10)
)charset utf8;

create table if not exists student(
name varchar(10),
gender varchar(10),
number int
)charset utf8;

create table class(
name varchar(10),
room varchar(10)
)charset utf8

修改字段
新增
alter table student
add column age int
first;

alter table student
add ages int
after name;
-- 修改
alter table student
modify number char(10) after id;

alter table student
modify id int
first;

-- 重命名
alter table student
change ages sex char(10);


-- 新增数据
insert into student values
(2,28,54,'xiaowang',1,'male'),
(3,22,86,'xiaohua',2,'female'),
(4,24,45,'xiaowang',2,'female')
;
-- 新增部分字段数据
insert into student(number,gender,name,id,age) values
('wanyi001','male','tom',5,32),
('wanyi002','male','lili',6,33)
;

-- 查看数据
select * from student;
-- 查看指定字段
select id,number,sex,name,gender from student where id=5;

-- 更新数据
update student set gender='female' where name='xiaoming';




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2