MySQL与SQLServer的语法区别

1.自增值的设置
  mysql:id int primary key auto_increment
  sqlserver:id int primary key identity(1, 1) //identity(1,1):从1开始,每次+1
2.SQL Server查看表结构:sp_help 表名 或 sp_columns 表名
3.查询前几条
  mysql:select * from student limit 10;
  sqlserver:select top 10 * from student;
4.获取当前时间
  mysql:now()
  sqlserver:getdate()
5.修改字段的数据类型
  mysql:alter table test2 modify id bigint;
  sqlserver:alter table emp alter column[id] bigint
6.对枚举字段的处理
  mysql:sex enum(‘male’,‘female’) not null default ‘male’
  sqlserver:sex NVARCHAR(2) CHECK(sex=‘男’ OR sex=‘女’)
7.截取字符串
  mysql:SUBSTRING和SUBSTR
  sqlserver:SUBSTRING
8.查看系统内所有数据库、所有表
  mysql:show databases;和 show tables;
  sqlserver:SELECT name, database_id, create_date FROM sys.databases; 和 select * from sysobjects where xtype= ‘U’;

原文地址:https://www.cnblogs.com/xyddm/p/10309482.html