MYSQL用户名:root
3306 中文乱码注意的地方: 1.先把有乱码的表删除掉 2.更改MYSQL的配置 (ini文件) 3.重启MYSQL服务 1. 创建一个数据库 create database 数据库名; create database forStudy; 2. 使用已存在的数据库 use 数据库名; use forStudy; SQL语句 1. 建表语句 create table 表名( 字段 字段类型 ); create table student( id int primary key, name varchar(50), sex varchar(10), address varchar(255) ); create table student( user varchar(10), passwd varchar(50) ); //primary key 是用来定义主键(唯一标识) 删除表语句 drop table 表名; drop table sudent; 2. 插入语句 insert into 表名(字段列表) values(对应字段值); INSERT INTO STUDENT (ID,NAME, SEX, ADDRESS) VALUES (3,'王五', '男','河南南阳'); INSERT INTO STUDENT (ID,NAME, SEX, ADDRESS) VALUES (4,'王丹', '女','河南南阳'); INSERT INTO STUDENT (ID,NAME, SEX, ADDRESS) VALUES (5,'刘六', '男','河南南阳'); 3.查询语句 SELECT * FROM 表名; select * from student; 4. 更新语句 update 表名 set name = '李四' where id = 2; UPDATE STUDENT SET NAME = '李四' WHERE ID = 2; UPDATE STUDENT SET NAME = '李丹', SEX = '女' WHERE ID = 2; 5. 删除语句 delete from 表名 where DELETE FROM STUDENT WHERE ID = 12; 增删查改四种操作 student s_id s_name d_id 系别 d_id d_name 1 '软件学院' select * from student where d_id = ( select d_id from dep where d_name = '软件学院'); SQL