1
0

004_AssetStore.sql 933 B

12345678910111213141516171819202122232425262728293031
  1. BEGIN TRANSACTION
  2. CREATE TABLE dbo.Tmp_assets
  3. (
  4. id uniqueidentifier NOT NULL,
  5. name varchar(64) NOT NULL,
  6. description varchar(64) NOT NULL,
  7. assetType tinyint NOT NULL,
  8. local bit NOT NULL,
  9. temporary bit NOT NULL,
  10. data image NOT NULL,
  11. create_time int NULL,
  12. access_time int NULL
  13. ) ON [PRIMARY]
  14. TEXTIMAGE_ON [PRIMARY]
  15. IF EXISTS(SELECT * FROM dbo.assets)
  16. EXEC('INSERT INTO dbo.Tmp_assets (id, name, description, assetType, local, temporary, data, create_time, access_time)
  17. SELECT CONVERT(uniqueidentifier, id), name, description, assetType, local, temporary, data, create_time, access_time FROM dbo.assets WITH (HOLDLOCK TABLOCKX)')
  18. DROP TABLE assets
  19. EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT'
  20. ALTER TABLE dbo.assets ADD CONSTRAINT
  21. PK__assets__id PRIMARY KEY CLUSTERED
  22. (
  23. id
  24. ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  25. COMMIT