zoukankan      html  css  js  c++  java
  • 数据定义——基本表

    基本表的创建:

          create table Student             create table <表名>

          (Sno  char(5)  not null  unique(唯一),    ( <列名><数据类型> [<列级完整性约束条件>],

          Sname  char(20)  unique,           ……

          Ssex  char(1),                  [<表级完整性约束条件>] );

          Sage  int,

          Sdept  char(15) );

       常用完整性约束:

          主码约束:  primary key          create table SC(

          唯一性约束:   unique             Sno char(5),

          非空值约束:   not  null             Cno char(3),

          参照完整性约束                Grade int,

                                 Primary key(Sno,Cno)

                                 foreign key(sno) references student(sno) );

    基本表的修改:   alter table <表名>

            [ADD <新列名><数据类型>[完整性约束]]

            [MODIFY <列名><数据类型>]    //修改

            [DROP <完整性约束名>];      //删除指定的完整性约束条件

        如:

          alter table Student   drop unique(Sname);

          alter table Student   modify Smallint;

          不论基本表中原来是否已有数据,新增加的列一律为空值。

          修改原有的列定义有可能会破坏已有数据。

    删除基本表:

          drop table <表名>;

  • 相关阅读:
    eclipse 中配置查看jdk基础源代码
    网页授权获取用户基本信息
    语系/地区码
    windows 下 PHP DOITPHP框架 memcache缓存开启。
    xheditor富文本框 存值与展示问题
    逻辑处理
    ajax图片单个上传(ajaxfileupload.js)
    18 南京 D
    poj 2069
    poj 2420
  • 原文地址:https://www.cnblogs.com/zhangchaoran/p/6939916.html
Copyright © 2011-2022 走看看