💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 数据库与表显示、创建、删除 ## 数据库显示 > **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) ``` ## 选中数据库 >[success] **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 表名;**