I have SQl dump file 34 GB

CREATE TABLE `table1`
CREATE TABLE `table6`
CREATE TABLE `table44fff`
CREATE TABLE `tablecvd`

I need quickly extract all tables names, i thinks must be something like

FOR /F "tokens=* delims=" %%A IN ('db1.sql ^| FIND "CREATE TABLE `"') DO ECHO %%A > output.txt

but i get error what my file is too big

I need to get table names list in output file

table1
table6
table44fff
tablecvd
....
有帮助吗?

解决方案

Haven't tried it on a file that large, but how about the following:

FOR /F "tokens=2 delims=`" %%A IN (
    'findstr "CREATE TABLE" db1.sql'
) DO (
    ECHO %%A >> output.txt
)

As per request, in Perl, this could be done by:

#!/usr/bin/perl
use v5.14;

open(IN, "<", "db1.sql");
open(OUT, ">>", "output.txt");

while (<IN>) {
    if(/^CREATE TABLE `(.*)`/){
        say OUT $1;
    } 
}

close(IN);
close(OUT);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top