自动生成的id 被当作primary key来使用

timestamp method生成 created_at 与 updated_at columns

create_table 和 drop_table 用来生成表与删除表

null:false 表明不能为null

rake db:rollback  ---- 返回到上次migration之前的状态

添加与删除列:

add_column :table_name, :column_name, :column_type

remove_column :table_name, :column_name

rake:schema:load 读取schema

重命名column:

rename_column :table_name, :old_column_name, :new_column_name

或者 rails g migration rename_make_to_company  =>   rename_column :cars, :make, :company

RoR - Creating and Modifying Table and Columns的更多相关文章

  1. 【C#】Creating/Querying/Modifying the .mdb databases

    As for databases, there are quit many kinds such as foxpro, mysql, sqlserver, etc. But when we need ...

  2. mysqladmin processlist; show processlist/status/open tables/engine/variables/table status/columns/grants/index/privileges/innodb status/logs/warnings/////; 结果筛选

    mysqladmin showprocesslist可查看完整sql需要权限. SHOW PROCESSLIST显示哪些线程正在运行.您也可以使用mysqladmin processlist语句得到此 ...

  3. Creating a settings table that can handle almost any type of value

    Update: Updated article here. Today I wanted to be able to have a table store any type of value as a ...

  4. Spark 2.x不支持ALTER TABLE ADD COLUMNS,没关系,我们改进下

    SparkSQL从2.0开始已经不再支持ALTER TABLE table_name ADD COLUMNS (col_name data_type [COMMENT col_comment], .. ...

  5. 自己动手为Spark 2.x添加ALTER TABLE ADD COLUMNS语法支持

    SparkSQL从2.0开始已经不再支持ALTER TABLE table_name ADD COLUMNS (col_name data_type [COMMENT col_comment], .. ...

  6. Table View Programming Guide for iOS---(五)---Creating and Configuring a Table View

    Creating and Configuring a Table View Your app must present a table view to users before it can mana ...

  7. MySQL 5.6 Reference Manual-14.7 InnoDB Table Compression

    14.7 InnoDB Table Compression 14.7.1 Overview of Table Compression 14.7.2 Enabling Compression for a ...

  8. [Hive - LanguageManual] Create/Drop/Alter Database Create/Drop/Truncate Table

    Hive Data Definition Language Hive Data Definition Language Overview Create/Drop/Alter Database Crea ...

  9. 13.1.17 CREATE TABLE Syntax

    13.1.17 CREATE TABLE Syntax 13.1.17.1 CREATE TABLE ... LIKE Syntax 13.1.17.2 CREATE TABLE ... SELECT ...

随机推荐

  1. Effective Java 第三版——64. 通过对象的接口引用对象

    Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...

  2. Gradle 打可执行jar包

    初次使用Gradle,想和maven一样,把gradle项目打成可执行jar包,具体步骤: 1.下载gradle 版本,并配置环境变量, 下载地址:https://gradle.org/release ...

  3. 斐讯K1 K2 开启Telnet

    官方V21.4.5.5前的ROM,直接打开下边这个链接就直接开telnet了,然后就可以随便搞了 http://192.168.2.1/goform/gra_NTPSyncWithLocal?text ...

  4. spring相关面试题

    1.spring有依赖的bean,怎么加载? 2.spring怎么解决循环依赖? https://blog.csdn.net/u010853261/article/details/77940767 h ...

  5. layui form表单自定义sm格式

    1. 新建以下sm样式,保存为layform_sm.css文件名,然后导入到layui.css的后面. .layui-input-sm,.layui-select-sm,.layui-textarea ...

  6. [mvc] 过滤器filter一览

    1.mvc的过滤器种类

  7. QtCreator pro中相对路径和debug文件夹下未放动态库时调试报QtCreator:during startup program exited with code 0xc0000135错误

    QtCreator  pro中相对路径一般是以pro文件(非main函数所在文件)所在的当前目录为起点,用$$PWD表示. 如头文件和库文件 INCLUDEPATH +=$$PWD/inc win32 ...

  8. c 时间转移函数

    /*                 @param       date                 @param       formart  of date                 @ ...

  9. JavaScript学习历程03

    一闪一闪亮晶晶 <script type="text/javascript"> var nn = Number(prompt('请输入一个1-9的正整数!')); va ...

  10. could not resolve property: leader_id of: pojo.Project

    https://www.cnblogs.com/zhaocundang/p/9211270.html hibernate 双向1对多 出现问题 外键解析错误! log4j:WARN No append ...