Monday, June 28, 2010

database operations

http://www.1keydata.com/sql/sql-create-index.html

 A  table index helps SQL statements run faster. The syntax for creating an index is:
CREATE INDEX IDX_CUSTOMER_LAST_NAME
on CUSTOMER (Last_Name)

 
 Copying table:
CREATE TABLE copyname SELECT * FROM originalname 

Creating key across multiple columns :
alter table tbl_name add primary key(col1,col2,col3);

If there are duplicates rows in a db across this combination:
alter ignore table judgments add unique index  `idx_nm` (col1,col2,col3);
and then drop the idx: alter ignore table judgments drop idx_name



Connections:
Q)How to check the number of connections to a db ?
A) show processlist;
 
Q)How to see the current indexes?
A) show indexes from table_name;

Thursday, June 3, 2010

View all files installed by a package with Debian

dpkg -l fortune : matches all packages with name containing fortune
dpkg -l fortunes-min: specifies files installed by package fortunes-min




Interesting commands:
cowsay , fortune ,toilet

Simple use of cut

ls -l | cut -d " " -f 1 : to print the permissions only
ls -l | cut -d " " -f2- : for the rest of fields

Nice post to detect ports.

http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/security-guide/s1-server-ports.html
nmap -sT -O localhost
netstat -anp | grep 834 
lsof -i | grep 834