zoukankan      html  css  js  c++  java
  • SQL server 学习笔记

    select *from  student--查询数据库
    create database s20150417 --新建数据库
    drop database [20150325] --删除数据库 数字开头的需要用[]括起
    use s20150417 --使用数据库
    go --连接符 不写也可以
    create table student--创建表
    (
    code int not null,--
    name varchar(50) not null,--
    sex int,--
    degree decimal(18,2) not null--
    ) 
    go
    insert into student values(1,'张三',0,99);--插入数据 对应上面建的表 四列插入数值 对应数据类型
    insert into student values(3,'李四',1,87);
    insert into student(code,name,degree) values(4,'王五',87);--指定列添加
    go
    update student set sex=0
    update student set sex=0 where code=3 --修改某一列的数值 用where选定某一行
    update student set name='田七' where code=4 --wheres筛选修改 一个控制条件
    go
    select *from  student
    select *from tongxunlu where name='张三'--查询
    go
    update student set name='飞船',code=5,degree=99 where name='田七'
    delete from student --删除所有数据
    delete from student where code=3 --删除code=3的一行
    drop table student --删除表
    --主键 起唯一识别的作用 提高查询效率
    create table teacher
    (
     tno int primary key identity(1,1),--自增长主键
     tname varchar(50)
    )
    --查询
    --select *from 表 where 列名 and 列名


    create table xinxibiao
    (
     no int primary key identity(1,1),--自增主键
     name varchar(50) not null,
     sex varchar(50) not null,
     age int not null,
     high int not null,
     tz decimal(18,2)not null,
     sfzh varchar(max)not null,
     zhuzhi varchar(max)not null
    )
    insert into xinxibiao values('洪一','',50,160,60,'370012598632152233','香港')
    select *from xinxibiao
    select *from xinxibiao where high>163 and sex=''
    update xinxibiao set name='张初' where name='范大'
    --between and 在什么和什么之间
    select *from xinxibiao where high between 165 and 175
    select *from xinxibiao where name like '李%'--查询表中姓李的
    --% 是通配符 可以代替任意字符和数据  like好像的意思
    
    
    
     
  • 相关阅读:
    回顾python,就当做笔记了
    测试知识回顾
    转发 Python接口自动化
    性能测试脚本调优
    java
    新的一年,希望自己有所提升,在这简单的记录,自己的学习。
    navicat 连接 mysql 出现Client does not support authentication protocol requested by server解决方案
    tomcat context配置
    tomcat host 配置
    flyway使用
  • 原文地址:https://www.cnblogs.com/happinesshappy/p/4435733.html
Copyright © 2011-2022 走看看