zoukankan      html  css  js  c++  java
  • sql server ,sql语句,练习笔记

    一、删除冗余记录

    DELETE [学生表] WHERE id NOT IN (SELECT MIN(id) FROM [学生表] GROUP BY [学号],[姓名],[课程编号],[课程],[分数])

    二、创建触发器

    if (object_id('账户插入', 'tr') is not null)
    drop trigger 账户插入
    go
    create trigger 账户插入
    on [学生表]
    for insert --插入触发
    as
    --定义变量
    declare @id int, @name varchar(20), @temp int;
    --在inserted表中查询已经插入记录信息
    select @id = 分数, @name = 姓名 from inserted;
    insert into [账户] values(@name, @id);
    print '添加学生成功!';
    go

    删除字段

    alter table [学生表] drop column id ;

    增加字段
    alter table [学生表] add id int NOT NULL identity(1,1);

  • 相关阅读:
    poj 2388
    BUAA 1489
    poj 2524
    poj 2109
    poj 2503 Babelfish
    poj All in All
    poj 1611 The Suspects
    poj 2299
    poj 1328
    hdu 1008 Elevator
  • 原文地址:https://www.cnblogs.com/mokeyish/p/5046829.html
Copyright © 2011-2022 走看看