©
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
show databases;
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | app_blogcurder | | auth_demo | | canzhieps | | cmsdemo | | mysql | | onethink | | performance_schema | | ranzhi | | thinkems | | thinksns_3_1 | | thinksns_4_0 | +--------------------+ 12 rows in set (0.01 sec)
create database 库名字;
mysql> create database test; Query OK, 1 row affected (0.00 sec)
drop database [IF EXISTS] 库名字;
mysql> drop database test; Query OK, 0 rows affected (0.01 sec)
use 库名;
mysql> use mysql Database changed mysql> \s -------------- mysql Ver 14.14 Distrib 5.6.17, for Win64 (x86_64) Connection id: 8 Current database: mysql Current user: root@localhost SSL: Not in use Using delimiter: ; Server version: 5.6.17 MySQL Community Server (GPL)
show tables;[需要县选中数据库]
mysql> use mysql Database changed mysql> show tables; +---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | db | | event | | func | | general_log | ... ...
desc 表名; 或者 describe 表名;
mysql> desc db; +-----------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------------+---------------+------+-----+---------+-------+ | Host | char(60) | NO | PRI | | | | Db | char(64) | NO | PRI | | | | User | char(16) | NO | PRI | | | ... ...
CREATE TABLE `member` ( `uid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID', `nickname` char(16) NOT NULL DEFAULT '' COMMENT '昵称', `sex` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '性别', `birthday` date NOT NULL DEFAULT '0000-00-00' COMMENT '生日', `qq` char(10) NOT NULL DEFAULT '' COMMENT 'qq号', `score` mediumint(8) NOT NULL DEFAULT '0' COMMENT '用户积分', `login` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '登录次数', `reg_ip` bigint(20) NOT NULL DEFAULT '0' COMMENT '注册IP', `reg_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '注册时间', `last_login_ip` bigint(20) NOT NULL DEFAULT '0' COMMENT '最后登录IP', `last_login_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后登录时间', `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '会员状态', PRIMARY KEY (`uid`), KEY `status` (`status`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='会员表';
drop table 表名;