zoukankan      html  css  js  c++  java
  • SQL创建表格——手写代码

    打开phpstudy,打开Navicat for MySQL,进入要创建表格的数据库,点击上方“查询”按钮,“创建查询”,即可输入代码进行创建。

    例:

    create table class
    (
     class_id int not null  primary key,
     class varchar(255) not null,
     major varchar(255) not null ,
     depart varchar(255) not null
    );
    create table stu_info
    (
     id int not null primary key,
     name varchar(90) not null ,
     sex varchar(100) not null,
     age int,
     class varchar(20) not null,
     foreign key (class) references class(class_id)
    );
    create table score
    (
     ids int auto_increment  primary key,
     stu_id int not null,
     subject varchar(255) not null,
     score int not null
    );

    注意:
    1.类型包含长度的在类型后面加括号,括号里面写长度
    2.上一列写完加逗号
    3.最后一列不要写逗号
    4.在每一条SQL语句写完之后要加分号
    5.如果有外键关系,先创建主表

    **自增长 auto_increment
    **主键 primary key
    **外键 foreign key (列名)  references 主表名(列名)
    **非空 not null

    创建数据库
    create database test2;
    删除数据库
    drop database test2;

  • 相关阅读:
    第十二章,结束练习
    第十一章,表单
    第十章,表格练习
    第九章,跨行跨列的表格
    第八章,表格
    第七章,列表
    第六章,body当中的属性
    第五章,标签的使用
    6. C# 命名规则
    5. c#变量
  • 原文地址:https://www.cnblogs.com/cmzhphp2017/p/7547340.html
Copyright © 2011-2022 走看看