MySQL 和 SQL Server一丝比较

以下SQL Server和MySQL中出现的test均为表(特殊说明除外)

1.查看表创建的脚本

SQL Server:

image

MySQL:

show create table test;

2.查看表结构

SQL Server

sp_columns test;

sp_help test;

MySQL:

show columns in test;

desc test;

3.查看数据库中有哪些表

SQL Server:

select name from sysobjects where xtype=‘U’

MySQL:

select table_name,table_rows from information_schema.tables

where table_schema=‘testdb’

这点上感觉MySQL做的比较好,infromation_schema就是一个数据库,数据库里有表有视图,和我们平时查询语句具有一致性,直接select 列名 from 表;table_rows说明当前这个表的行数。

use information_schema;

select table_name,table_rows from tables

where table_schema=‘testdb’

使用workbench连接MySQL,可以选择数据库,右键—Schema Inspector

image

这里会列出关于这个数据库几乎所有你所想要的信息,包括tables、columns、indexes、triggers、views等等

image

还有种简单的方法,

use 数据库名;

show tables;

4.查看有哪些数据库

MySQL:

show databases;

原文地址:https://www.cnblogs.com/cnmarkao/p/3880782.html