zoukankan      html  css  js  c++  java
  • SQL server 创建表,索引,主键,外键

    if object_id('student', 'U') is not null
    	drop table student
    go
    
    create table student(
    	sno		varchar(20) not null ,
    	sage	decimal not null,
    	sname	varchar(20)
    )
    go
    
    create nonclustered index stu_index on student(sno)
    go
    
    if(object_id('person', 'U') is not null)
    	drop table person
    go
    
    create table person(
    	sname varchar(20) not null
    )
    go
    
    alter table person add primary key(sname)
    go
    
    create nonclustered index person_index on person(sname)
    go
    
    alter table student add primary key(sno, sage)
    go
    
    alter table student add foreign key(sname) references person(sname)
    go
    
    

  • 相关阅读:
    总结!!!总结!!!
    Beta 总结
    BETA-7
    BETA-6
    BETA-5
    BETA-4
    BETA-3
    华为云-软件产品案例分析
    BETA-2
    BETA-1
  • 原文地址:https://www.cnblogs.com/marcotan/p/4256962.html
Copyright © 2011-2022 走看看