MYSQL原版的git下载地址:
https://resources.oreilly.com/examples/9780596520847
原版的sql文件导入到mysql中有没有报错,有没有需要修改的地方,暂时没有实验过。
由于本人使用的是SQL Server,所以专门针对性的对此修改过。
例如:
1、mysql中的limit 1对应SQL Server版本top 1(限制只显示查询出的第一条数据)。
select b.branch_id, e.emp_id
from branch b inner join employee e on e.assigned_branch_id = b.branch_id
where b.city = 'Woburn' limit 1;
select top 1 b.branch_id, e.emp_id
from branch b inner join employee e on e.assigned_branch_id = b.branch_id
where b.city = 'Woburn';
2、mysql中的temporary table临时表对应SQL Server中表名前加“#”前缀。
/*MYSQL创建临时表*/
create temporary table emp_tmp as
select emp_id, fname, lname from employee;
/*SQL Server创建临时表*/
select emp_id, fname, lname into #emp_tmp from employee;
3、mysql中的枚举数据类型enum对应在SQL Server中功能类似的check约束。
txn_type_cd enum('DBT','CDT'),
txn_type_cd varchar(3) check(txn_type_cd in('DBT','CDT')),
4、mysql中的AUTO_INCREMENT自增对应SQL Server中的identity。
5、对自增长主键列插入数据时,把该列(id)的值设为null,MySQL会做自处理,而SQL Server则会报错,对此,需要手动指定需要插入的列,但是不指定该列(id)(插入的数据量比较大时使用)。
SQL Server版下载地址:
链接:https://pan.baidu.com/s/11FNczhH46Khl6G24i9S4zw?pwd=1vze
提取码:1vze