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)
    )
    支持创建,但是没有功能

  • 相关阅读:
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Standard
    mybatis plus 代码生成器
    ServerU FTP服务器无法上传中文名文件怎么办
    关于java文件下载文件名乱码问题解决方案
    使用Redis模拟简单分布式锁,解决单点故障的问题
    springboot定时任务处理
    AtomicInteger类的理解与使用
    java队列——queue详细分析
    ABAP DEMO so批量导入
    ABAP DEMO ole示例程序
  • 原文地址:https://www.cnblogs.com/jlh915057902/p/6490110.html
Copyright © 2011-2022 走看看