Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-01 13:16:26
Original
881 people have browsed it

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

 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>
Copy after login

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

<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>
Copy after login

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>
Copy after login

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>
Copy after login

删除某行

"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>
Copy after login

删除所有行

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

<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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!