Merge branch 'master' of https://git.2li.ch/ibz/oop_II-6
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
This commit is contained in:
commit
1970f5a61e
|
@ -11,20 +11,14 @@
|
||||||
-- 180629 Ivan, Add inserts for fixed lists
|
-- 180629 Ivan, Add inserts for fixed lists
|
||||||
-- --------------------------------------------------
|
-- --------------------------------------------------
|
||||||
|
|
||||||
-- Set DB toSingle User so open connections do not block
|
|
||||||
-- --------------------------------------------------
|
|
||||||
PRINT 'Set Multiuser to Singleuser so all open connections are cut...';
|
|
||||||
use master
|
|
||||||
ALTER DATABASE EHEC_DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
|
|
||||||
-- --------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Auskommentieren für Löschung der Datenbank
|
-- Auskommentieren für Löschung der Datenbank
|
||||||
IF db_id('EHEC_DB') is not null
|
IF db_id('EHEC_DB') is not null
|
||||||
BEGIN;
|
BEGIN;
|
||||||
PRINT 'EHEC_DB already EXISTS, db will be deleted for a new creation.'
|
PRINT 'EHEC_DB already EXISTS, Set Multiuser to Singleuser so all open connections are cut...';
|
||||||
USE [master];
|
USE [master];
|
||||||
|
-- Set DB toSingle User so open connections do not block Destroy of DB
|
||||||
|
ALTER DATABASE EHEC_DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
|
||||||
|
PRINT 'DB will be deleted for a new creation.'
|
||||||
DROP DATABASE EHEC_DB;
|
DROP DATABASE EHEC_DB;
|
||||||
END;
|
END;
|
||||||
ELSE
|
ELSE
|
||||||
|
@ -192,89 +186,6 @@ CREATE TABLE [dbo].[Origin_Exam] (
|
||||||
);
|
);
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
|
||||||
---- --------------------------------------------------
|
|
||||||
--PRINT 'Creating all PRIMARY KEY constraints';
|
|
||||||
---- --------------------------------------------------
|
|
||||||
-- Creating primary key on [Origin_ExamId] in table 'Origin_Exam'
|
|
||||||
--ALTER TABLE [dbo].[Origin_Exam]
|
|
||||||
--ADD CONSTRAINT [PK_Origin_Exam]
|
|
||||||
-- PRIMARY KEY CLUSTERED ([Origin_ExamId] ASC);
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating primary key on [PatientId] in table 'Patient'
|
|
||||||
--ALTER TABLE [dbo].[Patient]
|
|
||||||
--ADD CONSTRAINT [PK_Patient]
|
|
||||||
-- PRIMARY KEY CLUSTERED ([PatientId] ASC);
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating primary key on [DoctorId] in table 'Doctor'
|
|
||||||
--ALTER TABLE [dbo].[Doctor]
|
|
||||||
--ADD CONSTRAINT [PK_Doctor]
|
|
||||||
-- PRIMARY KEY CLUSTERED ([DoctorId] ASC);
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating primary key on [OriginId] in table 'Origin'
|
|
||||||
--ALTER TABLE [dbo].[Origin]
|
|
||||||
--ADD CONSTRAINT [PK_Origin]
|
|
||||||
-- PRIMARY KEY CLUSTERED ([OriginId] ASC);
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating primary key on [ExamId] in table 'Exam'
|
|
||||||
--ALTER TABLE [dbo].[Exam]
|
|
||||||
--ADD CONSTRAINT [PK_Exam]
|
|
||||||
-- PRIMARY KEY CLUSTERED ([ExamId] ASC);
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating primary key on [ResultId] in table 'Result'
|
|
||||||
--ALTER TABLE [dbo].[Result]
|
|
||||||
--ADD CONSTRAINT [PK_Result]
|
|
||||||
-- PRIMARY KEY CLUSTERED ([ResultId] ASC);
|
|
||||||
--GO
|
|
||||||
|
|
||||||
---- --------------------------------------------------
|
|
||||||
--PRINT 'Creating all FOREIGN KEY constraints';
|
|
||||||
---- --------------------------------------------------
|
|
||||||
|
|
||||||
-- Creating foreign key on [ResultId] in table 'Exam'
|
|
||||||
--ALTER TABLE [dbo].[Exam]
|
|
||||||
--ADD CONSTRAINT [FK_ResultExam]
|
|
||||||
-- FOREIGN KEY ([ResultId])
|
|
||||||
-- REFERENCES [dbo].[Result]([ResultId])
|
|
||||||
-- ON DELETE NO ACTION ON UPDATE NO ACTION;
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating foreign key on [DoctorId] in table 'Exam'
|
|
||||||
--ALTER TABLE [dbo].[Exam]
|
|
||||||
--ADD CONSTRAINT [FK_DoctorExam]
|
|
||||||
-- FOREIGN KEY ([DoctorId])
|
|
||||||
-- REFERENCES [dbo].[Doctor]([DoctorId])
|
|
||||||
-- ON DELETE NO ACTION ON UPDATE NO ACTION;
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating foreign key on [PatientId] in table 'Exam'
|
|
||||||
--ALTER TABLE [dbo].[Exam]
|
|
||||||
--ADD CONSTRAINT [FK_PatientExam]
|
|
||||||
-- FOREIGN KEY ([PatientId])
|
|
||||||
-- REFERENCES [dbo].[Patient]([PatientId])
|
|
||||||
-- ON DELETE NO ACTION ON UPDATE NO ACTION;
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating foreign key on [OriginId] in table 'Origin_Exam'
|
|
||||||
--ALTER TABLE [dbo].[Origin_Exam]
|
|
||||||
--ADD CONSTRAINT [FK_Origin]
|
|
||||||
-- FOREIGN KEY ([OriginId])
|
|
||||||
-- REFERENCES [dbo].[Origin] ([OriginId])
|
|
||||||
-- ON DELETE NO ACTION ON UPDATE NO ACTION;
|
|
||||||
--GO
|
|
||||||
|
|
||||||
-- Creating foreign key on [ExamId] in table 'Origin_Exam'
|
|
||||||
--ALTER TABLE [dbo].[Origin_Exam]
|
|
||||||
--ADD CONSTRAINT [FK_Exam]
|
|
||||||
-- FOREIGN KEY ([ExamId])
|
|
||||||
-- REFERENCES [dbo].[Exam]([ExamId])
|
|
||||||
-- ON DELETE NO ACTION ON UPDATE NO ACTION;
|
|
||||||
--GO
|
|
||||||
-- --------------------------------------------------
|
-- --------------------------------------------------
|
||||||
PRINT 'Creating all INDEXES';
|
PRINT 'Creating all INDEXES';
|
||||||
-- --------------------------------------------------
|
-- --------------------------------------------------
|
||||||
|
@ -304,22 +215,13 @@ ON [dbo].[Origin_Exam]
|
||||||
([ExamId]);
|
([ExamId]);
|
||||||
GO
|
GO
|
||||||
|
|
||||||
---- --------------------------------------------------
|
|
||||||
--PRINT 'Creating inserts for fixed list objects';
|
|
||||||
---- --------------------------------------------------
|
|
||||||
|
|
||||||
--INSERT INTO Result(Name)
|
|
||||||
--VALUES
|
|
||||||
-- ('EHEC-A'),
|
|
||||||
-- ('EHEC-B'),
|
|
||||||
-- ('EHEC-C'),
|
|
||||||
-- ('EHEC-D'),
|
|
||||||
-- ('EHEC-E')
|
|
||||||
--GO
|
|
||||||
-- --------------------------------------------------
|
-- --------------------------------------------------
|
||||||
PRINT 'Set Singleuser mode back to Multiuser mode.';
|
IF DATABASEPROPERTYEX('EHEC_DB','UserAccess') = 'SINGLE_USER'
|
||||||
-- set DB back to Multiuser so multiconnections are alowed again.
|
begin;
|
||||||
ALTER DATABASE EHEC_DB SET MULTI_USER
|
PRINT 'Set Singleuser mode back to Multiuser mode.';
|
||||||
|
-- set DB back to Multiuser so multiconnections are alowed again.
|
||||||
|
ALTER DATABASE EHEC_DB SET MULTI_USER
|
||||||
|
end;
|
||||||
-- --------------------------------------------------
|
-- --------------------------------------------------
|
||||||
PRINT 'Successfull created your DB!';
|
PRINT 'Successfull created your DB!';
|
||||||
-- Script has ended
|
-- Script has ended
|
||||||
|
|
Loading…
Reference in New Issue