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

SQL基础整理

时间:2016-11-07 17:47:11      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:time   基础   into   table   分类   new   语言   查询语句   空值   

一.基础用法

查询:

select * from 表名 (where 列名=‘&abc‘);

eg.

select * from emp;

 

增:

插入多值时,用values:

insert into 表名 values (值1,值2,...);

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

eg.

insert into table (name) values(‘abc’);

 

插入空值时,用value:

eg.

insert into table value(null);

 

删:

delete from 表名 where 条件;

注:1.仅删除数据,不删除表本身,若要删除整个表,则用drop table;2.where条件子句,若无,则将删除表中所有数据。

 

改:

update 表名 set 列名=表达式 where 条件;

eg.把students表中,ym这个人的性别改为女

update students set sex=‘女‘ where name="ym";

 

二.sql语句分类

dml 语句( 数据操作语句) [insert , update ,delete]

ddl语句( 数据定义语言) [create table drop table ...]

dql 语句( 数据查询语句) [select]

dtl 语句( 数据控制语言) commit rollback

SQL基础整理

标签:time   基础   into   table   分类   new   语言   查询语句   空值   

原文地址:http://www.cnblogs.com/min-Mila/p/6039765.html

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