zoukankan      html  css  js  c++  java
  • python-day11-MYSQL 数据库及数据表

    创库
    create database lianx1 DEFAULT character set utf8


    表################################
    int, 数据类型,表示整数
    not null 表示不能为空
    auto_increment 表示自增
    PRIMARY key 表示主键
    constraint 外键名 foreign key(要关联的列) references 被关联的表(被关联的列);

    创建班级表
    create table class(
    cid int not null auto_increment PRIMARY key,
    caption char(32));


    创建学生表
    create table student(
    sid int not null auto_increment PRIMARY key,
    sname char(32),
    gender char(32),
    class_id int not null,
    constraint stu1 foreign key (class_id) references class(cid));


    创建老师表
    create table teacher(
    tid int not null auto_increment PRIMARY KEY,
    tname char(32));

    创建课程表
    create table course(
    cid int not null auto_increment PRIMARY KEY,
    cname char(32),
    tearch_id int not null,
    constraint cour1 foreign key(tearch_id) references teacher(tid));


    创建成绩表
    create table score(
    sid int not null auto_increment PRIMARY KEY,
    student_id int,
    corse_id int,
    number char(32),
    constraint score1 foreign key (student_id) references student(sid),
    constraint score2 foreign key (corse_id) references course(cid));

  • 相关阅读:
    DOS命令收集
    iis6配置支持.net4.0
    正则表达式限制文本框
    剖析XML(第一讲)
    DataTime.ToString("xx") 转换
    .net面试题大汇集
    django学习笔记(一)
    django学习笔记(一)
    django学习笔记(二)
    django学习笔记(二)
  • 原文地址:https://www.cnblogs.com/onda/p/7145360.html
Copyright © 2011-2022 走看看