19

テーブルの 1 つの列だけの mysql ダンプを取得する必要があるという要件があります。そのテーブルには列が多すぎるため、テーブル全体をダンプしたくありません。あるサーバーから別のサーバーにこのテーブルのダンプを取得する必要があります。どうすればこれを行うことができますか?

4

3 に答える 3

20

スキーマを含む mysql ダンプを取得する場合は、次の手順に従って実行できます。

一時テーブルを作成します。

create table temp_table like name_of_the_original_table;

temp_table へのデータの複製:

insert into temp_table select * from name_of_the_original_table;

不要なフィールドの削除:

alter table temp_table drop column somecolumn;

これを投稿すると、次を実行して mysqldump を取得できます。

mysqldump -u <username> -p <password> databasename temp_table

(スキーマなしで) データ ダンプを取得することが意図されている場合は、次のコマンドを実行できます。

select * from sometable into outfile '/tmp/datadump' fields terminated by '\t' lines terminated by '\n';
于 2015-07-07T07:12:21.793 に答える
8

列をファイルに選択しますか?

Select col from table into outfile 'fileame'
于 2013-03-07T06:34:05.393 に答える