zoukankan      html  css  js  c++  java
  • 数据库的增 删 查 改。。。。

    增加字段
    alter table tableName add 字段名 类型

    删除字段
    alter table tableName drop column 列名

    修改字段
    alter table tableName change 原列名 新列名 类型

    索引是对数据库表中一列或多列的值进行排序的一种结构,使用索引可快速访问数据库表中的特定信息。

    创建索引
    create index name_index on student(stu_No)

    CREATE INDEX <索引名> ON <表名>(<列名一>,[<列名二>],…);


    删除索引
    alter table student drop index name_index

    为什么要保证实体完整性
    保证每行所代表的实体能互相区别,不能存在两条一模一样的记录
    什么是实体完整性
    表中的一行数据如果与它所代表的实体完全一致,则具备实体完整性。
    create table student(
    stu_id int PRIMARY key,
    stu_name varchar(20)
    )
    主键(Primary Key)是表中的一到多个列,主键列不能为空,也不能重复。一个表中只能有一个主键。


    唯一约束
    create table student2(
    stu_id int PRIMARY key,
    stu_name varchar(20),
    stu_No varchar(20) UNIQUE
    )

    为什么要域完整性
    保证指定列的数据的有效性
    什么叫域完整性
    域完整性是指定列的输入有效性

    create table student3(
    stu_id int PRIMARY key,
    stu_name varchar(20) not null, --保证stu_name这个列不能有空值
    stu_No varchar(20) UNIQUE
    )

    --

    默认约束
    create table student4(
    stu_id int PRIMARY key,
    stu_name varchar(20) not null,
    stu_No varchar(20) UNIQUE,
    stu_address varchar(40) DEFAULT '郎沃学生宿舍楼' not null
    )
    check检查约束
    create table student5(
    stu_id int PRIMARY key,
    stu_name varchar(20) not null,
    stu_No varchar(20) UNIQUE,
    stu_address varchar(40) DEFAULT '郎沃学生宿舍楼' not null,
    stu_gender int CHECK(stu_gender=1 or stu_gender=0)
    )
    支持创建,但是没有功能

  • 相关阅读:
    一个不错的资源共享微盘
    LUA upvalue使用陷阱一例
    安卓破解视频教程合集
    开发Android逆向工具
    手机上编程,编写android apk
    smail修改字符串 汉字
    Android logcat命令详解
    protobuf
    Android Rxjava
    butterknife
  • 原文地址:https://www.cnblogs.com/jlh915057902/p/6490110.html
Copyright © 2011-2022 走看看