mysql 複製表以及表結構
阿新 • • 發佈:2018-11-12
1.複製表結構及資料到新表 create table新表select * from舊錶 2.只複製表結構到新表 方法1 :(低版本的mysql不支援,mysql4.0.25不支援,mysql5已經支援了) 建立表新表如舊錶 方法2: 建立表新表select * from舊錶limit 0 方法3: create table新表select * from舊錶其中不成立條件 3.複製舊錶的資料到新表 1,(假設兩個表結構一樣) 插入新表select * from舊錶 2,(假設兩個表結構不一樣) insert into新表(欄位1,欄位2,......)選擇欄位1,欄位2,......來自舊錶 如 INSERT INTO zbasecourse(zbasecourse.id, zbasecourse.username, zbasecourse.userId, zbasecourse.studyCount, zbasecourse.secondMajorTittle, zbasecourse.secondMajorId, zbasecourse.salesStatus, zbasecourse.`code`, zbasecourse.cover, zbasecourse.`name`, zbasecourse.isCompetitiveProducts, zbasecourse.displayName, zbasecourse.dateCreate, zbasecourse.majortittle, zbasecourse.majorId ) SELECT zbase_course.id, zbase_course.username, zbase_course.user_id, zbase_course.study_count, zbase_course.second_major_tittle, zbase_course.second_major_id, zbase_course.sales_status, zbase_course.`code`, zbase_course.cover, zbase_course.`name`, zbase_course.is_competitive_products, zbase_course.display_name, zbase_course.date_create, zbase_course.majortittle, zbase_course.major_id from zbase_course