The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parse String Using Sed racbern Shell Programming and Scripting 4 04-23-2008 09:14 AM
how to parse this string hcliff Shell Programming and Scripting 13 04-02-2008 01:43 AM
parse xml bin-doph High Level Programming 5 03-15-2004 08:19 AM
How to parse.. natter Shell Programming and Scripting 8 05-22-2003 06:11 AM
Parse nguda Shell Programming and Scripting 7 05-16-2002 06:10 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-23-2008
mirusnet's Avatar
Registered User
 

Join Date: Dec 2007
Posts: 139
Parse

I need a script that will always return an engine of table, which not
depends on the table structure.

I need it to be done exactly from the "show create table ..." statement.
If there is a easiest way, except "show table status", please write.

Code:
mysql -u root db -sBe "show create table table"
Table Create Table
table CREATE TABLE `dtt` (\n `id` int(11) DEFAULT NULL,\n `dt` datetime DEFAULT NULL,\n `tp` enum('start','stop') DEFAULT NULL\n) ENGINE=MyISAM DEFAULT CHARSET=latin1
Reply With Quote
Forum Sponsor
  #2  
Old 01-23-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,933
What's wrong with this (for MySQL >=5 IIRC):

Code:
$ mysql -u root -NBe 'select engine from information_schema.tables where table_name="user"'
MyISAM
For older versions (with GNU grep):

Code:
$ mysql -u root -NBe 'show create table mysql.user'|grep -o 'ENGINE=[^ ]*'
ENGINE=MyISAM
If you want to remove "ENGINE=":

Code:
$ engine="$(mysql -u root -NBe 'show create table mysql.user'|grep -o 'ENGINE=[^ ]*')"
$ echo "${engine#*=}"
MyISAM

Last edited by radoulov; 01-23-2008 at 03:55 PM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0