SHARE
TWEET

Untitled

bulletmys Nov 19th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. USE master;
  2. GO
  3.  
  4. CREATE DATABASE tset1
  5. ON (NAME = tset_dat1, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\tset1.mdf', SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5)
  6. LOG ON ( NAME = tset_log1, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\tset1.ldf',SIZE = 5, MAXSIZE = 25, FILEGROWTH = 5);
  7. GO
  8.  
  9. USE tset1;
  10. GO
  11.  
  12. CREATE TABLE Planet
  13. (
  14.   Planet_id int IDENTITY(5,10) NOT NULL PRIMARY KEY,
  15.   AddedTime datetime NOT NULL DEFAULT (getdate()),
  16.   Name varchar(15) NOT NULL DEFAULT ('Planet'),
  17.   PlanetWeight int,
  18.   CHECK (PlanetWeight > 0)
  19. )
  20. GO
  21.  
  22. INSERT INTO [dbo].[Planet]
  23.            ([Name])
  24.      VALUES
  25.            ('Kek1')
  26. GO
  27.  
  28. INSERT INTO [dbo].[Planet]
  29.            ([Name])
  30.      VALUES
  31.            ('Kek2')
  32. GO
  33.  
  34. INSERT INTO [dbo].[Planet]
  35.            ([Name])
  36.      VALUES
  37.            ('Kek3')
  38. GO
  39.  
  40.  
  41. SELECT SCOPE_IDENTITY()
  42. GO
  43.  
  44. CREATE TABLE Orders  (
  45. CustomerID uniqueidentifier NOT NULL PRIMARY KEY  
  46.    DEFAULT newid(),
  47. )
  48. GO
  49.  
  50. CREATE SCHEMA Audit ;  
  51. GO  
  52.  
  53. CREATE SEQUENCE Audit.EventCounter  
  54.     AS int  
  55.     START WITH 1  
  56.     INCREMENT BY 1 ;  
  57. GO  
  58.  
  59. CREATE TABLE Audit.ProcessEvents  
  60. (  
  61.     EventID int PRIMARY KEY DEFAULT (NEXT VALUE FOR Audit.EventCounter),  
  62.     EventTime datetime NOT NULL DEFAULT (getdate())
  63. ) ;  
  64. GO  
  65.  
  66. CREATE TABLE TempSalesReason
  67.    (
  68.       TempID int NOT NULL, Name nvarchar(50)
  69.       , CONSTRAINT PK_TempSales PRIMARY KEY (TempID)
  70.       , CONSTRAINT FK_TempSales_SalesReason FOREIGN KEY (TempID)
  71.         REFERENCES Audit.ProcessEvents (EventID)
  72.         ON DELETE CASCADE
  73.         ON UPDATE CASCADE
  74.    )
  75. ;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top