Código de SQL - script para operadores de ISP asignacion de estudiante

sin imagen de perfil
Val: 8
Ha aumentado su posición en 3 puestos en SQL (en relación al último mes)
Gráfica de SQL

script para operadores de ISP asignacion de estudiantegráfica de visualizaciones


SQL

Publicado el 2 de Agosto del 2018 por nelson
1.403 visualizaciones desde el 2 de Agosto del 2018
buen dia amigos, aqui les copio el script de una asignacion de un cliente (el cual no pago y lo recibio pero lo dejo para aprendizaje de los nuevos estudiante)

AUSTRALIA-MODEL-logico
AUSTRALIA-MODEL2
1
2
3
4
5
6

1

Publicado el 2 de Agosto del 2018gráfica de visualizaciones de la versión: 1
1.404 visualizaciones desde el 2 de Agosto del 2018
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
-- Generado por Oracle SQL Developer Data Modeler 3.1.1.703
--   en:        2018-08-02 08:13:37 VET
--   sitio:      Oracle Database 11g
--   tipo:      Oracle Database 11g
 
 
 
CREATE TABLE ACCESS_TYPE
    (
     ID INTEGER  NOT NULL ,
     ACCESS_NAME VARCHAR2 ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE ACCESS_TYPE
    ADD CONSTRAINT ACCESS_TYPE_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE ACCOUNT_BANK
    (
     ID INTEGER  NOT NULL ,
     ACCOUNT_NUMBER VARCHAR2 (25) ,
     BANK_ID INTEGER  NOT NULL ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE ACCOUNT_BANK
    ADD CONSTRAINT ACCOUNT_BANK_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE BANK
    (
     ID INTEGER  NOT NULL ,
     BANK_NAME VARCHAR2
    )
;
 
 
 
ALTER TABLE BANK
    ADD CONSTRAINT BANK_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE CLIENT
    (
     PERSON_ID INTEGER  NOT NULL ,
     JOIN_DATE DATE ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE CLIENT
    ADD CONSTRAINT CLIENT_PK PRIMARY KEY ( PERSON_ID ) ;
 
 
 
CREATE TABLE DETAIL
    (
     ID INTEGER  NOT NULL ,
     QTY INTEGER ,
     PLAN_NAME_ID INTEGER  NOT NULL ,
     SPEED_ID INTEGER  NOT NULL ,
     SHAPED_SPEED_ID INTEGER  NOT NULL ,
     SERVICE_CONTRACT_ID INTEGER  NOT NULL ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE DETAIL
    ADD CONSTRAINT DETAIL_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE DETAIL_PAY
    (
     ID INTEGER  NOT NULL ,
     NUMBER_REFERENCE VARCHAR2  NOT NULL ,
     AMOUNT_PAY NUMBER (10,2) ,
     INVOICE_ID INTEGER  NOT NULL ,
     ACCOUNT_BANK_ID INTEGER  NOT NULL ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE DETAIL_PAY
    ADD CONSTRAINT DETAIL_PAY_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE DETAIL_TICKET
    (
     DATE_STATUS DATE  NOT NULL ,
     TICKET_ID INTEGER  NOT NULL ,
     STATUS_TICKET_ID INTEGER  NOT NULL ,
     STAFF_PERSON_ID INTEGER  NOT NULL ,
     SUMMARY VARCHAR2 ,
     DETAIL_TICKET_TICKET_ID INTEGER ,
     STATUSTICKET_ID INTEGER ,
     ANCESTOR_ID DATE
    )
;
 
 
 
ALTER TABLE DETAIL_TICKET
    ADD CONSTRAINT DETAIL_TICKET_PK PRIMARY KEY ( TICKET_ID, STATUS_TICKET_ID, DATE_STATUS ) ;
 
 
 
CREATE TABLE INVOICE
    (
     ID INTEGER  NOT NULL ,
     DATE_INVOICE DATE  NOT NULL ,
     DATE_PAYLIMIT DATE ,
     TOTAL_AMOUNT NUMBER (10,2) ,
     CLIENT_PERSON_ID INTEGER  NOT NULL ,
     PAYMENT_WAY_ID INTEGER  NOT NULL ,
     SERVICE_CONTRACT_ID INTEGER  NOT NULL ,
     DEBT NUMBER (10,2)
    )
;
 
 
 
ALTER TABLE INVOICE
    ADD CONSTRAINT INVOICE_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE "LEVEL"
    (
     ID INTEGER  NOT NULL ,
     LEVEL_NAME VARCHAR2  NOT NULL ,
     AMOUNT_LEVEL NUMBER (10,2) ,
     ANCESTOR_ID INTEGER
    )
;
 
 
 
ALTER TABLE "LEVEL"
    ADD CONSTRAINT LEVEL_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE LOCATION
    (
     ID INTEGER  NOT NULL ,
     NAME_LOCATION VARCHAR2 ,
     ID_ANCESTOR INTEGER
    )
;
 
 
 
ALTER TABLE LOCATION
    ADD CONSTRAINT LOCATION_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE PAYMENT_WAY
    (
     ID INTEGER  NOT NULL ,
     NAME VARCHAR2
    )
;
 
 
 
ALTER TABLE PAYMENT_WAY
    ADD CONSTRAINT PAYMENT_WAY_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE PERSON
    (
     ID INTEGER  NOT NULL ,
     NAME VARCHAR2 ,
     LASTNAME VARCHAR2  NOT NULL ,
     BIRTH_DATE DATE ,
     TELEPHONE VARCHAR2 (50) ,
     EMAIL VARCHAR2 (50) ,
     ADDRESS VARCHAR2 ,
     LOCATION_ID INTEGER  NOT NULL ,
     ID_ANCESTOR INTEGER ,
     ZIP INTEGER ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE PERSON
    ADD CONSTRAINT PERSON_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE PLAN_NAME
    (
     ID INTEGER  NOT NULL ,
     PLAN_NAME VARCHAR2 ,
     QUOTA VARCHAR2 ,
     ACCESS_TYPE_ID INTEGER  NOT NULL ,
     PRICE NUMBER (10,2) ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE PLAN_NAME
    ADD CONSTRAINT PLAN_NAME_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE ROL
    (
     ID INTEGER  NOT NULL ,
     ROL_NAME VARCHAR2 ,
     ANCESTOR_ID INTEGER
    )
;
 
 
 
ALTER TABLE ROL
    ADD CONSTRAINT ROL_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE SERVICE_CONTRACT
    (
     ID INTEGER  NOT NULL ,
     DATE_HIRESERV DATE ,
     DATE_INSTALATION DATE ,
     TIME_INSTALATION VARCHAR2 (8) ,
     TOTAL_AMOUNT NUMBER (10,2) ,
     CLIENT_ID INTEGER  NOT NULL ,
     STAFF_PERSON_ID INTEGER  NOT NULL ,
     LOCATION_ID INTEGER  NOT NULL ,
     ADDRESS_INSTALATION VARCHAR2 ,
     MAX_MONTHDEBT INTEGER ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE SERVICE_CONTRACT
    ADD CONSTRAINT SERVICE_CONTRACT_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE SHAPED_SPEED
    (
     ID INTEGER  NOT NULL ,
     RATE VARCHAR2 ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE SHAPED_SPEED
    ADD CONSTRAINT SHAPED_SPEED_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE SPEED
    (
     ID INTEGER  NOT NULL ,
     SPEEPDESC VARCHAR2
    )
;
 
 
 
ALTER TABLE SPEED
    ADD CONSTRAINT SPEED_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE STAFF
    (
     PERSON_ID INTEGER  NOT NULL ,
     HIRE_DATE DATE ,
     ROL_ID INTEGER  NOT NULL ,
     LEVEL_ID INTEGER  NOT NULL ,
     MENTOR_ID INTEGER ,
     STATUS VARCHAR2 (1)
    )
;
 
 
 
ALTER TABLE STAFF
    ADD CONSTRAINT STAFF_PK PRIMARY KEY ( PERSON_ID ) ;
 
 
 
CREATE TABLE STATUS_TICKET
    (
     ID INTEGER  NOT NULL ,
     STATUS_NAME VARCHAR2
    )
;
 
 
 
ALTER TABLE STATUS_TICKET
    ADD CONSTRAINT STATUS_TICKET_PK PRIMARY KEY ( ID ) ;
 
 
 
CREATE TABLE TICKET
    (
     ID INTEGER  NOT NULL ,
     DATE_OPEN DATE  NOT NULL ,
     WAITTIME INTEGER ,
     CLIENT_PERSON_ID INTEGER  NOT NULL ,
     DURATION_TIME INTEGER ,
     SUMMARY VARCHAR2 (200) ,
     STATUS VARCHAR2 (1) ,
     SERVICE_CONTRACT_ID INTEGER  NOT NULL
    )
;
 
 
 
ALTER TABLE TICKET
    ADD CONSTRAINT TICKET_PK PRIMARY KEY ( ID ) ;
 
 
 
 
ALTER TABLE PLAN_NAME
    ADD CONSTRAINT ACCESSTYPE_FK1 FOREIGN KEY
    (
     ACCESS_TYPE_ID
    )
    REFERENCES ACCESS_TYPE
    (
     ID
    )
;
 
 
ALTER TABLE DETAIL_PAY
    ADD CONSTRAINT ACCOUNTBANK_FK1 FOREIGN KEY
    (
     ACCOUNT_BANK_ID
    )
    REFERENCES ACCOUNT_BANK
    (
     ID
    )
;
 
 
ALTER TABLE ACCOUNT_BANK
    ADD CONSTRAINT BANK_FK FOREIGN KEY
    (
     BANK_ID
    )
    REFERENCES BANK
    (
     ID
    )
;
 
 
ALTER TABLE SERVICE_CONTRACT
    ADD CONSTRAINT CLIENT_FK1 FOREIGN KEY
    (
     CLIENT_ID
    )
    REFERENCES CLIENT
    (
     PERSON_ID
    )
;
 
 
ALTER TABLE INVOICE
    ADD CONSTRAINT CLIENT_FK2 FOREIGN KEY
    (
     CLIENT_PERSON_ID
    )
    REFERENCES CLIENT
    (
     PERSON_ID
    )
;
 
 
ALTER TABLE INVOICE
    ADD CONSTRAINT CONTRACT_FK FOREIGN KEY
    (
     SERVICE_CONTRACT_ID
    )
    REFERENCES SERVICE_CONTRACT
    (
     ID
    )
;
 
 
ALTER TABLE DETAIL
    ADD CONSTRAINT CONTRACT_FK1 FOREIGN KEY
    (
     SERVICE_CONTRACT_ID
    )
    REFERENCES SERVICE_CONTRACT
    (
     ID
    )
;
 
 
ALTER TABLE DETAIL_TICKET
    ADD CONSTRAINT DETAILTICKET_FK FOREIGN KEY
    (
     DETAIL_TICKET_TICKET_ID,
     STATUSTICKET_ID,
     ANCESTOR_ID
    )
    REFERENCES DETAIL_TICKET
    (
     TICKET_ID,
     STATUS_TICKET_ID,
     DATE_STATUS
    )
;
 
 
ALTER TABLE DETAIL_PAY
    ADD CONSTRAINT INVOICE_FK1 FOREIGN KEY
    (
     INVOICE_ID
    )
    REFERENCES INVOICE
    (
     ID
    )
;
 
 
ALTER TABLE "LEVEL"
    ADD CONSTRAINT LEVEL_FK1 FOREIGN KEY
    (
     ANCESTOR_ID
    )
    REFERENCES "LEVEL"
    (
     ID
    )
;
 
 
ALTER TABLE STAFF
    ADD CONSTRAINT LEVEL_FK2 FOREIGN KEY
    (
     LEVEL_ID
    )
    REFERENCES "LEVEL"
    (
     ID
    )
;
 
 
ALTER TABLE SERVICE_CONTRACT
    ADD CONSTRAINT LOCATION_FK FOREIGN KEY
    (
     LOCATION_ID
    )
    REFERENCES LOCATION
    (
     ID
    )
;
 
 
ALTER TABLE LOCATION
    ADD CONSTRAINT LOCATION_FK1 FOREIGN KEY
    (
     ID_ANCESTOR
    )
    REFERENCES LOCATION
    (
     ID
    )
;
 
 
ALTER TABLE PERSON
    ADD CONSTRAINT LOCATION_FK2 FOREIGN KEY
    (
     LOCATION_ID
    )
    REFERENCES LOCATION
    (
     ID
    )
;
 
 
ALTER TABLE INVOICE
    ADD CONSTRAINT PAYMENTWAY_FK1 FOREIGN KEY
    (
     PAYMENT_WAY_ID
    )
    REFERENCES PAYMENT_WAY
    (
     ID
    )
;
 
 
ALTER TABLE CLIENT
    ADD CONSTRAINT PERSON_FK1 FOREIGN KEY
    (
     PERSON_ID
    )
    REFERENCES PERSON
    (
     ID
    )
;
 
 
ALTER TABLE PERSON
    ADD CONSTRAINT PERSON_FK2 FOREIGN KEY
    (
     ID_ANCESTOR
    )
    REFERENCES PERSON
    (
     ID
    )
;
 
 
ALTER TABLE STAFF
    ADD CONSTRAINT PERSON_FK3 FOREIGN KEY
    (
     PERSON_ID
    )
    REFERENCES PERSON
    (
     ID
    )
;
 
 
ALTER TABLE DETAIL
    ADD CONSTRAINT PLANNAME_FK1 FOREIGN KEY
    (
     PLAN_NAME_ID
    )
    REFERENCES PLAN_NAME
    (
     ID
    )
;
 
 
ALTER TABLE ROL
    ADD CONSTRAINT ROL_FK FOREIGN KEY
    (
     ANCESTOR_ID
    )
    REFERENCES ROL
    (
     ID
    )
;
 
 
ALTER TABLE STAFF
    ADD CONSTRAINT ROL_FK2 FOREIGN KEY
    (
     ROL_ID
    )
    REFERENCES ROL
    (
     ID
    )
;
 
 
ALTER TABLE TICKET
    ADD CONSTRAINT SERVICE_CONTRACT_FK FOREIGN KEY
    (
     SERVICE_CONTRACT_ID
    )
    REFERENCES SERVICE_CONTRACT
    (
     ID
    )
;
 
 
ALTER TABLE DETAIL
    ADD CONSTRAINT SHAPEDSPEED_FK1 FOREIGN KEY
    (
     SHAPED_SPEED_ID
    )
    REFERENCES SHAPED_SPEED
    (
     ID
    )
;
 
 
ALTER TABLE DETAIL
    ADD CONSTRAINT SPEED_FK1 FOREIGN KEY
    (
     SPEED_ID
    )
    REFERENCES SPEED
    (
     ID
    )
;
 
 
ALTER TABLE STAFF
    ADD CONSTRAINT STAFF_FK1 FOREIGN KEY
    (
     MENTOR_ID
    )
    REFERENCES STAFF
    (
     PERSON_ID
    )
;
 
 
ALTER TABLE DETAIL_TICKET
    ADD CONSTRAINT STAFF_FK3 FOREIGN KEY
    (
     STAFF_PERSON_ID
    )
    REFERENCES STAFF
    (
     PERSON_ID
    )
;
 
 
ALTER TABLE SERVICE_CONTRACT
    ADD CONSTRAINT STAFF_FK4 FOREIGN KEY
    (
     STAFF_PERSON_ID
    )
    REFERENCES STAFF
    (
     PERSON_ID
    )
;
 
 
ALTER TABLE DETAIL_TICKET
    ADD CONSTRAINT STATUSTICKET_FK1 FOREIGN KEY
    (
     STATUS_TICKET_ID
    )
    REFERENCES STATUS_TICKET
    (
     ID
    )
;
 
 
ALTER TABLE TICKET
    ADD CONSTRAINT TICKETCLIENT_FK3 FOREIGN KEY
    (
     CLIENT_PERSON_ID
    )
    REFERENCES CLIENT
    (
     PERSON_ID
    )
;
 
 
ALTER TABLE DETAIL_TICKET
    ADD CONSTRAINT TICKET_FK1 FOREIGN KEY
    (
     TICKET_ID
    )
    REFERENCES TICKET
    (
     ID
    )
;
 
 
 
-- Informe de Resumen de Oracle SQL Developer Data Modeler:
--
-- CREATE TABLE                            20
-- CREATE INDEX                             0
-- ALTER TABLE                             50
-- CREATE VIEW                              0
-- CREATE PACKAGE                           0
-- CREATE PACKAGE BODY                      0
-- CREATE PROCEDURE                         0
-- CREATE FUNCTION                          0
-- CREATE TRIGGER                           0
-- ALTER TRIGGER                            0
-- CREATE STRUCTURED TYPE                   0
-- CREATE COLLECTION TYPE                   0
-- CREATE CLUSTER                           0
-- CREATE CONTEXT                           0
-- CREATE DATABASE                          0
-- CREATE DIMENSION                         0
-- CREATE DIRECTORY                         0
-- CREATE DISK GROUP                        0
-- CREATE ROLE                              0
-- CREATE ROLLBACK SEGMENT                  0
-- CREATE SEQUENCE                          0
-- CREATE MATERIALIZED VIEW                 0
-- CREATE SYNONYM                           0
-- CREATE TABLESPACE                        0
-- CREATE USER                              0
--
-- DROP TABLESPACE                          0
-- DROP DATABASE                            0
--
-- ERRORS                                   0
-- WARNINGS                                 0



Comentarios sobre la versión: 1 (0)


No hay comentarios
 

Comentar la versión: 1

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s4737