zoukankan      html  css  js  c++  java
  • sql语句创建数据库

    1 创建数据库

    --系统数据库master中保存了所有本地数据库的名字
    use master
    go
    if exists(select * from sysdatabases where name='student')
    drop database student            --如果数据库存在就删除
    go
    
    create database student    --数据库名
    on
    (                            --使用的是小括号
    name='student',            --数据库逻辑名
    filename='E:\Data\student.mdf',  --数据库文件存放路径,注意路径用\不是/
    size=10mb,                        --数据库初始大小
    maxsize=100mb,                    --数据库最大文件大小
    filegrowth=5mb                    --增长幅度
    )
    log on                            --日志文件
    (
    name='student_log',                --日志逻辑名
    filename='E:\Data\student_log.ldf',  --日志文件路径
    size=5mb,
    maxsize=100mb,
    filegrowth=5mb
    );
    go
    
    
    
    --注意,分开创建
    use student
    create table T_Class
    (
    classid int    identity(1,1)        not null,
    name nvarchar(8)                not null,
    primary key ( classid )                --主键
    );
    
    create table T_StuInfo
    (
    stuid int primary key identity(1,1) not null, --主键,递增
    name nvarchar(8)        not null,
    phone nvarchar(11),    
    classid int                not null,
    foreign key (classid) references T_Class(classid) --定义外键,外键是其他表的主键    
    );
  • 相关阅读:
    Ping
    boost::python开发环境搭建
    mingw和libcurl
    ssh远程执行命令使用明文密码
    netty源码阅读之UnpooledByteBufAllocator
    Direct ByteBuffer学习
    clions的使用
    netty中的PlatformDependent
    STL之priority_queue(优先队列)
    c++线程调用python
  • 原文地址:https://www.cnblogs.com/wang7/p/2633884.html
Copyright © 2011-2022 走看看