Monday, August 15, 2011

Modify primary key syntax

MySQL:

ALTER TABLE your_table DROP PRIMARY KEY, ADD PRIMARY KEY ( some_field, other_field );


There is no problem some_field to be AUTO_INCREMENT.

Friday, August 12, 2011

Easier Command prompts recognition

If you use more that one Command Prompts in Windows, you probably mess them up. An easy way to distinguish them is with color command. Write in each of them color command with different arguments. Letter color changes, yeah!

Command Prompt window #1:
color A

Command Prompt window #2:
color B

MS DOS batch tips

So, by way of tribute to the dying art of the DOS Batch file, I present my top ten batch file tricks:

1 Use PUSHD / POPD to change directories
Read Scott Hanselman's writeup on PUSHD. The basic idea is that it keeps a stack, so at the simplest level you can do something like this:

PUSHD "C:\Working Directory\" ::DO SOME WORK POPD

That allows you to call the batch file from any directory and return to the original directory when you're done. The cool thing is that PUSHD can be nested, so you can move all over the place within your scripts and just POPD your way out when you're done.