• Laravel schema构建器列类型


    列类型

    点击查看原文链接:点击查看

    $table->bigIncrements('id');   //自增ID,类型为bigint
    $table->bigInteger('votes');   //等同于数据库中的BIGINT类型
    $table->binary('data');    //等同于数据库中的BLOB类型
    $table->boolean('confirmed');  //等同于数据库中的BOOLEAN类型
    $table->char('name', 4);   //等同于数据库中的CHAR类型
    $table->date('created_at');    //等同于数据库中的DATE类型
    $table->dateTime('created_at');    //等同于数据库中的DATETIME类型
    $table->dateTimeTz('created_at');  //等同于数据库中的DATETIME类型(带时区)
    $table->decimal('amount', 5, 2);   //等同于数据库中的DECIMAL类型,带一个精度和范围
    $table->double('column', 15, 8);   //等同于数据库中的DOUBLE类型,带精度, 总共15位数字,小数点后8位.
    $table->enum('choices', ['foo', 'bar']);   //等同于数据库中的 ENUM类型
    $table->float('amount');   //等同于数据库中的 FLOAT 类型
    $table->increments('id');  //数据库主键自增ID
    $table->integer('votes');  //等同于数据库中的 INTEGER 类型
    $table->ipAddress('visitor');  //等同于数据库中的 IP 地址
    $table->json('options');   //等同于数据库中的 JSON 类型
    $table->jsonb('options');  //等同于数据库中的 JSONB 类型
    $table->longText('description');   //等同于数据库中的 LONGTEXT 类型
    $table->macAddress('device');  //等同于数据库中的 MAC 地址
    $table->mediumIncrements('id');    //自增ID,类型为无符号的mediumint
    $table->mediumInteger('numbers');  //等同于数据库中的 MEDIUMINT类型
    $table->mediumText('description'); //等同于数据库中的 MEDIUMTEXT类型
    $table->morphs('taggable');    //添加一个 INTEGER类型的 taggable_id 列和一个 STRING类型的 taggable_type列
    $table->nullableTimestamps();  //和 timestamps()一样但允许 NULL值.
    $table->rememberToken();   //添加一个 remember_token 列: VARCHAR(100) NULL.
    $table->smallIncrements('id'); //自增ID,类型为无符号的smallint
    $table->smallInteger('votes'); //等同于数据库中的 SMALLINT 类型
    $table->softDeletes(); //新增一个 deleted_at 列 用于软删除.
    $table->string('email');   //等同于数据库中的 VARCHAR 列  .
    $table->string('name', 100);   //等同于数据库中的 VARCHAR,带一个长度
    $table->text('description');   //等同于数据库中的 TEXT 类型
    $table->time('sunrise');   //等同于数据库中的 TIME类型
    $table->timeTz('sunrise'); //等同于数据库中的 TIME 类型(带时区)
    $table->tinyInteger('numbers');    //等同于数据库中的 TINYINT 类型
    $table->timestamp('added_on'); //等同于数据库中的 TIMESTAMP 类型
    $table->timestampTz('added_on');   //等同于数据库中的 TIMESTAMP 类型(带时区)
    $table->timestamps();  //添加 created_at 和 updated_at列
    $table->timestampsTz();    //添加 created_at 和 updated_at列(带时区)
    $table->unsignedBigInteger('votes');   //等同于数据库中无符号的 BIGINT 类型
    $table->unsignedInteger('votes');  //等同于数据库中无符号的 INT 类型
    $table->unsignedMediumInteger('votes');    //等同于数据库中无符号的 MEDIUMINT 类型
    $table->unsignedSmallInteger('votes'); //等同于数据库中无符号的 SMALLINT 类型
    $table->unsignedTinyInteger('votes');  //等同于数据库中无符号的 TINYINT 类型
    $table->uuid('id');    //等同于数据库的UUID
  • 相关阅读:
    swagger在线文档配置
    SpringBoot中使用Shiro和JWT做认证和鉴权
    Java web基础
    spring boot基础
    spring MVC基础
    IDEA破解(自动重置试用期)
    Linux常用jar包启动停止脚本sh命令
    Docker Desktop 容器与镜像的保存和导入
    字符串有长度限制吗
    Thyemleaf报错: Method call: Attempted to call method *** on null context object
  • 原文地址:https://www.cnblogs.com/seeding/p/15598423.html
Copyright © 2020-2023  润新知