Editing the 9gb.sql File

I have a "slightly" large sql script saved as a text file. It stacks at 8.92 GB, so it's a bit of a beast.

I need to do a search and replace in this file (in particular, change all NOT NULL to NULL, so that all fields are NULL), and then do the black thing. Does anyone have any suggestions for a text editor that would be capable of this?

Another way I see to solve the problem is to write a program that reads a piece, replaces the material I need, and then saves it in a new file, but I would prefer to use some standard way to do this.

It also does not solve the problem of opening the beast in the sql server management studio to do the dirty thing ...

Any ideas?

Thanks Eric

+3
source share
5 answers

sed built for this kind of work.

sed -e 's/\( NOT\)\? NULL/ NOT NULL/g' < input.sql > output.sql

sedalso available on Windows .

Edit: I changed my statement to avoid creating NOT NOT NULLwhen the input already contains NOT NULL.

+6
source

Use sed or just perl -pne 's/foo/bar/' file.sql > newfile.sql(foo will be replaced with a string).

To load SQL, use osql.exe, which should be somewhere under c: \ program files ... \ sql server \ bin

+1
source

, . UltraEdit Notepad ++, , .

, .

0

perl. .

perl -pie "s/ NOT NULL/ NULL/g" hugefile.sql
0

Watch out for this ax Eugene ... you don't want to compress any WHERE clauses that should remain NOT NULL

0
source

Source: https://habr.com/ru/post/1736636/


All Articles