SQL Commands

Useful SQL commands

MSSQL

Describe table

exec sp_columns table_name

exec sp_columns table_name, @column_name = 'foo'

exec sp_columns table_name, @column_name = 'a%'

MySQL

Process List and Status

mysqladmin -uadmin -p processlist

mysqladmin -uadmin -p status

# using plesk
mysqladmin -uadmin -p`cat /etc/psa/.psa.shadow` processlist

mysqladmin -uadmin -p`cat /etc/psa/.psa.shadow` status

Users and Privileges (use ‘%’ for any host)

CREATE USER 'username'@'host' IDENTIFIED BY 'password';

GRANT ALL ON `database`.* TO 'username'@'host'; 

SHOW GRANTS FOR 'username'@'host';

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'username'@'host';
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s