表のhead,tailを5行ずつ表示: MySQL編

前回はsqliteでしたが今回はMySQLです。ほとんど同じですね。違う点はsubqueryにaliasを付けないと怒られる点です。

b600-mysql-cloud-service-en

以下INFORMATION_SCHEMAでの実行例です。

mysql> select * from (select  table_name from tables order by 1 limit 5) a
     -> union
     -> select '[...]'
     -> union
     -> select * from ( select  table_name from tables order by 1 desc limit 5) b ;
+---------------------------------------+
| table_name                            |
+---------------------------------------+
| CHARACTER_SETS                        |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| [...]                                 |
| VIEWS                                 |
| USER_PRIVILEGES                       |
| TRIGGERS                              |
| TABLE_PRIVILEGES                      |
| TABLE_CONSTRAINTS                     |
+---------------------------------------+
11 rows in set (0.00 sec)
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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s