Menu

[r8315]: / trunk / examples / sybase.sql  Maximize  Restore  History

Download this file

317 lines (257 with data), 9.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/*==============================================================*/
/* Database name: Sybase */
/* DBMS name: Sybase Adaptive Server Enterprise 12.5 */
/* Created on: 17.02.2003 20:22:43 */
/*==============================================================*/
IF DB_ID('zeoslib') IS NOT NULL
drop database zeoslib
go
CREATE DATABASE zeoslib
ON master=10
go
use zeoslib
go
set quoted_identifier on
go
if exists (select 1
from sysindexes
where id = object_id('cargo')
and name = 'cargo_FK'
and indid > 0
and indid < 255)
drop index cargo.cargo_FK
go
if exists (select 1
from sysindexes
where id = object_id('equipment2')
and name = 'equipment2_FK'
and indid > 0
and indid < 255)
drop index equipment2.equipment2_FK
go
if exists (select 1
from sysindexes
where id = object_id('equipment2')
and name = 'equipment_FK'
and indid > 0
and indid < 255)
drop index equipment2.equipment_FK
go
if exists (select 1
from sysindexes
where id = object_id('people')
and name = 'people_FK'
and indid > 0
and indid < 255)
drop index people.people_FK
go
if exists (select 1
from sysobjects
where id = object_id('cargo')
and type = 'U')
drop table cargo
if exists (select 1
from sysobjects
where id = object_id('department')
and type = 'U')
drop table department
go
if exists (select 1
from sysobjects
where id = object_id('equipment')
and type = 'U')
drop table equipment
go
if exists (select 1
from sysobjects
where id = object_id('equipment2')
and type = 'U')
drop table equipment2
go
if exists (select 1
from sysobjects
where id = object_id('people')
and type = 'U')
drop table people
go
if exists (select 1
from sysobjects
where id = object_id('"Case_Sensitive"')
and type = 'U')
drop table string_values
go
if exists (select 1
from sysobjects
where id = object_id('case_sensitive')
and type = 'U')
drop table string_values
go
if exists (select 1
from sysobjects
where id = object_id('high_load')
and type = 'U')
drop table string_values
go
/*==============================================================*/
/* Table : cargo */
/*==============================================================*/
create table cargo (
c_id int not null,
c_dep_id smallint null,
c_name char(10) null,
c_seal tinyint null,
c_date_came datetime null,
c_date_out datetime null,
c_weight float null,
c_width int null,
c_height int null,
c_cost money null,
c_attributes binary(10) null,
primary key (c_id)
)
go
/*==============================================================*/
/* Index: cargo_FK */
/*==============================================================*/
create index cargo_FK on cargo (
c_dep_id
)
go
/*==============================================================*/
/* Table : department */
/*==============================================================*/
create table department (
dep_id smallint not null,
dep_name varchar(20) null,
dep_shname char(5) null,
dep_address varchar(255) null,
primary key (dep_id)
)
go
/*==============================================================*/
/* Table : equipment */
/*==============================================================*/
create table equipment (
eq_id int not null,
eq_name varchar(30) null,
eq_type smallint null,
eq_cost numeric(9,4) null,
eq_date datetime null,
woff_date datetime null,
primary key (eq_id)
)
go
/*==============================================================*/
/* Table : equipment2 */
/*==============================================================*/
create table equipment2 (
dep_id smallint not null,
eq_id int not null,
primary key (dep_id, eq_id)
)
go
/*==============================================================*/
/* Index: equipment_FK */
/*==============================================================*/
create index equipment_FK on equipment2 (
dep_id
)
go
/*==============================================================*/
/* Index: equipment2_FK */
/*==============================================================*/
create index equipment2_FK on equipment2 (
eq_id
)
go
/*==============================================================*/
/* Table : people */
/*==============================================================*/
create table people (
p_id smallint not null,
p_dep_id smallint null,
p_name varchar(40) null,
p_begin_work datetime null,
p_end_work datetime null,
p_picture image null,
p_resume text null,
p_redundant tinyint null,
primary key (p_id)
)
go
/*==============================================================*/
/* Index: people_FK */
/*==============================================================*/
create index people_FK on people (
p_dep_id
)
go
/*==============================================================*/
/* Table : Case_Sensitive */
/*==============================================================*/
create table "Case_Sensitive" (
cs_id INTEGER not null,
"Cs_Data1" INTEGER null,
"cs_data1" INTEGER null,
"cs data1" INTEGER null,
primary key (cs_id)
)
go
/*==============================================================*/
/* Table : case_sensitive */
/*==============================================================*/
create table case_sensitive (
cs_id INTEGER not null,
"CS_DATA1" INTEGER null,
"CS_Data2" INTEGER null,
"Cs_Data3" INTEGER null,
primary key (cs_id)
)
go
/*==============================================================*/
/* Table : high_load */
/*==============================================================*/
create table high_load (
hl_id INTEGER NOT NULL,
data1 FLOAT,
data2 CHAR(10),
primary key (hl_id)
)
go
alter table cargo
add foreign key (c_dep_id) references department (dep_id)
go
alter table equipment2
add foreign key (dep_id) references department (dep_id)
go
alter table equipment2
add foreign key (eq_id) references equipment (eq_id)
go
alter table people
add foreign key (p_dep_id) references department (dep_id)
go
INSERT INTO department VALUES (2,'Container agency','USA','Krasnodar Komsomolskaya st. 17')
INSERT INTO department VALUES (1,'Line agency','RUS','Novorossiysk Lenina st. 2')
go
INSERT INTO equipment VALUES (1,'Volvo',1,15000.0000,'1998-03-04',NULL)
INSERT INTO equipment VALUES (2,'Laboratoy',10,40000.0000,'2001-10-07',NULL)
INSERT INTO equipment VALUES (3,'Computer',7,900.0000,'1999-09-03',NULL)
INSERT INTO equipment VALUES (4,'Radiostation',19,400.0000,'2000-07-08',NULL)
go
INSERT INTO equipment2 VALUES (1,1)
INSERT INTO equipment2 VALUES (1,2)
INSERT INTO equipment2 VALUES (1,4)
INSERT INTO equipment2 VALUES (2,1)
INSERT INTO equipment2 VALUES (2,3)
go
INSERT INTO people VALUES (1,1,'Vasia Pupkin','1899-12-30 09:00:00','1899-12-30 18:00:00',NULL,NULL,0)
INSERT INTO people VALUES (2,2,'Andy Karto','1899-12-30 08:30:00','1899-12-30 17:30:00',NULL,NULL,0)
INSERT INTO people VALUES (3,1,'Kristen Sato','1899-12-30 09:00:00','1899-12-30 18:00:00',NULL,NULL,0)
INSERT INTO people VALUES (4,2,'Aleksey Petrov','1899-12-30 08:30:00','1899-12-30 17:30:00',NULL,NULL,1)
INSERT INTO people VALUES (5,3,'Yan Pater','1899-12-30 08:00:00','1899-12-30 17:00:00',NULL,NULL,1)
go
INSERT INTO cargo VALUES (1,2,'Grain',1,'2002-12-20 02:00:00','2002-12-20 02:00:00',5000,NULL,NULL,1769.4300,NULL)
INSERT INTO cargo VALUES (2,1,'Paper',2,'2002-12-19 14:00:00','2002-12-23 00:00:00',1000,10,10,986.4700,convert(binary(10),'aaa'))
INSERT INTO cargo VALUES (3,1,'Wool',0,'2002-12-20 18:00:00',NULL,400,7,4,643.1100,NULL)
INSERT INTO cargo VALUES (4,2,'Suagr',1,'2002-12-21 10:20:00','2002-12-26 00:00:00',2034,NULL,NULL,1964.8700,NULL)
go
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.