码迷,mamicode.com
首页 > 数据库 > 详细

mysql增删改查

时间:2017-07-28 22:16:00      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:创建   删除表   数据库   


  • 创建数据表:

mysql> use simonwang

Database changed

mysql> show tables;

Empty set (0.00 sec)

mysql> create table t1 (`id` int(4), `name` char(40));

Query OK, 0 rows affected (0.01 sec)

  • 插入数据:

mysql> insert into studytable values(1,‘test‘);

Query OK, 1 row affected (0.00 sec)

mysql> select * from studytable;

+------+------+

| id   | name |

+------+------+

|    1 | test |

+------+------+

1 row in set (0.00 sec)

  • 修改数据:

mysql> update studytable set name=‘updatetest‘ where id=‘1‘;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from studytable;

+------+------------+

| id   | name       |

+------+------------+

|    1 | updatetest |

+------+------------+

1 row in set (0.00 sec)

  • 清空数据表:

mysql> truncate table studytable;

Query OK, 0 rows affected (0.00 sec)

mysql> select * from studytable;

Empty set (0.00 sec)

  • 删除数据表

mysql> drop table studytable;

Query OK, 0 rows affected (0.00 sec)

  • 删除数据库:

mysql> drop database simonwang;

Query OK, 0 rows affected (0.01 sec)



本文出自 “勤能补拙” 博客,请务必保留此出处http://echoroot.blog.51cto.com/11804540/1951818

mysql增删改查

标签:创建   删除表   数据库   

原文地址:http://echoroot.blog.51cto.com/11804540/1951818

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!