Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- E Arredondo
April 22, 2005, 5:10 pm
rate this thread
Re: creating a table from a text file with field names
E Arredondo wrote:
I would do the following:
1. Open the text file in an editor
2. Paste "CREATE TABLE myTableName (" at the start
3. Edit each line in the file into VARCHAR field definitions
(e.g. "name VARCHAR(10) NOT NULL DEFAULT '',")
4. Paste ");" at the end.
5. Save, quit, and run the resulting file as a script using the 'mysql'
When you have a task like this that likely only has to be done once,
finding and learning a fancy specialized tool to automate it is usually
not the best use of time. Just do the edit by hand and you'll be done.
Unless you need to do this on a much larger scale than you described,
i.e. thousands of fields, or be able to repeat the operation many times.
In which case, a script written in Perl is your friend (sed would work
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum