mysql学习笔记2

create table tablename( )

创建数据库表的命令, 列的名称以及该列的数据类型将在括号内完成;

括号内的内容:id, name, sex, age, tel每列的名称,列与列的描述用,隔开。

id int unsigned not null auto_increment primary 


向表中插入数据

insert   [into]   表名   [(列名1, 列名2, 列名3...)]   values  (值1, 值2, 值3...);

例:insert   into  students  values(...);

如果出现   query ok   那么表示数据插入成功。

如果插入部分数据时候:

insert   into   students(name,  sex,  age) values('name',  ''sex',  age);


查询表中的数据:(最重要,我也是因为工作需要才学习mysql,项目已经成熟, 一般做的只是些查询而已)

select 根据查询规则到数据库获取数据。

select  列名  from  表名  [查询条件];

假设查询学生姓名和性别:select   name,  sex   from   students;

select  *  from   students;  查询所有

  

where关键词用于查询的条件,一般为:select   *  from  students  where  age  >= 12;

列出所有的年龄大于12 的学生的信息。


更新表:update  表名  set  列名=新的value  where  条件;

例如:update  students  set  age=21 where name=lili;


删除:delete   from  表名  where  条件;


最后推荐几个不错的mysql学习网址:


http://blog.csdn.net/chinacodec/article/details/5797127


http://www.cnblogs.com/mr-wid/archive/2013/05/09/3068229.html#c1











猜你喜欢

转载自blog.csdn.net/qq_37347705/article/details/78334050