📄 instpubs.sql
字号:
CHECK (max_lvl <= 250)
)
GO
CREATE TABLE pub_info
(
pub_id char(4) NOT NULL
REFERENCES publishers(pub_id)
CONSTRAINT UPKCL_pubinfo PRIMARY KEY CLUSTERED,
logo image NULL,
pr_info text NULL
)
GO
CREATE TABLE employee
(
emp_id empid
CONSTRAINT PK_emp_id PRIMARY KEY NONCLUSTERED
CONSTRAINT CK_emp_id CHECK (emp_id LIKE
'[A-Z][A-Z][A-Z][1-9][0-9][0-9][0-9][0-9][FM]' or
emp_id LIKE '[A-Z]-[A-Z][1-9][0-9][0-9][0-9][0-9][FM]'),
fname varchar(20) NOT NULL,
minit char(1) NULL,
lname varchar(30) NOT NULL,
job_id smallint NOT NULL
DEFAULT 1
REFERENCES jobs(job_id),
job_lvl tinyint
DEFAULT 10,
pub_id char(4) NOT NULL
DEFAULT ('9952')
REFERENCES publishers(pub_id),
hire_date datetime NOT NULL
DEFAULT (getdate())
)
GO
raiserror('Now at the create trigger section ...',0,1)
GO
CREATE TRIGGER employee_insupd
ON employee
FOR insert, UPDATE
AS
--Get the range of level for this job type from the jobs table.
declare @min_lvl tinyint,
@max_lvl tinyint,
@emp_lvl tinyint,
@job_id smallint
select @min_lvl = min_lvl,
@max_lvl = max_lvl,
@emp_lvl = i.job_lvl,
@job_id = i.job_id
from employee e, jobs j, inserted i
where e.emp_id = i.emp_id AND i.job_id = j.job_id
IF (@job_id = 1) and (@emp_lvl <> 10)
begin
raiserror ('Job id 1 expects the default level of 10.',16,1)
ROLLBACK TRANSACTION
end
ELSE
IF NOT (@emp_lvl BETWEEN @min_lvl AND @max_lvl)
begin
raiserror ('The level for job_id:%d should be between %d and %d.',
16, 1, @job_id, @min_lvl, @max_lvl)
ROLLBACK TRANSACTION
end
GO
raiserror('Now at the inserts to authors ....',0,1)
GO
insert authors
values('409-56-7008', 'Bennet', 'Abraham', '415 658-9932',
'6223 Bateman St.', 'Berkeley', 'CA', '94705', 1)
insert authors
values('213-46-8915', 'Green', 'Marjorie', '415 986-7020',
'309 63rd St. #411', 'Oakland', 'CA', '94618', 1)
insert authors
values('238-95-7766', 'Carson', 'Cheryl', '415 548-7723',
'589 Darwin Ln.', 'Berkeley', 'CA', '94705', 1)
insert authors
values('998-72-3567', 'Ringer', 'Albert', '801 826-0752',
'67 Seventh Av.', 'Salt Lake City', 'UT', '84152', 1)
insert authors
values('899-46-2035', 'Ringer', 'Anne', '801 826-0752',
'67 Seventh Av.', 'Salt Lake City', 'UT', '84152', 1)
insert authors
values('722-51-5454', 'DeFrance', 'Michel', '219 547-9982',
'3 Balding Pl.', 'Gary', 'IN', '46403', 1)
insert authors
values('807-91-6654', 'Panteley', 'Sylvia', '301 946-8853',
'1956 Arlington Pl.', 'Rockville', 'MD', '20853', 1)
insert authors
values('893-72-1158', 'McBadden', 'Heather',
'707 448-4982', '301 Putnam', 'Vacaville', 'CA', '95688', 0)
insert authors
values('724-08-9931', 'Stringer', 'Dirk', '415 843-2991',
'5420 Telegraph Av.', 'Oakland', 'CA', '94609', 0)
insert authors
values('274-80-9391', 'Straight', 'Dean', '415 834-2919',
'5420 College Av.', 'Oakland', 'CA', '94609', 1)
insert authors
values('756-30-7391', 'Karsen', 'Livia', '415 534-9219',
'5720 McAuley St.', 'Oakland', 'CA', '94609', 1)
insert authors
values('724-80-9391', 'MacFeather', 'Stearns', '415 354-7128',
'44 Upland Hts.', 'Oakland', 'CA', '94612', 1)
insert authors
values('427-17-2319', 'Dull', 'Ann', '415 836-7128',
'3410 Blonde St.', 'Palo Alto', 'CA', '94301', 1)
insert authors
values('672-71-3249', 'Yokomoto', 'Akiko', '415 935-4228',
'3 Silver Ct.', 'Walnut Creek', 'CA', '94595', 1)
insert authors
values('267-41-2394', 'O''Leary', 'Michael', '408 286-2428',
'22 Cleveland Av. #14', 'San Jose', 'CA', '95128', 1)
insert authors
values('472-27-2349', 'Gringlesby', 'Burt', '707 938-6445',
'PO Box 792', 'Covelo', 'CA', '95428', 3)
insert authors
values('527-72-3246', 'Greene', 'Morningstar', '615 297-2723',
'22 Graybar House Rd.', 'Nashville', 'TN', '37215', 0)
insert authors
values('172-32-1176', 'White', 'Johnson', '408 496-7223',
'10932 Bigge Rd.', 'Menlo Park', 'CA', '94025', 1)
insert authors
values('712-45-1867', 'del Castillo', 'Innes', '615 996-8275',
'2286 Cram Pl. #86', 'Ann Arbor', 'MI', '48105', 1)
insert authors
values('846-92-7186', 'Hunter', 'Sheryl', '415 836-7128',
'3410 Blonde St.', 'Palo Alto', 'CA', '94301', 1)
insert authors
values('486-29-1786', 'Locksley', 'Charlene', '415 585-4620',
'18 Broadway Av.', 'San Francisco', 'CA', '94130', 1)
insert authors
values('648-92-1872', 'Blotchet-Halls', 'Reginald', '503 745-6402',
'55 Hillsdale Bl.', 'Corvallis', 'OR', '97330', 1)
insert authors
values('341-22-1782', 'Smith', 'Meander', '913 843-0462',
'10 Mississippi Dr.', 'Lawrence', 'KS', '66044', 0)
GO
raiserror('Now at the inserts to publishers ....',0,1)
GO
insert publishers values('0736', 'New Moon Books', 'Boston', 'MA', 'USA')
insert publishers values('0877', 'Binnet & Hardley', 'Washington', 'DC', 'USA')
insert publishers values('1389', 'Algodata Infosystems', 'Berkeley', 'CA', 'USA')
insert publishers values('9952', 'Scootney Books', 'New York', 'NY', 'USA')
insert publishers values('1622', 'Five Lakes Publishing', 'Chicago', 'IL', 'USA')
insert publishers values('1756', 'Ramona Publishers', 'Dallas', 'TX', 'USA')
insert publishers values('9901', 'GGG&G', 'M乶chen', NULL, 'Germany')
insert publishers values('9999', 'Lucerne Publishing', 'Paris', NULL, 'France')
GO
raiserror('Now at the inserts to pub_info ....',0,1)
GO
insert pub_info values('0736', 0x474946383961D3001F00B30F00000000800000008000808000000080800080008080808080C0C0C0FF000000FF00FFFF000000FFFF00FF00FFFFFFFFFF21F9040100000F002C00000000D3001F004004FFF0C949ABBD38EBCDBBFF60288E245001686792236ABAB03BC5B055B3F843D3B99DE2AB532A36FB15253B19E5A6231A934CA18CB75C1191D69BF62AAD467F5CF036D8243791369F516ADEF9304AF8F30A3563D7E54CFC04BF24377B5D697E6451333D8821757F898D8E8F1F76657877907259755E5493962081798D9F8A846D9B4A929385A7A5458CA0777362ACAF585E6C6A84AD429555BAA9A471A89D8E8BA2C3C7C82DC9C8AECBCECF1EC2D09143A66E80D3D9BC2C41D76AD28FB2CD509ADAA9AAC62594A3DF81C65FE0BDB5B0CDF4E276DEF6DD78EF6B86FA6C82C5A2648A54AB6AAAE4C1027864DE392E3AF4582BF582DFC07D9244ADA2480BD4C6767BFF32AE0BF3EF603B3907490A4427CE21A7330A6D0584B810664D7F383FA25932488FB96D0F37BDF9491448D1A348937A52CAB4A9D3784EF5E58B4A5545D54BC568FABC9A68DD526ED0A6B8AA17331BD91E5AD9D1D390CED23D88F54A3ACB0A955ADDAD9A50B50D87296E3EB9C76A7CDAABC86B2460040DF34D3995515AB9FF125F1AFA0DAB20A0972382CCB9F9E5AEBC368B21EEDB66EDA15F1347BE2DFDEBB44A7B7C6889240D9473EB73322F4E8D8DBBE14D960B6519BCE5724BB95789350E97EA4BF3718CDD64068D751A261D8B1539D6DCDE3C37F68E1FB58E5DCED8A44477537049852EFD253CEE38C973B7E9D97A488C2979FB936FBAFF2CF5CB79E35830400C31860F4A9BE925D4439F81B6A073BEF1575F593C01A25B26127255D45D4A45B65B851A36C56154678568A20E1100003B,
'This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
This is sample text data for New Moon Books, publisher 0736 in the pubs database. New Moon Books is located in Boston, Massachusetts.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -