Home  >  Article  >  Database  >  mysql快速入门

mysql快速入门

WBOY
WBOYOriginal
2016-06-07 16:04:24926browse

在使用过其它数据库如:oracle,sybase等之后,在使用mysql数据库入门时,一般关心我怎样知道当前的数据库,在数据库里有哪些表,表结构如何?怎样执行一个外部的sql文件等,本文根据sql的资料整理了mysql快速入门的一些信息,希望对了解其他数据库而想转入my

在使用过其它数据库如:oracle,sybase等之后,在使用mysql数据库入门时,一般关心我怎样知道当前的数据库,在数据库里有哪些表,表结构如何?怎样执行一个外部的sql文件等,本文根据sql的资料整理了mysql快速入门的一些信息,希望对了解其他数据库而想转入mysql的入门者有帮助。
1: 显示数据库
SHOW DATABASES,
2:当前选择的数据库,
mysql> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| test    |
+------------+
3:当前数据库包含的表信息:
mysql> SHOW TABLES;
+---------------------+
| Tables in test   |
+---------------------+
| mytable1      |
| mytable2      |
+---------------------+
4:获取表结构
mysql> desc mytable1;
+---------+-------------+------+-----+---------+-------+
| Field  | Type    | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| s1   | varchar(20) | YES |   | NULL  |    |
+---------+-------------+------+-----+---------+-------+
5:执行外部的sql脚本
shell> mysql 在当前数据库上执行input.sql

shell> mysql test 在test数据库上执行input.sql

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:安装MySQL步骤详解Next article:MYSQL使用简述