Tuesday, November 15, 2011

mysql add AUTO_INCREMENT

1, if the table no primary key, you need add primary key first

mysql> alter table blacklist add primary key (alarmID) ;

2, mysql> alter table blacklist modify alarmID int(10) unsigned AUTO_INCREMENT, AUTO_INCREMENT=50000;

mysqldump with where condition

mysqldump -u user -ppasswd yourDB yourTable --where="service_category_id in (261, 262)"> signatures_blacklist.sql

Wednesday, November 9, 2011

line terminator

The line terminator expected for each file format is:

unix LF only (each line ends with an LF character).
dos CRLF (each line ends with two characters, CR then LF).
mac CR only (each line ends with a CR character).
CR is carriage return (return cursor to left margin), which is Ctrl-M or ^M or hex 0D.
LF is linefeed (move cursor down), which is Ctrl-J or ^J or hex 0A. Sometimes, LF is written as NL (newline).

Mac OS version 9 and earlier use mac line endings, while Mac OS X and later use unix line endings.


Carriage Return (^M or \r).

LF:    Line Feed, U+000A
 VT:    Vertical Tab, U+000B
 FF:    Form Feed, U+000C
 CR:    Carriage Return, U+000D
 CR+LF: CR (U+000D) followed by LF (U+000A)
 NEL:   Next Line, U+0085
 LS:    Line Separator, U+2028
 PS:    Paragraph Separator, U+2029

Monday, November 7, 2011

mysql concat string

update compounds set link=concat("http://www.chemmol.com/chemmol/", mol_id , ".html") ;

Thursday, November 3, 2011

Remove blank lines

Type the following command:
$ sed '/^$/d' input.txt > output.txt
Task: Remove blank lines using grep

$ grep -v '^$' input.txt > output.txt

Thursday, October 27, 2011

Wednesday, September 21, 2011