views:

344

answers:

2

How do you view all the constraints (Primary keys, Secondary keys, Assertions , Triggers, etc) in a MySQL Database / Table in the command line environment.

+1  A: 

DESCRIBE is an alias for SHOW COLUMNS, like a shortcut. If you want all the other stuff then you need to use SHOW commands for your stuff. And SHOW COLUMNS for the rest.

Describe

Show

Arto Uusikangas
Thanks Arto!I googled on this and there exists a series of commands for this purpose. Please referhttp://dev.mysql.com/doc/refman/5.0/en/show.html
EFreak
+1  A: 

Just dump the database without data using

mysqldump --no-data  (other options)

As if you were taking a backup. Use the same options as you do when taking a backup (maybe --lock-tables=0 - you don't need a lock when dumping the schema)

Without the data, you get just the schema which includes all those things you said above.

MarkR
I tried this but am unable to use this option as I don't have the permission to lock tables/dbs
EFreak
You do not need to lock the tables to dump the schema. I specifically suggested not trying to.
MarkR
sry! I missed that.This is a better solution I guess. Dumps all the information it has.Syntax:mysqldump -uusername -hhostname -p --no-data --lock-tables=0 dbnameMore details available athttp://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
EFreak