Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # encoding: UTF-8
- # show create tables from a database
- require 'mysql2'
- m = Mysql2::Client.new :username => 'root', :password => '', :host => 'localhost', :database => 'dbname'
- result = m.query("SHOW TABLES").collect do |row|
- table = row['Tables_in_dbname']
- puts table
- puts m.query("SHOW CREATE TABLE #{table}").first['Create Table']
- puts
- end
- m.close
Add Comment
Please, Sign In to add comment