zoukankan      html  css  js  c++  java
  • 常用SQL语句

    1、创建数据库
        create database database_name
    
    2、删除数据库
        drop database database_name
    
    3、创建新表
        create table tablen_ame(col1 type1[not null][primary key],col2 type[not null],...)
        根据已有表来创建新表
        create table table_new like table_old
        create table table_new as select col1, col2,.. from table definition only
    
    4、删除表
        drop table table_name
    
    5、增加列
        alter table table_name add column col_name type
        
    6、添加主键
        alter table table_name add primary key(col_name)
        alter table table_name drop primary key(col_name)
    
    7、创建索引
        create [unique] index idx_name on table_ame(col...)
    
    8、查询
        select * from table_name where 范围
    
    9、插入
        insert into table_name(field1,filed2) values(value1,value2)
    
    10、删除
        delete from table_name where 范围
    
    11、更新
        update table_name set filed1=value1 where 范围
    
    12、几个简单的函数
        select sum(filed1) as sum_value from table_mame
        select value(filed2) as avg_value from table_name
        select min(filed1) as min_value from table_name
        select max(filed1) as max_value from table_name
    
    13、查询前10条
        select top 10 *from table_name
        随机选择10条记录
        select top 10 * from table_name order by newid()
    
    14、in操作符
        select * from table_name where col_name in (value11,value2,...)
  • 相关阅读:
    jquery冲突细节
    最懂中文的H5前端框架amazeUI
    IT Girl
    json_encode注意
    YII2 Activedataprovider 类分页的使用
    Yii框架,在页面输出执行sql语句,方便调试
    yii2的GridView和ActiveDataProvider具体使用
    文件压缩工具类
    将dubbo中使用的动态代理作为工具类
    spring中使用动态代理(AOP)
  • 原文地址:https://www.cnblogs.com/zengyjun/p/10400708.html
Copyright © 2011-2022 走看看