数据库Mysql基本操作命令

一、Mysql服务的启动和停止(后面没有分号)

net stop mysql

net start mysql


二、操作数据库(有分号)

1 显示数据库列表

show databases;

2 显示库中的数据表

Use 库名;

show tables;

3 查询表中内容

Select * from 表名;

4 清空表中内容

Delete from 表名;

5 创建一个新数据库

create database 库名;

6 创建一个新表

create table 表名 (字段设定列表);

例如:create table myfirsttable(id int,name varchar(10));

7 向表中加入一条数据

Insert into 表名 values(“字段”,”值”);

如:insert into myfirsttable values(9,'nian');

8 更新表中数据

Update 表名 set ()=() where ()=() ;

例如:update myfirsttable set id=8 where name="ppp" ;

update myfirsttable1 set id=8,password="120" where name="yiyi" ;

update myfirsttable setname="wei" where id=77;(如果没有where后面的内容,则这一整列都改变)

—— 完 ——