zoukankan      html  css  js  c++  java
  • SQL简短汇总

    建立数据库:

    create database 数据库名
    on
    (
    name=数据库名_dat;
    filename='****数据库位置*****数据库名.mdf',
    size=**,
    maxfile=**,
    filegrowth=10%
    )
    log on
    (
    name=数据库名_log,
    filename='****数据库位置*****数据库名.ldf',
    size=**,
    maxfile=**,
    filegrowth=10%
    )

    删除数据库:
    drop database 数据库名;



    建立数据库的表:
    create table 表名
    (
    列名 数据类型 ({可加可不加}约束),  --主键:primary key
    列名 数据类型 ({可加可不加}约束),
    ....
    列名 数据类型 ({可加可不加}约束)
    )
    ---数据类型:int、varchar、char...
    ---约束: not null、

    删除表:
    drop table 表名;



    表中添加数据:
    insert into 表名(列名1,列名2,...列名n)
    values (列值1,列值2,...列值n);
    ----字符串类型的列值用单引号引起来;
    ---当添加表中所有数据时,表名后的列名可不写

    删除表中的数据:
    delete from 表名 where 表中的列名满足的条件;

    修改表中数据:
    update  表名 set 列名=“表达式(要修改的内容)”
    where 条件表达式;

    删除表中的所有数据:
    truncate table 表名;


    查询表中的数据:
    select * from 表名  where 条件表达式;














    添加表的列:
    alter table 表名 add 列名 数据类型;
    删除列:
    alter table 表名 drop 列名;
    修改列的数据类型:
    alter table 表名 alter column 列名 数据类型;
    更改列名:
    sp_rename '表名.旧列名','新列名';

    更改表名:
    sp_rename '数据库名.旧表名','新表名';


  • 相关阅读:
    C#获取当前路径的七种方法
    map容器对象插入数据的4种方式【转】
    为VMware虚拟机内安装的Ubuntu 16.04设置静态IP地址【转】
    Ubuntu16手动配置IP地址
    当前上下文不存在名称“***”
    C++读写文件ofstream,ifstream,fstream)[转]
    atoi()函数
    C++常用输出 cout、cerr、clog
    Lucene教程(转)
    selenium环境搭建1
  • 原文地址:https://www.cnblogs.com/xianshui/p/4477210.html
Copyright © 2011-2022 走看看