zoukankan      html  css  js  c++  java
  • SQLServer数据库基本操作,导入Excel数据

    打开SQLServer客户端,连上服务端
    先建立数据库,点击新建查询
    基本操作如下

    创建表
    create table mytest (
    id int primary key identity(1,1),
    name varchar(20) unique not null,
    Age tinyint,
    notetime smalldatetime default getdate()
    )
    create table 表名(字段名称 字段类型 约束条件)
    清空表
    truncate table mytest
    
    删除表
    drop table mytest
    
    添加列,添加字段约束名称
    alter table mytest add gender1 varchar(20) constraint llala1 unique not null
    
    删除列之前删除约束
    alter table mytest drop column gender
    
    修改列时修改约束
    alter table mytest alter column gender int null
    
    因为这几个字段存在约束,所以先去除约束然后再修改才行
    
    删除字段约束
    创建约束的时候,一般会默认指定一个约束名称,如果你不显示指定约束名称。 
    在键或者约束中找到
    alter table mytest drop constraint PK__mytest__3213E83F316AA3E1
    alter table mytest drop constraint llala
    
    添加列时添加约束约束
    alter table mytest add name1 varchar(20) constraint lala primary key
    
    添加数据
    insert into mytest(name,Age) values('we',123)
    
    删除数据
    delete from mytest where Age=123
    
    修改数据
    update mytest set Age=234 where Age=123
    
    查询数据
    select * from mytest
    select name,Age from mytest
    select sum(Age) from mytest
    select count(Age) from mytest
    
  • 相关阅读:
    leetcode-383-Ransom Note(以空间换时间)
    AtCoder
    AtCoder
    Hadoop序列化案例实操
    Java实现MapReduce Wordcount案例
    HDFS常用API操作 和 HDFS的I/O流操作
    HBase常用的JAVA API操作
    ZooKeeper之服务器动态上下线案例
    机器学习(6)——逻辑回归
    机器学习(5)——多项式回归与模型泛化
  • 原文地址:https://www.cnblogs.com/wuqingzangyue/p/5463689.html
Copyright © 2011-2022 走看看