【问题标题】:Migrate User Define Types from Oracle to MSSQL将用户定义类型从 Oracle 迁移到 MSSQL
【发布时间】:2016-05-10 01:58:43
【问题描述】:

您能帮我将以下几行从 Oracle 迁移到 MSSQL。谢谢。

create or replace TYPE "GPS_SEGMENT" is object (
  lat1 numeric (14,5),
  lon1 numeric (14,5),
  lat2 numeric (14,5),
  lon2 numeric (14,5)
  );

create or replace TYPE "GPS_SEGMENT_TABLE" is table of  gps_segment;   

谢谢。

【问题讨论】:

    标签: sql-server oracle database-migration


    【解决方案1】:

    我相信您在 SQL Server 中想要的是用户定义的表类型:

    CREATE TYPE udtGpsSegment AS TABLE
    (
      lat1 numeric (14,5),
      lon1 numeric (14,5),
      lat2 numeric (14,5),
      lon2 numeric (14,5)
    );
    

    然后您可以在 MSSQL 中将其用作表变量:

    DECLARE @gpsSegment udtGpsSegment;
    INSERT @gpsSegment(....)
    

    或者将其作为存储过程的参数:

    CREATE PROCEDURE example (@gpsSegment udtGpsSegment READONLY)
    AS
    BEGIN
      -- note that you can't update/insert/delete udtGpsSegment, but you can select from it - if needed, select it into a temp table or table variable that can be updated/deleted/inserted.
    END
    

    另请注意,这只适用于 SQL Server 2008R2+

    【讨论】:

      猜你喜欢
      • 2017-08-05
      • 2021-10-28
      • 2016-06-22
      • 2014-09-03
      • 1970-01-01
      • 2012-09-14
      • 2013-10-03
      • 2019-09-17
      相关资源
      最近更新 更多