// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
#contents

*** データベースを作成する [#d036fe90]
 mysql> CREATE DATABASE データベース名

*** データベースを表示する [#j9c0a1c4]
 [root@www ~]# mysqlshow   -uroot -p
 Enter password:
 +--------------------+
 |     Databases      |
 +--------------------+
 | information_schema |
 | mysql              |
 | test               |
 | webdb1             |
 +--------------------+

MySQLのプロンプト内で

 mysql> show databases;
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | mysql              |
 | test               |
 | webdb1             |
 +--------------------+
 5 rows in set (0.00 sec)
 ->
とすることもできます。


***データベース情報を表示する [#j291d710]
 [root@www ~]# mysqlshow webdb1 -p -uroot
 Enter password:
 Database: webdb1
 +--------+
 | Tables |
 +--------+
 | rss    |
 +--------+

MySQLのプロンプト内で、
 mysql> use webdb1;
 Database changed
 mysql> show tables;
 +------------------+
 | Tables_in_webdb1 |
 +------------------+
 | rss              |
 +------------------+
 1 row in set (0.00 sec)
とすることもできます。

***テーブル情報を表示する [#z88c039d]

 [root@www ~]# mysql webdb1 -p -uroot
 Enter password:
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 53 to server version: 5.0.15-max-log
 
 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
 mysql> describe rss;
 +-------+------------------+------+-----+---------------------+----------------+
 | Field | Type             | Null | Key | Default             | Extra          |
 +-------+------------------+------+-----+---------------------+----------------+
 | id    | int(10) unsigned | NO   | PRI | NULL                | auto_increment |
 | title | varchar(255)     | YES  |     |                     |                |
 | link  | text             | YES  |     | NULL                |                |
 | date  | datetime         | NO   |     | 0000-00-00 00:00:00 |                |
 +-------+------------------+------+-----+---------------------+----------------+
 4 rows in set (0.00 sec)
 
 mysql>



*** テーブル定義を参照する [#qc88633b]
テーブルがどの様なSQL文で作成されたか表示します。

 mysql> show create table webdb1.rss;
 --------------------------+
 | Table | Create Table
 --------------------------+
 | rss   | CREATE TABLE `rss` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `title` varchar(255) default '',
   `link` text,
   `date` datetime NOT NULL default '0000-00-00 00:00:00',
   PRIMARY KEY  (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=ujis COMMENT='RSS List' |
 +-------+---------------------------------------------------
 1 row in set (0.00 sec)
参考:~
http://www.rfs.jp/sitebuilder/sql/04/07.html#SHOW%20CREATE%20TABLE



----
この記事は
#vote(おもしろかった[2],そうでもない[4])
#vote(おもしろかった[3],そうでもない[4])

#comment
#topicpath


SIZE(10){現在のアクセス:&counter;}

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS