1. 程式人生 > >mysql將一個表中資料插入另一張表,排重,刪除,匯入

mysql將一個表中資料插入另一張表,排重,刪除,匯入

將一個表中資料插入另一張表的語句:

insert into 目標表(欄位1,欄位2,欄位3……) select  欄位1,欄位2,欄位3… from 來源表 where 條件1 and 條件2;

排重很簡單,只要在需要排重的欄位前加distinct就可以嘞!eg~

查詢記錄裡有多少條不同的id:select count(distinct id) from tableName;

查詢打印出不同的記錄:select distinct * from tabelName;

刪除表中的列:

ALTER   TABLE  表名   DROP   COLUMN   列名;

將本地檔案中資料匯入資料庫:

load data local infile 'd:/檔案.txt' into table 表名;