Home  >  Article  >  Database  >  mysql学习之二:sql语句学习3_MySQL

mysql学习之二:sql语句学习3_MySQL

WBOY
WBOYOriginal
2016-06-01 13:16:26892browse

好吧,大家觉得这种字体还是比较好看,所有我们就换这种字体了。

 INSERT INTO 语句用于向表格中插入新的行。

语法

<strong><code style="padding:0px; font-family:Monaco,'Andale Mono','Courier New',monospace; font-size:12px; color:inherit; background-color:transparent; border:0px">INSERT INTO 表名称 VALUES (值1, 值2,....)</code></strong>

我们也可以指定所要插入数据的列:

<strong><code style="padding:0px; font-family:Monaco,'Andale Mono','Courier New',monospace; font-size:12px; color:inherit; background-color:transparent; border:0px">INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)</code></strong>

Update 语句用于修改表中的数据。

语法:

<strong><code style="padding:0px; font-family:Monaco,'Andale Mono','Courier New',monospace; font-size:12px; color:inherit; background-color:transparent; border:0px">UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值</code></strong>

DELETE 语句用于删除表中的行。

语法

<strong><code style="padding:0px; font-family:Monaco,'Andale Mono','Courier New',monospace; font-size:12px; color:inherit; background-color:transparent; border:0px">DELETE FROM 表名称 WHERE 列名称 = 值</code></strong>

删除某行

"Fred Wilson" 会被删除:

<strong><code style="padding:0px; font-family:Monaco,'Andale Mono','Courier New',monospace; font-size:12px; color:inherit; background-color:transparent; border:0px">DELETE FROM Person WHERE LastName = 'Wilson' </code></strong>

删除所有行

可以在不删除表的情况下删除所有的行。这意味着表的结构、属性和索引都是完整的:

<code style="padding:0px; font-family:Monaco,'Andale Mono','Courier New',monospace; font-size:12px; color:inherit; background-color:transparent; border:0px"><strong>DELETE FROM table_name</strong>或者:<strong>DELETE * FROM table_name</strong></code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn