【发布时间】:2016-07-23 13:41:40
【问题描述】:
是否可以将旧表中的数据复制到新表中?我们正在计划一次重大的数据库重新安排,将所有数据传递到当前表到新创建的表 表。
我们意识到处理新闻提要等数据会很容易。这是我的迁移:
/*students table*/
public function up()
{
Schema::create('students', function (Blueprint $table) {
$table->increments('id');
$table->string('lname');
$table->string('mname')->nullable();
$table->string('fname');
$table->char('gender', 1);
$table->date('date_of_birth');
$table->string('address');
$table->tinyInteger('yr_lvl');
$table->string('contact_no');
$table->text('about_me')->nullable();
$table->text('education')->nullable();
$table->text('achievements')->nullable();
$table->text('seminars')->nullable();
$table->text('organizations')->nullable();
$table->tinyInteger('status')->default(1);
$table->timestamps();
});
}
/*newly created table works*/
Schema::create('works', function (Blueprint $table) {
$table->increments('id');
$table->integer('student_id')->unsigned()->nullable();
$table->foreign('student_id')->references('id')->on('students')->onDelete('cascade');
$table->text('about_me')->nullable();
$table->timestamps();
});
【问题讨论】:
-
您有具有不同数据结构的“旧”表,您需要将该数据传输到“新”表(具有不同结构)?
-
不,我只是想将一些数据(about_me)复制到一个新表中......如果你能看到另一个表(作品)有一个关于我的字段和一个来自学生的外键