• T-SQL 增删改查操作


    T-SQL

    1.创建表

    create table Car
    (
    Code varchar(50) primary key ,
    Name varchar(50) not null,
    Time date ,
    Price float ,
    Brand varchar(50) references Brand(Code)
    );

    create table Brand
    (
    Code varchar(50) primary key ,
    Name varchar(50)
    );

    create table PinPai
    (
    Ids int auto_increment primary key,
    Name varchar(50)
    );

    primary key 主键

    not null 非空

    references 引用

    auto_increment 自增长

    注意:所有符号必须是英文状态下的

    每个表创建完之后加分号

    表里面的最后一列写完之后不要加逗号

    删除表:
    drop table PinPai


    数据的操作:CRUD操作 增删改查

    1.添加数据:

    insert into Brand values('b001','宝马5');#第一种方式

    insert into Brand (Code) values('b002');#第二种方式

    insert into PinPai (Name) values('大众');#处理自增长列

    insert into PinPai values('','大众');#处理自增长列

    2.最简单查询

    select * from PinPai #查询所有数据

    select * from PinPai where Ids = 1;#根据条件查询

    3.修改

    update PinPai set Name ='保时捷' where Ids = 4; #修改某一条数据

    update Car set Name = '哈弗' , Time = '2012-3-4' , Price = 16 , Brand = 'b002' where Code = 'c001'

    4.删除数据

    delete from Brand #删除所有数据

    delete from PinPai where Ids = 4; #根据条件删除数据

  • 相关阅读:
    Hadoop功能模块之hdfs
    Hadoop介绍
    大数据的介绍
    Hadoop之shell命令
    Flume
    C# DataTable使用方法详解
    npoi 操作excell 可以下载的链接
    node.js mqtt样例
    node.js压缩
    arcgis中打印所有变量的名称和值
  • 原文地址:https://www.cnblogs.com/yifangtongxing/p/5271362.html
Copyright © 2020-2023  润新知