zoukankan      html  css  js  c++  java
  • 数据库中的T-sql语句 条件修改 高级查询

        

    1.创建数据库:create database --数据库名,不能中文,不能数字开头,不能符号开头


    2.删除数据库:drop database-- 数据库名

           use  student--使用数据库

    3.注释:一段 /* */

              一行 --

    4.创建表: create table 表名
                create table 表名
                (
                  列名 数据类型,
                   ...
                   ...
                  设置主键列: primary key
                  设置唯一列: unique
                  设置非空:not null
                  设置自增列:identity(1,1) - 从1开始计数,每次自增1
                )

               5. 删除表 drop table 表名
               6.添加列alter table 表名 add 列名 数据类型
               7. 删除列alter table 表名 drop column 列名

               8.添加数据insert into 表名 values('S001','2000-1-1',01/'true''False',100)

               9. 修改数据update 表名 set 列名 = 值

               10。删除数据delete from 表名 / truncate table 表名

               11.查询数据select *from 表名

    --------------------------------------------------------------------
    条件修改:
    update 表名 set 列名 = 值 where 列名 = 值
    条件删除
    delete from 表名 where 列名 = 值
    -高级查询
    +条件查询
    + 查列 *改为要查看的列,多列逗号隔开
    + 筛选条件 where 列名 = >= <= > < 值 and or
    +模糊查询
    select * from 表名 where 列名 like '%值%' %通配符

    可匹配任意类型和长度的字符,如果是中文,请使用

    两个百分号即

    %%


    +排序查询
    select * from 表名 where order by 列名 asc / desc
    +去重查询
    select distinct 列名 from 表名
    +分组查询
    select 某一列名 from 表名 group by 对应的列名
    +子查询
    将查询语句当做值来使用

  • 相关阅读:
    迷你版 smarty --模板引擎和解析
    php 常用五种模式
    23种设计模式全解析 (java版本)
    centos 软件安装 删除
    centos 交换分区
    centos 忘记 root 密码
    Windows7 下安装 CentOS6.5
    centos 基本操作(输入法安装,adls宽带连接,查找文件,模拟终端)
    【Storm篇】--Storm并发机制
    【Storm篇】--Storm分组策略
  • 原文地址:https://www.cnblogs.com/jiulinghoudabai/p/6535875.html
Copyright © 2011-2022 走看看