sql基本

Posted Uhey

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql基本相关的知识,希望对你有一定的参考价值。

SELECT:

  select * from table

  select 列名 from table

  select DISTINCT 列名 from table

INSERT:

  insert into table values(‘‘,‘‘,‘‘,‘‘...)

  insert into table(列,列..) values(‘‘,‘‘,..)

UPDATE:

  update table set 列=新值 where 列=某值

DELETE:

  delete from table where 列=某值

  delete * from table   (删除数据,不破坏表结构,属性,索引)

TOP:

  select top 2 * from table

  select * from table limit 2

  select top 50 percent * from table (选取50%的记录)

LIKE:

  select * from table where 列 NOT LIKE ‘%lon%‘;

通配符:

  %:替代一个或多个字符

  _:一个字符

    [ char list]:字符列中任一单个字符

  [^char list] 或者[!charlist] :不在字符列中的任一单个字符

  select * from table where column like ‘[ALN]%‘;   //以A / L / N开头的

IN:

  select * from table where column IN (value1,value2,...)

Alias(别名):

  select p.Firstname from persons AS p where p.Lastname=‘John‘

 

以上是关于sql基本的主要内容,如果未能解决你的问题,请参考以下文章

oracle数据库的基本语法与SQL一样吗?

PL/SQL的基本语法

SQL语言总结(基本查询)

sql注入的基本防范手段

SQL基本语句

MySQL 最基本的SQL语法/语句