mysql快速入门

来源:互联网 发布:mac怎么换管理员名字 编辑:程序博客网 时间:2024/04/30 18:33
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
在使用过其它数据库如: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
在当前数据库上执行input.sql

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

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    
转自:动态网制作指南 www.knowsky.com<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击