blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 3 276 | src_encoding stringclasses 33
values | length_bytes int64 23 9.61M | score float64 2.52 5.28 | int_score int64 3 5 | detected_licenses listlengths 0 44 | license_type stringclasses 2
values | text stringlengths 23 9.43M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
682744b14ff870dbeca05f3f8a1fa4f342e2367b | SQL | ricknussell31/Fall-2014-CMPT308-Database | /Final Database Project Scripts TEMP.sql | UTF-8 | 21,497 | 3.34375 | 3 | [] | no_license | --Nicholas Russell--
--Professor Labouseur --
--Final Database Project: World Cup 2014--
--create teams table --
drop table teams;
create table countries(
cid text NOT NULL PRIMARY KEY,
country text UNIQUE,
qualifyingZone text,
preWorldCupRanking int,
postWorldCupRanking int,
timesInWCIncluding2014 int
);
INSERT INTO countries(cid, country, qualifyingZone, preWorldCupRanking, postWorldCupRanking, timesInWCIncluding2014)
VALUES ('c01', 'Brazil', 'CONMEBOL', 3, 7, 20),
('c02', 'Mexico', 'CONCACAF', 20, 18, 15),
('c03', 'Croatia', 'UEFA', 18, 17, 4),
('c04', 'Cameroon', 'CAF', 56, 53, 7),
('c05', 'Netherlands', 'UEFA', 15, 3, 10),
('c06', 'Chile', 'CONMEBOL', 14, 12, 9),
('c07', 'Spain', 'UEFA', 1, 8, 14),
('c08', 'Australia', 'AFC', 62, 76, 4),
('c09', 'Colombia', 'CONMEBOL', 8, 4, 5),
('c10', 'Greece', 'UEFA', 12, 13, 3),
('c11', 'Ivory Coast', 'CAF', 23, 25, 3),
('c12', 'Japan', 'AFC', 46, 45, 5),
('c13', 'Costa Rica', 'CONCACAF', 28, 16, 4),
('c14', 'Uruguay', 'CONMEBOL', 7, 6, 12),
('c15', 'Italy', 'UEFA', 9, 14, 18),
('c16', 'England', 'UEFA', 10, 20, 14),
('c17', 'France', 'UEFA', 17, 10, 14),
('c18', 'Switzerland', 'UEFA', 6, 9, 10),
('c19', 'Ecuador', 'CONMEBOL', 26, 21, 3),
('c20', 'Honduras', 'CONCACAF', 33, 40, 3),
('c21', 'Argentina', 'CONMEBOL', 5, 2, 16),
('c22', 'Nigeria', 'CAF', 44, 34, 5),
('c23', 'Bosnia-Herzegovina', 'UEFA', 21, 19, 1),
('c24', 'Iran', 'CAF', 43, 49, 4),
('c25', 'Germany', 'UEFA', 2, 1, 18),
('c26', 'United States', 'CONCACAF', 13, 15, 10),
('c27', 'Portugal', 'UEFA', 4, 11, 6),
('c28', 'Ghana', 'CAF', 37, 38, 3),
('c29', 'Belgium', 'UEFA', 11, 5, 12),
('c30', 'Algeria', 'CAF', 22, 24, 4),
('c31', 'Russia', 'UEFA', 19, 23, 10),
('c32', 'South Korea', 'AFC', 57, 56, 9);
select *
from countries;
--create referees table--
create table referees(
rid text NOT NULL PRIMARY KEY,
firstName text,
lastName text,
dateOfBirthMDY text,
zoneOfRefereeing text,
countryOfOrigin text,
numberOfYearsInFifa int
);
INSERT INTO referees (rid, firstName, lastName, dateOfBirthMDY, zoneOfRefereeing, countryOfOrigin, numberOfYearsInFifa)
VALUES ('r01', 'Ravshan', 'Irmatov', '08/09/1977' , 'AFC', 'Uzbekistan', 11),
('r02', 'Yuichi', 'Nishimura', '04/17/1972','AFC', 'Japan', 10),
('r03', 'Nawaf', 'Shukralla', '10/13/1976','AFC', 'Bahrain', 7),
('r04', 'Ben', 'Williams', '04/14/1977','AFC', 'Australia', 9),
('r05', 'Noumandiez', 'Doue', '09/29/1970', 'CAF', 'Ivory Coast', 10),
('r06', 'Bakary', 'Gassama', '02/10/1979','CAF', 'Gambia', 7),
('r07', 'Djamel', 'Hairmoudi', '12/10/1970','CAF', 'Algeria', 10),
('r08', 'Joel', 'Aguilar', '07/02/1975' ,'CONCACAF', 'El Salvador', 13),
('r09', 'Mark', 'Geiger', '08/25/1974' , 'CONCACAF', 'United States', 6),
('r10', 'Marco', 'Rodriguez', '11/10/1973' , 'CONCACAF', 'Mexico', 15),
('r11', 'Nestor', 'Pitana', '06/17/1975', 'CONMEBOL', 'Argentina', 4),
('r12', 'Sandro', 'Ricci', '11/19/1974' , 'CONMEBOL', 'Brazil', 3),
('r13', 'Enrique', 'Osses', '06/25/1976' , 'CONMEBOL', 'Chile', 9),
('r14', 'Wilmar', 'Roldan', '01/24/1980', 'CONMEBOL', 'Colombia', 6),
('r15', 'Carlos', 'Vera', '06/25/1976' , 'CONMEBOL', 'Ecuador', 8),
('r16', 'Peter', 'OLeary', '03/03/1972' ,'OFC', 'New Zealand', 11),
('r17', 'Felix', 'Brych', '08/03/1975' ,'UEFA', 'Germany', 7),
('r18', 'Cuneyt', 'Cakir', '11/23/1976' ,'UEFA', 'Turkey', 8),
('r19', 'Jonas', 'Eriksson', '03/28/1974' ,'UEFA', 'Sweden', 12),
('r20', 'Bjorn', 'Kuipers', '03/28/1973', 'UEFA', 'Netherlands', 8),
('r21', 'Milorad', 'Mazic', '03/23/1973', 'UEFA', 'Serbia', 5),
('r22', 'Nicola', 'Rizzoli', '10/05/1971','UEFA', 'Italy', 7),
('r23', 'Carlos', 'Velasco Carballo', '03/16/1971', 'UEFA', 'Spain', 6),
('r24', 'Pedro', 'Proenca', '11/03/1970','UEFA', 'Portugal', 11),
('r25', 'Howard', 'Webb', '07/14/1971' ,'UEFA', 'England', 9);
select *
from referees
order by lastName ASC;
--create refereedIn table--
create table refereedIn(
gameNumber int PRIMARY KEY references games(gameNumber),
rid text references referees(rid),
totalYellowCards int,
totalRedCards int
);
INSERT INTO refereedIn(gameNumber, rid, totalYellowCards, totalRedCards)
VALUES (1, 'r02', 4,0),
(2, 'r14', 2,0),
(3, 'r22', 4,0),
(4, 'r05', 4,0),
(5, 'r09', 3,0),
(6, 'r17', 4,0),
(7, 'r20', 3,1),
(8, 'r13', 1,0),
(9, 'r01', 2,0),
(10,'r12', 7,1),
(11,'r08', 2,0),
(12,'r21', 1,0),
(13,'r15', 1,1),
(14,'r19', 2,0),
(15,'r10', 4,0),
(16,'r18', 2,0),
(17,'r11', 4,0),
(18,'r07', 1,1),
(19,'r09', 2,0),
(20,'r24', 3,0),
(21,'r25', 2,0),
(22,'r23', 5,1),
(23,'r08', 2,0),
(24,'r12', 2,0),
(25,'r20', 1,0),
(26,'r04', 5,0),
(27,'r21', 2,0),
(28,'r16', 2,0),
(29,'r12', 1,0),
(30,'r11', 1,0),
(31,'r17', 3,0),
(32,'r14', 3,0),
(33,'r19', 3,0),
(34,'r01', 3,1),
(35,'r03', 3,0),
(36,'r06', 2,0),
(37,'r24', 2,0),
(38,'r15', 3,0),
(39,'r10', 4,1),
(40,'r07', 3,0),
(41,'r11', 1,0),
(42,'r05', 1,2),
(43,'r22', 2,0),
(44,'r23', 2,0),
(45,'r01', 3,0),
(46,'r03', 4,0),
(47,'r04', 2,1),
(48,'r18', 5,0),
(49,'r25', 7,0),
(50,'r20', 3,0),
(51,'r24', 3,0),
(52,'r04', 8,0),
(53,'r09', 1,0),
(54,'r12', 2,0),
(55,'r19', 5,0),
(56,'r07', 2,0),
(57,'r11', 2,0),
(58,'r23', 4,0),
(59,'r22', 3,0),
(60,'r01', 6,0),
(61,'r10', 1,0),
(62,'r18', 3,0),
(63,'r07', 5,0),
(64,'r22', 4,0);
--create stadiums table--
drop table stadiums;
create table stadiums(
sid text NOT NULL PRIMARY KEY,
stadiumName text,
locationCity text,
capacity int,
numberOfGamesHosted int,
costToBuildUSDinMillions int
);
INSERT INTO stadiums(sid, stadiumName, locationCity, capacity, numberOfGamesHosted, costToBuildUSDinMillions)
VALUES ('s01', 'Maracana Stadium', 'Rio de Janeiro', 74738, 7, 1200),
('s02', 'Estadio Mineirao', 'Belo Horizonte', 58259, 6, 695),
('s03', 'Arena Fonte Nova', 'Salvador', 51708, 6, 267),
('s04', 'Arena Pantanal', 'Cuiaba', 41112, 4, 293),
('s05', 'Arena de Amazonia', 'Manaus', 40549, 4, 270),
('s06', 'Arena das Dunas', 'Natal', 39971, 4, 400),
('s07', 'Arena da Baixada', 'Curitiba', 39631, 4, 295),
('s08', 'Arena Pernambuco', 'Recife', 42583, 5, 426),
('s09', 'Estadio Beira-Rio', 'Porto Alegre', 43394, 5, 326),
('s10', 'Estadio Castelao', 'Fortaleza', 60348, 6, 207),
('s11', 'Arena Corinthians', 'Sao Paulo', 63321, 6, 435),
('s12', 'Estadio Nacional Mane Garrincha', 'Brasilia', 69432, 7, 900);
select *
from stadiums;
--create StadiumPlayedIn table--
create table stadiumPlayedIn(
gameNumber int references games(gameNumber),
sid text references stadiums(sid),
attendance int,
primary key(gameNumber)
);
INSERT INTO stadiumPlayedIn(gameNumber, sid, attendance)
VALUES (1, 's11', 62103),
(2, 's06', 39216),
(3, 's03', 48173),
(4, 's04', 40275),
(5, 's02', 57174),
(6, 's08', 40267),
(7, 's10', 58679),
(8, 's05', 39800),
(9, 's12', 68351),
(10,'s09', 43012),
(11,'s01', 74738),
(12,'s07', 39081),
(13,'s03', 51081),
(14,'s06', 39760),
(15,'s02', 56800),
(16,'s04', 37603),
(17,'s10', 60342),
(18,'s05', 39982),
(19,'s01', 42877),
(20,'s09', 74101),
(21,'s12', 68748),
(22,'s06', 39485),
(23,'s11', 62575),
(24,'s08', 40285),
(25,'s03', 51003),
(26,'s07', 39224),
(27,'s02', 57698),
(28,'s04', 40499),
(29,'s10', 59621),
(30,'s05', 40123),
(31,'s01', 73819),
(32,'s09', 42732),
(33,'s12', 69112),
(34,'s08', 41212),
(35,'s07', 39375),
(36,'s11', 62996),
(37,'s04', 40340),
(38,'s10', 59095),
(39,'s06', 39706),
(40,'s02', 57823),
(41,'s05', 40322),
(42,'s01', 73749),
(43,'s09', 43285),
(44,'s03', 48011),
(45,'s08', 41876),
(46,'s12', 67540),
(47,'s11', 61397),
(48,'s07', 39311),
(49,'s02', 57714),
(50,'s01', 73804),
(51,'s10', 58817),
(52,'s08', 41242),
(53,'s12', 67882),
(54,'s09', 43063),
(55,'s11', 63255),
(56,'s03', 51227),
(57,'s10', 74240),
(58,'s01', 60342),
(59,'s03', 68551),
(60,'s12', 51179),
(61,'s02', 58141),
(62,'s11', 63267),
(63,'s12', 68034),
(64,'s01', 74738);
select *
from stadiumPlayedIn;
--create groups table --
create table groups(
grid text NOT NULL PRIMARY KEY
);
INSERT INTO groups (grid)
VALUES ('groupA'),
('groupB'),
('groupC'),
('groupD'),
('groupE'),
('groupF'),
('groupG'),
('groupH');
--create GroupedIn table --
drop table groupedIn;
create table groupedIn(
cid text references countries(cid),
grid text references groups(grid),
groupStageWins int,
groupStageTies int,
groupStageLosses int,
goalsForInGroup int,
goalsAgainstInGroup int,
goalDifferentialInGroup int,
pointsTotaledInGroup int,
placeInGroup int,
CHECK (groupStageWins >= 0
AND groupStageTies >= 0
AND groupStageWins >= 0
AND goalsForInGroup >= 0
AND goalsAgainstInGroup >=0
AND pointsTotaledInGroup >= 0
AND pointsTotaledInGroup <= 9
AND placeInGroup >= 1
AND placeInGroup <= 4
),
primary key(cid)
);
INSERT INTO groupedIn(cid, grid, groupStageWins, groupStageTies, groupStageLosses, goalsForInGroup, goalsAgainstInGroup, goalDifferentialInGroup, pointsTotaledInGroup, placeInGroup)
VALUES ('c01', 'groupA', 2, 1, 0, 7, 2, 5, 7, 1),
('c02', 'groupA', 2, 1, 0, 4, 1, 3, 7, 2),
('c03', 'groupA', 1, 0, 2, 6, 6, 0, 3, 3),
('c04', 'groupA', 0, 0, 3, 1, 9, -8, 0,4),
('c05', 'groupB', 3, 0, 0, 10, 3, 7, 9, 1),
('c06', 'groupB', 2, 0, 1, 5, 3, 2, 6, 2),
('c07', 'groupB', 1, 0, 2, 4, 7, -3, 3, 3),
('c08', 'groupB', 0, 0, 3, 3, 9, -6, 0, 4),
('c09', 'groupC', 3, 0, 0, 9, 2, 7, 9, 1),
('c10', 'groupC', 1, 1, 1, 2, 4, -2, 4, 2),
('c11', 'groupC', 1, 0, 2, 4, 5, -1, 3, 3),
('c12', 'groupC', 0, 1, 2, 2, 6, -4, 1, 4),
('c13', 'groupD', 2, 1, 0, 4, 1, 3, 7, 1),
('c14', 'groupD', 2, 0, 1, 4, 4, 0, 6, 2),
('c15', 'groupD', 1, 0, 2, 2, 3, -1, 3, 3),
('c16', 'groupD', 0, 1, 2, 2, 4, -2, 1, 4),
('c17', 'groupE', 2, 1, 0, 8, 2, 6, 7, 1),
('c18', 'groupE', 2, 0, 1, 7, 6, 1, 6, 2),
('c19', 'groupE', 1, 1, 1, 3, 3, 0, 4, 3),
('c20', 'groupE', 0, 0, 3, 1, 8, -7, 0, 4),
('c21', 'groupF', 3, 0, 0, 6, 3, 3, 9, 1),
('c22', 'groupF', 1, 1, 1, 3, 3, 0, 4, 2),
('c23', 'groupF', 1, 0, 2, 4, 4, 0, 3, 3),
('c24', 'groupF', 0, 1, 2, 1, 4, -3, 1, 4),
('c25', 'groupG', 2, 1, 0, 7, 2, 5, 7, 1),
('c26', 'groupG', 1, 1, 1, 4, 4, 0, 4, 2),
('c27', 'groupG', 1, 1, 1, 4, 7, -3, 4, 3),
('c28', 'groupG', 0, 1, 2, 4, 6, -2, 1, 4),
('c29', 'groupH', 3, 0, 0, 4, 1, 3, 9, 1),
('c30', 'groupH', 1, 1, 1, 6, 5, 1, 4, 2),
('c31', 'groupH', 0, 2, 1, 2, 3, -1, 2, 3),
('c32', 'groupH', 0, 1, 2, 3, 6, -3, 1, 4);
--Find the standings for countries in Group H--
select c.country, g.pointsTotaledInGroup
from countries c, groupedIn g
where g.cid = c.cid
AND g.grid = 'groupH'
order by g.pointsTotaledInGroup DESC;
--create Games table--
drop table games;
create table games(
gameNumber int NOT NULL PRIMARY KEY,
dateOfGameMD text,
typeOfGame text,
CHECK (typeOfGame in ('Group Stage', 'Round of 16', 'Quarterfinal', 'Semifinal', 'Third Place', 'Final')),
cid1 text references countries(cid),
cid2 text references countries(cid),
CHECK (cid1 != cid2),
isTieInRegularTime boolean,
wentIntoOvertime boolean
)
INSERT INTO games (gameNumber, dateOfGameMD, typeOfGame, cid1, cid2, isTieInRegularTime, wentIntoOvertime)
VALUES (1, '06/12', 'Group Stage', 'c01', 'c03', false, false),
(2, '06/13', 'Group Stage', 'c02', 'c04', false, false),
(3, '06/13', 'Group Stage', 'c07', 'c05', false, false),
(4, '06/13', 'Group Stage', 'c06', 'c08', false, false),
(5, '06/14', 'Group Stage', 'c09', 'c10', false, false),
(6, '06/14', 'Group Stage', 'c11', 'c12', false, false),
(7, '06/14', 'Group Stage', 'c14', 'c13', false, false),
(8, '06/14', 'Group Stage', 'c16', 'c15', false, false),
(9, '06/15', 'Group Stage', 'c18', 'c19', false, false),
(10, '06/15', 'Group Stage', 'c17', 'c20', false, false),
(11, '06/15', 'Group Stage', 'c21', 'c23', false, false),
(12, '06/16', 'Group Stage', 'c24', 'c22', true, false),
(13, '06/16', 'Group Stage', 'c25', 'c27', false, false),
(14, '06/16', 'Group Stage', 'c28', 'c26', false, false),
(15, '06/17', 'Group Stage', 'c29', 'c30', false, false),
(16, '06/17', 'Group Stage', 'c31', 'c32', true, false),
(17, '06/17', 'Group Stage', 'c01', 'c02', true, false),
(18, '06/18', 'Group Stage', 'c04', 'c03', false, false),
(19, '06/18', 'Group Stage', 'c07', 'c06', false, false),
(20, '06/18', 'Group Stage', 'c08', 'c05', false, false),
(21, '06/19', 'Group Stage', 'c09', 'c11', false, false),
(22, '06/19', 'Group Stage', 'c12', 'c10', true, false),
(23, '06/19', 'Group Stage', 'c14', 'c16', false, false),
(24, '06/20', 'Group Stage', 'c15', 'c13', false, false),
(25, '06/20', 'Group Stage', 'c18', 'c17', false, false),
(26, '06/20', 'Group Stage', 'c20', 'c19', false, false),
(27, '06/21', 'Group Stage', 'c21', 'c24', false, false),
(28, '06/21', 'Group Stage', 'c22', 'c23', true, false),
(29, '06/21', 'Group Stage', 'c25', 'c28', true, false),
(30, '06/22', 'Group Stage', 'c26', 'c27', false, false),
(31, '06/22', 'Group Stage', 'c29', 'c31', false, false),
(32, '06/22', 'Group Stage', 'c32', 'c30', false, false),
(33, '06/23', 'Group Stage', 'c04', 'c01', false, false),
(34, '06/23', 'Group Stage', 'c03', 'c02', false, false),
(35, '06/23', 'Group Stage', 'c08', 'c07', false, false),
(36, '06/23', 'Group Stage', 'c05', 'c06', false, false),
(37, '06/24', 'Group Stage', 'c12', 'c09', false, false),
(38, '06/24', 'Group Stage', 'c10', 'c11', false, false),
(39, '06/24', 'Group Stage', 'c15', 'c14', false, false),
(40, '06/24', 'Group Stage', 'c13', 'c16', true, false),
(41, '06/25', 'Group Stage', 'c20', 'c18', false, false),
(42, '06/25', 'Group Stage', 'c19', 'c17', true, false),
(43, '06/25', 'Group Stage', 'c22', 'c21', false, false),
(44, '06/25', 'Group Stage', 'c23', 'c24', false, false),
(45, '06/26', 'Group Stage', 'c26', 'c25', false, false),
(46, '06/26', 'Group Stage', 'c27', 'c28', false, false),
(47, '06/26', 'Group Stage', 'c32', 'c29', false, false),
(48, '06/26', 'Group Stage', 'c30', 'c31', true, false),
(49, '06/28', 'Round of 16', 'c01', 'c06', true, true),
(50, '06/28', 'Round of 16', 'c09', 'c14', false, false),
(51, '06/29', 'Round of 16', 'c05', 'c02', false, false),
(52, '06/29', 'Round of 16', 'c13', 'c10', true, true),
(53, '06/30', 'Round of 16', 'c17', 'c22', false, false),
(54, '06/30', 'Round of 16', 'c25', 'c30', true, true),
(55, '07/01', 'Round of 16', 'c21', 'c18', true, true),
(56, '07/01', 'Round of 16', 'c29', 'c26', true, true),
(57, '07/04', 'Quarterfinal', 'c01', 'c09', false, false),
(58, '07/04', 'Quarterfinal', 'c17', 'c25', false, false),
(59, '07/05', 'Quarterfinal', 'c05', 'c13', true, true),
(60, '07/05', 'Quarterfinal', 'c21', 'c29', false, false),
(61, '07/08', 'Semifinal', 'c01', 'c25', false, false),
(62, '07/09', 'Semifinal', 'c05', 'c21', true, true),
(63, '07/12', 'Third Place', 'c01', 'c05', false, false),
(64, '07/13', 'Final', 'c25', 'c21', true, true);
select *
from games;
--create Goals Table--
create table goals(
gameNumber int references games(gameNumber),
cid text references countries(cid),
goalsScored int,
result char(1),
CHECK (goalsScored >= 0),
CHECK (result = 'W' OR result = 'T' OR result = 'L'),
primary key(gameNumber, cid)
);
INSERT INTO goals(gameNumber, cid, goalsScored, result)
VALUES (1,'c01',3, 'W'),
(1,'c03',1, 'L'),
(2,'c02',1, 'W'),
(2,'c04',0, 'L'),
(3,'c07',1, 'L'),
(3,'c05',5, 'W'),
(4,'c06',3, 'W'),
(4,'c08',1, 'L'),
(5,'c09',3, 'W'),
(5,'c10',0, 'L'),
(6,'c11',2, 'W'),
(6,'c12',1, 'L'),
(7,'c14',1, 'L'),
(7,'c13',3, 'W'),
(8,'c16',1, 'L'),
(8,'c15',2, 'W'),
(9,'c18',2, 'W'),
(9,'c19',1, 'L'),
(10,'c17',3, 'W'),
(10,'c20',0, 'L'),
(11,'c21',2, 'W'),
(11,'c23',1, 'L'),
(12,'c24',0, 'T'),
(12,'c22',0, 'T'),
(13,'c25',4, 'W'),
(13,'c27',0, 'L'),
(14,'c28',1, 'L'),
(14,'c26',2, 'W'),
(15,'c29',2, 'W'),
(15,'c30',1, 'L'),
(16,'c31',1, 'T'),
(16,'c32',1, 'T'),
(17,'c01',0, 'T'),
(17,'c02',0, 'T'),
(18,'c04',0, 'L'),
(18,'c03',4, 'W'),
(19,'c07',0, 'L'),
(19,'c06',2, 'W'),
(20,'c08',2, 'L'),
(20,'c05',3, 'W'),
(21,'c09',2, 'W'),
(21,'c11',1, 'L'),
(22,'c12',0, 'T'),
(22,'c10',0, 'T'),
(23,'c14',2, 'W'),
(23,'c16',1, 'L'),
(24,'c15',0, 'L'),
(24,'c13',1, 'W'),
(25,'c18',2, 'L'),
(25,'c17',5, 'W'),
(26,'c20',1, 'L'),
(26,'c19',2, 'W'),
(27,'c21',1, 'W'),
(27,'c24',0, 'L'),
(28,'c22',1, 'W'),
(28,'c23',0, 'L'),
(29,'c25',2, 'T'),
(29,'c28',2, 'T'),
(30,'c26',1, 'T'),
(30,'c27',0, 'T'),
(31,'c29',2, 'L'),
(31,'c31',4, 'W'),
(32,'c32',1, 'L'),
(32,'c30',4, 'W'),
(33,'c04',1, 'L'),
(33,'c01',3, 'W'),
(34,'c03',0, 'L'),
(34,'c02',3, 'W'),
(35,'c08',2, 'W'),
(35,'c07',0, 'L'),
(36,'c05',1, 'L'),
(36,'c06',4, 'W'),
(37,'c12',2, 'W'),
(37,'c09',1, 'L'),
(38,'c10',0, 'L'),
(38,'c11',1, 'W'),
(39,'c15',0, 'L'),
(39,'c14',1, 'W'),
(40,'c13',0, 'T'),
(40,'c16',0, 'T'),
(41,'c20',0, 'L'),
(41,'c18',3, 'W'),
(42,'c19',0, 'T'),
(42,'c17',0, 'T'),
(43,'c22',2, 'L'),
(43,'c21',3, 'W'),
(44,'c23',3, 'W'),
(44,'c24',1, 'L'),
(45,'c26',0, 'L'),
(45,'c25',1, 'W'),
(46,'c27',2, 'W'),
(46,'c28',1, 'L'),
(47,'c32',0, 'L'),
(47,'c29',1, 'W'),
(48,'c30',1, 'T'),
(48,'c31',1, 'T'),
(49,'c01',1, 'W'),
(49,'c06',1, 'L'),
(50,'c09',2, 'W'),
(50,'c14',0, 'L'),
(51,'c05',2, 'W'),
(51,'c02',1, 'L'),
(52,'c13',1, 'W'),
(52,'c10',1, 'L'),
(53,'c17',2, 'W'),
(53,'c22',0, 'L'),
(54,'c25',2, 'W'),
(54,'c30',1, 'L'),
(55,'c21',1, 'W'),
(55,'c18',0, 'L'),
(56,'c29',2, 'W'),
(56,'c26',1, 'L'),
(57,'c01',2, 'W'),
(57,'c09',1, 'L'),
(58,'c17',0, 'L'),
(58,'c25',1, 'W'),
(59,'c05',0, 'W'),
(59,'c13',0, 'L'),
(60,'c21',1, 'W'),
(60,'c29',0, 'L'),
(61,'c01',1, 'L'),
(61,'c25',7, 'W'),
(62,'c05',0, 'L'),
(62,'c21',0, 'L'),
(63,'c01',0, 'W'),
(63,'c05',3, 'L'),
(64,'c25',1, 'L'),
(64,'c21',0, 'W');
--create OvertimeGames table--
create table overtimeGames(
gameNumber int references games(gameNumber) PRIMARY KEY,
wentIntoPenaltyShootout boolean
);
INSERT INTO overtimeGames(gameNumber, wentIntoPenaltyShootout)
VALUES (49, true),
(52, true),
(54, false),
(55, false),
(56, false),
(59, true),
(62, true),
(64, false);
--create penaltyShootout table--
drop table penaltyShootout;
create table penaltyShootout(
gameNumber int references overtimeGames(gameNumber),
cid text references countries(cid),
penaltiesMade int,
CHECK (penaltiesMade >= 0),
primary key(gameNumber, cid)
);
INSERT INTO penaltyShootout(gameNumber, cid, penaltiesMade)
VALUES (49, 'c01', 3),
(49, 'c06', 2),
(52, 'c13', 5),
(52, 'c10', 3),
(59, 'c05', 4),
(59, 'c13', 3),
(62, 'c05', 2),
(62, 'c21', 4); | true |
b56b7bd13c76e4399a195e758fc3bd228a166394 | SQL | marcoliverteschke/kloenschnack | /sql/0004.sql | UTF-8 | 144 | 2.578125 | 3 | [] | no_license | ALTER TABLE posts ADD COLUMN user_id INT NOT NULL REFERENCES users(id);
ALTER TABLE files ADD COLUMN user_id INT NOT NULL REFERENCES users(id);
| true |
17f8ca7f66b881215744cb8fe042335562116417 | SQL | leodockerhub/leo | /todoVal.sql | UTF-8 | 1,647 | 3.40625 | 3 | [] | no_license | CREATE TABLE lists (
`id` INT UNSIGNED NOT NULL auto_increment,
`uuid` CHAR(36) NOT NULL default '',
`ow` INT NOT NULL default 0,
`name` VARCHAR(50) NOT NULL default '',
`d_created` INT UNSIGNED NOT NULL default 0,
`d_edited` INT UNSIGNED NOT NULL default 0,
`sorting` TINYINT UNSIGNED NOT NULL default 0,
`published` TINYINT UNSIGNED NOT NULL default 0,
`taskview` INT UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id`),
UNIQUE KEY(`uuid`)
);
CREATE TABLE todolist (
`id` INT UNSIGNED NOT NULL auto_increment,
`uuid` CHAR(36) NOT NULL default '',
`list_id` INT UNSIGNED NOT NULL default 0,
`d_created` INT UNSIGNED NOT NULL default 0, /* time() timestamp */
`d_completed` INT UNSIGNED NOT NULL default 0, /* time() timestamp */
`d_edited` INT UNSIGNED NOT NULL default 0, /* time() timestamp */
`compl` TINYINT UNSIGNED NOT NULL default 0,
`title` VARCHAR(250) NOT NULL,
`note` TEXT,
`prio` TINYINT NOT NULL default 0, /* priority -,0,+ */
`ow` INT NOT NULL default 0, /* order weight */
`tags` VARCHAR(600) NOT NULL default '', /* for fast access to task tags */
`tags_ids` VARCHAR(250) NOT NULL default '', /* no more than 22 tags (x11 chars) */
`duedate` DATE default NULL,
PRIMARY KEY(`id`),
KEY(`list_id`),
UNIQUE KEY(`uuid`)
);
CREATE TABLE tags (
`id` INT UNSIGNED NOT NULL auto_increment,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY(`id`),
UNIQUE KEY `name` (`name`)
);
CREATE TABLE tag2task (
`tag_id` INT UNSIGNED NOT NULL,
`task_id` INT UNSIGNED NOT NULL,
`list_id` INT UNSIGNED NOT NULL,
KEY(`tag_id`),
KEY(`task_id`),
KEY(`list_id`) /* for tagcloud */
);
| true |
ba569e9c874cb33a0ad636ce871e69e0eb173cc3 | SQL | profchiso/nig-e-vote | /db/nimc (2).sql | UTF-8 | 11,199 | 3.140625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Sep 08, 2019 at 07:17 AM
-- Server version: 10.1.32-MariaDB
-- PHP Version: 5.6.36
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `nimc`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`id` int(50) NOT NULL,
`Admin_name` varchar(100) NOT NULL,
`Admin_username` varchar(100) NOT NULL,
`Admin_pwd` varchar(100) NOT NULL,
`Admin_rank` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id`, `Admin_name`, `Admin_username`, `Admin_pwd`, `Admin_rank`) VALUES
(1, 'okorie chinedu sunday', 'chinedu', 'chinedu1', '12');
-- --------------------------------------------------------
--
-- Table structure for table `candidate`
--
CREATE TABLE `candidate` (
`id` int(254) NOT NULL,
`fullname` varchar(200) NOT NULL,
`gender` varchar(100) NOT NULL,
`lga` varchar(100) NOT NULL,
`state_of_origin` varchar(50) NOT NULL,
`party` varchar(50) NOT NULL,
`post` varchar(50) NOT NULL,
`passport` varchar(100) NOT NULL,
`party_logo` varchar(100) NOT NULL,
`vote` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `citizens`
--
CREATE TABLE `citizens` (
`id` int(254) NOT NULL,
`last_name` varchar(50) NOT NULL,
`first_name` varchar(50) NOT NULL,
`othernames` varchar(50) NOT NULL,
`town_of_residence` varchar(100) NOT NULL,
`country_of_residence` varchar(50) NOT NULL,
`state_of_residence` varchar(50) NOT NULL,
`lga_of_residence` varchar(50) NOT NULL,
`address_of_residence` varchar(100) NOT NULL,
`religion` varchar(30) NOT NULL,
`country_of_origin` varchar(50) NOT NULL,
`state_of_origin` varchar(50) NOT NULL,
`lga_of_origin` varchar(50) NOT NULL,
`gender` varchar(50) NOT NULL,
`residence_status` varchar(50) NOT NULL,
`NIN` varchar(100) NOT NULL,
`marital_status` varchar(30) NOT NULL,
`phone_number` varchar(20) NOT NULL,
`email` varchar(100) NOT NULL,
`VIN` varchar(100) NOT NULL,
`password` varchar(50) NOT NULL,
`year_of_birth` varchar(20) NOT NULL,
`month_of_birth` varchar(20) NOT NULL,
`day_of_birth` varchar(20) NOT NULL,
`QRcode` varchar(100) NOT NULL,
`date_of_validation` varchar(50) NOT NULL,
`voted` int(1) NOT NULL DEFAULT '0',
`vote_starts` varchar(50) NOT NULL DEFAULT '8',
`vote_ends` varchar(50) NOT NULL DEFAULT '14',
`otp` varchar(8) NOT NULL,
`voting_state` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `citizens`
--
INSERT INTO `citizens` (`id`, `last_name`, `first_name`, `othernames`, `town_of_residence`, `country_of_residence`, `state_of_residence`, `lga_of_residence`, `address_of_residence`, `religion`, `country_of_origin`, `state_of_origin`, `lga_of_origin`, `gender`, `residence_status`, `NIN`, `marital_status`, `phone_number`, `email`, `VIN`, `password`, `year_of_birth`, `month_of_birth`, `day_of_birth`, `QRcode`, `date_of_validation`, `voted`, `vote_starts`, `vote_ends`, `otp`, `voting_state`) VALUES
(5, 'okorie', 'chinedu', 'sunday', 'Ikorodu', 'Nigeria', 'lagos', 'ikorodu', '121 Agric lagos', 'Male', 'Nigeria', 'Ebonyi', 'Ohaozara', 'Male', 'Male', '36009397', 'Male', '08036009397', 'okoriechinedusunday@gmail.com', '36009397', 'chinedu', '1994', '10', '10', 'okoriechinedusunady@gmail.com.png', '18/06/19', 0, '16:00', '10:00', '', 'imo'),
(6, 'Edebor', 'grace', 'osas', 'Benin', 'Nigeria', 'Edo', 'Egor', '200 Uselu Lagos rd', 'Female', 'Nigeria', 'Edo', 'Egor', 'Male', 'Male', '222333444', 'Male', '293323390', 'chinedusundayokorie@gmail.com', '12345', '12345', '2008', '10', '10', 'chinedusundayokorie@gmail.com.png', '18/06/19', 1, '16:00', '10:00', '', 'imo'),
(7, 'Ben', 'Akono', 'Abey', 'Uyo', 'Nigeria', 'Akwaibom', 'Uyo', 'Abak road', 'Male', 'Nigeria', 'Cross-river', 'ogoja', 'Male', '', '2020202', 'Female', '08036009397', 'chisonwaguy@yahoo.com', '12345', 'chiso', '1996', '10', '10', 'chisonwaguy@yahoo.com.png', '18/06/19', 1, '16:00', '10:00', '', 'imo'),
(8, 'oko', 'oko', 'g', 'g', 'g', 'g', 'e', 'e', 'Female', 'e', 'e', 'e', 'Male', 'Male', '444', 'Female', '08036009397', 'oko@gmail.com', '1234', '', '1990', '10', '24', 'oko@gmail.com.png', '', 0, '16:00', '10:00', '59097', 'imo'),
(9, 'okorie', 'chinedu', 'sunady', 'lagos', 'nigeria', 'lagos', 'ikorodu', 'agric', 'Male', 'nigeria', 'ebonyi', 'ohaozara', 'Male', 'Male', '21234', 'Male', '08036009397', 'chisonwaguy@gmail.com', '', '', '1994', '10', '10', 'chisonwaguy@gmail.com.png', '', 0, '16:00', '10:00', '25174', 'imo'),
(10, 'ben', 'ben', 'ben', 'oooo', 'jsjsj', 'sjjjsjs', 'jsjsjsj', 'sooos', 'Female', 'jsjjsjs', 'hshsh', 'hhshsh', 'Male', 'Female', '8484884', 'Female', '9499494', 'oko@gmail.com', '12345', '', '2010', '10', '10', 'oko@gmail.com.png', '', 0, '16:00', '10:00', '59685', 'imo'),
(11, 'chinedu', 'chinedu', '', 'lagos', 'nigeria', 'lagos', 'ikorodu', 'mainlan', 'Male', 'nigeria', 'ebonyi', 'ohaozra', 'Male', 'Female', '1233144', 'Female', '99000', 'oo@g.co', '90H5B05042408703429', '12345', '1900', '10', '10', 'oo@g.co.png', '', 0, '16:00', '10:00', '79916', 'imo');
-- --------------------------------------------------------
--
-- Table structure for table `pvc`
--
CREATE TABLE `pvc` (
`id` int(50) NOT NULL,
`Name` varchar(50) NOT NULL,
`Gender` varchar(50) NOT NULL,
`Date_of_birth` varchar(50) NOT NULL,
`Phone_number` varchar(50) NOT NULL,
`State` varchar(50) NOT NULL,
`LGA` varchar(50) NOT NULL,
`VIN` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `pvc`
--
INSERT INTO `pvc` (`id`, `Name`, `Gender`, `Date_of_birth`, `Phone_number`, `State`, `LGA`, `VIN`) VALUES
(1, 'Chukwudi Odii', 'Male', '25/09/1984', '08055085567', 'Edo', 'Etsako east', '90F5B05042408703424'),
(2, 'Kingsley Oboh', 'Male', '25/09/1986', '08057635491', 'Lagos', 'Ojo', '90A5B05042408703434'),
(3, 'Esther chitah', 'Female', '11/06/1984', '07055098743', 'Ebonyi ', 'Ohaozara', '90E5B05042408703426'),
(4, 'Ngozi Godswill', 'Female', '11/09/1975', '07031588360', 'Ebonyi ', 'Afikpo', '90G5B05042408703425'),
(5, 'Blessing Igboke', 'Female', '21/03/1989', '08067127781', 'Ebonyi ', 'Afikpo', '90H5B05042408703429');
-- --------------------------------------------------------
--
-- Table structure for table `senate`
--
CREATE TABLE `senate` (
`senate` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `voters`
--
CREATE TABLE `voters` (
`id` int(233) NOT NULL,
`last_name` varchar(100) NOT NULL,
`first_name` varchar(100) NOT NULL,
`othernames` varchar(100) NOT NULL,
`town_of_residence` varchar(100) NOT NULL,
`country_of_residence` varchar(100) NOT NULL,
`state_of_residence` varchar(100) NOT NULL,
`lga_of_residence` varchar(100) NOT NULL,
`address_of_residence` varchar(100) NOT NULL,
`religion` varchar(100) NOT NULL,
`country_of_origin` varchar(100) NOT NULL,
`state_of_origin` varchar(100) NOT NULL,
`lga_of_origin` varchar(100) NOT NULL,
`gender` varchar(10) NOT NULL,
`residence_status` varchar(50) NOT NULL,
`NIN` varchar(100) NOT NULL,
`marital_status` varchar(100) NOT NULL,
`phone_number` varchar(100) NOT NULL,
`year_of_birth` varchar(100) NOT NULL,
`email` varchar(50) NOT NULL,
`month_of_birth` varchar(100) NOT NULL,
`day_of_birth` varchar(100) NOT NULL,
`QRcode` varchar(100) NOT NULL,
`otp` varchar(100) NOT NULL,
`VIN` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `voters`
--
INSERT INTO `voters` (`id`, `last_name`, `first_name`, `othernames`, `town_of_residence`, `country_of_residence`, `state_of_residence`, `lga_of_residence`, `address_of_residence`, `religion`, `country_of_origin`, `state_of_origin`, `lga_of_origin`, `gender`, `residence_status`, `NIN`, `marital_status`, `phone_number`, `year_of_birth`, `email`, `month_of_birth`, `day_of_birth`, `QRcode`, `otp`, `VIN`) VALUES
(1, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''),
(2, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''),
(3, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'chisonwaguy@yahoo.com ', '', '', '', '', ''),
(4, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'chisonwaguy@yahoo.com ', '', '', '', '', ''),
(5, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'chisonwaguy@yahoo.com ', '', '', '', '', ''),
(6, 'okorie', 'chinedu', 'sunady', 'lagos', 'nigeria', 'lagos', 'ikorodu', 'agric', 'Male', 'nigeria', 'ebonyi', 'ohaozara', 'Male', 'Male', '21234', 'Male', '08036009397', '1994', 'chisonwaguy@gmail.com', '10', '10', 'chisonwaguy@gmail.com.png', '25174', ''),
(7, 'chinedu', 'chinedu', '', 'lagos', 'nigeria', 'lagos', 'ikorodu', 'mainlan', 'Male', 'nigeria', 'ebonyi', 'ohaozra', 'Male', 'Female', '1233144', 'Female', '99000', '1900', 'oo@g.co', '10', '10', 'oo@g.co.png', '79916', '90H5B05042408703429');
-- --------------------------------------------------------
--
-- Table structure for table `votes`
--
CREATE TABLE `votes` (
`id` int(245) NOT NULL,
`president` varchar(100) NOT NULL,
`senate` varchar(100) NOT NULL,
`HouseOfRep` varchar(100) NOT NULL,
`governors` varchar(100) NOT NULL,
`HouseOfAss` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `candidate`
--
ALTER TABLE `candidate`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `citizens`
--
ALTER TABLE `citizens`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `pvc`
--
ALTER TABLE `pvc`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `voters`
--
ALTER TABLE `voters`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `votes`
--
ALTER TABLE `votes`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id` int(50) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `candidate`
--
ALTER TABLE `candidate`
MODIFY `id` int(254) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `citizens`
--
ALTER TABLE `citizens`
MODIFY `id` int(254) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `pvc`
--
ALTER TABLE `pvc`
MODIFY `id` int(50) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `voters`
--
ALTER TABLE `voters`
MODIFY `id` int(233) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `votes`
--
ALTER TABLE `votes`
MODIFY `id` int(245) NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
0a199aef010f62622a91fbd21c1980bad13df673 | SQL | AlbLioDam/Serveur_Rest | /Script suricat FINAL.sql | UTF-8 | 28,967 | 3.296875 | 3 | [
"MIT"
] | permissive | #------------------------------------------------------------
# Script MySQL.
#------------------------------------------------------------
DROP DATABASE IF EXISTS suricat;
CREATE DATABASE IF NOT EXISTS suricat;
USE suricat;
#------------------------------------------------------------
# Table: Users
#------------------------------------------------------------
CREATE TABLE Users(
idUser int (11) Auto_increment NOT NULL ,
email Varchar (50) NOT NULL ,
password Varchar (20) NOT NULL ,
status Varchar (30) NOT NULL,
idDepartment Int NOT NULL ,
firstname Varchar (30) ,
lastname Varchar (30) ,
car Bool ,
carsharing Bool ,
active Bool ,
address Varchar (100) ,
city Varchar (100) ,
corporateLifeRepresentative Bool ,
workCouncilRepresentative Bool ,
PRIMARY KEY (idUser )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: Team
#------------------------------------------------------------
CREATE TABLE Team(
idTeam int (11) Auto_increment NOT NULL ,
teamName Varchar (30) NOT NULL ,
projectName Varchar (30) ,
projectDescription Varchar (500) ,
PRIMARY KEY (idTeam )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: Department
#------------------------------------------------------------
CREATE TABLE Department(
idDepartment int (11) Auto_increment NOT NULL ,
departmentName Varchar (30) NOT NULL ,
PRIMARY KEY (idDepartment ) ,
UNIQUE (departmentName )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: Actuality
#------------------------------------------------------------
CREATE TABLE Actuality(
idActuality int (11) Auto_increment NOT NULL ,
title Varchar (50) ,
dateActuality Datetime NOT NULL ,
publication Varchar (2000) NOT NULL ,
photo blob ,
idUser Int NOT NULL ,
PRIMARY KEY (idActuality )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: LeisureActuality
#------------------------------------------------------------
CREATE TABLE LeisureActuality(
category Varchar (50) NOT NULL ,
idActuality Int NOT NULL ,
PRIMARY KEY (idActuality )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: TeamActuality
#------------------------------------------------------------
CREATE TABLE TeamActuality(
idActuality Int NOT NULL ,
idTeam Int NOT NULL ,
PRIMARY KEY (idActuality )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: Rdv
#------------------------------------------------------------
CREATE TABLE Rdv(
idRdv int (11) Auto_increment NOT NULL ,
dateRdv Datetime NOT NULL ,
description Varchar (100) NOT NULL ,
color Varchar (10) ,
idTeam Int NOT NULL ,
PRIMARY KEY (idRdv )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: Task
#------------------------------------------------------------
CREATE TABLE Task(
idTask int (11) Auto_increment NOT NULL ,
taskName Varchar (60) NOT NULL ,
detail Varchar (250) ,
PRIMARY KEY (idTask )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: Tool
#------------------------------------------------------------
CREATE TABLE Tool(
idTool int (11) Auto_increment NOT NULL ,
toolName Varchar (60) NOT NULL ,
PRIMARY KEY (idTool ) ,
UNIQUE (toolName )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: CorporateLifeActuality
#------------------------------------------------------------
CREATE TABLE CorporateLifeActuality(
idActuality Int NOT NULL ,
PRIMARY KEY (idActuality )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: WorksCouncilActuality
#------------------------------------------------------------
CREATE TABLE WorksCouncilActuality(
idActuality Int NOT NULL ,
PRIMARY KEY (idActuality )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: Message
#------------------------------------------------------------
CREATE TABLE Message(
idMessage int (11) Auto_increment NOT NULL ,
message Varchar (250) NOT NULL ,
dateMessage Datetime NOT NULL ,
idUser Int NOT NULL ,
idUser_Users Int NOT NULL ,
readStatus Bool ,
PRIMARY KEY (idMessage )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: notify
#------------------------------------------------------------
CREATE TABLE notify(
idUser Int NOT NULL ,
idActuality Int NOT NULL ,
PRIMARY KEY (idUser ,idActuality )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: postComment
#------------------------------------------------------------
CREATE TABLE postComment(
commentary Varchar (250) NOT NULL ,
dateCommentary Datetime NOT NULL ,
idUser Int NOT NULL ,
idActuality Int NOT NULL ,
PRIMARY KEY (idUser ,idActuality, dateCommentary)
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: have
#------------------------------------------------------------
CREATE TABLE have(
idTeam Int NOT NULL ,
idTask Int NOT NULL ,
idUser Int NOT NULL ,
PRIMARY KEY (idTeam ,idTask ,idUser )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: gotShortcut
#------------------------------------------------------------
CREATE TABLE gotShortcut(
shortcut Varchar (200) NOT NULL ,
idUser Int NOT NULL ,
idTeam Int NOT NULL ,
PRIMARY KEY (idUser ,idTeam, shortcut)
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: gotTool
#------------------------------------------------------------
CREATE TABLE gotTool(
visible Bool NOT NULL ,
position TinyINT NOT NULL ,
idUser Int NOT NULL ,
idTeam Int NOT NULL ,
idTool Int NOT NULL ,
PRIMARY KEY (idUser ,idTeam ,idTool )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: toDo
#------------------------------------------------------------
CREATE TABLE toDo(
duration TinyINT NOT NULL ,
status Varchar (30) NOT NULL ,
weight TinyINT ,
dateDeDebut Datetime ,
dateDeFin Datetime ,
idTeam Int NOT NULL ,
idTask Int NOT NULL ,
PRIMARY KEY (idTeam ,idTask )
)ENGINE=InnoDB;
#------------------------------------------------------------
# Table: belongTo
#------------------------------------------------------------
CREATE TABLE belongTo(
idUser Int NOT NULL ,
idTeam Int NOT NULL ,
PRIMARY KEY (idUser ,idTeam )
)ENGINE=InnoDB;
ALTER TABLE Users ADD CONSTRAINT FK_Users_idDepartment FOREIGN KEY (idDepartment) REFERENCES Department(idDepartment);
ALTER TABLE Actuality ADD CONSTRAINT FK_Actuality_idUser FOREIGN KEY (idUser) REFERENCES Users(idUser);
ALTER TABLE LeisureActuality ADD CONSTRAINT FK_LeisureActuality_idActuality FOREIGN KEY (idActuality) REFERENCES Actuality(idActuality);
ALTER TABLE TeamActuality ADD CONSTRAINT FK_TeamActuality_idActuality FOREIGN KEY (idActuality) REFERENCES Actuality(idActuality);
ALTER TABLE TeamActuality ADD CONSTRAINT FK_TeamActuality_idTeam FOREIGN KEY (idTeam) REFERENCES Team(idTeam);
ALTER TABLE Rdv ADD CONSTRAINT FK_Rdv_idTeam FOREIGN KEY (idTeam) REFERENCES Team(idTeam);
ALTER TABLE CorporateLifeActuality ADD CONSTRAINT FK_CorporateLifeActuality_idActuality FOREIGN KEY (idActuality) REFERENCES Actuality(idActuality);
ALTER TABLE WorksCouncilActuality ADD CONSTRAINT FK_WorksCouncilActuality_idActuality FOREIGN KEY (idActuality) REFERENCES Actuality(idActuality);
ALTER TABLE Message ADD CONSTRAINT FK_Message_idUser FOREIGN KEY (idUser) REFERENCES Users(idUser);
ALTER TABLE Message ADD CONSTRAINT FK_Message_idUser_Users FOREIGN KEY (idUser_Users) REFERENCES Users(idUser);
ALTER TABLE notify ADD CONSTRAINT FK_notify_idUser FOREIGN KEY (idUser) REFERENCES Users(idUser);
ALTER TABLE notify ADD CONSTRAINT FK_notify_idActuality FOREIGN KEY (idActuality) REFERENCES Actuality(idActuality);
ALTER TABLE postComment ADD CONSTRAINT FK_postComment_idUser FOREIGN KEY (idUser) REFERENCES Users(idUser);
ALTER TABLE postComment ADD CONSTRAINT FK_postComment_idActuality FOREIGN KEY (idActuality) REFERENCES Actuality(idActuality);
ALTER TABLE have ADD CONSTRAINT FK_have_idTeam FOREIGN KEY (idTeam) REFERENCES Team(idTeam);
ALTER TABLE have ADD CONSTRAINT FK_have_idTask FOREIGN KEY (idTask) REFERENCES Task(idTask);
ALTER TABLE have ADD CONSTRAINT FK_have_idUser FOREIGN KEY (idUser) REFERENCES Users(idUser);
ALTER TABLE gotShortcut ADD CONSTRAINT FK_gotShortcut_idUser FOREIGN KEY (idUser) REFERENCES Users(idUser);
ALTER TABLE gotShortcut ADD CONSTRAINT FK_gotShortcut_idTeam FOREIGN KEY (idTeam) REFERENCES Team(idTeam);
ALTER TABLE gotTool ADD CONSTRAINT FK_gotTool_idUser FOREIGN KEY (idUser) REFERENCES Users(idUser);
ALTER TABLE gotTool ADD CONSTRAINT FK_gotTool_idTeam FOREIGN KEY (idTeam) REFERENCES Team(idTeam);
ALTER TABLE gotTool ADD CONSTRAINT FK_gotTool_idTool FOREIGN KEY (idTool) REFERENCES Tool(idTool);
ALTER TABLE toDo ADD CONSTRAINT FK_toDo_idTeam FOREIGN KEY (idTeam) REFERENCES Team(idTeam);
ALTER TABLE toDo ADD CONSTRAINT FK_toDo_idTask FOREIGN KEY (idTask) REFERENCES Task(idTask);
ALTER TABLE belongTo ADD CONSTRAINT FK_belongTo_idUser FOREIGN KEY (idUser) REFERENCES Users(idUser);
ALTER TABLE belongTo ADD CONSTRAINT FK_belongTo_idTeam FOREIGN KEY (idTeam) REFERENCES Team(idTeam);
#------------------------------------------------------------
# INSERT : DEPARTMENT
#------------------------------------------------------------
INSERT INTO Department(departmentName) VALUES ("Service développement");
INSERT INTO Department(departmentName) VALUES ("Service secrétariat");
INSERT INTO Department(departmentName) VALUES ("Service marketing");
INSERT INTO Department(departmentName) VALUES ("Administrateur");
#------------------------------------------------------------
# INSERT : USERS
#------------------------------------------------------------
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("david.dimarcantonio@suricat.fr", "1234", "David", "Di-marcantonio", "Admin", true, true, true, "Chez David", "Ville de David", 4, 0, 0);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("lionel.chialvo@suricat.fr", "1234", "Lionel", "Chialvo", "Chef de projet", true, true, true, "Chez Lionel", "Ville de Lionel", 1, 1, 0);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("alban.martinez@suricat.fr", "1234", "Alban", "Martinez", "Utilisateur", true, true, true, "Chez Alban", "Ville d'Alban", 1, 0, 1);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("damien.elsabbagh@suricat.fr", "1234", "Damien", "El sabbagh", "Utilisateur", true, true, true, "Chez Damien", "Ville de Damien", 1, 0, 0);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("cyril.mathieu@suricat.fr", "1234", "Cyril", "Mathieu", "Chef de projet", true, true, true, "Chez Cyril", "Ville de Cyril", 1, 0, 0);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("benjamin.champetier@suricat.fr", "1234", "Benjamin", "Champetier", "Utilisateur", true, true, true, "Chez Benji", "Ville de Benji", 1, 0, 0);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("mathieu.peyramard@suricat.fr", "1234", "Mathieu", "Peyramard", "Chef de projet", true, true, true, "Chez Mathieu", "Ville de Mathieu", 1, 0, 1);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("florent.valadier@suricat.fr", "1234", "Florent", "Valadier", "Utilisateur", true, true, true, "Chez Florent", "Ville de Florent", 1, 0, 0);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("manu.piat@suricat.fr", "1234", "Manu", "Piat", "Utilisateur", true, true, true, "Chez Manu", "Ville de Manu", 1, 0, 1);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("anais.gueyte@suricat.fr", "1234", "Anais", "Gueyte", "Utilisateur", true, true, true, "Chez Anais", "Ville de Anais", 1, 0, 1);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("khadidja.boudjema@suricat.fr", "1234", "Khadidja", "Boudjema", "Chef de projet", true, true, true, "Chez Khadidja", "Ville de Khadidja", 1, 1, 1);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("marc.naouache@suricat.fr", "1234", "Marc", "Naouache", "Utilisateur", true, true, true, "Chez Marc", "Ville de Marc", 1, 0, 1);
INSERT INTO Users(email, password, firstname, lastname, status, car, carsharing, active, address, city, idDepartment, corporateLifeRepresentative, workCouncilRepresentative)
VALUES ("audric.lespagnol@suricat.fr", "1234", "Audric", "Lespagnol", "Chef de projet", true, true, true, "Chez Audric", "Ville d'Audric", 1, 0, 1);
#------------------------------------------------------------
# INSERT : TEAM
#------------------------------------------------------------
INSERT INTO Team(teamName, projectName, projectDescription) VALUES ("Team Suricat", "Suricat", "Site web communautaire en entreprise");
INSERT INTO Team(teamName, projectName, projectDescription) VALUES ("Team MonitorYourLan", "MonitorYourLan", "Application lourde et mobile de détection matériel");
INSERT INTO Team(teamName, projectName, projectDescription) VALUES ("Team WhiskyBoard", "WhiskyBoard", "Application de dégustation");
INSERT INTO Team(teamName, projectName, projectDescription) VALUES ("Team GoldenEyes", "GoldenEyes", "Application mobile de surveillance d'habitation'");
INSERT INTO Team(teamName, projectName, projectDescription) VALUES ("Team EntreNous", "EntreNous", "Site web de recherche de bar commun");
#------------------------------------------------------------
# INSERT : belongTo (Users - Team)
#------------------------------------------------------------
INSERT INTO belongTo(idUser, idTeam) VALUES (1, 1);
INSERT INTO belongTo(idUser, idTeam) VALUES (1, 2);
INSERT INTO belongTo(idUser, idTeam) VALUES (1, 3);
INSERT INTO belongTo(idUser, idTeam) VALUES (1, 4);
INSERT INTO belongTo(idUser, idTeam) VALUES (1, 5);
INSERT INTO belongTo(idUser, idTeam) VALUES (2, 1);
INSERT INTO belongTo(idUser, idTeam) VALUES (3, 1);
INSERT INTO belongTo(idUser, idTeam) VALUES (4, 1);
INSERT INTO belongTo(idUser, idTeam) VALUES (5, 2);
INSERT INTO belongTo(idUser, idTeam) VALUES (6, 2);
INSERT INTO belongTo(idUser, idTeam) VALUES (7, 3);
INSERT INTO belongTo(idUser, idTeam) VALUES (8, 3);
INSERT INTO belongTo(idUser, idTeam) VALUES (12, 4);
INSERT INTO belongTo(idUser, idTeam) VALUES (13, 4);
INSERT INTO belongTo(idUser, idTeam) VALUES (9, 5);
INSERT INTO belongTo(idUser, idTeam) VALUES (10, 5);
INSERT INTO belongTo(idUser, idTeam) VALUES (11, 5);
#------------------------------------------------------------
# INSERT : Task
#------------------------------------------------------------
INSERT INTO Task(taskName, detail) VALUES ("Fonctionnalité Login", "Mettre en place la page de connection");
INSERT INTO Task(taskName, detail) VALUES ("Fonctionnalité Inscription", "Mettre en place la page d'inscription");
INSERT INTO Task(taskName, detail) VALUES ("Fonctionnalité design main page", "Mettre en place la page princpale");
INSERT INTO Task(taskName, detail) VALUES ("Fonctionnalité implementer server", "Mettre en place le serveur rest");
#------------------------------------------------------------
# INSERT : toDo (Team - Task)
#------------------------------------------------------------
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (1, 1, 3, "In Progress");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (1, 2, 4, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (1, 3, 5, "To Verify");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (1, 4, 7, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (2, 1, 2, "In Progress");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (2, 2, 3, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (2, 3, 4, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (2, 4, 6, "In Progress");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (3, 1, 1, "In Progress");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (3, 2, 6, "Done");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (3, 3, 8, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (3, 4, 10, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (4, 1, 3, "In Progress");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (4, 2, 4, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (4, 3, 5, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (4, 4, 7, "To Do");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (5, 1, 3, "Done");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (5, 2, 4, "Done");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (5, 3, 5, "In Progress");
INSERT INTO toDo(idTeam, idTask, duration, status) VALUES (5, 4, 7, "In Progress");
#------------------------------------------------------------
# INSERT : have (Users - Team - Task)
#------------------------------------------------------------
INSERT INTO have(idTeam, idTask, idUser) VALUES (1, 1, 2);
INSERT INTO have(idTeam, idTask, idUser) VALUES (1, 2, 3);
INSERT INTO have(idTeam, idTask, idUser) VALUES (1, 3, 4);
INSERT INTO have(idTeam, idTask, idUser) VALUES (2, 1, 5);
INSERT INTO have(idTeam, idTask, idUser) VALUES (2, 2, 6);
INSERT INTO have(idTeam, idTask, idUser) VALUES (3, 3, 7);
INSERT INTO have(idTeam, idTask, idUser) VALUES (3, 4, 8);
INSERT INTO have(idTeam, idTask, idUser) VALUES (4, 1, 9);
INSERT INTO have(idTeam, idTask, idUser) VALUES (4, 3, 10);
INSERT INTO have(idTeam, idTask, idUser) VALUES (4, 4, 11);
INSERT INTO have(idTeam, idTask, idUser) VALUES (5, 1, 12);
INSERT INTO have(idTeam, idTask, idUser) VALUES (5, 2, 13);
/*
#------------------------------------------------------------
# INSERT : Tool
#------------------------------------------------------------
INSERT INTO Tool(toolName) VALUES ("Kanban");
INSERT INTO Tool(toolName) VALUES ("Calendar");
INSERT INTO Tool(toolName) VALUES ("Actualité d'équipe");
#------------------------------------------------------------
# INSERT : gotTool (Users - Team)
#------------------------------------------------------------
INSERT INTO gotTool(idTeam, idUser, idTool, visible, position) VALUES (1, 1, 1, true, 1);
INSERT INTO gotTool(idTeam, idUser, idTool, visible, position) VALUES (1, 1, 2, true, 2);
INSERT INTO gotTool(idTeam, idUser, idTool, visible, position) VALUES (1, 2, 2, true, 1);
#------------------------------------------------------------
# INSERT : gotShortcut (Users - Team)
#------------------------------------------------------------
INSERT INTO gotShortcut(idTeam, idUser, shortcut) VALUES (1, 1, "U:\Partage\19- FIL ROUGE\Projet WEB Lionel Alban Doom\Gestion projet Suricat\UML");
INSERT INTO gotShortcut(idTeam, idUser, shortcut) VALUES (1, 1, "U:\Partage\01- Expose\Alban Lionel Cyril Benjamin");
*/
#------------------------------------------------------------
# INSERT : Actuality
#------------------------------------------------------------
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du CE 1", NOW(), "est une actualité de test CE 1", null, 3);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du CE 2", NOW(), "est une actualité de test CE 2", null, 7);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du CE 3", NOW(), "est une actualité de test CE 3", null, 3);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du CE 4", NOW(), "est une actualité de test CE 4", null, 10);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du CE 5", NOW(), "est une actualité de test CE 5", null, 10);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du CE 6", NOW(), "est une actualité de test CE 6", null, 10);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du CE 7", NOW(), "est une actualité de test CE 7", null, 11);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du CE 8", NOW(), "est une actualité de test CE 8", null, 12);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 9", NOW(), "est une actualité de test Team 1", null, 2);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 10", NOW(), "est une actualité de test Team 2", null, 2);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 11", NOW(), "est une actualité de test Team 1", null, 5);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 12", NOW(), "est une actualité de test Team 2", null, 5);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 13", NOW(), "est une actualité de test Team 1", null, 7);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 14", NOW(), "est une actualité de test Team 2", null, 7);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 15", NOW(), "est une actualité de test Team 3", null, 7);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 16", NOW(), "est une actualité de test Team 1", null, 11);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de la Team 17", NOW(), "est une actualité de test Team 1", null, 13);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de loisir 1", NOW(), "est une actualité de test Loisir 1", null, 1);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de loisir 2", NOW(), "est une actualité de test Loisir 2", null, 3);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de loisir 3", NOW(), "est une actualité de test Loisir 3", null, 7);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de loisir 4", NOW(), "est une actualité de test Loisir 4", null, 8);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de loisir 5", NOW(), "est une actualité de test Loisir 5", null, 8);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality de loisir 6", NOW(), "est une actualité de test Loisir 6", null, 12);
INSERT INTO Actuality(title, dateActuality, publication, photo, idUser) VALUES ("Actuality du VE 1", NOW(), "est une actualité de test CE 1", null, 11);
#------------------------------------------------------------
# INSERT : WorksCouncilActuality
#------------------------------------------------------------
INSERT INTO WorksCouncilActuality(idActuality) VALUES (1);
INSERT INTO WorksCouncilActuality(idActuality) VALUES (2);
INSERT INTO WorksCouncilActuality(idActuality) VALUES (3);
INSERT INTO WorksCouncilActuality(idActuality) VALUES (4);
INSERT INTO WorksCouncilActuality(idActuality) VALUES (5);
INSERT INTO WorksCouncilActuality(idActuality) VALUES (6);
INSERT INTO WorksCouncilActuality(idActuality) VALUES (7);
INSERT INTO WorksCouncilActuality(idActuality) VALUES (8);
#------------------------------------------------------------
# INSERT : TeamActuality
#------------------------------------------------------------
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (9, 1);
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (10, 1);
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (11, 2);
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (12, 2);
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (13, 3);
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (14, 3);
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (15, 3);
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (16, 4);
INSERT INTO TeamActuality(idActuality, idTeam) VALUES (17, 5);
#------------------------------------------------------------
# INSERT : LeisureActuality
#------------------------------------------------------------
INSERT INTO LeisureActuality(idActuality, category) VALUES (18, "Cuisine");
INSERT INTO LeisureActuality(idActuality, category) VALUES (19, "Sport");
INSERT INTO LeisureActuality(idActuality, category) VALUES (20, "Sport");
INSERT INTO LeisureActuality(idActuality, category) VALUES (21, "Covoiturage");
INSERT INTO LeisureActuality(idActuality, category) VALUES (22, "Covoiturage");
INSERT INTO LeisureActuality(idActuality, category) VALUES (23, "Sport");
#------------------------------------------------------------
# INSERT : CorporateLifeActuality
#------------------------------------------------------------
INSERT INTO CorporateLifeActuality(idActuality) VALUES (24);
/*
#------------------------------------------------------------
# INSERT : notify (TeamActuality - Users)
#------------------------------------------------------------
INSERT INTO notify(idActuality, idUser) VALUES (2, 2);
#------------------------------------------------------------
# INSERT : postComment (LeisureActuality - Users)
#------------------------------------------------------------
INSERT INTO postComment(idActuality, idUser, dateCommentary, commentary) VALUES (3, 2, NOW(), "Sympa ce post !");
#------------------------------------------------------------
# INSERT : Message
#------------------------------------------------------------
INSERT INTO Message(dateMessage, message, idUser, idUser_Users) VALUES (NOW(), "Tu es là ?", 1, 2);
INSERT INTO Message(dateMessage, message, idUser, idUser_Users) VALUES (DATE_ADD(NOW(), INTERVAL 1 SECOND), "Oui je bosse tu crois quoi ?!", 2, 1);
INSERT INTO Message(dateMessage, message, idUser, idUser_Users) VALUES (DATE_ADD(NOW(), INTERVAL 2 SECOND), "Je m'en doutais... Tu as basculé du côté obscur...", 1, 2);
*/ | true |
91a244d424a9112d24e4eeff0f02ca4c15ec3b55 | SQL | vitalik-lapushkin/telegramFSBsnitchBot | /src/resources/dbScripts/script.sql | UTF-8 | 221 | 2.734375 | 3 | [] | no_license | create schema fsb_snitch_bot;
create table fsb_snitch_bot.users(
id integer CONSTRAINT userPK PRIMARY KEY,
username varchar(150),
alias varchar(150),
rating integer CHECK (rating>=0) default 0
);
| true |
3b4e1d780a40d0bd6670c2e24499c22ed9acfc50 | SQL | zhaoy1992/xtbg-whtjy-new | /.svn/pristine/3b/3b4e1d780a40d0bd6670c2e24499c22ed9acfc50.svn-base | UTF-8 | 1,019 | 3.421875 | 3 | [] | no_license | -- Create table
create table TA_OA_TRAIN
(
TR_ID VARCHAR2(40) not null,
TR_LEVEL VARCHAR2(100),
TR_TITLE VARCHAR2(200),
TR_CONTENT VARCHAR2(2000),
TR_TIME DATE,
TR_HOUR NUMBER,
TR_ADDRESS VARCHAR2(200),
TR_MONEY NUMBER,
TR_USERSN VARCHAR2(40)
);
-- Add comments to the columns
comment on column TA_OA_TRAIN.TR_ID
is '主键ID';
comment on column TA_OA_TRAIN.TR_LEVEL
is '培训级别';
comment on column TA_OA_TRAIN.TR_TITLE
is '培训主题';
comment on column TA_OA_TRAIN.TR_CONTENT
is '培训内容';
comment on column TA_OA_TRAIN.TR_TIME
is '培训时间';
comment on column TA_OA_TRAIN.TR_HOUR
is '培训课时';
comment on column TA_OA_TRAIN.TR_ADDRESS
is '地点';
comment on column TA_OA_TRAIN.TR_MONEY
is '培训费用';
comment on column TA_OA_TRAIN.TR_USERSN
is '用户id';
-- Create/Recreate primary, unique and foreign key constraints
alter table TA_OA_TRAIN
add constraint PK_TA_OA_TRAIN_ID primary key (TR_ID);
| true |
1007f623d9bab5596afb88e98a21b1466aad6705 | SQL | drishh207/Paytm-Database | /SQL dump/paytm_metro_locations.sql | UTF-8 | 2,559 | 3.0625 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.21, for Win64 (x86_64)
--
-- Host: localhost Database: paytm
-- ------------------------------------------------------
-- Server version 8.0.21
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `metro_locations`
--
DROP TABLE IF EXISTS `metro_locations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `metro_locations` (
`station_id` int NOT NULL,
`location name` varchar(45) DEFAULT NULL,
`city_code` int DEFAULT NULL,
PRIMARY KEY (`station_id`),
KEY `city_code_idx` (`city_code`),
CONSTRAINT `city_code` FOREIGN KEY (`city_code`) REFERENCES `metro_types` (`city_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `metro_locations`
--
LOCK TABLES `metro_locations` WRITE;
/*!40000 ALTER TABLE `metro_locations` DISABLE KEYS */;
INSERT INTO `metro_locations` VALUES (1,'Airport Road',1),(2,'Marol Naka',1),(3,'Saki Naka',1),(4,'Asalpha',1),(5,'Jagruti Nagar',1),(6,'AIIMS',2),(7,'Green Park',2),(8,'Hauz Khas',2),(9,'Saket',2),(10,'Qutab Minar',2),(11,'Sultanpur',2),(12,'Yamuna Bank',2),(13,'Karkarduma',2),(14,'Welcome',2),(15,'Balangar',3),(16,'SR Nagar',3),(17,'Ameerpet',3),(18,'Gandhi Bhavan',3),(19,'New Market',3),(20,'Chandni Chowk',4),(21,'Mahatma Gandhi Road',4),(22,'Shyambazar',4),(23,'Dum Dum',4);
/*!40000 ALTER TABLE `metro_locations` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-12-09 18:40:03
| true |
8313cf55055dd3c6db1b72491397445ec47e303a | SQL | DianaSanchezOrdonez/NEST-Nerdery-Challenge | /prisma/migrations/20210619045134_create_table_user/migration.sql | UTF-8 | 560 | 3.609375 | 4 | [] | no_license | -- CreateEnum
CREATE TYPE "Role" AS ENUM ('MANAGER', 'CLIENT');
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"first_name" TEXT NOT NULL,
"last_name" TEXT NOT NULL,
"email" VARCHAR(255) NOT NULL,
"password" TEXT NOT NULL,
"email_verified" BOOLEAN NOT NULL DEFAULT false,
"username" VARCHAR(255) NOT NULL,
"role" "Role" NOT NULL,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "User.username_unique" ON "User"("username");
| true |
6a3874555f3dd1587b13a9aeddcfc2d1b0d7de46 | SQL | hoquangnam45/CSDLTH2 | /sql file/Import course basic information.sql | UTF-8 | 3,863 | 2.84375 | 3 | [] | no_license | -- nhập Course
INSERT INTO Course_table VALUES ('000000014','Machine learning', 'Lorem ipsum dolor sit amet',0,100,'crignall1',0);
INSERT INTO Course_table VALUES ('000000015','Database 101','Lorem ipsum dolor sit amet',0,1000,'rabbs7',1);
INSERT INTO Course_table VALUES ('000000016','Financial 101','Lorem ipsum dolor sit amet',100,100000,'ccasaro5',2);
INSERT INTO Course_table VALUES ('000000017','Programming begin 101','Lorem ipsum dolor sit amet',10,33,'tsolan9',3);
INSERT INTO Course_table VALUES ('000000018','Data Structure','Lorem ipsum dolor sit amet',4,0,'lpatriskson3',4);
-- Nhập tag --
INSERT INTO Tag_table VALUES('','000000014', 'Machine');
INSERT INTO Tag_table VALUES('','000000014', 'Computer');
INSERT INTO Tag_table VALUES('','000000015', 'Database');
INSERT INTO Tag_table VALUES('','000000015', 'Computer');
INSERT INTO Tag_table VALUES('','000000016', 'Financial');
INSERT INTO Tag_table VALUES('','000000016', 'Math');
INSERT INTO Tag_table VALUES('','000000017', 'Programming');
INSERT INTO Tag_table VALUES('','000000017', 'Math');
INSERT INTO Tag_table VALUES('','000000018', 'Data');
INSERT INTO Tag_table VALUES('','000000018', 'Structure');
--Nhập Quiz --
INSERT INTO Quiz_table VALUES ('ABCDEF', 45, 4, '', '000000014');
INSERT INTO Quiz_table VALUES ('ABCDEG', 45, 1, '', '000000015');
INSERT INTO Quiz_table VALUES ('ABCDEH', 45, 1, '', '000000016');
INSERT INTO Quiz_table VALUES ('ABCDEI', 45, 1, '', '000000017');
INSERT INTO Quiz_table VALUES ('ABCDEJ', 45, 2, '', '000000018');
--Nhập điểm quiz--
INSERT INTO Quiz_taken_table VALUES(1, 'ABCDEF', 'mleser7', 0);
INSERT INTO Quiz_taken_table VALUES(2, 'ABCDEF', 'mleser7', 5);
INSERT INTO Quiz_taken_table VALUES(3, 'ABCDEF', 'mleser7', 7);
INSERT INTO Quiz_taken_table VALUES(4, 'ABCDEF', 'mleser7', 10);
INSERT INTO Quiz_taken_table VALUES(1, 'ABCDEG', 'bcount8', 9);
INSERT INTO Quiz_taken_table VALUES(1, 'ABCDEG', 'smaccrae9', 5);
INSERT INTO Quiz_taken_table VALUES(1, 'ABCDEH', 'smaccrae9', 8);
INSERT INTO Quiz_taken_table VALUES(1, 'ABCDEI', 'cbroszkiewicza', 7);
INSERT INTO Quiz_taken_table VALUES(1, 'ABCDEJ', 'cbroszkiewicza', 10);
--Nhập learning material--
INSERT INTO Learningmaterial VALUES('0x123', 'crignall1', 'Slide', '000000014');
INSERT INTO Learningmaterial VALUES('0x124', 'crignall1', 'Video', '000000014');
INSERT INTO Learningmaterial VALUES('0x125', 'crignall1', 'Misc', '000000014');
INSERT INTO Learningmaterial VALUES('0x126', 'rabbs7', 'Slide', '000000015');
INSERT INTO Learningmaterial VALUES('0x127', 'ccasaro5', 'Video', '000000016');
INSERT INTO Learningmaterial VALUES('0x128', 'tsolan9', 'Misc', '000000017');
INSERT INTO Learningmaterial VALUES('0x129', 'tsolan9', 'Misc', '000000018');
--Nhập register table--
ALTER SESSION SET NLS_DATE_FORMAT = 'MM-DD-YYYY';
INSERT INTO Register_table VALUES('mleser7', '000000014', '01-01-1997', '01-02-1997', 9, 4, 12, 'ngan hang');
INSERT INTO Register_table VALUES('bcount8', '000000015', '01-01-1997', '01-02-1997', 8,1, 111, 'tien mat');
INSERT INTO Register_table VALUES('smaccrae9', '000000015', '01-01-1997', '01-02-1997', 7, 4, 121, 'ngan hang');
INSERT INTO Register_table VALUES('smaccrae9', '000000016', '01-01-1997', '01-02-1997', 6, 3, 54, 'ngan hang');
INSERT INTO Register_table VALUES('cbroszkiewicza', '000000017', '01-01-1997', '01-02-1997', 8, 5, 132, 'ngan hang');
INSERT INTO Register_table VALUES('cbroszkiewicza', '000000018', '01-01-1997', '01-02-1997', 7, 5, 114, 'tien mat');
--Nhập open table--
INSERT INTO Open_table VALUES('crignall1', '000000014', 'kgallego4');
INSERT INTO Open_table VALUES('rabbs7', '000000015', 'pstoile0');
INSERT INTO Open_table VALUES('ccasaro5', '000000016', 'gfilipson6');
INSERT INTO Open_table VALUES('tsolan9', '000000017', 'pstoile0');
INSERT INTO Open_table VALUES('lpatriskson3', '000000018', 'gfilipson6');
| true |
b47f87395e1f80c5484aade188e173eddd9b2ad3 | SQL | Jlima2016306/Tonys-kinal | /base de datos/DBTonysKinal2016306_.sql | UTF-8 | 34,359 | 3.640625 | 4 | [] | no_license | #Julio Samuel Isaac Lima Donis
drop database if exists DBTonysKinal2016306;
create database DBTonysKinal2016306;
use DBTonysKinal2016306;
###########################################################
###########################################################
################ EMPRESAS ############################
###########################################################
###########################################################
###########################################################
###tabla###
CREATE TABLE Empresas (
codigoEmpresa INT NOT NULL auto_increment,
nombreEmpresa VARCHAR(150) NOT NULL,
direccion VARCHAR(150) NOT NULL,
telefono VARCHAR(10) NOT NULL,
PRIMARY KEY Pk_codigoEmpresa (codigoEmpresa)
);
###Procedimientos###
#Listar
###########################################################
Delimiter $
create Procedure sp_ListarEmpresas(
)
begin
select
Empresas.codigoEmpresa,
Empresas.nombreEmpresa,
Empresas.direccion,
Empresas.telefono
From
Empresas;
end $
delimiter ;
#Agregar
###########################################################
Delimiter $
create Procedure sp_AgregarEmpresas(
in nombreEmpresa varchar(150),
in direccion varchar(150),
in telefono varchar(10)
)
begin
insert into Empresas(nombreEmpresa,Direccion,telefono)
value(nombreEmpresa,Direccion,telefono );
end $
delimiter ;
#Actualizar
###########################################################
Delimiter $
create Procedure sp_ActualizarEmpresas(
in Codigo int,
in CnombreEmpresa varchar(150),
in Cdireccion varchar(150),
in Ctelefono varchar(10)
)
begin
update empresas set empresas.nombreEmpresa=CNombreEmpresa,
empresas.Direccion=Cdireccion,
empresas.Telefono= Ctelefono
where codigoEmpresa=Codigo;
end $
delimiter ;
#Eliminar
###########################################################
Delimiter $
create Procedure sp_EliminarEmpresas(
in CCodigoEmpresa int
)
begin
delete from empresas where CodigoEmpresa=CCodigoEmpresa;
end $
delimiter ;
#Buscar
###########################################################
Delimiter $
create Procedure sp_BuscarEmpresas(
in CCodigoEmpresa int
)
begin
select
Empresas.CodigoEmpresa,
Empresas.nombreEmpresa,
Empresas.Direccion,
Empresas.Telefono
From
Empresas
where
Empresas.CodigoEmpresa=CCodigoEmpresa;
end $
delimiter ;
call sp_BuscarEmpresas(1);
call sp_AgregarEmpresas("Carnitas Chepe","7ma Avenida 11va calle zona 2","11111112");
call sp_AgregarEmpresas("Arnolds Pizza","8va calle zona 5","00004123");
call sp_AgregarEmpresas("Delish Lima","7ma calle zona 21","50560000");
call sp_AgregarEmpresas("La casa del tocino","12va avenida zona 23","14562135");
call sp_AgregarEmpresas("Los 12 platillos","9na Avenida 12va calle zona 3","00004212");
call sp_ListarEmpresas();
###########################################################
###########################################################
################ PRESUPUESTO ############################
###########################################################
###########################################################
###########################################################
#Tablas
###########################################################
create table Presupuesto(
codigoPresupuesto int not null auto_increment,
fechaSolicitud date not null,
cantidadPresupuesto decimal(10,2) not null,
codigoEmpresa INT not null,
primary key PK_codigoPresupuesto (codigoPresupuesto),
Constraint FK_Presupuesto_Empresas foreign key (codigoEmpresa) references Empresas(CodigoEmpresa)
);
###Procedimientos###
#Listar
###########################################################
Delimiter $
create procedure sp_ListarPresupuesto(
)
begin
select
Presupuesto.codigoPresupuesto,
Presupuesto.fechaSolicitud,
Presupuesto.cantidadPresupuesto,
Presupuesto.codigoEmpresa
from
Presupuesto;
end$
Delimiter ;
#Agregar
###########################################################
Delimiter $
create procedure sp_AgregarPresupuesto(
in fechaSolicitud date ,
in cantidadPresupuesto decimal(10,2),
in codigoEmpresa INT
)
begin
Insert Into Presupuesto( fechaSolicitud, cantidadPresupuesto, codigoEmpresa)
values( fechaSolicitud, cantidadPresupuesto, codigoEmpresa);
end$
Delimiter ;
call sp_AgregarPresupuesto("2020-10-12", 3200.00, 1);
call sp_AgregarPresupuesto("2020-10-10", 400.00, 2);
call sp_AgregarPresupuesto("2020-9-12", 1300.00, 3);
call sp_AgregarPresupuesto("2020-5-30", 200.00, 4);
call sp_AgregarPresupuesto("2020-4-28", 200.00, 5);
call sp_ListarPresupuesto();
#Actualizar
###########################################################
Delimiter $
create procedure sp_ActualizarPresupuesto(
in Codigo int ,
in CfechaSolicitud date ,
in CcantidadPresupuesto decimal(10,2),
in CcodigoEmpresa INT
)
begin
update Presupuesto set
Presupuesto.fechaSolicitud=CfechaSolicitud,
Presupuesto.cantidadPresupuesto=CcantidadPresupuesto,
Presupuesto.codigoEmpresa=CcodigoEmpresa
where
codigoPresupuesto=Codigo;
end$
Delimiter ;
call sp_ActualizarPresupuesto(4,"10-10-2",100,1);
#Eliminar
###########################################################
Delimiter $
create procedure sp_EliminarPresupuesto(
in CcodigoPresupuesto int
)
begin
delete from
Presupuesto
where
codigoPresupuesto=CcodigoPresupuesto;
end$
Delimiter ;
#Buscar
###########################################################
Delimiter $
create procedure sp_BuscarPresupuesto(
in CcodigoPresupuesto int
)
begin
select
Presupuesto.CodigoPresupuesto,
Presupuesto.FechaSolicitud,
Presupuesto.CantidadPresupuesto,
Presupuesto.CodigoEmpresa
from
Presupuesto
where
codigoPresupuesto=CcodigoPresupuesto ;
end$
Delimiter ;
###########################################################
###########################################################
####################SERVICIOS ###########################
###########################################################
###########################################################
###########################################################
CREATE TABLE Servicios (
codigoServicio INT NOT NULL auto_increment,
fechaServivio DATE NOT NULL,
tipoServicio VARCHAR(100) NOT NULL,
horaServicio TIME NOT NULL,
lugarServicio VARCHAR(100) NOT NULL,
telefonoContacto VARCHAR(10) NOT NULL,
codigoEmpresa INT not null,
PRIMARY KEY PK_codigoServicio (codigoServicio),
CONSTRAINT FK_Servicios_Empresas FOREIGN KEY (codigoEmpresa)
REFERENCES Empresas (codigoEmpresa)
);
###Procedimientos###
#Listar
Delimiter $
create procedure sp_ListarServicios(
)
begin
select
Servicios.codigoServicio,
Servicios.fechaServivio,
Servicios.tipoServicio,
Servicios.horaServicio,
Servicios.lugarServicio,
Servicios.telefonoContacto,
Servicios.codigoEmpresa
from
Servicios;
end $
Delimiter ;
#Agregar
Delimiter $
create Procedure sp_AgregarServicios(
in fechaServivio date,
in tipoServicio varchar(200),
in horaServicio time,
in lugarServicio varchar(200),
in telefonoContacto varchar(200),
in codigoEmpresa int
)
begin
insert into Servicios(fechaServivio, tipoServicio, horaServicio, lugarServicio, telefonoContacto, codigoEmpresa)
values(fechaServivio, tipoServicio, horaServicio, lugarServicio, telefonoContacto, codigoEmpresa);
end $
Delimiter ;
call sp_AgregarServicios("20/10/12", "Desayuno","6:00:00","Mixco", "1265 4564",1);
call sp_AgregarServicios("20/12/12", "Armuerzo","12:00:00","Ciudad de Guatemala", "3225 4564",2);
call sp_AgregarServicios("20/9/12", "Cena","18:00:00","Mixco", "1441 4874",3);
call sp_AgregarServicios("20/8/12", "Refaccion","16:00:00","Ciudad de Guatemala", "3265 4764",4);
call sp_AgregarServicios("20/7/12", "Postre","8:00:00","Ciudad de guatemala", "2245 2264",5);
#Actualizar
Delimiter $
create Procedure sp_ActualizarServicios(
in Codigo int,
in CfechaServivio date,
in CtipoServicio varchar(200),
in ChoraServicio time,
in ClugarServicio varchar(200),
in CtelefonoContacto varchar(200),
in CcodigoEmpresa int
)
begin
update Servicios set
Servicios.fechaServivio=CfechaServivio,
Servicios.tipoServicio=CtipoServicio,
Servicios.horaServicio=ChoraServicio,
Servicios.lugarServicio=ClugarServicio,
Servicios.telefonoContacto=CtelefonoContacto,
Servicios.codigoEmpresa=CcodigoEmpresa
where
Servicios.codigoServicio=Codigo;
end $
Delimiter ;
#Eliminar
Delimiter $
create procedure sp_EliminarServicios(
in CcodigoServicio int
)
begin
delete
from
Servicios
where
Servicios.CodigoServicio=CcodigoServicio;
end $
Delimiter ;
#Buscar
Delimiter $
create procedure sp_BuscarServicios(
in CcodigoServicio int
)
begin
select
Servicios.codigoServicio,
Servicios.fechaServivio,
Servicios.tipoServicio,
Servicios.horaServicio,
Servicios.lugarServicio,
Servicios.telefonoContacto,
Servicios.codigoEmpresa
from
Servicios
where
Servicios.CodigoServicio=CcodigoServicio;
end $
Delimiter ;
###########################################################
###########################################################
################ TIPOEMPLEADO ####################
###########################################################
###########################################################
###########################################################
CREATE TABLE TipoEmpleado (
codigoTipoEmpleado INT NOT NULL auto_increment,
descripcion VARCHAR(100) NOT NULL,
PRIMARY KEY PK_codigoTipoEmpleado (codigoTipoEmpleado)
);
###Procedimientos###
#Listar
###########################################################
Delimiter $
create Procedure sp_ListarTipoEmpleado(
)
begin
select
TipoEmpleado.codigoTipoEmpleado,
TipoEmpleado.descripcion
from
TipoEmpleado;
end $
Delimiter ;
#Agregar
###########################################################
Delimiter $
create Procedure sp_AgregarTipoEmpleado(
in Descripcion varchar(100)
)
begin
insert into TipoEmpleado(Descripcion)
values(Descripcion);
end $
Delimiter ;
call sp_AgregarTipoEmpleado("Chef");
call sp_AgregarTipoEmpleado(" Chef Ejecutivo");
call sp_AgregarTipoEmpleado("co Chef");
call sp_AgregarTipoEmpleado("Mesero");
call sp_AgregarTipoEmpleado("Lavaplatos");
#Actualizar
###########################################################
Delimiter $
create Procedure sp_ActualizarTipoEmpleado(
in Codigo int,
in CDescripcion varchar(100)
)
begin
update TipoEmpleado set TipoEmpleado.Descripcion=CDescripcion where TipoEmpleado.CodigoTipoEmpleado=Codigo;
end $
Delimiter ;
#Eliminar
###########################################################
Delimiter $
create Procedure sp_EliminarTipoEmpleado(
in CCodigoTipoEmpleado int
)
begin
delete
from
TipoEmpleado
where
TipoEmpleado.CodigoTipoEmpleado=CCodigoTipoEmpleado;
end $
Delimiter ;
#Buscar
###########################################################
Delimiter $
create Procedure sp_BuscarTipoEmpleado(
in CCodigoTipoEmpleado int
)
begin
select
TipoEmpleado.codigoTipoEmpleado,
TipoEmpleado.descripcion
from
TipoEmpleado
where
TipoEmpleado.CodigoTipoEmpleado=CCodigoTipoEmpleado;
end $
Delimiter ;
###########################################################
###########################################################
################ EMPLEADOS ###########################
###########################################################
###########################################################
###########################################################
create table Empleados(
codigoEmpleado int not null auto_increment,
numeroEmpleado int not null,
apellidosEmpleado varchar(150) not null,
nombresEmpleado varchar(150) not null,
direccionEmpleado Varchar(150) not null,
telefonoContacto varchar(10) not null,
gradoCocinero varchar(50) ,
codigoTipoEmpleado int not null,
primary key PK_codigoEmpleado (codigoEmpleado),
Constraint FK_Empleados_TipoEmpleado
foreign key (CodigoTipoEmpleado) references TipoEmpleado(CodigoTipoEmpleado)
);
###Procedimientos###
#Listar
###########################################################
Delimiter $
Create Procedure sp_ListarEmpleados(
)
begin
select
Empleados.codigoEmpleado,
Empleados.numeroEmpleado,
Empleados.apellidosEmpleado,
Empleados.nombresEmpleado,
Empleados.direccionEmpleado,
Empleados.telefonoContacto,
Empleados.gradoCocinero,
Empleados.codigoTipoEmpleado
From
Empleados;
end $
Delimiter ;
#Agregar
###########################################################
Delimiter $
Create Procedure sp_AgregarEmpleados(
in numeroEmpleado int,
in apellidosEmpleado varchar(150),
in nombresEmpleado varchar(150),
in direccionEmpleado varchar(150),
in telefonoContacto varchar(10),
in gradoCocinero varchar(50),
in codigoTipoEmpleado int
)
begin
Insert into Empleados(numeroEmpleado, apellidosEmpleado, nombresEmpleado, direccionEmpleado, telefonoContacto, gradoCocinero, codigoTipoEmpleado)
Values(numeroEmpleado, apellidosEmpleado, nombresEmpleado, direccionEmpleado, telefonoContacto, gradoCocinero, codigoTipoEmpleado);
end $
Delimiter ;
#Actualizar
###########################################################
Delimiter $
create procedure sp_ActualizarEmpleados(
in Codigo int,
in CnumeroEmpleado int,
in CapellidosEmpleado varchar(150),
in CnombresEmpleado varchar(150),
in CdireccionEmpleado varchar(150),
in CtelefonoContacto varchar(10),
in CgradoCocinero varchar(50),
in CcodigoTipoEmpleado int
)
Begin
Update Empleados set Empleados.numeroEmpleado = CnumeroEmpleado,
Empleados.apellidosEmpleado = CapellidosEmpleado,
Empleados.nombresEmpleado = CnombresEmpleado,
Empleados.direccionEmpleado = CdireccionEmpleado,
Empleados.telefonoContacto = CtelefonoContacto,
Empleados.gradoCocinero = CgradoCocinero,
Empleados.codigoTipoEmpleado = CcodigoTipoEmpleado
where
Empleados.codigoEmpleado = Codigo ;
end $
Delimiter ;
#Eliminar
###########################################################
Delimiter $
create Procedure sp_EliminarEmpleados(
in CcodigoEmpleado int
)
begin
Delete
from
Empleados
where
Empleados.codigoEmpleado= CcodigoEmpleado;
end $
Delimiter ;
#Buscar
###########################################################
Delimiter $
Create Procedure sp_BuscarEmpleados(
in CcodigoEmpleado int
)
begin
select
Empleados.codigoEmpleado,
Empleados.numeroEmpleado,
Empleados.apellidosEmpleado,
Empleados.nombresEmpleado,
Empleados.direccionEmpleado,
Empleados.telefonoContacto,
Empleados.gradoCocinero,
Empleados.codigoTipoEmpleado
From
Empleados
where
Empleados.codigoEmpleado= CcodigoEmpleado;
end $
Delimiter ;
call sp_AgregarEmpleados(1,"Lima Donis","Julio Samuel","4to avenida ","4561 4682", "Alta cocina",1);
call sp_AgregarEmpleados(22,"Fernandez Lopéz","Armando Joel","5to avenida ","2231 2385", "Alta cocina",2);
call sp_AgregarEmpleados(33,"Ordoñes Jors"," Jasuel","9to avenida ","6761 4682", "Media cocina",3);
call sp_AgregarEmpleados(42,"Villa toro","James","7ma avenida ","4856 9582", "Ninguno",4);
call sp_AgregarEmpleados(52,"Pan y Agua ","Javier","9nao avenida ","4879 4672", "Ninguno",5);
###########################################################
###########################################################
########### SERVICIOS_HAS_EMPLEADOS #################
###########################################################
###########################################################
###########################################################
create table Servicios_has_Empleados(
Servicios_codigoServicios int auto_increment,
codigoServicio INT,
codigoEmpleado int,
fechaEvento date not null,
horaEvento time not null,
lugarEvento Varchar(150) not null,
primary key PK_Servicios_codigoServicios(Servicios_codigoServicios),
constraint FK_Servicios_has_empleados_Servicios foreign key (CodigoServicio) references Servicios(codigoServicio) ON DELETE cascade,
constraint FK_Servicios_has_empleados_Empleados foreign key (CodigoEmpleado) references Empleados(codigoEmpleado) on delete cascade
);
###Procedimientos###
#Listar
###########################################################
Delimiter $
create Procedure sp_ListarServicios_has_Empleados(
)
begin
select
Servicios_has_Empleados.Servicios_codigoServicios,
Servicios_has_Empleados.codigoServicio,
Servicios_has_Empleados.codigoEmpleado,
Servicios_has_Empleados.fechaEvento,
Servicios_has_Empleados.horaEvento,
Servicios_has_Empleados.lugarEvento
from
Servicios_has_Empleados;
end$
Delimiter ;
call
#Agregar
###########################################################
Delimiter $
create Procedure sp_AgregarServicios_has_Empleados(
in Servicios_codigoServicio int,
in Empleados_codigoEmpleados int,
in fechaEvento date ,
in horaEvento time,
in lugarEvento varchar(150)
)
begin
insert into Servicios_has_Empleados(codigoServicio, codigoEmpleado, fechaEvento, horaEvento, lugarEvento)
values(Servicios_codigoServicio, Empleados_codigoEmpleados, fechaEvento, horaEvento, lugarEvento);
end$
Delimiter ;
CALL sp_AgregarServicios_has_Empleados(1,1,"20/1/12",now(), "Mixco");
CALL sp_AgregarServicios_has_Empleados(2,2,"20/4/12",now(), "Guatemala");
CALL sp_AgregarServicios_has_Empleados(3,3,"20/6/12",now(), "Mixco");
CALL sp_AgregarServicios_has_Empleados(4,4,"20/8/12",now(), "Guatemala");
CALL sp_AgregarServicios_has_Empleados(5,5,"20/12/12",now(), "villa Nueva");
#Actualizar
###########################################################
Delimiter $
Create Procedure sp_ActualizarServicios_has_empleados(
in Codigo int,
in CCodigoServicio int,
in CEmpleados_codigoEmpleados int,
in CfechaEvento date ,
in ChoraEvento time,
in ClugarEvento varchar(150)
)
begin
Update Servicios_has_empleados set
servicios_has_empleados.codigoServicio= CCodigoServicio,
Servicios_has_empleados.CodigoEmpleado=CEmpleados_codigoEmpleados,
Servicios_has_empleados.fechaEvento=CfechaEvento,
Servicios_has_empleados.horaEvento=ChoraEvento,
Servicios_has_empleados.lugarEvento=ClugarEvento
where
Servicios_has_empleados.Servicios_codigoServicios=Codigo;
end $
Delimiter ;
#Eliminar
###########################################################
Delimiter $
create Procedure sp_EliminarServicios_has_Empleados(
in CServicios_codigoServicios int
)
begin
delete
from
Servicios_has_Empleados
where
Servicios_has_empleados.Servicios_codigoServicios=CServicios_codigoServicios;
end$
Delimiter ;
#Buscar
###########################################################
Delimiter $
create Procedure sp_BuscarServicios_has_Empleados(
in CServicios_codigoServicio int
)
begin
select
Servicios_has_Empleados.codigoServicio,
Servicios_has_Empleados.codigoEmpleados,
Servicios_has_Empleados.fechaEvento,
Servicios_has_Empleados.horaEvento,
Servicios_has_Empleados.lugarEvento
from
Servicios_has_Empleados
where
Servicios_has_empleados.Servicios_codigoServicios=CServicios_codigoServicio;
end$
Delimiter ;
###########################################################
###########################################################
############### PRODUCTOS #################
###########################################################
###########################################################
###########################################################
create table Productos(
codigoProducto int not null auto_increment,
nombreProducto varchar(150) not null,
cantidad int,
primary key PK_codigoProducto (codigoProducto)
);
###Procedimientos###
#Listar
###########################################################
Delimiter $
create Procedure sp_ListarProductos(
)
Begin
select
Productos.codigoProducto,
Productos.nombreProducto,
Productos.cantidad
from
Productos;
end $
Delimiter ;
#Agregar
###########################################################
Delimiter $
create Procedure sp_AgregarProductos(
in nombreProducto varchar(150) ,
in cantidad int
)
Begin
insert into Productos(nombreProducto, cantidad)
value(nombreProducto, cantidad);
end $
Delimiter ;
call sp_AgregarProductos("Camarones", 14);
call sp_AgregarProductos("Bistec", 14);
call sp_AgregarProductos("Pollo", 12);
call sp_AgregarProductos("Café", 4);
call sp_AgregarProductos("Pescado", 4);
#Actualizar
###########################################################
Delimiter $
create Procedure sp_ActualizarProductos(
in Codigo int,
in CnombreProducto varchar(150) ,
in Ccantidad int
)
Begin
update Productos set Productos.nombreProducto=CnombreProducto,
Productos.cantidad=Ccantidad
where
Productos.CodigoProducto=Codigo;
end $
Delimiter ;
#Eliminar
###########################################################
Delimiter $
create Procedure sp_EliminarProductos(
in CcodigoProducto int
)
Begin
delete
from
Productos
where
Productos.CodigoProducto=CCodigoProducto;
end $
Delimiter ;
#Buscar
###########################################################
Delimiter $
create Procedure sp_BuscarProductos(
in CcodigoProducto int
)
Begin
select
Productos.codigoProducto,
Productos.nombreProducto,
Productos.cantidad
from
Productos
where
Productos.CodigoProducto=CCodigoProducto;
end $
Delimiter ;
###########################################################
###########################################################
################ TIPOPLATO ###########################
###########################################################
###########################################################
###########################################################
create table TipoPlato(
codigoTipoPlato INT not null auto_increment,
descripcionTipo varchar(100) not null,
primary key PK_codigoTipoPlato (codigoTipoPlato)
);
###Procedimientos###
#Listar
###########################################################
Delimiter $
create Procedure sp_ListarTipoPlato(
)
begin
select
TipoPlato.codigoTipoPlato,
TipoPlato.descripcionTipo
from
TipoPlato;
end $
Delimiter ;
#Agregar
###########################################################
Delimiter $
create Procedure sp_AgregarTipoPlato(
in DescripcionTipo varchar(100)
)
begin
insert into TipoPlato(DescripcionTipo)
values(DescripcionTipo);
end $
Delimiter ;
#Actualizar
###########################################################
Delimiter $
create Procedure sp_ActualizarTipoPlato(
in Codigo int,
in CDescripcionTipo varchar(100)
)
begin
update TipoPlato set TipoPlato.DescripcionTipo=CDescripcionTipo where TipoPlato.CodigoTipoPlato=Codigo;
end $
Delimiter ;
#Eliminar
###########################################################
Delimiter $
create Procedure sp_EliminarTipoPlato(
in CCodigoTipoPlato int
)
begin
delete
from
TipoPlato
where
TipoPlato.CodigoTipoPlato=CCodigoTipoPlato;
end $
Delimiter ;
#Buscar
###########################################################
Delimiter $
create Procedure sp_BuscarTipoPlato(
in CCodigoTipoPlato int
)
begin
select
TipoPlato.codigoTipoPlato,
tipoplato.descripcionTipo
from
TipoPlato
where
TipoPlato.CodigoTipoPlato=CCodigoTipoPlato;
end $
Delimiter ;
call sp_AgregarTipoPlato("Mariscos");
call sp_AgregarTipoPlato("Azados");
call sp_AgregarTipoPlato("Fritos");
call sp_AgregarTipoPlato("Café");
call sp_AgregarTipoPlato("Caldos");
###########################################################
###########################################################
################ PLATOS ###########################
###########################################################
###########################################################
###########################################################
create table Platos(
codigoPlato int not null auto_increment,
cantidad int not null ,
nombrePlato varchar(150) not null,
descripcionPlato varchar(150) not null,
precioPlato DECIMAL (10.2) not null,
codigoTipoPlato INT,
primary key PK_codigoPlato (codigoPlato),
constraint FK_Platos_TipoPlato foreign key (codigoTipoPlato) references Tipoplato(codigotipoPlato)
);
###Procedimientos###
#Listar
###########################################################
Delimiter $
create procedure sp_ListarPlatos(
)
begin
select
Platos.codigoPlato,
Platos.cantidad,
Platos.nombrePlato,
Platos.descripcionPlato,
Platos.precioPlato ,
Platos.codigoTipoPlato
from
Platos;
end$
Delimiter ;
#Agregar
###########################################################
Delimiter $
create procedure sp_AgregarPlatos(
in cantidad int ,
in nombrePlato varchar(150) ,
in descripcionPlato varchar(150) ,
in precioPlato DECIMAL (10.2) ,
in codigoTipoPlato INT
)
begin
insert into Platos( cantidad, nombrePlato, descripcionPlato, precioPlato, codigoTipoPlato)
values( cantidad, nombrePlato, descripcionPlato, precioPlato, codigoTipoPlato);
end$
Delimiter ;
call sp_AgregarPlatos(12,"Camarones al agio", "Camarones sofreidos en aceite de oliva con la mezcla secreta de agio",30,1);
call sp_AgregarPlatos(12,"Pollo frito", "Pollo freido a alta temperatura",20,2);
call sp_AgregarPlatos(12,"Bistec azado", " Bistec Azado a alta temperatura",20,3);
call sp_AgregarPlatos(12,"Café con cremora", "Café Hervido con cremora",20,4);
call sp_AgregarPlatos(12,"Pescado azado", "Pescado azado a las brazas con salsas de tomate e inglesas",40,5);
#Actualizar
###########################################################
delimiter $
create procedure sp_ActualizarPlatos(
in Codigo int,
in Ccantidad int ,
in CnombrePlato varchar(150),
in CdescripcionPlato varchar(150) ,
in CprecioPlato DECIMAL (10.2) ,
in CcodigoTipoPlato INT
)
begin
update Platos set
Platos.cantidad=Ccantidad,
Platos.nombrePlato=CnombrePlato,
Platos.descripcionPlato=CdescripcionPlato,
Platos.precioPlato=CprecioPlato,
Platos.codigoTipoPlato=CcodigoTipoPlato
where
Platos.codigoPlato=Codigo ;
end$
Delimiter ;
#Eliminar
###########################################################
delimiter $
create procedure sp_EliminarPlatos(
in CcodigoPlato int
)
begin
delete
from
Platos
where
Platos.codigoPlato=CcodigoPlato ;
end$
Delimiter ;
#Buscar
###########################################################
Delimiter $
create procedure sp_BuscarPlatos(
in CcodigoPlato int
)
begin
select
Platos.codigoPlato,
Platos.cantidad,
Platos.nombrePlato,
Platos.descripcionPlato,
Platos.precioPlato ,
Platos.codigoTipoPlato
from
Platos
where
Platos.codigoPlato=CcodigoPlato ;
end$
Delimiter ;
###########################################################
###########################################################
############ PRODUCTOS_HAS_PLATOS ##############
###########################################################
###########################################################
###########################################################
create table Productos_has_Platos(
codigoProductos int,
CodigoPlato int,
constraint FK_Productos_has_platos_Productos foreign key (codigoProductos) references Productos(codigoProducto),
constraint FK_Productos_has_platos_Platos foreign key (CodigoPlato) references Platos(codigoPlato)
);
###Procedimientos###
#Listar
###########################################################
delimiter $
create procedure sp_ListarProductos_has_Platos(
)
begin
select productos.codigoProducto, platos.codigoplato from productos, platos
where codigoProducto = codigoProducto and CodigoPlato = CodigoPlato;
end $
delimiter ;
#Agregar
###########################################################
delimiter $
create procedure sp_AgregarProductos_has_Platos(
in Productos_codigoProductos int,
in Platos_CodigoPlato int
)
begin
insert into Productos_has_Platos(Productos_codigoProductos,Platos_CodigoPlato)
value(Productos_codigoProductos,Platos_CodigoPlato);
end $
delimiter ;
#Actualizar
###########################################################
delimiter $
create procedure sp_ActualizarProductos_has_Platos(
in Codigo int,
in CPlatos_CodigoPlato int
)
begin
update Productos_has_Platos set
Productos_has_Platos.Platos_CodigoPlato=CPlatos_CodigoPlato
where
Productos_has_Platos.Productos_codigoProductos= Codigo;
end $
delimiter ;
#Eliminar
###########################################################
delimiter $
create procedure sp_EliminarProductos_has_Platos(
in CProductos_codigoProductos int
)
begin
Delete
from
Productos_has_Platos
where
Productos_has_Platos.Productos_codigoProductos=CProductos_codigoProductos;
end $
delimiter ;
#Buscar
###########################################################
delimiter $
create procedure sp_BuscarProductos_has_Platos(
in CProductos_codigoProductos int
)
begin
select
Productos_has_Platos.Productos_codigoProductos,
Productos_has_Platos.Platos_CodigoPlato
from
Productos_has_Platos
where
Productos_has_Platos.Productos_codigoProductos=CProductos_codigoProductos;
end $
delimiter ;
###########################################################
###########################################################
############# SERVICIOs_HAS_PLATOS #############
###########################################################
###########################################################
###########################################################
create table Servicios_has_Platos(
codigoServicio INT,
CodigoPlato int,
constraint FK_Servicios_has_platos_Servicios foreign key (codigoServicio) references Servicios(codigoServicio),
constraint FK_Servicios_has_platos_Platos foreign key (CodigoPlato) references Platos(codigoPlato)
);
###Procedimientos###
#Listar
###########################################################
delimiter $
create procedure sp_ListarServicios_has_Platos(
)
begin
select
c1.codigoServicio, c2.codigoPlato from
(select s.codigoServicio as codigoServicio from servicios s
left join servicios_has_platos shp on shp.codigoServicio= s.codigoServicio) c1,
(select pl.codigoPlato as codigoPlato from platos pl
left join servicios_has_Platos shp on shp.codigoPlato = pl.codigoPlato) c2 ;
end $
delimiter ;
#Agregar
###########################################################
delimiter $
create procedure sp_AgregarServicios_has_Platos(
in codigoServicios int,
in CodigoPlato int
)
begin
insert into Servicios_has_Platos(codigoServicios,CodigoPlato)
value(codigoServicios,CodigoPlato);
end $
delimiter ;
#Actualizar
###########################################################
delimiter $
create procedure sp_ActualizarServicios_has_Platos(
in Codigo int,
in CPlatos_CodigoPlato int
)
delimiter ;
#Eliminar
###########################################################
delimiter $
create procedure sp_EliminarServicios_has_Platos(
in CServicios_codigoServicios int
)
delimiter ;
#Buscar
###########################################################
delimiter $
create procedure sp_BuscarServicios_has_Platos(
in CServicios_codigoServicios int
)
begin
select
Servicios_has_Platos.Servicios_codigoServicios,
Servicios_has_Platos.Platos_CodigoPlato
from
Servicios_has_Platos
where
Servicios_has_Platos.Servicios_codigoServicios=CServicios_codigoServicios;
end $
delimiter ;
#reportes
###########################################################
Delimiter $
Create procedure sp_ListarReporte (in codEmpresa int)
begin
select *
from empresas E inner join presupuesto P on
E.codigoEmpresa= P.codigoEmpresa
inner join Servicios S on
E.codigoEmpresa= S.codigoEmpresa
where E.codigoEmpresa = codEmpresa order by P.cantidadPresupuesto;
end$
delimiter ;
delimiter $
create procedure sp_ListarReporteServi (in codServicios int)
begin
select S.tipoServicio,Pl.cantidad, Tp.descripcionTipo, Pr.nombreProducto from TipoPlato as Tp
inner join Platos as Pl on
Tp.codigoTipoPlato = Pl.codigoTipoPlato
inner join Servicios as S on
Pl.codigoTipoPlato = S.codigoServicio
inner join Productos as Pr
where S.codigoServicio = codServicios ;
end$
delimiter ;
call sp_ListarReporteServi(3);
ALTER USER 'root'@'localhost' identified WITH mysql_native_password BY 'admin'; | true |
bfdd5db3c2c05ab7895747bae0501e80aa1a19a6 | SQL | seeRoseCode/SQL-bear-organizer-lab-atlanta-web-042219 | /lib/insert.sql | UTF-8 | 995 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
INSERT INTO bears(name, age, gender, color, temperament, alive)
VALUES ("Mr. Chocolate", 5, "male", "brown", "hungry", TRUE);
INSERT INTO bears(name, age, gender, color, temperament, alive)
VALUES ("Rowdy", 1, "male", "black", "hungry", TRUE);
INSERT INTO bears(name, age, gender, color, temperament, alive)
VALUES ("Tabitha", 10, "female", "light brown", "calm", TRUE);
INSERT INTO bears(name, age, gender, color, temperament, alive)
VALUES ("Sergeant Brown", 1, "male", "dark brown", "playful", TRUE);
INSERT INTO bears(name, age, gender, color, temperament, alive)
VALUES ("Melissa", 5, "female", "light brown", "lazy", FALSE);
INSERT INTO bears(name, age, gender, color, temperament, alive)
VALUES ("Grinch", 9, "male", "white", "aggressive", TRUE);
INSERT INTO bears(name, age, gender, color, temperament, alive)
VALUES ("Wendy", 3, "female", "black", "sweet", TRUE);
INSERT INTO bears(name, age, gender, color, temperament, alive)
VALUES (null, 3, "female", "brown", "aggressive", FALSE);
| true |
feb4a1ec32ed7f2200923d2568ed7af251b2391c | SQL | ProgRB/SalProject | /AddRetention/Queries/Rep_SalaryTransferImportToXml.sql | WINDOWS-1251 | 3,269 | 3.265625 | 3 | [] | no_license | with v_cartulary as
(
select owner_family, owner_name, owner_middle_name, number_account,
sum(sum_sal) sum_sal
from
{1}.view_SALARY_transfer
join {0}.transfer using (transfer_id)
join {1}.client_account using (client_account_id)
join {1}.type_bank using (type_bank_id)
where
cartulary_id = :p_cartulary_id
and nvl(custom_sign,0)=0
and TRN=:p_TRN
group by number_account, OWNER_FAMILY, OWNER_NAME, OWNER_MIDDLE_NAME
having sum(sum_sal)!=0
order by owner_family, owner_name, owner_middle_name
)
select
XMLSERIALIZE(DOCUMENT
XMLRoot(
XMLElement( "",
XMLAttributes(
sysdate as "",
'09160017' as "",
' -' as "",
'0323018510' as "",
(select max(CURRENT_ACCOUNT) keep (dense_rank FIRST order by BANK_OFFICE) FROM {1}.TYPE_BANK WHERE TRN=:p_TRN and custom_sign=0) as "",
' ' as "",
(select CARTULARY_NUM from {1}.CARTULARY where cartulary_id=:p_cartulary_id) as "",
(select DATE_CLOSE_CART from {1}.CARTULARY where cartulary_id=:p_cartulary_id) as ""
),
(select XMLElement("",
XMLAgg(
XMLElement("",
XMLAttributes(rownum as ""),
XMLForest(trim(owner_family) as "",
trim(owner_name) as "",
trim(owner_middle_name) as "",
'8601' as "",
'8601' as "",
number_account as "",
sum_sal as "")
)
)
)
from v_cartulary
),
xmlElement("", '01'),
xmlElement("", ' '),
xmlElement("", sysdate),
xmlElement("", (select xmlForest(count(distinct number_account) as "", sum(sum_sal) as "") from v_cartulary))
), VERSION '1.0" encoding="windows-1251', STANDALONE YES)
as CLOB VERSION '1.0' INDENT SIZE=4 )
as XML
from dual | true |
ef0d79cb72154a81b4ef4e523b811a93b64bbbee | SQL | smarek/dotacni-parazit | /SQL/splatka_kalendar.sql | UTF-8 | 869 | 3.375 | 3 | [] | no_license | CREATE TABLE `splatka_kalendar` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`about` varchar(150) COLLATE utf8_bin NOT NULL,
`castkaSplatkaPlanovana` decimal(10,2) DEFAULT NULL,
`castkaSplatkaSkutecna` decimal(10,2) NOT NULL,
`uroceniIndikator` varchar(5) COLLATE utf8_bin DEFAULT NULL,
`zaznamAktualizaceDatumCas` datetime DEFAULT NULL,
`zaznamIdentifikator` varchar(50) COLLATE utf8_bin NOT NULL,
`modified` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `about` (`about`),
UNIQUE KEY `zaznamIdentifikator` (`zaznamIdentifikator`),
KEY `zaznamAktualizaceDatumCas` (`zaznamAktualizaceDatumCas`),
KEY `uroceniIndikator` (`uroceniIndikator`),
KEY `castkaSplatkaSkutecna` (`castkaSplatkaSkutecna`),
KEY `castkaSplatkaPlanovana` (`castkaSplatkaPlanovana`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_bin
| true |
2b147cc9a0e830326438b1fe115de1c3126fb058 | SQL | marksniper/SpringHibernateSemantic | /db/createDBFromModel.sql | UTF-8 | 3,907 | 3.375 | 3 | [
"MIT"
] | permissive | -- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema DATABASE
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema DATABASE
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `DATABASE` ;
USE `DATABASE` ;
-- -----------------------------------------------------
-- Table `DATABASE`.`USER`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DATABASE`.`USER` (
`idUSER` INT NOT NULL AUTO_INCREMENT,
`firstName` VARCHAR(45) NOT NULL,
`lastName` VARCHAR(45) NOT NULL,
`dateRegistration` DATETIME NULL,
`username` VARCHAR(45) NOT NULL,
`password` BLOB NOT NULL,
`token` BLOB NULL,
`isActive` TINYINT NOT NULL,
PRIMARY KEY (`idUSER`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DATABASE`.`CUSTOMER`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DATABASE`.`CUSTOMER` (
`idCUSTOMER` INT NOT NULL,
`USER_idUSER` INT NOT NULL,
`address` VARCHAR(45) NULL,
`city` VARCHAR(45) NULL,
`zipcode` VARCHAR(10) NULL,
PRIMARY KEY (`idCUSTOMER`),
INDEX `fk_CUSTOMER_USER_idx` (`USER_idUSER` ASC) VISIBLE,
CONSTRAINT `fk_CUSTOMER_USER`
FOREIGN KEY (`USER_idUSER`)
REFERENCES `DATABASE`.`USER` (`idUSER`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DATABASE`.`EMPLOYEE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DATABASE`.`EMPLOYEE` (
`idEMPLOYEE` INT NOT NULL,
`salary` VARCHAR(45) NULL,
`USER_idUSER` INT NOT NULL,
PRIMARY KEY (`idEMPLOYEE`),
INDEX `fk_EMPLOYEE_USER1_idx` (`USER_idUSER` ASC) VISIBLE,
CONSTRAINT `fk_EMPLOYEE_USER1`
FOREIGN KEY (`USER_idUSER`)
REFERENCES `DATABASE`.`USER` (`idUSER`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DATABASE`.`PRODUCT`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DATABASE`.`PRODUCT` (
`idproduct` INT NOT NULL,
`name` VARCHAR(45) NOT NULL,
`quantity` INT NULL,
`price` FLOAT NULL,
`dateInsert` DATETIME NULL,
`ispresent` TINYINT NOT NULL,
PRIMARY KEY (`idproduct`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `DATABASE`.`BUY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DATABASE`.`BUY` (
`CUSTOMER_idCUSTOMER` INT NOT NULL,
`PRODUCT_idproduct` INT NOT NULL,
`purchaseDate` VARCHAR(45) NULL,
PRIMARY KEY (`CUSTOMER_idCUSTOMER`, `PRODUCT_idproduct`),
INDEX `fk_product_has_CUSTOMER_CUSTOMER1_idx` (`CUSTOMER_idCUSTOMER` ASC) VISIBLE,
INDEX `fk_BUY_PRODUCT1_idx` (`PRODUCT_idproduct` ASC) VISIBLE,
CONSTRAINT `fk_product_has_CUSTOMER_CUSTOMER1`
FOREIGN KEY (`CUSTOMER_idCUSTOMER`)
REFERENCES `DATABASE`.`CUSTOMER` (`idCUSTOMER`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_BUY_PRODUCT1`
FOREIGN KEY (`PRODUCT_idproduct`)
REFERENCES `DATABASE`.`PRODUCT` (`idproduct`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
USE `DATABASE` ;
-- -----------------------------------------------------
-- routine1
-- -----------------------------------------------------
DELIMITER $$
USE `DATABASE`$$
$$
DELIMITER ;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
| true |
f971789d88546f335f85563f2c1605035ac0699d | SQL | parkseoeun5322/Class_Example | /Oracle/수업자료/2020_05_28_DB_lecture.sql | UHC | 16,336 | 4.5 | 4 | [] | no_license | ǥ : ''(Ȭǥ )
ڵͿ ¥ʹ Ȭǥ('') ǥؾ Ѵ.
ڵʹ ҹڸ Ѵ.
07. King
, ̸, μڵ ȸ
SELECT employee_id, first_name, last_name
FROM employees
WHERE last_name = 'King'; -- King;
--⺻ ¥ ȸ
ý ¥ ȯϴ Լ - SYSDATE
ٸ Լʹ ĶͰ () .
SELECT *
FROM v$nls_parameters;
SELECT VALUE
FROM NLS_SESSION_PARAMETERS
WHERE PARAMETER = 'NLS_DATE_FORMAT';
-- ¥ ȸ, dual : , ¥
SELECT SYSDATE
FROM dual;
--¥ Ͽ ڰ ϴ ڷ ٲ ȯ
SELECT TO_CHAR(SYSDATE, 'YYYY/MM/DD')
FROM dual;
SELECT TO_CHAR(SYSDATE, 'YYYY/MONTH/DD')
FROM dual;
SELECT TO_CHAR(SYSDATE, 'YYYY/MM/DD HH:MI:SS')
FROM dual;
SELECT TO_CHAR(SYSDATE, 'YYYY/MM/DD HH24:MI:SS')
FROM dual;
--⺻
ALTER SESSION SET NLS_DATE_FORMAT = [ ];
ALTER SESSION
SET NLS_DATE_FORMAT = 'YYYY/MM/DD HH24:MI:SS';
Ŭ ⺻ ǿ
SELECT SYSDATE
FROM dual; --20/10/06
ALTER SESSION
SET NLS_DATE_FORMAT = 'RR/MM/DD';
SELECT SYSDATE
FROM dual;
08. 2003 Ի
ڵ, , Իڸ ȸ
SELECT employee_id, last_name, hire_date
FROM employees
WHERE hire_date <= '2003-12-31';
--WHERE hire_date < '2004-01-01';
--WHERE hire_date < '2004/01/01';
--WHERE hire_date < '04-01-01';
--WHERE TO_CHAR(hire_date,'YYYY') < 2004;
4. :
4.1 AND : TRUE TRUE ȯѴ.
01. 30 μ 10000
ڵ, , , μڵ带 ȸѴ.
̸ ؼ ϰ 'name' Ѵ
SELECT employee_id, first_name || ' ' || last_name name, salary, department_id
FROM employees
WHERE department_id = 30
AND salary <= 10000;
02. 30 μ 10000 ̸鼭 2005 (2004) Ի
ȣ, , , μڵ, Իڸ ȸѴ.
̸ ؼ ϰ 'name' Ѵ.
SELECT employee_id, first_name || ' ' || last_name name, salary, department_id, hire_date
FROM employees
WHERE department_id = 30
AND salary <= 10000
--AND hire_date < '05-01-01';
--AND hire_date <= '05-12-31';
AND TO_CHAR(hire_date,'YYYY') <= 2004;
03. μڵ尡 10 ̻ 30
, , μڵ ȸ
̸ ؼ ϰ 'name' Ѵ
SELECT employee_id, first_name || ' ' || last_name name, department_id
FROM employees
WHERE department_id >=10
AND department_id <= 30 ;--μڵ尡 10 ̻ 30 ;
04. 10000 ̻ 15000
, , , ڵ ȸ
̸ ؼ ϰ 'name' Ѵ
SELECT employee_id, first_name || ' ' || last_name name, salary, job_id
FROM employees
WHERE salary>=10000
AND salary<=15000; -- 10000 ̻ 15000
05. μ 60 μ 5000 ̻
, , μڵ, ȸ
̸ ؼ ϰ 'name' Ѵ
SELECT employee_id, first_name || ' ' || last_name name, department_id, salary
FROM employees
WHERE department_id = 60
AND salary >= 5000;--μ 60 μ 5000 ̻
/¥ ǥ: ''
06. μڵ尡 60 ̸鼭 2003 6 17 Ի
, , Ի ȸ
̸ ؼ ϰ 'name' Ѵ
SELECT employee_id, first_name || ' ' || last_name name, hire_date
FROM employees
WHERE hire_date <= '2003-06-17' -- 2003 6 17 Ի;
AND department_id <= 60; --μڵ尡 60
4.2 OR ڴ ϳ TRUE ̸ TRUE ȯѴ.
07. 30 μ 60 μ
, , μڵ带 ȸѴ
SELECT first_name || ' ' || last_name name, salary, department_id dept_id
FROM employees
WHERE department_id = 30
OR department_id = 60;
08. μڵ尡 10, 20, 30 μ
, , μڵ, ڵ ȸ
SELECT employee_id, first_name || ' ' || last_name name, department_id, job_id
FROM employees
WHERE department_id = 10
OR department_id = 20
OR department_id = 30; --μڵ尡 10,20,30;
09. 150, 170, 190
, , μڵ, ڵ, Ի ȸ
SELECT employee_id, first_name || ' ' || last_name name, department_id, job_id, hire_date
FROM employees
WHERE employee_id = 150
OR employee_id = 170
OR employee_id = 190 ; -- 150, 170, 190 ;
4.3 AND ڿ OR ڸ ȥϿ ۼѴ.
10. 30 μ 10000̸ 60 μ 5000̻
, , μڵ ȸѴ.
SELECT first_name ||' ' ||last_name name, salary, department_id dept_id
FROM employees
WHERE department_id = 30 AND salary < 10000
OR department_id = 60 AND salary >= 5000;
AND OR ȥյǾ Ǵ ȣ ٿִ .
SELECT first_name || ' ' || last_name name, salary, department_id dept_id
FROM employees
WHERE ( department_id = 30 AND salary < 10000 )
OR ( department_id = 60 AND salary >= 5000 );
11. μڵ尡 30 μ 10000 ̸
μڵ尡 60 μ 5000 ̻
, , μڵ, ȸ
SELECT employee_id, first_name || ' ' || last_name name, department_id, salary
FROM employees
WHERE (department_id=30 AND salary<10000)
OR (department_id=60 AND salary>=5000);
--department_id=30 AND salary<10000 --μڵ尡 30 μ 10000 ̸
--OR department_id=60 AND salary>=5000; --μڵ尡 60 μ 5000 ̻
ڿ 켱 ִ
: *,/ -> +,-
: AND : -> OR :
7+(7/7)+(7*7)-7
5. BETWEEN
BETWEEN ۰ AND ۰ ̻ .
BETWEEN ̳ 迬ڷ ִ ڵ, ڵ, ¥
A̻ B: ÷ BETWEEN A AND B
A̸ Bʰ: ÷ NOT BETWEEN A AND B
NOT ÷ BETWEEN A AND B
NOT ڴ BETWEEN ٷ ̳ ÷ տ ٿ , ȸȴ.
01. 110 120
110 ̻ 120
ȣ, , , μڵ带 ȸѴ.
SELECT employee_id emp_id, first_name ||' ' ||last_name name,
salary, department_id dept_id
FROM employees
WHERE employee_id >= 110 AND employee_id <= 120;
--WHERE employee_id BETWEEN 110 AND 120;
02. 110 ̸ 120 ʰ
ȣ, , , μڵ带 ȸѴ.
SELECT employee_id emp_id, first_name ||' ' ||last_name name,
salary, department_id dept_id
FROM employees
WHERE employee_id < 110 OR employee_id > 120;
--WHERE NOT employee_id BETWEEN 110 AND 120;
03. ڸ
μڵ尡 10 ̸ 40 ʰ
, , μڵ ȸ
SELECT employee_id, first_name || ' ' || last_name name, department_id
FROM employees
WHERE department_id < 10 OR department_id > 40;
--WHERE NOT department_id BETWEEN 10 AND 40;
--WHERE department_id NOT BETWEEN 10 AND 40;
--WHERE NOT (department_id>=10 AND department_id<=40); --μڵ尡 10 ̸ 40 ʰ
04. 110 120 5000 10000
ȣ, , , μڵ带 ȸѴ.
SELECT employee_id emp_id, first_name || ' ' || last_name name,
salary, department_id dept_id
FROM employees
WHERE employee_id BETWEEN 110 AND 120
AND salary BETWEEN 5000 AND 10000;
05. 2005 1 1 ĺ 2007 12 31 ̿ Ի
, , , Ի ȸѴ.
SELECT employee_id, first_name || ' ' || last_name name, salary, hire_date
FROM employees
WHERE hire_date BETWEEN TO_DATE('2005-01-01') AND TO_DATE('2007-12-31');
SELECT employee_id emp_id, first_name || ' ' || last_name name, salary, hire_date
FROM employees
WHERE hire_date BETWEEN '05-01-01' AND '07-12-31';
DATE Ÿ HIRE_DATE ڰ
Ŭ SQL ڵ ȯ ߱ ̴.
ȯϴ ٶϴ.
ȯ Լ TO_DATE() ̴.
SELECT employee_id emp_id, first_name || ' ' || last_name name, salary, hire_date
FROM employees
WHERE hire_date BETWEEN TO_DATE('05-01-01') AND TO_DATE('07-12-31');
06. Իڰ 2003 8 1 2005 7 31 شϴ
, , Ի ȸ
SELECT employee_id, first_name || ' ' || last_name name, hire_date
FROM employees
WHERE hire_date BETWEEN TO_DATE('03-08-01') AND TO_DATE('05-07-31');
--Իڰ 2003 8 1 2005 7 31;
07. μڵ尡 20,30,40,60,100,110 μ
, , μڵ ȸ
SELECT employee_id, first_name || ' ' || last_name name, department_id
FROM employees
--WHERE department_id=20
--OR department_id=30
--OR department_id=40
--OR department_id=60
--OR department_id=100
--OR department_id=110; --μڵ尡 20,30,40,60,100
WHERE deparment_id IN (20,30,40,60,100);
6. IN
߿ ġϴ ִ IN (1, 2, 3 ...) ·
ϴ Ѵ.
÷ǥ ǽ OR
÷ǥ IN ( Ͱ )
<-> ÷ǥ NOT IN ( Ͱ )
NOT ÷ǥ IN ( Ͱ )
IN ڴ OR ڿ
OR ڸ ϸ SQL µ
IN ڸ ϸ .
IN ٷ ̳ ÷ տ NOT ڸ ξ ݴǴ .
01. 30 μ Ǵ 60 μ Ǵ 90 μ
, , , μڵ带 ȸѴ
SELECT employee_id emp_id, first_name ||' ' ||last_name name,
salary, department_id dept_id
FROM employees
WHERE department_id = 30
OR department_id = 60
OR department_id = 90;
SELECT employee_id emp_id, first_name ||' ' || last_name name,
salary, department_id dept_id
FROM employees
WHERE department_id IN (30, 60, 90);
--department_id NOT IN (30, 60, 90);
--NOT department_id IN (30, 60, 90);
02. 30 μ, 60 μ, 90 μ ̿ μ
, , , μڵ ȸѴ.
SELECT employee_id emp_id, first_name || ' ' || last_name name,
salary, department_id dept_id
FROM employees
WHERE department_id NOT IN (30, 60, 90);
7. ˻ شϴ : ʵ LIKE (ϴ)
: ʵ NOT LIKE ( ʴ)
÷ ߿ Ư Ͽ ϴ ȸϰ LIKE ڸ Ѵ.
% : ڿ, ڰ
_ : ϳ , ϳ ڰ ڰ
÷ǥ LIKE ˻ + %
% : ڰ
LIKE 'ȫ%' ȫ ϴ : ȫ浿, ȫ, ȫ, ȫ, ȫϹ...
LIKE '%ȫ' ȫ : Ȳȫ, ȫ, ȫ, ȫ, Ϲ...ȫ
LIKE '%ȫ%' ȫ ϴ : ȫ浿, ȫ, ȫ, ȫ, ȫϹ,
Ȳȫ, ȫ, ȫ, ȫ, Ϲ...ȫ, ȫ, ...
01. ̸ K ۵Ǵ
, ̸, ȸ
SELECT employee_id, first_name, last_name
FROM employees
WHERE first_name LIKE 'K%';
02. ̸ s ̸
, ̸, ȸ
SELECT employee_id, first_name, last_name
FROM employees
WHERE first_name LIKE '%s';
03. ҹ z Ե
, ̸, ȸ
SELECT employee_id, first_name, last_name
FROM employees
WHERE last_name LIKE '%z%'; -- z Ե
04. ҹ ϰ z Ե
, ̸, ȸ
SELECT employee_id, first_name, last_name
FROM employees
WHERE last_name LIKE '%z%'
OR last_name LIKE '%Z%';
-- ҹ ϰ z Ե
05. ҹ ϰ z Ե
, ȸ
SELECT employee_id, first_name || ' ' || last_name name
FROM employees
WHERE last_name||first_name LIKE '%z%'
OR last_name||first_name LIKE '%Z%';
-- ҹ ϰ z Ե
06. ҹ z 2° ġ ִ
, ȸ
SELECT employee_id, first_name || ' ' || last_name name
FROM employees
WHERE last_name LIKE '_z%'; -- ҹ z 2° ġ ִ
07. ҹ z 5° ġ ִ
, ȸ
SELECT employee_id, first_name || ' ' || last_name name
FROM employees
WHERE last_name LIKE '____z%'; -- ҹ z 5° ġ ִ
08. ҹ z ڿ 5° ġ ִ
, ȸ
SELECT employee_id, first_name || ' ' || last_name name
FROM employees
WHERE last_name LIKE '%z____';
LIKE BETWEEN ̳ IN NOT ڿ Բ ִ.
09. ȭȣ 6 ۵ ʴ
, , , ȭ ȸ
SELECT employee_id emp_id, first_name || ' ' || last_name name,
salary, phone_number phone
FROM employees
WHERE phone_number NOT LIKE '6%';
10. Իڰ 12 Ի
, , Ի ȸ
SELECT employee_id, last_name, hire_date
FROM employees
--WHERE TO_CHAR(hire_date, 'MM') = 12;
--WHERE hire_date LIKE '___12___';
WHERE hire_date LIKE '__%12%__';
WHERE hire_date LIKE '%12%'; --XXX
-----------------------------------------------------------------------------------------------
LIKE ڿ Բ %, _ ü ǰ Ϸ
%, _ տ ȣڸ ̰ escape ɼ Ѵ.
÷ǥ LIKE Ư '\_' escape '\'
Ư ~, !, @, #, $, ^, &, *, -, ?, \
-----------------------------------------------------------------------------------------------
(ڵ) ľϰ Ѵ.
ڵ尡 _A , , ڵ带 ȸ
: , FI_ACCOUNT, AD_ASST, AC_ACCOUNT
SELECT employee_id, last_name, job_id
FROM employees
--WHERE job_id LIKE '%_A%'; --Aտ ѱ ִ
WHERE job_id LIKE '%@_A%' escape '@'; --ڵ尡 _A
--WHERE job_id LIKE '%@__A%' escape '@'; --_ ϰ Aտ ѱڰ ִ
----------------------------------------------------------------------------------------------- | true |
33eb7ed33323344c6995311593d928d56c883163 | SQL | PhilCR/web-trocaverde.com | /BD/17_jadder_5.sql | UTF-8 | 964 | 3.375 | 3 | [] | no_license | USE trocaverde;
DROP PROCEDURE atualiza_cliente;
DELIMITER |
CREATE PROCEDURE atualiza_cliente(app_email1 VARCHAR(70), app_nome VARCHAR(200), app_snome VARCHAR(50), app_tel VARCHAR(11),
app_celular VARCHAR(11), app_data_nasc DATE, app_email2 VARCHAR(70), app_cpf VARCHAR(11),
app_rua VARCHAR(200), app_num INTEGER, app_complemento VARCHAR(20), app_bairro VARCHAR(30), app_cidade VARCHAR(50),
app_estado VARCHAR(2), app_cep VARCHAR(10), app_senha VARCHAR(16))
BEGIN
UPDATE cliente SET nome = app_nome, snome = app_snome, telefone = app_tel,
celular = app_celular, data_nasc = app_data_nasc, email = app_email2,
CPF = app_cpf, rua = app_rua, numero = app_num, complemento = app_complemento,
bairro = app_bairro, cidade = app_cidade, cep = app_cep
WHERE email = app_email1;
UPDATE login SET email = app_email2, senha = app_senha
WHERE email = app_email1;
SELECT email FROM cliente WHERE email = app_email2;
END;
| | true |
c01dd361e5ba8345b29ae2dd9a1414e3363dc61a | SQL | kgalieva/cinarra | /cassandra-service/src/main/resources/auction.cql | UTF-8 | 317 | 3.140625 | 3 | [] | no_license | CREATE TABLE auction.product_transactions (
product_id text,
transaction_date bigint,
transaction_id text,
win_price decimal,
PRIMARY KEY((product_id, transaction_date), transaction_id)
);
CREATE TABLE auction.products (
transaction_date bigint,
product_id text,
PRIMARY KEY(transaction_date, product_id)
);
| true |
71578984a045bc7c8d5bd46b3299400b37f2b225 | SQL | DashaDasha88/grid | /server/db/db.sql | UTF-8 | 1,309 | 2.9375 | 3 | [] | no_license | CREATE TABLE plants (
id SERIAL PRIMARY KEY NOT NULL,
name VARCHAR(50) NOT NULL,
genus_species VARCHAR(50) NOT NULL,
description TEXT
);
INSERT INTO plants (name, genus_species, description) VALUES ('Common Sage', 'Salvia officinalis', 'Fragrant herb, member of the mint family, native to the Mediterranean');
INSERT INTO plants (name, genus_species, description) VALUES ('English Lavender', 'Lavandula angustifolia', 'Beautiful, versatile plant with a distinctive colour and scent');
INSERT INTO plants (name, genus_species, description) VALUES ('Rosemary', 'Rosmarinus officinalis', 'A kitchen staple that comes in a variety of shapes and sizes');
**OLD DEFAULT VALUES**
INSERT INTO plants (name, genus_species, uses, correspondences) VALUES ('Sage', 'Salvia officinalis', 'Helps with anxiety, boosts liver function; cleansing and protection', 'Earth/Air, Feminine, Jupiter');
INSERT INTO plants (name, genus_species, uses, correspondences) VALUES ('Lavender', 'Lavandula', 'Use to treat skin issues; use as sleeping aid; Peace, friendship, love, harmony', 'Air, Masculine, Mercury');
INSERT INTO plants (name, genus_species, uses, correspondences) VALUES ('Rosemary', 'Salvia rosmarinus', 'A good hair supplement; contains Vitamin C; Banishes negativity and nightmares', 'Fire, Sun, Masculine');
| true |
a73d3410dfe5bfb9362e8fb86a97ca698569f7d4 | SQL | IgorGato/MySQL-Banco-de-Dados- | /AULA1/exemplo_sql.sql | UTF-8 | 1,070 | 3.59375 | 4 | [] | no_license | -- criar banco de dados
create database db_servico_rh;
-- acesso ao db
use db_servico_rh;
-- cria uma tabela
create table tb_funcionario(
id bigint(5) auto_increment,
nome varchar(255) not null,
salario float not null,
idade int not null,
primary key(id)
);
-- busca da tabela funcionario
select * from tb_funcionario;
insert into tb_funcionario (nome, salario, idade) values ("Lais", 10000, 00);
insert into tb_funcionario (nome, salario, idade) values ("Ju", 12000, 00);
insert into tb_funcionario (nome, salario, idade) values ("Everton", 12000, 00);
insert into tb_funcionario (nome, salario, idade) values (" Geandro", 12000, 00);
update tb_funcionario set salario = 12000 where id = 1;
delete from tb_funcionario where id = 4;
-- adicionar uma coluna nova
alter table tb_funcionario
add descricao varchar(255);
-- alterar coluna
ALTER TABLE tb_funcionario CHANGE nome primeiro_nome varchar(255);
ALTER TABLE tb_funcionario ADD COLUMN cargo varchar(255) AFTER primeiro_nome;
-- deletar uma coluna
alter table tb_funcionario
drop column descricao
| true |
545ffcd8e06678ebd54751dd8c5f2ec240e0da50 | SQL | chenqifeng92/JavaDemos | /ServletJspCurd/src/main/webapp/workers_mysql.sql | UTF-8 | 557 | 3.46875 | 3 | [] | no_license | -- 创建一个id主键自增,带表注释的workers表
CREATE TABLE workers (id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(20) COMMENT '姓名',
salary DOUBLE(10,2) COMMENT '工资,精确到小数点后两位',
age INT(10) COMMENT '年龄');
-- 插入数据
INSERT INTO workers (name,salary,age) VALUES ('杜雯',55000.00,28);
-- 删除数据
DELETE FROM workers WHERE id=?;
-- 修改数据
UPDATE workers SET name=?,salary=?,age=? WHERE id=?;
-- 查询数据
SELECT * FROM workers;
-- 删除workers表全部数据
TRUNCATE workers; | true |
4be3e531d94906442981dd94f096c172171e6c8f | SQL | reginapilip/upload-app | /inc/db/user-registrations.sql | UTF-8 | 2,259 | 3.125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 09, 2019 at 07:41 PM
-- Server version: 10.1.37-MariaDB
-- PHP Version: 7.3.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `upload`
--
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`user_id` int(11) NOT NULL,
`email` varchar(64) NOT NULL,
`first_name` varchar(30) NOT NULL,
`last_name` varchar(30) NOT NULL,
`password` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`user_id`, `email`, `first_name`, `last_name`, `password`) VALUES
(1, 'b.elgort@random.edu', 'Bruce', 'Elgort', 'secret'),
(5, 'bruce@gmail.com', 'sdfsaf', 'safsfsaf', 'sadfsdf'),
(7, 'beau@martin.com', 'sdaff', 'sdfsda', 'sdafs'),
(10, 'ahagha@gaga.com', 'sdfsdaf', 'sfdsdf', 'sdfsafsadf'),
(15, 'lady@gaga.com', 'sdafsadf', 'sddfadff', 'sdafsadf'),
(17, 'iosif@frenchfries.org', 'sadfasf', 'sadfsdf', 'sdfdsafsa'),
(20, 'june@pain.com', 'June', 'Pain', 'sha512(password)'),
(21, 'b@b.com', 'sdfsadf', 'sadfsdf', ''),
(24, 'scott@scott.com', 'scott', 'scott', 'b119701f3d3eaa97d998a4e8021307785e7f107f26d4f9f72f1cc58591a712ea84e1c2349335412e307c518d572526b2f92c7a8d20d0cd108ee97654e3455d5b'),
(35, 'A@A.COM', 'Cat', 'Stevens', '4241b986a49591d445ebb840bc4b49c12b10b392b49222bc45dfd8b871cb3d0e742cdba152aa782e253026c7fc93fe8287b95c5fd0e22467e99c89501a502cd4'),
(51, 'joani@joani.com', 'Joani', 'Jendgleski', '4241b986a49591d445ebb840bc4b49c12b10b392b49222bc45dfd8b871cb3d0e742cdba152aa782e253026c7fc93fe8287b95c5fd0e22467e99c89501a502cd4');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`user_id`,`email`),
ADD UNIQUE KEY `email` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=52;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
9fe755664fdddf7dc79f7017d500ee1220a06676 | SQL | pingting420/LeetCode_SQL_Solutions | /Medium/LC1285. Find start and end number of consective.sql | UTF-8 | 155 | 3.328125 | 3 | [] | no_license | select min(log_id) as start_id, max(log_id) as end_id
from
(select log_id, log_id - rank_over()partition(order by log_id) as diff
from Logs)
group by diff
| true |
2f80931bc63c86668e991f4320d8de25443caa8c | SQL | jobovy/segue-maps | /sql/kdwarf.sql | UTF-8 | 1,836 | 2.734375 | 3 | [] | no_license | select spp.mjd, spp.plate, spp.fiberID,
s.ra as RA, s.dec as Dec, s.b as b, s.l as l, spp.ebv,
s.psfMag_u as u, s.extinction_u as ext_u,
s.psfMag_u-s.extinction_u as dered_u, s.psfMagErr_u as u_err,
s.psfMag_g as g, s.extinction_g as ext_g,
s.psfMag_g-s.extinction_g as dered_g, s.psfMagErr_g as g_err,
s.psfMag_r as r, s.extinction_r as ext_r,
s.psfMag_r-s.extinction_r as dered_r, s.psfMagErr_r as r_err,
s.psfMag_i as i, s.extinction_i as ext_i,
s.psfMag_i-s.extinction_i as dered_i, s.psfMagErr_i as i_err,
s.psfMag_g as z, s.extinction_z as ext_z,
s.psfMag_z-s.extinction_z as dered_z, s.psfMagErr_z as z_err,
spp.ELODIERV as vr, spp.ELODIERVERR as vr_err,
--pm.pmL, pm.pmB, pm.pmRa, pm.pmDec, pm.pmRaErr, pm.pmDecErr,
spp.targ_pmmatch as match, spp.targ_pml as pml,
spp.targ_pmb as pmb, spp.targ_pmra as pmra, spp.targ_pmraerr as pmra_err,
spp.targ_pmdec as pmdec, spp.targ_pmdecerr as pmdec_err,
--spp.FEHADOP as FeHa, spp.FEHADOPUNC as feha_err,
--spp.FEHSPEC as FeH_spe, spp.FEHSPECUNC as FeH_spe_err,
--spp.LOGGADOP as log_g, spp.TEFFADOP as teff
spp.feha as feh, spp.fehaerr as feh_err, spp.teffa as Teff,
spp.teffaerr as Tef_err, spp.logga as logga,
spp.loggaerr as logg_err,spp.alphafe as afe,spp.alphafeerr as afe_err,
spp.zbsubclass as Type, spp.zbelodiesptype, soa.primtarget as
primtarget, spp.sna as sna,s.run, s.rerun, s.camcol, s.field, s.obj
into MyDB.kdwarf
from sppParams as spp, SpecObjAll as soa, star as s, platex as p
--, ProperMotions pm
where p.programname like '%segue%'
and p.plate = soa.plate
and soa.primtarget = -2147450880
and spp.specobjid = soa.specobjid and soa.bestobjid = s.objid
--and s.objid = pm.objid
--and s.psfMag_r-s.extinction_r between 14.5 and 19.0
and s.psfMag_g-s.extinction_g-s.psfMag_r+s.extinction_r between .5 and .8
--and pm.pmRaErr > 0. and spp.SNR > 15.0 | true |
8aa3453d6a6016f85ae98622154d15690f460bec | SQL | OHDSI/Vocabulary-v5.0 | /working/packages/vocabulary_pack/py_git_release.sql | UTF-8 | 1,023 | 3.140625 | 3 | [
"Unlicense"
] | permissive | CREATE OR REPLACE FUNCTION vocabulary_pack.py_git_release(git_repo text, release_title text, release_body text, release_tag text, git_token text)
RETURNS text AS
$BODY$
#A small script for publishing a release on GitHub
#Returns the release_id if success
import json
from urllib.request import urlopen, Request
url_template = 'https://{}.github.com/repos/' + git_repo + '/releases'
try:
_json = json.loads(urlopen(Request(
url_template.format('api'),
json.dumps({
'tag_name': release_tag,
'name': release_title,
'body': release_body
}).encode(),
headers={
'Accept': 'application/vnd.github.v3+json',
'Authorization': 'token ' + git_token,
},
),
timeout=30).read().decode())
release_id = _json['id']
except Exception as ex:
release_id = ex
return release_id
$BODY$
LANGUAGE 'plpython3u' STRICT;
REVOKE EXECUTE ON FUNCTION vocabulary_pack.py_git_release FROM PUBLIC, role_read_only; | true |
7ff9741c7879b4c17258d35d6ad6730e385aa764 | SQL | vmware-archive/greenplum-5-introduction-workshop | /workshop-exercises/Workshop/01_Create_Tables/02_create_load_table.sql | UTF-8 | 3,280 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | /* *******************************************************************************************************
Copyright (C) 2019-Present Pivotal Software, Inc. All rights reserved.
This program and the accompanying materials are made available under the terms of the under the Apache
License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
******************************************************************************************************* */
drop table if exists faa.otp_load;
create table faa.otp_load(
flt_year smallint,
flt_quarter smallint,
flt_month smallint,
flt_dayofmonth smallint,
flt_dayofweek smallint,
flightdate date,
uniquecarrier character varying(7),
airlineid smallint,
carrier character(3),
tailnum character(6),
flightnum character varying(5),
origin character(3),
origincityname character varying(35),
originstate character(2),
originstatefipscode smallint,
originstatename character varying(50),
originwacid smallint,
dest character(3),
destcityname character varying(35),
deststate character(2),
deststatefipscode smallint,
deststatename character varying(50),
destwacid smallint,
crsdeptime time,
deptime time,
depdelay smallint,
depdelayminutes smallint,
depdel15 boolean,
departuredelaygroups smallint,
deptimeblkid character(10),
taxiout smallint,
wheelsoff time,
wheelson time,
taxiin smallint,
crsarrtime time,
arrtime time,
arrdelay smallint,
arrdelayminutes smallint,
arrdel15 boolean,
arrivaldelaygroups smallint,
arrtimeblkid character(10),
cancelled boolean,
cancellationcode character(1),
diverted boolean,
crselapsedtime smallint,
actualelapsedtime smallint,
airtime smallint,
flights smallint,
distance smallint,
distancegroup smallint,
carrierdelay smallint,
weatherdelay smallint,
nasdelay smallint,
securitydelay smallint,
lateaircraftdelay smallint,
firstdeptime time,
totaladdgtime smallint,
longestaddgtime smallint,
divairportlandings smallint,
divertedreacheddest boolean,
divactualelapsedtime smallint,
divarrdelay smallint,
divdistance smallint,
div1airport character(3),
div1wheelson time,
div1totalgtime smallint,
divlongestgtime smallint,
div1wheelsoff time,
div1tailnum character(6),
div2airport character(3),
div2wheelson time,
div2totalgtime smallint,
div2longestgtime smallint,
div2wheelsoff time,
div2tailnum character(6),
div3airport character(3),
div3wheelson time,
div3totalgtime smallint,
div3longestgtime smallint,
div3wheelsoff time,
div3tailnum character(6),
div4airport character(3),
div4wheelson time,
div4totalgtime smallint,
div4longestgtime smallint,
div4wheelsoff time,
div4tailnum character(6),
div5airport character(3),
div5wheelson time,
div5totalgtime smallint,
div5longestgtime smallint,
div5wheelsoff time,
div5tailnum character(6)
)
with (oids=false)
distributed randomly
;
| true |
de88ed01785ff94256ec370a8e73204003cf390a | SQL | patricknaka/Nova | /Views Bunzl/VW_BZL_DEV_DEVOLUCAO.sql | UTF-8 | 8,784 | 3.15625 | 3 | [] | no_license | SELECT
-- O campo CD_CIA foi incluido para diferenciar NIKE(13) E BUNZL(15)
--**********************************************************************************************************************************************************
CAST((FROM_TZ(TO_TIMESTAMP(TO_CHAR(cisli940dev.t$rcd_utc, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), 'GMT')
AT time zone 'America/Sao_Paulo') AS DATE) DT_ULT_ATUALIZACAO,
15 CD_CIA,
(SELECT tcemm030.t$euca FROM baandb.ttcemm124602 tcemm124, baandb.ttcemm030602 tcemm030
WHERE tcemm124.t$cwoc=cisli940dev.t$cofc$l
AND tcemm030.t$eunt=tcemm124.t$grid
AND tcemm124.t$loco=602
AND rownum=1) CD_FILIAL,
tdrec940rec.t$docn$l NR_NF, -- Nota fiscal recebimento devolução
tdrec940rec.t$seri$l NR_SERIE_NF, -- Serie NF rec. devolução
tdrec940rec.t$opfc$l CD_NATUREZA_OPERACAO,
tdrec940rec.t$opor$l SQ_NATUREZA_OPERACAO,
CAST((FROM_TZ(TO_TIMESTAMP(TO_CHAR(cisli940org.t$date$l, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), 'GMT')
AT time zone 'America/Sao_Paulo') AS DATE) DT_FATURA,
cisli940org.t$itbp$l CD_CLIENTE_FATURA,
cisli940org.t$stbp$l CD_CLIENTE_ENTREGA,
znsls401org.t$sequ$c SQ_ENTREGA,
znsls401org.t$pecl$c NR_PEDIDO,
(select znsls410.t$poco$c
FROM baandb.tznsls410602 znsls410
WHERE znsls410.t$ncia$c=znsls401dev.t$ncia$c
AND znsls410.t$uneg$c=znsls401dev.t$uneg$c
AND znsls410.t$pecl$c=znsls401dev.t$pecl$c
AND znsls410.t$sqpd$c=znsls401dev.t$sqpd$c
AND znsls410.t$entr$c=znsls401dev.t$entr$c
AND znsls410.t$dtoc$c= (SELECT MAX(c.t$dtoc$c)
FROM baandb.tznsls410602 c
WHERE c.t$ncia$c=znsls410.t$ncia$c
AND c.t$uneg$c=znsls410.t$uneg$c
AND c.t$pecl$c=znsls410.t$pecl$c
AND c.t$sqpd$c=znsls410.t$sqpd$c
AND c.t$entr$c=znsls410.t$entr$c)
AND rownum=1) CD_STATUS,
(SELECT
CAST((FROM_TZ(TO_TIMESTAMP(TO_CHAR(MAX(znsls410.t$dtoc$c), 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), 'GMT')
AT time zone 'America/Sao_Paulo') AS DATE)
FROM baandb.tznsls410602 znsls410
WHERE znsls410.t$ncia$c=znsls401dev.t$ncia$c
AND znsls410.t$uneg$c=znsls401dev.t$uneg$c
AND znsls410.t$pecl$c=znsls401dev.t$pecl$c
AND znsls410.t$sqpd$c=znsls401dev.t$sqpd$c
AND znsls410.t$entr$c=znsls401dev.t$entr$c) DT_STATUS,
tdrec940rec.t$rfdt$l CD_TIPO_NF,
tdrec940rec.t$fire$l NR_REFERENCIA_FISCAL_DEVOLUCAO, -- Ref. Fiscal recebimento devolção
ltrim(rtrim(znsls401dev.t$item$c)) CD_ITEM,
znsls401dev.t$qtve$c QT_DEVOLUCAO,
(SELECT a.t$amnt$l FROM baandb.tcisli943602 a
WHERE a.t$fire$l=cisli941dev.t$fire$l
AND a.t$line$l=cisli941dev.t$line$l
AND a.t$brty$l=1) VL_ICMS,
cisli941dev.t$gamt$l VL_PRODUTO,
cisli941dev.t$fght$l VL_FRETE,
cisli941dev.t$gexp$l VL_DESPESA,
cisli941dev.t$tldm$l VL_DESCONTO_INCONDICIONAL,
cisli941dev.t$amnt$l VL_TOTAL_ITEM,
znsls401org.t$orno$c NR_PEDIDO_ORIGINAL,
CAST((FROM_TZ(TO_TIMESTAMP(TO_CHAR(znsls400org.t$dtin$c, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), 'GMT')
AT time zone 'America/Sao_Paulo') AS DATE) DT_PEDIDO,
znsls400org.t$idca$c CD_CANAL_VENDAS,
tccom130.t$ftyp$l CD_TIPO_CLIENTE,
tccom130.t$ccit CD_CIDADE,
tccom130.t$ccty CD_PAIS,
tccom130.t$cste CD_ESTADO,
q1.mauc VL_CMV,
cisli940org.t$docn$l NR_NF_FATURA, -- NF fatura entrega org
cisli940org.t$seri$l NR_SERIE_NF_FATURA,
cisli940dev.t$fire$l NR_REF_FISCAL_REMESSA,
cisli940dev.t$docn$l NR_NF_REMESSA, -- NF devolução
cisli940dev.t$seri$l NR_SERIE_NF_REMESSA,
(SELECT a.t$amnt$l FROM baandb.tcisli943602 a
WHERE a.t$fire$l=cisli941dev.t$fire$l
AND a.t$line$l=cisli941dev.t$line$l
AND a.t$brty$l=5) VL_PIS,
(SELECT a.t$amnt$l FROM baandb.tcisli943602 a
WHERE a.t$fire$l=cisli941dev.t$fire$l
AND a.t$line$l=cisli941dev.t$line$l
AND a.t$brty$l=6) VL_COFINS,
znsls401dev.t$uneg$c CD_UNIDADE_NEGOCIO,
CASE WHEN
nvl((select znsls401nr.t$pecl$c
FROM baandb.tznsls401602 znsls401nr
WHERE znsls401nr.t$ncia$c=znsls401dev.t$ncia$c
AND znsls401nr.t$uneg$c=znsls401dev.t$uneg$c
AND znsls401nr.t$pecl$c=znsls401dev.t$pecl$c
AND znsls401nr.t$sqpd$c=znsls401dev.t$sqpd$c
AND znsls401nr.t$entr$c>znsls401dev.t$entr$c
AND rownum=1),1)=1 then 2
ELSE 1
END IN_REPOSICAO,
(SELECT tcemm124.t$grid FROM baandb.ttcemm124602 tcemm124
WHERE tcemm124.t$cwoc=cisli940dev.t$cofc$l
AND tcemm124.t$loco=602
AND rownum=1) CD_UNIDADE_EMPRESARIAL,
tdsls406rec.t$rcid NR_REC_DEVOLUCAO,
znsls401dev.t$lcat$c NM_MOTIVO_CATEGORIA,
znsls401dev.t$lass$c NM_MOTIVO_ASSUNTO,
znsls401dev.t$lmot$c NM_MOTIVO_ETIQUETA,
CASE WHEN nvl(( select max(a.t$list$c) from baandb.tznsls405602 a
where a.t$ncia$c=znsls401dev.t$ncia$c
and a.t$uneg$c=znsls401dev.t$uneg$c
and a.t$pecl$c=znsls401dev.t$pecl$c
and a.t$sqpd$c=znsls401dev.t$sqpd$c
and a.t$entr$c=znsls401dev.t$entr$c
and a.t$sequ$c=znsls401dev.t$sequ$c),1)=0 THEN 1 ELSE 2 END ID_FORCADO,
to_char(znsls401org.t$entr$c) NR_ENTREGA_ORIGINAL,
to_char(znsls401dev.t$entr$c) NR_ENTREGA_DEVOLUCAO,
cisli941dev.t$cwar$l CD_ARMAZEM,
cisli940org.t$fire$l NR_REFERENCIA_FISCAL_FATURA,
to_char(znsls401dev.t$ccat$c) CD_MOTIVO_CATEGORIA,
to_char(znsls401dev.t$cass$c) CD_MOTIVO_ASSUNTO,
to_char(znsls401dev.t$cmot$c) CD_MOTIVO_ETIQUETA,
tdsls400.t$orno NR_ORDEM_VENDA_DEVOLUCAO,
tdsls400.t$hdst CD_STATUS_ORDEM_VDA_DEV,
CAST((FROM_TZ(TO_TIMESTAMP(TO_CHAR(tdsls400.t$odat, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), 'GMT')
AT time zone 'America/Sao_Paulo') AS DATE) DT_ORDEM_VENDA_DEVOLUCAO,
tcmcs080.t$suno CD_PARCEIRO_TRANSPORTADORA_FAT,
cisli941org.t$refr$l NR_REFERENCIA_FISCAL
FROM
baandb.tznsls401602 znsls401dev -- Pedido de devolução
INNER JOIN baandb.ttdsls400602 tdsls400
ON tdsls400.t$orno = znsls401dev.t$orno$c
INNER JOIN baandb.tznsls401602 znsls401org -- Pedido de venda original
ON znsls401org.t$pecl$c=znsls401dev.t$pvdt$c
AND znsls401org.t$ncia$c=znsls401dev.t$ncia$c
AND znsls401org.t$uneg$c=znsls401dev.t$uneg$c
AND znsls401org.t$entr$c=znsls401dev.t$endt$c
AND znsls401org.t$sequ$c=znsls401dev.t$sedt$c
INNER JOIN baandb.tznsls400602 znsls400org
ON znsls400org.t$ncia$c=znsls401org.t$ncia$c
AND znsls400org.t$uneg$c=znsls401org.t$uneg$c
AND znsls400org.t$pecl$c=znsls401org.t$pecl$c
AND znsls400org.t$sqpd$c=znsls401org.t$sqpd$c
INNER JOIN baandb.tcisli245602 cisli245dev -- Rel Devolução
ON cisli245dev.t$ortp=1
AND cisli245dev.t$koor=3
AND cisli245dev.t$slso=znsls401dev.t$orno$c
AND cisli245dev.t$pono=znsls401dev.t$pono$c
INNER JOIN baandb.tcisli940602 cisli940dev
ON cisli940dev.t$fire$l=cisli245dev.t$fire$l
INNER JOIN baandb.tcisli941602 cisli941dev
ON cisli941dev.t$fire$l=cisli245dev.t$fire$l
AND cisli941dev.t$line$l=cisli245dev.t$line$l
INNER JOIN baandb.tcisli245602 cisli245org -- Rel ordem orig
ON cisli245dev.t$ortp=1
AND cisli245dev.t$koor=3
AND cisli245org.t$slso=znsls401org.t$orno$c
AND cisli245org.t$pono=znsls401org.t$pono$c
INNER JOIN baandb.tcisli940602 cisli940org
ON cisli940org.t$fire$l=cisli245org.t$fire$l
INNER JOIN baandb.tcisli941602 cisli941org
ON cisli941org.t$fire$l=cisli245org.t$fire$l
AND cisli941org.t$line$l=cisli245org.t$line$l
INNER JOIN baandb.ttccom130602 tccom130
ON tccom130.t$cadr=cisli940org.t$stoa$l
LEFT JOIN baandb.ttcmcs080602 tcmcs080
ON tcmcs080.t$cfrw = cisli940org.t$cfrw$L
LEFT JOIN baandb.ttdsls406602 tdsls406rec -- Rec da devolução
ON tdsls406rec.t$orno=znsls401dev.t$orno$c
AND tdsls406rec.t$pono=znsls401dev.t$pono$c
LEFT JOIN baandb.ttdrec947602 tdrec947rec
ON tdrec947rec.t$oorg$l=1
AND tdrec947rec.t$orno$l=znsls401dev.t$orno$c
AND tdrec947rec.t$pono$l=znsls401dev.t$pono$c
LEFT JOIN baandb.ttdrec940602 tdrec940rec
ON tdrec940rec.t$fire$l=tdrec947rec.t$fire$l
LEFT JOIN baandb.ttdrec941602 tdrec941rec
ON tdrec941rec.t$fire$l=tdrec947rec.t$fire$l
AND tdrec941rec.t$line$l=tdrec947rec.t$line$l
LEFT JOIN ( SELECT
whwmd217.t$item,
whwmd217.t$cwar,
case when (max(whwmd215.t$qhnd) - max(whwmd215.t$qchd) - max(whwmd215.t$qnhd))=0 then 0
else round(sum(whwmd217.t$mauc$1)/(max(whwmd215.t$qhnd) - max(whwmd215.t$qchd) - max(whwmd215.t$qnhd)),4)
end mauc
FROM baandb.twhwmd217602 whwmd217, baandb.twhwmd215602 whwmd215
WHERE whwmd215.t$cwar=whwmd217.t$cwar
AND whwmd215.t$item=whwmd217.t$item
group by whwmd217.t$item, whwmd217.t$cwar) q1
ON q1.t$item = cisli941dev.t$item$l AND q1.t$cwar = cisli941dev.t$cwar$l | true |
64d360f52ae0f06c69dce4e7c3ba65eb4e608875 | SQL | DanAlbert/whdsched | /scripts/schema.mysql.sql | UTF-8 | 3,016 | 3.765625 | 4 | [] | no_license | CREATE TABLE consultants
(
id INT NOT NULL AUTO_INCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(40) NOT NULL,
engr VARCHAR(20) NOT NULL,
phone VARCHAR(10) NOT NULL,
preferred_email VARCHAR(255) DEFAULT NULL,
max_hours INT NOT NULL DEFAULT 20,
recv_nightly BOOLEAN NOT NULL DEFAULT 1,
recv_instant BOOLEAN NOT NULL DEFAULT 0,
recv_taken BOOLEAN NOT NULL DEFAULT 1,
hidden BOOLEAN NOT NULL DEFAULT 0,
admin BOOLEAN NOT NULL DEFAULT 0,
PRIMARY KEY (id),
UNIQUE (engr)
) ENGINE=InnoDB;
CREATE TABLE shifts
(
id INT NOT NULL AUTO_INCREMENT,
start_time TIME,
end_time TIME,
location ENUM('WHD', 'Lab', 'KEC', 'Owen', 'WHD-Temp'),
day DATE,
consultant_id INT,
PRIMARY KEY (id),
UNIQUE (start_time, end_time, location, day),
FOREIGN KEY (consultant_id) REFERENCES consultants (id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE temp_shifts
(
id INT NOT NULL AUTO_INCREMENT,
shift_id INT NOT NULL,
temp_consultant_id INT,
post_time TIMESTAMP NOT NULL DEFAULT NOW(),
response_time TIMESTAMP,
assigned_to INT,
timeout INT,
PRIMARY KEY (id),
UNIQUE (shift_id),
FOREIGN KEY (shift_id) REFERENCES shifts (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (temp_consultant_id) REFERENCES consultants (id) ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (assigned_to) REFERENCES consultants (id) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE terms
(
id INT NOT NULL AUTO_INCREMENT,
term ENUM('Summer', 'Fall', 'Winter Break', 'Winter', 'Spring Break', 'Spring') NOT NULL,
year INT NOT NULL,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
PRIMARY KEY (id),
UNIQUE (term, year)
) ENGINE=InnoDB;
CREATE TABLE logs
(
id INT NOT NULL AUTO_INCREMENT,
log_time TIMESTAMP NOT NULL DEFAULT NOW(),
type ENUM('temp.create', 'temp.retemp', 'temp.late-retemp', 'temp.cancel', 'temp.take', 'debug.db', 'debug.auth') NOT NULL,
message TEXT NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
CREATE TABLE meetings
(
id INT NOT NULL AUTO_INCREMENT,
day ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') NOT NULL,
start_time TIME NOT NULL,
end_time TIME NOT NULL,
location VARCHAR (255),
term_id INT NOT NULL,
PRIMARY KEY (id),
UNIQUE (term_id, day, start_time),
FOREIGN KEY (term_id) REFERENCES terms (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE cancelled_meetings
(
id INT NOT NULL AUTO_INCREMENT,
meeting_id INT NOT NULL,
day DATE NOT NULL,
PRIMARY KEY (id),
UNIQUE (meeting_id, day),
FOREIGN KEY (meeting_id) REFERENCES meetings (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE meeting_attendees
(
id INT NOT NULL AUTO_INCREMENT,
consultant_id INT NOT NULL,
meeting_id INT NOT NULL,
PRIMARY KEY (id),
UNIQUE (consultant_id, meeting_id),
FOREIGN KEY (consultant_id) REFERENCES consultants (id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (meeting_id) REFERENCES meetings (id) ON DELETE CASCADE ON UPDATE CASCADE
) Engine=InnoDB;
| true |
ad777ec73eb915d0d393fa9a0f346836763432f0 | SQL | kknd9819/blog | /src/main/java/com/zz/blog/tables.sql | UTF-8 | 317 | 2.515625 | 3 | [] | no_license | drop table if exists `t_article`;
create table `t_article` (
`id` int not null auto_increment,
`title` varchar(36) not null,
`summary` varchar(100) not null,
`content` text not null,
`img_url` varchar(40),
`create_date` datetime not null,
PRIMARY key(`id`)
) ENGINE=INNODB DEFAULT charset = 'utf8mb4';
| true |
eb9447c13d6162b8fcdc367f3b80eac8c957c43b | SQL | zhengbingyanbj/JavaSE | /JavaEE就业班多线程和数据库/作业题1/day20_work/答案/test02.sql | UTF-8 | 3,889 | 4.59375 | 5 | [] | no_license | 需求1:多表练习
1.1:为甚么使用多表操作?
答:为了使数据的使用和维护更加的方便
3.2:表与表之间如何产生联系?
答:表与表之间依靠外键产生联系。
3.3:多表关系中是存在主表和从表的,那么什么是主表,什么是从表。
答:
主表 :数据来源表,主键ID所在的表
例如:分类表----是分类名称数据的来源表,主键CID所在表
从表: 数据引用表,外键所在的表
例如:商品表---引用了分类表数据,外键category_cid所在表
3.4:外键的特点?
从表外键指向了主表的主键。
从表的外键的数据类型和长度 与主表的主键的数据类型一致。
3.5:什么是外键约束?
问题1:从表尝试引用主表不存在的数据
问题2:主表尝试删除从表引用的数据
使用外键约束解决上述问题:
答:强制性约束,强制保证外键数据完整
需求2:多表关系
2.1:一对多关系(分类表与商品表)。
#创建分类表
create table category(
cid varchar(32) PRIMARY KEY ,
cname varchar(100) #分类名称
);
# 商品表
CREATE TABLE `products` (
`pid` varchar(32) PRIMARY KEY ,
`name` VARCHAR(40) ,
`price` DOUBLE
);
#添加外键字段
alter table products add column category_id varchar(32);
#添加约束
alter table products add constraint product_fk foreign key (category_id) references category (cid);
4.3.3 操作
#1 向分类表中添加数据
INSERT INTO category (cid ,cname) VALUES('c001','服装');
#2 向商品表添加普通数据,没有外键数据,默认为null
INSERT INTO products (pid,name) VALUES('p001','商品名称');
#3 向商品表添加普通数据,含有外键信息(category表中存在这条数据)
INSERT INTO products (pid ,name ,category_id) VALUES('p002','商品名称2','c001');
#4 向商品表添加普通数据,含有外键信息(category表中不存在这条数据) -- 失败,异常
INSERT INTO products (pid ,name ,category_id) VALUES('p003','商品名称2','c999');
#5 删除指定分类(分类被商品使用) -- 执行异常
DELETE FROM category WHERE cid = 'c001';
需求3 :商品表和订单表是多对多关系,请尝试书写建表语句,并加入外键约束:
# 商品表[已存在]
# 订单表
create table `orders`(
`oid` varchar(32) PRIMARY KEY ,
`totalprice` double #总计
);
# 订单项表
create table orderitem(
oid varchar(50),-- 订单id
pid varchar(50)-- 商品id
);
#---- 订单表和订单项表的主外键关系
alter table `orderitem` add constraint orderitem_orders_fk foreign key (oid) references orders(oid);
#---- 商品表和订单项表的主外键关系
alter table `orderitem` add constraint orderitem_product_fk foreign key (pid) references products(pid);
# 联合主键(可省略)
alter table `orderitem` add primary key (oid,pid);
4.4.3 操作
#1 向商品表中添加数据
INSERT INTO products (pid,pname) VALUES('p003','商品名称');
#2 向订单表中添加数据
INSERT INTO orders (oid ,totalprice) VALUES('x001','998');
INSERT INTO orders (oid ,totalprice) VALUES('x002','100');
#3向中间表添加数据(数据存在)
INSERT INTO orderitem(pid,oid) VALUES('p001','x001');
INSERT INTO orderitem(pid,oid) VALUES('p001','x002');
INSERT INTO orderitem(pid,oid) VALUES('p002','x002');
#4删除中间表的数据
DELETE FROM orderitem WHERE pid='p002' AND oid = 'x002';
#5向中间表添加数据(数据不存在) -- 执行异常
INSERT INTO orderitem(pid,oid) VALUES('p002','x003');
#6删除商品表的数据 -- 执行异常
DELETE FROM products WHERE pid = 'p001';
| true |
836752d71c2d5e9d91802e4368a454fd16523b57 | SQL | SPDEVGUY/VotingInfoWebsite | /VotingInfo/Database/SQL/Alter/04-Views/Client/Candidates.sql | UTF-8 | 479 | 3.140625 | 3 | [
"MIT"
] | permissive | CREATE VIEW [Client].[Candidates] WITH SCHEMABINDING
AS
SELECT
C.[CandidateId],
C.[ContentInspectionId],
C.[CandidateName],
C.[OrganizationId],
CI.[IsArchived],
CI.[IsBeingProposed],
CI.[ProposedByUserId],
CI.[ConfirmedByUserId],
CI.[FalseInfoCount],
CI.[TrueInfoCount],
CI.[AdminInpsected],
CI.[DateLastChecked],
CI.[SourceUrl]
FROM [Data].[Candidate] C
INNER JOIN [Data].[ContentInspection] CI
ON C.[ContentInspectionId] = CI.[ContentInspectionId]
| true |
98c3c993a1679c5ecd67fae8dad1fca1bd2b29ed | SQL | Falcomfr/Cours-obj-3w | /Sql/exportPopo.sql | UTF-8 | 4,452 | 3.0625 | 3 | [] | no_license | -- MySQL dump 10.16 Distrib 10.1.31-MariaDB, for Win32 (AMD64)
--
-- Host: localhost Database: popo
-- ------------------------------------------------------
-- Server version 10.1.31-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `conversation`
--
DROP TABLE IF EXISTS `conversation`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `conversation` (
`c_id` int(11) NOT NULL AUTO_INCREMENT,
`c_date` datetime NOT NULL,
`c_termine` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`c_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `conversation`
--
LOCK TABLES `conversation` WRITE;
/*!40000 ALTER TABLE `conversation` DISABLE KEYS */;
/*!40000 ALTER TABLE `conversation` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `message`
--
DROP TABLE IF EXISTS `message`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `message` (
`m_id` int(11) NOT NULL AUTO_INCREMENT,
`m_contenu` varchar(2040) NOT NULL,
`m_date` datetime NOT NULL,
`m_auteur_fk` int(11) NOT NULL,
`m_conversation_fk` int(11) NOT NULL,
PRIMARY KEY (`m_id`),
KEY `m_auteur_fk_user` (`m_auteur_fk`),
KEY `m_conversation_fk_conversation` (`m_conversation_fk`),
CONSTRAINT `m_auteur_fk_user` FOREIGN KEY (`m_auteur_fk`) REFERENCES `user` (`u_id`) ON UPDATE CASCADE,
CONSTRAINT `m_conversation_fk_conversation` FOREIGN KEY (`m_conversation_fk`) REFERENCES `conversation` (`c_id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `message`
--
LOCK TABLES `message` WRITE;
/*!40000 ALTER TABLE `message` DISABLE KEYS */;
/*!40000 ALTER TABLE `message` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `rang`
--
DROP TABLE IF EXISTS `rang`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `rang` (
`r_id` int(11) NOT NULL AUTO_INCREMENT,
`r_libelle` varchar(255) NOT NULL,
PRIMARY KEY (`r_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `rang`
--
LOCK TABLES `rang` WRITE;
/*!40000 ALTER TABLE `rang` DISABLE KEYS */;
/*!40000 ALTER TABLE `rang` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
`u_id` int(11) NOT NULL AUTO_INCREMENT,
`u_login` varchar(30) NOT NULL,
`u_prenom` varchar(255) DEFAULT NULL,
`u_nom` varchar(255) DEFAULT NULL,
`u_date_naissance` date DEFAULT NULL,
`u_date_inscription` datetime NOT NULL,
`u_rang_fk` int(11) NOT NULL,
PRIMARY KEY (`u_id`),
KEY `u_rang_fk_rang` (`u_rang_fk`),
CONSTRAINT `u_rang_fk_rang` FOREIGN KEY (`u_rang_fk`) REFERENCES `rang` (`r_id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user`
--
LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-08-09 13:56:30
| true |
7ed750204bb91c54befca1eeb3cc5861cb028ed5 | SQL | NTXpro/NTXbases_de_datos | /DatabaseNTXpro/ERP/Stored Procedures/Procs1/Usp_Sel_MovimientoTesoreria_Borrador.sql | UTF-8 | 852 | 3.75 | 4 | [] | no_license | CREATE PROC [ERP].[Usp_Sel_MovimientoTesoreria_Borrador]
@IdEmpresa INT
AS
BEGIN
SELECT MT.ID,
MT.Orden,
ETD.NumeroDocumento,
MT.Nombre NombreMovimiento,
CTM.Nombre NombreCategoriaMovimiento,
MT.Fecha,
MT.IdTipoMovimiento,
CASE WHEN MT.IdTipoMovimiento = 1 THEN --INGRESO
MT.Total
ELSE
CAST(0 AS DECIMAL(14,5))
END AS Ingreso,
CASE WHEN MT.IdTipoMovimiento = 2 THEN --SALIDA
MT.Total
ELSE
CAST(0 AS DECIMAL(14,5))
END AS Egreso
FROM ERP.MovimientoTesoreria MT
LEFT JOIN Maestro.CategoriaTipoMovimiento CTM ON CTM.ID = MT.IdCategoriaTipoMovimiento
LEFT JOIN ERP.Entidad E ON E.ID = MT.IdEntidad
LEFT JOIN ERP.EntidadTipoDocumento ETD ON ETD.IdEntidad = E.ID
WHERE MT.FlagBorrador = 1
AND MT.IdEmpresa = @IdEmpresa
END | true |
600db4eb7285ab4d414925770929667114a533e5 | SQL | ZVlad1980/pipelined_exam | /sql/Views/pension_agreements_v.sql | UTF-8 | 1,342 | 3.140625 | 3 | [] | no_license | create or replace view pension_agreements_v as
select bcn.fk_document fk_base_contract,
cn.fk_document fk_contract,
cn.cntr_number cntr_number,
pa.state state,
pa.period_code period_code,
pa.isarhv,
bcn.fk_account fk_debit,
cn.fk_account fk_credit,
pa.fk_pay_detail,
cn.fk_company,
cn.fk_scheme,
cn.fk_contragent,
pa.effective_date,
pa.expiration_date,
pa.amount pa_amount,
coalesce(pa.expiration_date, to_date(99991231, 'yyyymmdd')) last_pay_date,
pa.creation_date,
pa.last_update,
bcn.fk_cntr_type fk_base_cntr_type,
bcn.fk_scheme fk_base_scheme,
pa.date_pension_age
from pension_agreements pa,
contracts cn,
contracts bcn
where 1 = 1
and bcn.fk_document = pa.fk_base_contract
and pa.fk_contract = cn.fk_document
and bcn.fk_scheme in (1, 2, 3, 4, 5, 6, 8)
and cn.fk_scheme in (1, 2, 3, 4, 5, 6, 8)
and cn.fk_cntr_type = 6
/
| true |
e96e3ad91b9f8b1f0bcad3bd13386561d25731e8 | SQL | dalmem/database | /제약조건quiz.sql | UTF-8 | 995 | 3.78125 | 4 | [] | no_license | create table members(
m_name varchar(5),
m_num number(10),
reg_date date,
gender varchar(1),
loca number(10)
);
alter table members modify m_name varchar(5) not null;
alter table members add constraints mem_memnum_pk primary key(m_num);
alter table members modify reg_date date not null;
alter table members add constraints mem_regdate_uk unique (reg_date);
alter table members add constraints mem_loca_loc_locid_fk foreign key (loca) REFERENCES locations(location_id);
INSERT INTO members VALUES ('AAA',1,'2018-07-01','M',1800);
INSERT INTO members VALUES ('BBB',2,'2018-07-02','F',1900);
INSERT INTO members VALUES ('CCC',3,'2018-07-03','M',2000);
INSERT INTO members VALUES ('DDD',4,sysdate,'M',2000);
select * from members;
select m_name,
m_num,
street_address,
l.location_id,
reg_date
from members m
inner join locations l
on m.loca = l.location_id
order by m_num;
commit; | true |
7e5877cbf109123e58d8ccd4a637e99d581649cf | SQL | OHDSI/Achilles | /inst/sql/sql_server/analyses/2201.sql | UTF-8 | 519 | 3.765625 | 4 | [
"Apache-2.0"
] | permissive | -- 2201 Number of note records, by note_type_concept_id
--HINT DISTRIBUTE_ON_KEY(stratum_1)
select 2201 as analysis_id,
CAST(m.note_type_CONCEPT_ID AS VARCHAR(255)) as stratum_1,
cast(null as varchar(255)) as stratum_2, cast(null as varchar(255)) as stratum_3, cast(null as varchar(255)) as stratum_4, cast(null as varchar(255)) as stratum_5,
COUNT_BIG(m.PERSON_ID) as count_value
into @scratchDatabaseSchema@schemaDelim@tempAchillesPrefix_2201
from
@cdmDatabaseSchema.note m
group by m.note_type_CONCEPT_ID
;
| true |
86b3ad533d145c92ed6c0302194f255fc9795173 | SQL | amit12nig96/resurgence2017smvdu | /amit/registered_users.sql | UTF-8 | 1,788 | 2.890625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 22, 2017 at 06:17 PM
-- Server version: 10.1.21-MariaDB
-- PHP Version: 5.6.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `resurgence`
--
-- --------------------------------------------------------
--
-- Table structure for table `registered_users`
--
CREATE TABLE `registered_users` (
`id` int(8) NOT NULL,
`user_name` varchar(255) NOT NULL,
`branch` varchar(255) NOT NULL,
`city` varchar(255) NOT NULL,
`college` varchar(50) NOT NULL,
`Mobile_no` varchar(15) NOT NULL,
`email` varchar(55) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `registered_users`
--
INSERT INTO `registered_users` (`id`, `user_name`, `branch`, `city`, `college`, `Mobile_no`, `email`) VALUES
(25, 'amit kumar yadav ', 'cse', 'lko', 'smvdu', '9596561100', 'amit12nig96@gmail.com'),
(26, 'amit kumar yadav ', 'somputer science ', 'lucknow ', 'smvdu', '9596561100', 'aj@amityadavcse.com');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `registered_users`
--
ALTER TABLE `registered_users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `registered_users`
--
ALTER TABLE `registered_users`
MODIFY `id` int(8) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
b80c1ce6a54dbcd3c5fe37ddeccf8a422ebace64 | SQL | Wribbe/SQL_the_hard_way | /ex4.sql | UTF-8 | 1,290 | 3.46875 | 3 | [] | no_license | CREATE TABLE person (
id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
age INTEGER
);
CREATE TABLE pet (
id INTEGER PRIMARY KEY,
name TEXT,
breed TEXT,
age INTEGER,
dead INTEGER
);
CREATE TABLE person_pet (
person_id INTEGER,
pet_id INTEGER
);
CREATE TABLE car (
id INTIGER PRIMARY KEY,
year INTEGER,
model TEXT,
manifacturer TEXT,
color TEXT
);
CREATE TABLE person_car (
person_id INTEGER,
car_id INTEGER
);
INSERT INTO person (id, first_name, last_name, age)
VALUES (0, 'Zed', 'Shaw', 37);
INSERT INTO pet (id, name, breed, age, dead)
VALUES (0, 'Fluffy', 'Unicorn', 1000, 0);
INSERT INTO pet VALUES(1, 'Gigantor', 'Robot', 1, 1);
INSERT INTO person (id, first_name, last_name, age)
VALUES (1, 'Stefan', 'Eng', 31);
INSERT INTO pet (id, name, breed, age, dead)
VALUES (2, 'Billy', 'Cat', 13, 1);
INSERT INTO person_pet (person_id, pet_id) VALUES (0, 0);
INSERT INTO person_pet VALUES (0, 1);
INSERT INTO person_pet (person_id, pet_id) VALUES (1,2);
INSERT INTO person_pet (person_id, pet_id) VALUES (1,1);
-- Now I am the owner of Gigantor to~
/*
Drills:
-------
1.) Add self+pet relation; see above.
2.) Possible to store multiple owners of a pet.
3.) The current design is better for multiple ownership.
*/
| true |
a94c970a6362497c22c6eaadb3b10225529b90b3 | SQL | ezen1130/ezen1130 | /ImployeeManagement/src/TeamProject.sql | UTF-8 | 468 | 3.625 | 4 | [] | no_license | CREATE TABLE employee2(
id varchar2(10),
name varchar2(15),
position varchar2(15)
)
alter table employee2 add constraint pk_employee_id primary key(id)
CREATE TABLE attendee(
id varchar2(10),
name varchar2(15),
intime date,
exittime date
)
alter table attendee add constraint pk_ettendee_id primary key(id)
alter table attendee add constraint fk_attendee_id foreign key(id) references employee2(id)
SELECT * FROM employee2
SELECT * FROM attendee | true |
e33ef695b28515295dde713e1c3d09e7368e9420 | SQL | anisahnq/cutionline | /cuti.sql | UTF-8 | 2,262 | 2.9375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Dec 12, 2017 at 05:28 AM
-- Server version: 10.1.19-MariaDB
-- PHP Version: 5.6.28
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `cuti`
--
-- --------------------------------------------------------
--
-- Table structure for table `karyawan`
--
CREATE TABLE `karyawan` (
`id` int(11) NOT NULL,
`nip` varchar(9) NOT NULL,
`name` varchar(30) NOT NULL,
`jenisKelamin` varchar(2) NOT NULL,
`tglLahir` date NOT NULL,
`jabatan` varchar(30) NOT NULL,
`status` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `karyawan`
--
INSERT INTO `karyawan` (`id`, `nip`, `name`, `jenisKelamin`, `tglLahir`, `jabatan`, `status`) VALUES
(0, '00001', 'adip', 'L', '2017-12-14', 'admin', 'adm'),
(0, '', '', '', '0000-00-00', '', '--Pilih St'),
(0, '', '', '', '0000-00-00', '', '--Pilih St'),
(0, '', '', '', '0000-00-00', '', '--Pilih St'),
(0, '', '', '', '0000-00-00', '', '--Pilih St'),
(0, '', '', '', '0000-00-00', '', '--Pilih St'),
(0, '00002', 'adi', 'L', '2017-12-06', 'hrd', 'hrd'),
(3, '002', 'ghali', 'L', '2017-12-06', 'ceo', 'kyr');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id_user` int(11) NOT NULL,
`nama` varchar(50) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id_user`, `nama`, `username`, `password`) VALUES
(0, 'adiputra@gmail.com', 'admin', '123456'),
(0, 'ghali@gma', 'gha', '123456'),
(0, '', 'paok', 'bego'),
(0, '', 'mhmd', 'gume'),
(0, '', 'ichsan', 'cinta'),
(4, 'gane', 'bggt', 'cinta');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
7b0d530fa4b81a90d3af3023c44b8a09b68def22 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day14/select2330.sql | UTF-8 | 178 | 2.65625 | 3 | [] | no_license |
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-13T23:30:00Z' AND timestamp<'2017-11-14T23:30:00Z' AND temperature>=21 AND temperature<=90
| true |
4aeb7d46bd402db741cb9ba076059a23b8d726e5 | SQL | PabloYepes27/holbertonschool-higher_level_programming | /0x0D-SQL_introduction/7-insert_value.sql | UTF-8 | 259 | 2.6875 | 3 | [] | no_license | -- inserts a new row in the table first_table (database hbtn_0c_0) in your MySQL server.
-- INSERT INTO table (columns) VALUES (values) -> Insert value to selected columns
INSERT
INTO first_table (
id,
name
)
VALUES (
89,
'Holberton School'
)
| true |
0c15a40376c6c4977012f5d3e2c57eca35b782e6 | SQL | Nashipae/PostgreSQL_Getting_Started | /PostgreSQL Fundamentals/Module 1-3.sql | UTF-8 | 8,477 | 3.5 | 4 | [] | no_license | -----------------------------------
-- O'reilly Online Training -------
-- PostgreSQL fundamentals --------
-- Module 1.3: Accessing Objects --
-----------------------------------
-- https://github.com/ami-levin/OReilly-Training/tree/master/PostgreSQL%20Fundamentals
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
CREATE SCHEMA oreilly;
-- Using public schema
CREATE USER oreilly WITH PASSWORD = 'some_password';
CREATE TABLE oreilly.customers (customer varchar(20), country varchar(20));
SELECT * FROM customers;
SELECT * FROM oreilly.customers;
-- assigning permissions (DCL)
/*
███████╗██╗ ██╗███████╗██████╗ ██████╗██╗███████╗███████╗ ██╗
██╔════╝╚██╗██╔╝██╔════╝██╔══██╗██╔════╝██║██╔════╝██╔════╝ ███║
█████╗ ╚███╔╝ █████╗ ██████╔╝██║ ██║███████╗█████╗ ╚██║
██╔══╝ ██╔██╗ ██╔══╝ ██╔══██╗██║ ██║╚════██║██╔══╝ ██║
███████╗██╔╝ ██╗███████╗██║ ██║╚██████╗██║███████║███████╗ ██║
╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝╚═╝╚══════╝╚══════╝ ╚═╝
* NOTE: dbfiddle users skip this exercise
*/
-- Create a new user called "oreilly" using the query tool editor or PSQL.
CREATE USER oreilly WITH PASSWORD 'some_password';
-- In PgAdmin, right click on Login/Group Roles and click "Refresh".
-- Make sure user oreilly is visible.
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
/*
███████╗██╗ ██╗███████╗██████╗ ██████╗██╗███████╗███████╗ ██████╗
██╔════╝╚██╗██╔╝██╔════╝██╔══██╗██╔════╝██║██╔════╝██╔════╝ ╚════██╗
█████╗ ╚███╔╝ █████╗ ██████╔╝██║ ██║███████╗█████╗ █████╔╝
██╔══╝ ██╔██╗ ██╔══╝ ██╔══██╗██║ ██║╚════██║██╔══╝ ██╔═══╝
███████╗██╔╝ ██╗███████╗██║ ██║╚██████╗██║███████║███████╗ ███████╗
╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝╚═╝╚══════╝╚══════╝ ╚══════╝
* NOTE: dbfiddle users skip this exercise
*/
-- In PgAdmin or PSQL, execute the query:
-- * NOTE: Make sure your connection is set to the basicdemos database!
CREATE SCHEMA oreilly;
-- In PgAdmin, right click "Schemas" (under basicdemos) and click "Refresh".
-- Right click "Schemas" -> "Create" -> "Schema" and view the options but don't save, cancel.
-- In PgAdmin or PSQL execute the queries:
CREATE TABLE oreilly.customers (customer varchar(20), country varchar(20));
INSERT INTO oreilly.customers VALUES ('your name', 'your country');
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
/*
███████╗██╗ ██╗███████╗██████╗ ██████╗██╗███████╗███████╗ ██████╗
██╔════╝╚██╗██╔╝██╔════╝██╔══██╗██╔════╝██║██╔════╝██╔════╝ ╚════██╗
█████╗ ╚███╔╝ █████╗ ██████╔╝██║ ██║███████╗█████╗ █████╔╝
██╔══╝ ██╔██╗ ██╔══╝ ██╔══██╗██║ ██║╚════██║██╔══╝ ╚═══██╗
███████╗██╔╝ ██╗███████╗██║ ██║╚██████╗██║███████║███████╗ ██████╔╝
╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝╚═╝╚══════╝╚══════╝ ╚═════╝
*NOTE: dbfiddle users skip this exercise
*/
-- Right click "basicdemos" -> properties. switch to "Security" and click the + sign next to "Privileges".
-- Add "oreilly" as "Grantee", and click the "connect" checkbox under the Privileges tab.
-- Click "Save".
-- In PgAdmin, expand "basicdemos" -> "Schemas".
-- Right click the "oreilly" schema and click "properties".
-- Switch to "Security" and click the + sign next to "Privileges".
-- Add "oreilly" as Grantee, and the "Usage" privilege.
-- Click "Save".
-- In PgAdmin, expand "basicdemos" -> "Schemas" -> "oreilly" -> "tables".
-- Right click "customers" and choose "Properties".
-- Switch to "Security" tab and click the + sign next to "Privileges".
-- Add "oreilly" as "Grantee", and click "All" permissions checkbox.
-- Click "Save".
-- Launch a new PSQL window, type "basicdemos" for database, and "oreilly" as user name, provide your password.
-- Execute the following query:
SELECT * FROM customers;
-- Can you explain the result?
-- Execute the following query:
SELECT * FROM public.customers;
-- Can you explain the result?
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
/*
██████╗ ███████╗███████╗ ██████╗ ██╗ ██╗██████╗ ██████╗███████╗███████╗
██╔══██╗██╔════╝██╔════╝██╔═══██╗██║ ██║██╔══██╗██╔════╝██╔════╝██╔════╝
██████╔╝█████╗ ███████╗██║ ██║██║ ██║██████╔╝██║ █████╗ ███████╗
██╔══██╗██╔══╝ ╚════██║██║ ██║██║ ██║██╔══██╗██║ ██╔══╝ ╚════██║
██║ ██║███████╗███████║╚██████╔╝╚██████╔╝██║ ██║╚██████╗███████╗███████║
╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚══════╝
Additional Reading:
-------------------
https://www.postgresql.org/docs/12/sql-createdatabase.html
https://www.postgresql.org/docs/12/ddl-schemas.html
https://www.postgresql.org/docs/12/user-manag.html
https://www.postgresql.org/docs/12/sql-createschema.html
https://www.postgresql.org/docs/12/sql-createuser.html
https://www.postgresql.org/docs/12/sql-createrole.html
https://www.postgresql.org/docs/12/client-authentication.html
https://www.postgresql.org/docs/12/sql-grant.html
https://www.postgresql.org/docs/12/sql-revoke.html
*/ | true |
dd535201e7bff4787a76a8a42217ebf97df611de | SQL | sf-burgos/dataBaseOracleAndSql | /proyectoDeCurso/atributos.sql | UTF-8 | 419 | 2.578125 | 3 | [] | no_license |
ALTER TABLE INFORMACION_PERSONAL ADD CONSTRAINT CK_CORREO_INFORMACION_PERSONAL CHECK(correo NOT LIKE '%@%@%');
ALTER TABLE REFERENCIA ADD CONSTRAINT CK_CORREO_REFERENCIA CHECK(correo NOT LIKE '%@%@%');
ALTER TABLE LIBRO ADD CONSTRAINT CK_N_PAGE CHECK(numero_paginas>1);
ALTER TABLE LIBRO ADD CONSTRAINT CK_N_DIS CHECK(disponible>=0);
ALTER TABLE LIBRO ADD CONSTRAINT CK_N_EJEMPLARES CHECK(numero_ejemplares>0);
| true |
a3f3e9bcb489e4a301edc4626096b5735f376082 | SQL | rzhang86/test | /conf/evolutions/default/1.sql | UTF-8 | 532 | 2.6875 | 3 | [] | no_license | # --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions
# --- !Ups
create table stroke (
id bigint auto_increment not null,
ip varchar(255),
name varchar(255),
date_time datetime,
x integer,
y integer,
constraint pk_stroke primary key (id))
;
# --- !Downs
SET FOREIGN_KEY_CHECKS=0;
drop table stroke;
SET FOREIGN_KEY_CHECKS=1;
| true |
2ed2857916ee8e15f947d035e34e39d26431b439 | SQL | sunhome1220/ULTicket | /WebContent/scripts/sample.sql | UTF-8 | 1,800 | 4.0625 | 4 | [] | no_license | --由票根號查出某人索票資料
SELECT * FROM proctick where tickname+ticktel in(
SELECT tickname+ticktel FROM proctick where tickid=22409)
--以某張回條查出該票索票人索得票出席狀況
SELECT * FROM showtick where tickid in(
SELECT tickid FROM proctick where tickname+ticktel in(
SELECT tickname+ticktel FROM proctick where tickid=22409))
SELECT count(*) FROM proctick where tickname+ticktel in(
SELECT tickname+ticktel FROM proctick where tickid=22409)
group by tickname, ticktel
--更新出席狀態
UPDATE proctick
SET presentStatus= 1
where presentStatus<>1 and evid=20181103 and tickid in(select tickid from showtick where evid=20181103)
UPDATE proctick SET presentStatus= 1
where presentStatus<>1 and tickid in(select tickid from showtick)
--出席狀況清單
SELECT evid as 場編,event as 場次, team as 組別, procman as 發票人 ,procaddr as 發票地,tickid as 票號,
tickname as 索票人, ticktel as 電話,tickmemo as 備註, iif(presentStatus>0,'V','') as 出席狀況
FROM proctick where team='合歡' and evid=20181103
--
SELECT p.evid as 場編,event as 場次, team as 組別, procman as 發票人 ,procaddr as 發票地,p.tickid as 票號,
tickname as 索票人, p.ticktel as 電話,tickmemo as 備註, iif(presentStatus>0,'V','') as 出席狀況 ,
c.calltimes 已, c.contactStatus, c.updatetime,c.lastestCallernm
FROM proctick p left join tickcomment c on p.evid=c.evid and p.tickid=c.tickid
where team='合歡' and p.evid=20181103
update perform set perform.reqcnt=p.reqcnt
from perform left join(SELECT evid,count(*) as reqcnt FROM proctick group by evid) p on perform.evid=p.evid
update perform set perform.showcnt=s.showcnt
from perform left join(SELECT evid,count(*) as showcnt FROM showtick group by evid) s on perform.evid=s.evid
| true |
523c59b6308c43e3fc64498f25f31969fd7fd92b | SQL | TharikH/sql-pl-sql | /pl-sql-blocks/update_table.sql | UTF-8 | 235 | 2.625 | 3 | [] | no_license | declare
cust_id integer:=1;
val float;
begin
select emi into val from customer where id=cust_id;
if(val ~= 0 and val is not null)then
update customer set emi=val/2 where id=cust_id;
else
dbms_output.put_line('not poss');
end if;
end; | true |
8702c11ae51e5dc8d2a48a5af18fc8fc6a885c0f | SQL | rendrooy/CRUD-Laravel | /obat.sql | UTF-8 | 8,064 | 3.109375 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 07, 2020 at 10:19 PM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.3.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `obat`
--
-- --------------------------------------------------------
--
-- Table structure for table `jenis`
--
CREATE TABLE `jenis` (
`id` int(10) UNSIGNED NOT NULL,
`nama_jenis` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `jenis`
--
INSERT INTO `jenis` (`id`, `nama_jenis`, `created_at`, `updated_at`) VALUES
(1, 'obat mabo', '2020-07-07 13:16:41', '2020-07-07 13:16:45'),
(2, 'obat pusing', '2020-07-07 13:16:49', '2020-07-07 13:16:49'),
(3, 'obat kobam', '2020-07-07 13:16:53', '2020-07-07 13:16:53');
-- --------------------------------------------------------
--
-- Table structure for table `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `migrations`
--
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2014_10_12_000000_create_users_table', 1),
(2, '2014_10_12_100000_create_password_resets_table', 1),
(3, '2020_07_04_094030_create_table_obat', 1),
(4, '2020_07_04_094107_create_table_jenis', 1),
(5, '2020_07_04_101338_create_table_perusahaan', 1),
(6, '2020_07_04_101411_create_table_perusahaan_obat', 1);
-- --------------------------------------------------------
--
-- Table structure for table `obat`
--
CREATE TABLE `obat` (
`id` int(10) UNSIGNED NOT NULL,
`nama_obat` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`harga` int(11) NOT NULL,
`id_jenis` int(10) UNSIGNED NOT NULL,
`foto` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `obat`
--
INSERT INTO `obat` (`id`, `nama_obat`, `harga`, `id_jenis`, `foto`, `created_at`, `updated_at`) VALUES
(1, 'eksimer', 15000, 1, '20200707201825.jpg', '2020-07-07 13:17:32', '2020-07-07 13:18:32'),
(2, 'tratolol', 31233, 3, '20200707201845.jpg', '2020-07-07 13:18:45', '2020-07-07 13:18:45');
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `perusahaan`
--
CREATE TABLE `perusahaan` (
`id` int(10) UNSIGNED NOT NULL,
`nama_perusahaan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `perusahaan`
--
INSERT INTO `perusahaan` (`id`, `nama_perusahaan`, `created_at`, `updated_at`) VALUES
(1, 'kimiasantuy', '2020-07-07 13:17:02', '2020-07-07 13:17:08'),
(2, 'panasonic', '2020-07-07 13:17:12', '2020-07-07 13:17:12'),
(3, 'panasondak', '2020-07-07 13:17:15', '2020-07-07 13:17:15');
-- --------------------------------------------------------
--
-- Table structure for table `perusahaan_obat`
--
CREATE TABLE `perusahaan_obat` (
`id_obat` int(10) UNSIGNED NOT NULL,
`id_perusahaan` int(10) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `perusahaan_obat`
--
INSERT INTO `perusahaan_obat` (`id_obat`, `id_perusahaan`, `created_at`, `updated_at`) VALUES
(1, 2, '2020-07-07 13:17:49', '2020-07-07 13:17:49');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`level` enum('admin','operator') COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `level`, `created_at`, `updated_at`) VALUES
(1, 'narendra', 'narendra@gmail.com', NULL, '$2y$10$Wl8geldPnBY4GsndiiU4b.x4mrnLI1t8o3CEClQLI4SuLea06.7u2', NULL, 'admin', '2020-07-07 13:16:24', '2020-07-07 13:16:24');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `jenis`
--
ALTER TABLE `jenis`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `obat`
--
ALTER TABLE `obat`
ADD PRIMARY KEY (`id`),
ADD KEY `obat_id_jenis_foreign` (`id_jenis`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`);
--
-- Indexes for table `perusahaan`
--
ALTER TABLE `perusahaan`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `perusahaan_obat`
--
ALTER TABLE `perusahaan_obat`
ADD PRIMARY KEY (`id_obat`,`id_perusahaan`),
ADD KEY `perusahaan_obat_id_obat_index` (`id_obat`),
ADD KEY `perusahaan_obat_id_perusahaan_index` (`id_perusahaan`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `jenis`
--
ALTER TABLE `jenis`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `obat`
--
ALTER TABLE `obat`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `perusahaan`
--
ALTER TABLE `perusahaan`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `obat`
--
ALTER TABLE `obat`
ADD CONSTRAINT `obat_id_jenis_foreign` FOREIGN KEY (`id_jenis`) REFERENCES `jenis` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `perusahaan_obat`
--
ALTER TABLE `perusahaan_obat`
ADD CONSTRAINT `perusahaan_obat_id_obat_foreign` FOREIGN KEY (`id_obat`) REFERENCES `obat` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `perusahaan_obat_id_perusahaan_foreign` FOREIGN KEY (`id_perusahaan`) REFERENCES `perusahaan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
b55c79b6ae075ed1e6bf108b46c11a7b5c4fa20c | SQL | FloridaGeologicalSurvey/KORI | /sql/views/rnoaa_coops.sql | UTF-8 | 346 | 2.953125 | 3 | [] | no_license | --View that is oriented towards R users
CREATE OR REPLACE VIEW public.rcoops
(
site_name,
date_time,
val,
var,
dataset
)
AS
SELECT S.site_name, COOPS.date_time, COOPS.wle as val, text 'tidal_wle' as var, text 'COOPS' as dataset FROM (extra.coops AS COOPS INNER JOIN extra.sites AS S USING (site_id)) | true |
38a9451ef639659689307d715a997b6f0d863f49 | SQL | meera-ramesh19/sololearn-python | /advancedlevel2/class2/if then statement in groupby.sql | UTF-8 | 1,185 | 4.4375 | 4 | [] | no_license | /*Pull the total shipping gross margin $ (ship rev - ship cost) by city and state.
Any city/state that had a ship profit dollar less than or equal to $0, label it as
No Profit. If the profit dollar is greater than $0, label as profit.*/
select Zip.city,
Zip.State,
sum(Shipping_Carrier.Shipping_Revenues-Shipping_Carrier.Shipping_Cost) as 'Total ship GM%',
case when Shipping_Carrier.Shipping_Revenues-Shipping_Carrier.Shipping_Cost < 0 then
'No Profit' else 'Profit' end as 'Profitable'
from Shipping_Carrier join Zip on Zip.zipCode=Shipping_Carrier.Zip
group by Zip.City,
Zip.state ,
case when Shipping_Carrier.Shipping_Revenues-Shipping_Carrier.Shipping_Cost < 0 then
'No Profit' else 'Profit' end
/* Below we get different results even though the query works without case in groupby*/
/*so the above query is the right query*/
SELECT
Zip.city,
Zip.state,
SUM(Shipping_Carrier.Shipping_revenues - Shipping_Carrier.Shipping_cost) AS 'GM $',
CASE WHEN SUM(Shipping_Carrier.Shipping_revenues - Shipping_Carrier.Shipping_cost) <= 0 THEN 'No Profit' ELSE 'Profit' END AS 'Profitable'
FROM Shipping_Carrier JOIN Zip
ON Shipping_Carrier.zip = Zip.zipCode
GROUP BY Zip.city,Zip.state
| true |
b2e98133acf09ba9ba82e6c1591d5363b691ea09 | SQL | fiffu/arisa2 | /database/schema_colours.sql | UTF-8 | 280 | 2.515625 | 3 | [] | no_license | DROP TABLE IF EXISTS colours;
CREATE TABLE "colours" (
userid BIGINT NOT NULL,
mutateorreroll TEXT NOT NULL,
tstamp TIMESTAMP NOT NULL,
colour TEXT,
is_frozen BOOLEAN,
PRIMARY KEY (userid, mutateorreroll)
);
| true |
f2830c871cf5abffcba854efc3302895b3a03a9e | SQL | LeonidSergeev/mail_analytics | /SQL/Restrictions_android.sql | UTF-8 | 422 | 2.578125 | 3 | [] | no_license | SELECT count(*)
,dtEvent
FROM moosic_analytics.mytracker_custom_events
WHERE
eventName in ('Purchase_cache','Purchase_background','Purchase_audio_adv','Purchase_restricted','Purchase_banner','Purchase_profile','Purchase_feed','Purchase_special_project','Track_region_restricted')
AND idAppVersionTitle LIKE '5.1%'
AND dtEvent >= '2021-05-21'
AND idPlatformTitle = 'Android'
group by dtEvent | true |
f5fe17c30d8bb3fed0b0a507680aa5c83594fb18 | SQL | 1141125335/Group9_DayCareManagementSystem | /daycare/sql.sql | UTF-8 | 8,505 | 3.515625 | 4 | [] | no_license | -- Adminer 4.3.1 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP DATABASE IF EXISTS `daycaresystem`;
CREATE DATABASE `daycaresystem` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;
USE `daycaresystem`;
DROP TABLE IF EXISTS `daycare_board`;
CREATE TABLE `daycare_board` (
`board_id` int(11) NOT NULL AUTO_INCREMENT,
`board_title` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`board_desc` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`board_date` date NOT NULL,
PRIMARY KEY (`board_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_board`;
INSERT INTO `daycare_board` (`board_id`, `board_title`, `board_desc`, `board_date`) VALUES
(9, 'Sport day', 'blah blah blah', '2017-10-05'),
(10, 'Title 3', '', '2017-10-20');
DROP TABLE IF EXISTS `daycare_child`;
CREATE TABLE `daycare_child` (
`child_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`parent_id` int(11) NOT NULL,
`child_nickname` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`child_fullname` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`child_ic` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`child_dob` date NOT NULL,
`child_hobby` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`child_favfood` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`child_allergy` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`child_emerph` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`child_emername` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`child_address` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`child_pic` mediumtext COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`child_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_child`;
INSERT INTO `daycare_child` (`child_id`, `parent_id`, `child_nickname`, `child_fullname`, `child_ic`, `child_dob`, `child_hobby`, `child_favfood`, `child_allergy`, `child_emerph`, `child_emername`, `child_address`, `child_pic`) VALUES
(1, 1, 'Child 1', 'Child 1', '1234567890', '0000-00-00', '', '', '', '', '', '', '');
DROP TABLE IF EXISTS `daycare_foodschedule`;
CREATE TABLE `daycare_foodschedule` (
`foodschedule_id` int(11) NOT NULL AUTO_INCREMENT,
`foodschedule_title` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`foodschedule_desc` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`foodschedule_day` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`foodtitle_id` int(11) NOT NULL,
`isactive` int(1) NOT NULL,
PRIMARY KEY (`foodschedule_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_foodschedule`;
INSERT INTO `daycare_foodschedule` (`foodschedule_id`, `foodschedule_title`, `foodschedule_desc`, `foodschedule_day`, `foodtitle_id`, `isactive`) VALUES
(1, 'Steak', 'Steak for breakfast', 'Monday', 1, 1),
(5, 'Teh C', '', 'Wednesday', 4, 1),
(6, 'Teh O ice limau', '', 'Thursday', 4, 1),
(7, 'Pork', '', 'Friday', 4, 1),
(8, 'Nasi Goreng Kampung', '', 'Tuesday', 4, 1),
(9, 'Nasi Ayam', '', 'Monday', 4, 1);
DROP TABLE IF EXISTS `daycare_foodtitle`;
CREATE TABLE `daycare_foodtitle` (
`foodtitle_id` int(11) NOT NULL AUTO_INCREMENT,
`foodtitle_title` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`created` date NOT NULL,
PRIMARY KEY (`foodtitle_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_foodtitle`;
INSERT INTO `daycare_foodtitle` (`foodtitle_id`, `foodtitle_title`, `created`) VALUES
(1, 'Breakfast', '1997-00-00'),
(2, 'Tea Time 1', '2000-00-00'),
(3, 'Tea Time 2', '2001-00-00'),
(4, 'Lunch', '2000-01-01');
DROP TABLE IF EXISTS `daycare_gallery`;
CREATE TABLE `daycare_gallery` (
`gallery_id` int(11) NOT NULL AUTO_INCREMENT,
`gallery_title` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`gallery_date` date NOT NULL,
PRIMARY KEY (`gallery_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_gallery`;
INSERT INTO `daycare_gallery` (`gallery_id`, `gallery_title`, `gallery_date`) VALUES
(1, 'Gallery 1', '2017-01-01');
DROP TABLE IF EXISTS `daycare_image`;
CREATE TABLE `daycare_image` (
`image_id` int(11) NOT NULL AUTO_INCREMENT,
`image_uri` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`gallery_id` int(11) NOT NULL,
PRIMARY KEY (`image_id`)
) ENGINE=InnoDB AUTO_INCREMENT=177 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_image`;
INSERT INTO `daycare_image` (`image_id`, `image_uri`, `gallery_id`) VALUES
(170, 'http://localhost/fyp-daycare/upload/gallery/Gallery 1/CUSJ4pzKhlefcq_rcd83voRCb9cf1J_f.jpg', 1),
(171, 'http://localhost/fyp-daycare/upload/gallery/Gallery 1/2C4QHvHlbIscWc_s5j4Dm7lUBHOqdv_t.jpg', 1),
(172, 'http://localhost/fyp-daycare/upload/gallery/Gallery 1/LI8nMyP7qrqAcN_hCkvWUxnZmLJ7le_s.jpg', 1),
(173, 'http://localhost/fyp-daycare/upload/gallery/Gallery 1/Lb17IQVoCpy3GD_oAW1sR7OTZxPWFZ_5.jpg', 1),
(174, 'http://localhost/fyp-daycare/upload/gallery/Gallery 1/czKAQnhfWnwWB7_w71NdFUk3G118R4_o.jpg', 1),
(175, 'http://localhost/fyp-daycare/upload/gallery/Gallery 1/uzEaLIYngqjQic_deGkUtCk0o6xm8f_w.jpg', 1),
(176, 'http://localhost/fyp-daycare/upload/gallery/Gallery 1/R3vFIQvpuZprMo_ZDQYaK1GJIhgQdz_B.jpg', 1);
DROP TABLE IF EXISTS `daycare_parent`;
CREATE TABLE `daycare_parent` (
`parent_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`parent_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`parent_phnum` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`parent_email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`user_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`parent_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_parent`;
INSERT INTO `daycare_parent` (`parent_id`, `parent_name`, `parent_phnum`, `parent_email`, `user_id`) VALUES
(1, 'Parent 1', '', '', 0);
DROP TABLE IF EXISTS `daycare_payment`;
CREATE TABLE `daycare_payment` (
`payment_id` int(11) NOT NULL AUTO_INCREMENT,
`payment_date` date NOT NULL,
`parent_id` int(11) NOT NULL,
PRIMARY KEY (`payment_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_payment`;
DROP TABLE IF EXISTS `daycare_paymentline`;
CREATE TABLE `daycare_paymentline` (
`paymentline_id` int(11) NOT NULL AUTO_INCREMENT,
`paymentline_item` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`paymentline_desc` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`paymentline_unitprice` decimal(12,2) NOT NULL,
`paymentline_qty` int(11) NOT NULL,
`paymentline_total` decimal(12,2) NOT NULL,
`payment_id` int(11) NOT NULL,
PRIMARY KEY (`paymentline_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_paymentline`;
DROP TABLE IF EXISTS `daycare_timetable`;
CREATE TABLE `daycare_timetable` (
`timetable_id` int(11) NOT NULL AUTO_INCREMENT,
`timetable_title` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`timetable_desc` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`timetable_day` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`timetable_fromtime` time NOT NULL,
`timetable_totime` time NOT NULL,
`isactive` int(1) NOT NULL,
PRIMARY KEY (`timetable_id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_timetable`;
INSERT INTO `daycare_timetable` (`timetable_id`, `timetable_title`, `timetable_desc`, `timetable_day`, `timetable_fromtime`, `timetable_totime`, `isactive`) VALUES
(1, 'IT Programming', 'Learn IT from 5 years old', 'Monday', '08:30:00', '12:00:00', 1),
(2, 'Hello', '', 'Wednesday', '10:30:00', '11:30:00', 1),
(3, 'Science', '', 'Tuesday', '09:00:00', '11:00:00', 1),
(4, 'Data Structure', '', 'Monday', '12:00:00', '15:00:00', 1),
(11, 'Math Tech 2', '', 'Thursday', '11:30:00', '15:30:00', 1);
DROP TABLE IF EXISTS `daycare_user`;
CREATE TABLE `daycare_user` (
`user_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_username` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`user_password` varbinary(100) NOT NULL,
`user_email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`user_permission` int(1) NOT NULL,
PRIMARY KEY (`user_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
TRUNCATE `daycare_user`;
INSERT INTO `daycare_user` (`user_ID`, `user_username`, `user_password`, `user_email`, `user_permission`) VALUES
(14, 'test', UNHEX('97295E514A492D508A5478692A59E1FA'), 'test', 1);
-- 2017-10-08 07:30:39 | true |
4bae3e0fee4620e82669e6f1ebe39c6f60e1ffc5 | SQL | mpdevs/mplib | /src/mplib/scripts/hql/dnr/l_motherbaby_user_denoise.sql | UTF-8 | 1,133 | 3.828125 | 4 | [] | no_license | USE transforms;
DROP TABLE IF EXISTS motherbaby_user_noise;
CREATE TABLE motherbaby_user_noise AS
SELECT
user_id,
COUNT(*) AS cnt
FROM l_motherbaby.post
WHERE noise = '1'
GROUP BY
user_id
HAVING COUNT(*) >= 5;
USE l_motherbaby;
DROP TABLE IF EXISTS user_tmp;
CREATE TABLE user_tmp LIKE user;
INSERT INTO user_tmp
PARTITION (platform_id)
SELECT
u.user_id,
u.brief_intro,
u.user_tags,
u.user_name,
u.detail_url,
u.user_gender,
u.user_birthday,
u.user_age,
u.user_level,
u.baby_count,
u.baby_info,
u.baby_gender,
u.baby_birthday,
u.baby_agenow,
u.ask_count,
u.reply_count,
u.post_count,
u.reply_post_count,
u.quality_post_count,
u.best_answer_count,
u.fans_count,
u.following_count,
u.device,
u.address,
u.tel,
u.province,
u.city,
u.created_at,
u.updated_at,
CASE WHEN n.user_id IS NULL THEN 0 ELSE 1 END AS noise,
u.platform_id
FROM transforms.motherbaby_user AS u
LEFT JOIN transforms.motherbaby_user_noise AS n
ON u.user_id = n.user_id;
DROP TABLE user;
ALTER TABLE user_tmp RENAME TO user;
| true |
493f5ab8c9df7538791c5ed06ee83a4ca2494489 | SQL | AbrahamMendoza/A-la-mano-Brenda-Daniel-Abraham | /bd1.sql | UTF-8 | 570 | 3.0625 | 3 | [] | no_license | DROP DATABASE IF EXISTS Proyecto;
CREATE DATABASE Proyecto;
USE Proyecto;
DROP TABLE IF EXISTS producto;
CREATE TABLE producto(
codigo VARCHAR(10) NOT NULL PRIMARY KEY,
nombre VARCHAR(30) NOT NULL,
descripcion VARCHAR(50) NOT NULL,
cveCategoria INT NOT NULL,
cantidad INT NOT NULL,
precioCompra DOUBLE NOT NULL,
precioVenta DOUBLE NOT NULL,
cveProveedor INT NOT NULL)
Engine = InnoDB;
DESC producto;
INSERT INTO producto VALUES (1,"coca","refresco",1,100,50.50,75.50,10);
INSERT INTO producto VALUES (2,"papas","comida",2,50,3000,3500,5);
SELECT * FROM Producto; | true |
413e6a16d222761c14ac78972e3db44118e0aeda | SQL | ibzan79/BEDU | /ejercicios_sesion02.sql | UTF-8 | 2,930 | 4.25 | 4 | [] | no_license | USE classicmodels;
# 1. Dentro de la tabla employees, obtén el número de empleado, apellido y nombre de todos los empleados cuyo nombre empiece con A.
SELECT employeeNumber, lastName, firstName
FROM employees
WHERE firstName LIKE 'A%';
# 2. Dentro de la tabla employees, obtén el número de empleado, apellido y nombre de todos los empleados cuyo apellido termina con on.
SELECT employeeNumber, lastName, firstName
FROM employees
WHERE lastName LIKE '%on';
# 3. Dentro de la tabla employees, obtén el número de empleado, apellido y nombre de todos los empleados cuyo nombre incluye la cadena on.
SELECT employeeNumber, lastName, firstName
FROM employees
WHERE firstName LIKE '%on%';
# 4. Dentro de la tabla employees, obtén el número de empleado, apellido y nombre de todos los empleados cuyos nombres tienen seis letras e inician con G.
SELECT employeeNumber, lastName, firstName
FROM employees
WHERE firstName LIKE 'G_____';
# 5. Dentro de la tabla employees, obtén el número de empleado, apellido y nombre de todos los empleados cuyo nombre no inicia con B.
SELECT employeeNumber, lastName, firstName
FROM employees
WHERE firstName NOT LIKE 'B%';
# 6. Dentro de la tabla products, obtén el código de producto y nombre de los productos cuyo código incluye la cadena _20.
SELECT productCode, productName
FROM products
WHERE productCode LIKE '%\_20%';
# 7. Dentro de la tabla orderdetails, obtén el total de cada orden.
SELECT orderNumber, sum(quantityOrdered * priceEach) total
FROM orderdetails
GROUP BY orderNumber
ORDER BY orderNumber;
# 8. Dentro de la tabla orders obtén el número de órdenes por año.
SELECT year(orderDate) año, count(*) ordenes_año
FROM orders
GROUP BY año;
# 9. Obtén el apellido y nombre de los empleados cuya oficina está ubicada en USA.
SELECT lastName, firstName
FROM employees AS e
WHERE officeCode IN
(SELECT officeCode
FROM offices
WHERE country = 'USA');
# 10. Obtén el número de cliente, número de cheque y cantidad del cliente que ha realizado el pago más alto.
SELECT customerNumber, checkNumber, amount
FROM payments
WHERE amount = (SELECT max(amount) FROM payments);
# 11. Obtén el número de cliente, número de cheque y cantidad de aquellos clientes cuyo pago es más alto que el promedio.
SELECT customerNumber, checkNumber, amount
FROM payments
WHERE amount > (SELECT avg(amount) FROM payments)
ORDER BY amount;
# 12. Obtén el nombre de aquellos clientes que no han hecho ninguna orden.
SELECT customerName
FROM customers
WHERE customerNumber NOT IN (SELECT customerNumber FROM orders);
# 13. Obtén el máximo, mínimo y promedio del número de productos en las órdenes de venta.
SELECT max(quantityOrdered) max, min(quantityOrdered) min, avg(quantityOrdered) promedio
FROM orderdetails;
# 14. Dentro de la tabla orders, Obtén el número de órdenes que hay por cada estado.
SELECT status, count(*)
FROM orders
GROUP BY status; | true |
ebd78ed6e6635cdb7de2a31e790fad208c1ea7df | SQL | darold/pgFormatter | /t/pg-test-files/expected/async.sql | UTF-8 | 809 | 2.796875 | 3 | [
"Artistic-2.0"
] | permissive | --
-- ASYNC
--
--Should work. Send a valid message via a valid channel name
SELECT
pg_notify('notify_async1', 'sample message1');
SELECT
pg_notify('notify_async1', '');
SELECT
pg_notify('notify_async1', NULL);
-- Should fail. Send a valid message via an invalid channel name
SELECT
pg_notify('', 'sample message1');
SELECT
pg_notify(NULL, 'sample message1');
SELECT
pg_notify('notify_async_channel_name_too_long______________________________', 'sample_message1');
--Should work. Valid NOTIFY/LISTEN/UNLISTEN commands
NOTIFY notify_async2;
LISTEN notify_async2;
UNLISTEN notify_async2;
UNLISTEN *;
-- Should return zero while there are no pending notifications.
-- src/test/isolation/specs/async-notify.spec tests for actual usage.
SELECT
pg_notification_queue_usage ();
| true |
e173901bf621600a81a4bfd53ff6531f84adb915 | SQL | jgomezatse/plsql | /TRESbodyBACK.sql | WINDOWS-1252 | 23,130 | 3.375 | 3 | [] | no_license | create or replace PACKAGE BODY TRES is
--------------------------------------------------------------------------------
-- Normaliza caracteres Portafirmas
--------------------------------------------------------------------------------
function nz(vIn varchar2) return varchar2 is
begin
return translate(vIn,
'/',
'aeiouaeiouaoaeiooaeioucAEIOUAEIOUAOAEIOOAEIOUC-nN');
end;
--------------------------------------------------------------------------------
-- Aadir/Eliminar Destinatarios
--------------------------------------------------------------------------------
procedure procesarDestinatario(vEsmid number,vNif varchar2) is
cursor cDestinatario(vEsmid number,vNif varchar2) is
select d.esmid, d.destinatario,
decode(instr(d.destinatario,vNif),null,2,0,0,1) fin,
decode(instr(d.destinatario,vNif||';'),null,2,0,0,1) medio
from depuracion.escritosmultas_doc d
where d.esmid=vEsmid and d.cestado=1;
vDestinatario varchar2(200):='';
begin
for d in cDestinatario(vEsmid,vNif) loop
if d.medio=2 then
vDestinatario:=d.destinatario||vNif;
elsif d.medio=1 then
vDestinatario:=replace(d.destinatario,vNif||';','');
elsif d.fin=1 then
vDestinatario:=replace(d.destinatario,';'||vNif,'');
vDestinatario:=replace(vDestinatario,vNif,'');
else
vDestinatario:=d.destinatario||';'||vNif;
end if;
update depuracion.escritosmultas_doc d2
set d2.destinatario=vDestinatario
where d2.esmid=d.esmid;
commit;
end loop;
end;
--------------------------------------------------------------------------------
-- Seleccionar Destinatarios
--------------------------------------------------------------------------------
function selectDestinatarios(vEsmid number) return varchar2 is
cursor cDes(vGrupo number) is
select '<option value="' || u.nif || '">' || u.nombre || '</option>' texto
from depuracion.usufirma u
where
(login in ('cavidgar','rivilmac','esbenmar','mtmaqped','saferlop','viortsae','jurodrod') and vGrupo=2)
or
(login in ('veguelar','ficruvil','mapersev','criglpue','mjmorpal','jlloplem','agmurpei','ilcanrem') and vGrupo=1)
order by u.nombre
;
cursor cEscrito(vEsmid number) is
select decode(e.tidomid,101,2,1) grupo
from alba.escritosmultas e
where e.esmid=vEsmid;
vOut varchar2(2000);
begin
vOut:='';
for e in cEscrito(vEsmid) loop
for t in cDes(e.grupo) loop
vOut:=vOut||t.texto;
end loop;
end loop;
return vOut;
end;
--------------------------------------------------------------------------------
-- GENERACIN DATOS DE INFORME
--------------------------------------------------------------------------------
procedure generarInforme(vEsmid number) is
cursor cEscrito(vEsmid number) is
select
e3.esmid,
(select count(e2.esmid) from alba.escritosmultas e2 where e2.esmid=e3.esmid
--and e2.tdmresid in (261,281,385,401,421)
) escrito,
(select count(d.esmid) from depuracion.escritosmultas_doc d where d.esmid=e3.esmid) informe
from
(select vEsmid esmid from dual) e3,
(select * from alba.escritosmultas) e
where e3.esmid=e.esmid(+)
;
cursor cDatos(vEsmid number) is
SELECT DISTINCT *
FROM
(SELECT
upper(d.nombred) || ' ' || upper(d.nifd) recurrente,
upper(d.domiciliod) domicilio,
(SELECT esmivalor FROM alba.escritosmultasinfo inf
WHERE inf.esmid =e.esmid AND esmietiqueta='PLENO'
AND rownum<2 AND esmiiestado =1) AS "PLENO",
(SELECT esmivalor FROM alba.escritosmultasinfo inf
WHERE inf.esmid =e.esmid AND esmietiqueta='EXPTE. TEA'
AND rownum<2 AND esmiiestado=1) AS "EXPTEA",
NVL((SELECT esmivalor
FROM alba.escritosmultasinfo inf WHERE inf.esmid =e.esmid
AND esmietiqueta='ASUNTO' AND rownum<2 AND esmiiestado =1),
'ACTUACION PROVIDENCIA DE APREMIO, DILIGENCIA DE EMBARGO DE CUENTAS BANCARIAS, A PLAZO, EFECTIVO.') AS "ASUNTO",
e.usuidmod usuid,
l.liqid, l.liqnumerorecliquidacion liquidacion, ex.expcod expediente,
(select tidomdesc from tipos_doc_multas where tidomid=e.tidomid) tipo,
(select tdmnombre from tipos_doc_multas_res where tdmresid=e.tdmresid) estado
FROM alba.liquidaciones l, alba.expingre ex, alba.multas m, alba.escritosmultas e,
TABLE(depuracion.trml.dmultas(m.mulid,e.esmid)) d
WHERE e.mulid =m.mulid and e.esmid=vEsmid
AND m.EXPIDEXP=ex.expid AND ex.expid =l.EXPID(+)
);
cursor usuarios(vUsuid number) is
select u.nif,u.nombre from depuracion.usufirma u
where u.usuid=vUsuid and rownum<2;
cursor destinatario(vEsmid number) is
select d.destinatario from depuracion.escritosmultas_doc d
where d.esmid=vEsmid;
cursor cInformec(vEsmid number) is
select depuracion.tres.informe(d.esmid) informeNew,
d.informec informeOld, d.estado estado from depuracion.escritosmultas_doc d
where d.esmid=vEsmid;
vInformen VARCHAR2(200):='';
vNifremite VARCHAR2(20):='';
vNombreremite VARCHAR2(200):='';
vReferencia VARCHAR2(200):='';
vAsunto VARCHAR2(200):='';
vTexto VARCHAR2(200):='';
vDestinatario VARCHAR2(200):='';
vEstado varchar2(30):='PENDIENTE';
vInformeNew clob:='';
vInformeOld clob:='';
begin
for i in cDatos(vEsmid) loop
vNifremite:='';
vNombreremite:=nz('');
for u in usuarios(i.usuid) loop
vNifremite:=nz(u.nif);
vNombreremite:=nz(u.nombre);
end loop;
if vNombreremite is null or vNombreremite='' then
vNombreremite:='No existe usuario ' || i.usuid;
end if;
vReferencia:='esmid'||vEsmid;
vAsunto:=nz(substr(i.tipo || ' ' || i.estado || ' ' || nvl(i.exptea,i.expediente),1,200));
vTexto:=nz(substr(i.tipo || ' ' || i.estado || ' ' || nvl(i.exptea,i.expediente) || ' ' || i.recurrente || ' ' || ' #WSDEB#',1,200));
--vInformen:=nz('Exptea_' || i.exptea ||'.pdf');
if i.exptea is null then
vInformen:=nz(i.expediente || '_' || vEsmid || '_' || i.tipo || '.pdf');
else
vInformen:=nz('TEA_' || i.exptea || '_' || vEsmid || '.pdf');
end if;
vDestinatario:='';
end loop;
for d in destinatario(vEsmid) loop
vDestinatario:=d.destinatario;
end loop;
for i in cEscrito(vEsmid) loop
if i.escrito=1 then
if vInformen is null or vInformen=''
or vNifremite is null or vNifremite=''
or vReferencia is null or vReferencia=''
or vAsunto is null or vAsunto=''
or vTexto is null or vTexto=''
or vDestinatario is null or vDestinatario=''
then
vEstado:='INCOMPLETO';
end if;
if i.informe=0 then
insert into depuracion.escritosmultas_doc d
(esmid,esmdfhoramod,usuidmod,esmdmotivo,informec,cestado,estado,
informen,nifremite,nombreremite,referencia,asunto,texto,destinatario)
values
(vEsmid,sysdate,0,'alta',(select depuracion.tres.informe(vEsmid) informe from dual),1,'GENERAR_PDF',
vInformen,vNifremite,vNombreremite,vReferencia,vAsunto,vTexto,vDestinatario);
commit;
else
for i in cInformec(vEsmid) loop
vInformeNew:=i.informeNew;
vInformeOld:=i.informeOld;
if i.estado='GENERAR_PDF' then
vEstado:='GENERAR_PDF';
end if;
end loop;
if dbms_lob.compare(vInformeNew,vInformeOld)=0 then
update depuracion.escritosmultas_doc d
set
d.cestado=1,d.estado=vEstado,d.esmdfhoramod=sysdate,
d.usuidmod=0, d.esmdmotivo='mofificacion',
--d.informec=(select depuracion.tres.informe(vEsmid) informe from dual),
--d.informeb=null,
d.informen=vInformen,d.nifremite=vNifremite,d.nombreremite=vNombreremite,
d.referencia=vReferencia,d.asunto=vAsunto,d.texto=vTexto,
d.destinatario=vDestinatario
where d.esmid=vEsmid and d.cestado in (0,1);
else
update depuracion.escritosmultas_doc d
set
d.cestado=1,d.estado='GENERAR_PDF',d.esmdfhoramod=sysdate,
d.usuidmod=0,d.esmdmotivo='mofificacion',
d.informec=vInformeNew,
d.informeb=null,
d.informen=vInformen,d.nifremite=vNifremite,
d.nombreremite=vNombreremite,d.referencia=vReferencia,
d.asunto=vAsunto,d.texto=vTexto,d.destinatario=vDestinatario
where d.esmid=vEsmid and d.cestado in (0,1);
end if;
commit;
end if;
end if;
end loop;
end;
-------------------------------------------------------------------------------
-- INFORME MULTAS Y RESTO
--------------------------------------------------------------------------------
function informe1(vEsmid number) return clob is
cursor cDatos(vEsmid number) is
SELECT
d.nexpediente expediente,d.boletin,d.fdenuncia fecha,d.hora,d.lugar,d.matricula,
d.vehiculo,d.motivonoentrega motivo,d.hecho,d.tiemporetirada importe,
upper(d.nifd) nif,
upper(d.nombred) denunciado,
upper(d.domiciliod) domicilio
FROM alba.liquidaciones l,
alba.expingre ex,
alba.multas m,
alba.escritosmultas e,
TABLE(depuracion.trml.dmultas(m.mulid,e.esmid)) d
WHERE e.mulid =m.mulid
AND m.EXPIDEXP=ex.expid
AND ex.expid=l.EXPID(+)
and e.esmid=vEsmid
;
cursor cLiquidaciones(vEsmid number) is
select distinct
ex.expcod EXPTE, l.LIQNUMERORECLIQUIDACION LIQUIDACION
from
alba.liquidaciones l, alba.expingre ex, alba.multas m, alba.escritosmultas e
where e.mulid=m.mulid and m.EXPIDEXP=ex.expid and ex.expid=l.EXPID
and exists
(select 1 from alba.escritosmultas e2
where e2.esmid=vEsmid and e.esmcaja=e2.esmcaja
and e.esmlote=e2.esmlote and e.esmindice=e2.esmindice)
and l.liqid in
(select max(l2.liqid) from liquidaciones l2 where l2.expid=l.expid)
order by l.LIQNUMERORECLIQUIDACION asc
;
cursor cCabecera(vEsmid number) is
select
replace(
replace(rsaresolucion,CHR(13),'\\'||CHR(10)||CHR(13))
,'"','``')
res
from
alba.resoluciones rs, alba.escritosmultas e, alba.resol_alegaciones r
WHERE r.resid=rs.resid
and r.ESMID=e.esmid
and rs.orden in ('CABECERA','PRUEBA CABECERA') and rownum<2
and exists
(select 1 from alba.escritosmultas e2
where e2.esmid=vEsmid and e.esmcaja=e2.esmcaja
and e.esmlote=e2.esmlote and e.esmindice=e2.esmindice)
;
cursor cDetalle(vEsmid number) is
select
'\\'||CHR(10)||CHR(13)||
replace(
replace(
replace(
replace(rsaresolucion,CHR(13),'\\'||CHR(10)||CHR(13)),
'@recibos',
depuracion.trml.parametro(e.esmid,r.resid,'recibos')),
'@recibo',
depuracion.trml.parametro(e.esmid,r.resid,'recibo')
),'"','``') || '\\'
res
from
alba.resoluciones rs, alba.escritosmultas e, alba.resol_alegaciones r
WHERE r.resid=rs.resid and r.ESMID=e.esmid
and r.rsaresolucion is not null
and (rs.orden is null or rs.orden='PRUEBA DETALLE')
and exists
(select 1 from alba.escritosmultas e2
where e2.esmid=vEsmid and e.esmcaja=e2.esmcaja
and e.esmlote=e2.esmlote and e.esmindice=e2.esmindice)
order by r.rsaid asc
;
cursor cPie(vEsmid number) is
select
replace(
replace(rsaresolucion,CHR(13),'\\'||CHR(10)||CHR(13))
,'"','``')
res
from
alba.resoluciones rs, alba.escritosmultas e, alba.resol_alegaciones r
WHERE r.resid=rs.resid and r.ESMID=e.esmid
and rs.orden in ('PIE','PRUEBA PIE') and rownum<2
and exists
(select 1 from alba.escritosmultas e2
where e2.esmid=vEsmid and e.esmcaja=e2.esmcaja
and e.esmlote=e2.esmlote and e.esmindice=e2.esmindice)
;
vSalida clob;
vAux clob;
vTemp clob;
begin
vSalida:=q'~
\documentclass[10pt]{article}
\usepackage[sfdefault,light]{roboto}
\usepackage[T1]{fontenc}
\usepackage[spanish,activeacute]{babel}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{fancyhdr}
\usepackage{anysize}
\usepackage{float}
\usepackage{lastpage}
\usepackage[none]{hyphenat} %evitar salto de linea
\papersize{29.7cm}{21.0cm} %para tamao carta, para otros eligieran la correcta
\marginsize{2cm}{2cm}{3cm}{2cm} %\marginsize{Izque}{Derec}{Arrib}{Abajo}
\setlength{\parindent}{0cm} % evita sangrado de prrafos
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt} % grosor de la lnea de la cabecera
\renewcommand{\footrulewidth}{0pt} % grosor de la lnea del pie
\lhead{\begin{picture}(0,0) \put(0,0){\includegraphics[width=0.25\textwidth]{/var/www/html/logo.jpg}} \end{picture} \\}
\chead{{\tiny REA DE COORDINACIN\\DELEGACIN DE HACIENDA\\AGENCIA TRIBUTARIA DE SEVILLA\\DEPARTAMENTO DE GESTIN DE SANCIONES\\}}
\rhead{@expediente \\}
\lfoot{SRA. GERENTE DE LA AGENCIA TRIBUTARIA DE SEVILLA}
\cfoot{}
\rfoot{pg. \thepage}
\begin{document}
\sloppy %evitar salto de linea
\small
@datos
@lista_liquidaciones
\small
@contenido
\end{document}
~';
-----------------
-- Datos
-----------------
for i in cDatos(vEsmid) loop
vAux:=q'~
\setlength\arrayrulewidth{0.1pt}
\begin{table}[H]
\begin{left}
\begin{tabular}{|p{0.1\textwidth} p{0.85\textwidth}|}
\hline
{\small Fecha:}& \textbf{@fecha} \hspace{0.6cm} {\small Hora:} \textbf{@hora}\\
{\small Lugar:}& \textbf{@lugar}\\
{\small Matrcula:}& \textbf{@matricula} \hspace{0.6cm} {\small Vehculo:} \textbf{@vehiculo}\\
{\small Denunciado:}& \textbf{@denunciado} \hspace{0.6cm} {\small Nif:} \textbf{@nif}\\
{\small Domicilio:}& \textbf{@domicilio}\\
{\small Hecho Denunciado:}& \textbf{@hecho}\\
{\small Importe:}& \textbf{ @importe} \hspace{0.6cm} {\small Motivo de no entrega en el acto:} \textbf{@motivo}\\
\hline
\end{tabular}
\end{center}
\end{table}
~';
vAux:=replace(vAux,'@fecha',i.fecha);
vAux:=replace(vAux,'@hora',i.hora);
vAux:=replace(vAux,'@lugar',i.lugar);
vAux:=replace(vAux,'@matricula',i.matricula);
vAux:=replace(vAux,'@vehiculo',i.vehiculo);
vAux:=replace(vAux,'@denunciado',i.denunciado);
vAux:=replace(vAux,'@nif',i.nif);
vAux:=replace(vAux,'@domicilio',i.domicilio);
vAux:=replace(vAux,'@motivo',i.motivo);
vAux:=replace(vAux,'@importe',i.importe);
vAux:=replace(vAux,'@hecho',i.hecho);
vSalida:=replace(vSalida,'@expediente','Expediente \textbf{' || i.expediente || '} \\ Boletn \textbf{' || i.boletin || '}');
end loop;
vSalida:=replace(vSalida,'@datos',vAux);
-------------------------
-- Cabecera, Detalle, Pie
-------------------------
vAux:='';
for i in cCabecera(vEsmid) loop
vAux:=vAux || i.res;
end loop;
for i in cDetalle(vEsmid) loop
vAux:=vAux || i.res;
end loop;
for i in cPie(vEsmid) loop
vAux:=vAux || i.res;
end loop;
vSalida:=replace(vSalida,'@contenido',vAux);
return vSalida;
end;
--------------------------------------------------------------------------------
-- INFORME TEA
--------------------------------------------------------------------------------
function informe2(vEsmid number) return clob is
cursor cDatos(vEsmid number) is
SELECT DISTINCT *
FROM
(SELECT
upper(d.nombred) recurrente,
upper(d.domiciliod) domicilio,
(SELECT esmivalor FROM alba.escritosmultasinfo inf WHERE inf.esmid =e.esmid
AND esmietiqueta='PLENO' AND rownum<2 AND esmiiestado =1) AS "PLENO",
(SELECT esmivalor FROM alba.escritosmultasinfo inf WHERE inf.esmid =e.esmid
AND esmietiqueta='EXPTE. TEA' AND rownum<2 AND esmiiestado =1) AS "EXPTEA",
NVL(
(SELECT esmivalor FROM alba.escritosmultasinfo inf WHERE inf.esmid =e.esmid
AND esmietiqueta='ASUNTO' AND rownum<2 AND esmiiestado =1
), 'ACTUACION PROVIDENCIA DE APREMIO, DILIGENCIA DE EMBARGO DE CUENTAS BANCARIAS, A PLAZO, EFECTIVO.') AS "ASUNTO"
FROM alba.liquidaciones l,
alba.expingre ex,
alba.multas m,
alba.escritosmultas e,
TABLE(depuracion.trml.dmultas(m.mulid,e.esmid)) d
WHERE e.mulid =m.mulid
AND m.EXPIDEXP=ex.expid
AND ex.expid=l.EXPID(+)
AND EXISTS
(SELECT 1 FROM alba.escritosmultasinfo ei WHERE ei.esmid=e.esmid AND ei.esmietiqueta='EXPTE. TEA')
AND EXISTS
(SELECT 1 FROM alba.escritosmultas e2 WHERE e2.esmid =vEsmid
AND e.esmcaja=e2.esmcaja AND e.esmlote=e2.esmlote AND e.esmindice=e2.esmindice)
ORDER BY l.LIQNUMERORECLIQUIDACION ASC
)
;
cursor cLiquidaciones(vEsmid number) is
select distinct
ex.expcod EXPTE, l.LIQNUMERORECLIQUIDACION LIQUIDACION
from
alba.liquidaciones l, alba.expingre ex, alba.multas m, alba.escritosmultas e
where e.mulid=m.mulid and m.EXPIDEXP=ex.expid and ex.expid=l.EXPID
and exists
(select 1 from alba.escritosmultas e2
where e2.esmid=vEsmid and e.esmcaja=e2.esmcaja
and e.esmlote=e2.esmlote and e.esmindice=e2.esmindice)
and l.liqid in
(select max(l2.liqid) from liquidaciones l2 where l2.expid=l.expid)
order by l.LIQNUMERORECLIQUIDACION asc
;
cursor cCabecera(vEsmid number) is
select
replace(
replace(rsaresolucion,CHR(13),'\\'||CHR(10)||CHR(13))
,'"','``')
res
from
alba.resoluciones rs, alba.escritosmultas e, alba.resol_alegaciones r
WHERE r.resid=rs.resid
and r.ESMID=e.esmid
and rs.orden in ('CABECERA','PRUEBA CABECERA') and rownum<2
and exists
(select 1 from alba.escritosmultas e2
where e2.esmid=vEsmid and e.esmcaja=e2.esmcaja
and e.esmlote=e2.esmlote and e.esmindice=e2.esmindice)
;
cursor cDetalle(vEsmid number) is
select
'\\'||CHR(10)||CHR(13)||
replace(
replace(
replace(
replace(rsaresolucion,CHR(13),'\\'||CHR(10)||CHR(13)),
'@recibos',
depuracion.trml.parametro(e.esmid,r.resid,'recibos')),
'@recibo',
depuracion.trml.parametro(e.esmid,r.resid,'recibo')
),'"','``') || '\\'
res
from
alba.resoluciones rs, alba.escritosmultas e, alba.resol_alegaciones r
WHERE r.resid=rs.resid and r.ESMID=e.esmid
and r.rsaresolucion is not null
and (rs.orden is null or rs.orden='PRUEBA DETALLE')
and exists
(select 1 from alba.escritosmultas e2
where e2.esmid=vEsmid and e.esmcaja=e2.esmcaja
and e.esmlote=e2.esmlote and e.esmindice=e2.esmindice)
order by r.rsaid asc
;
cursor cPie(vEsmid number) is
select
replace(
replace(rsaresolucion,CHR(13),'\\'||CHR(10)||CHR(13))
,'"','``')
res
from
alba.resoluciones rs, alba.escritosmultas e, alba.resol_alegaciones r
WHERE r.resid=rs.resid and r.ESMID=e.esmid
and rs.orden in ('PIE','PRUEBA PIE') and rownum<2
and exists
(select 1 from alba.escritosmultas e2
where e2.esmid=vEsmid and e.esmcaja=e2.esmcaja
and e.esmlote=e2.esmlote and e.esmindice=e2.esmindice)
;
vSalida clob;
vAux clob;
vTemp clob;
begin
vSalida:=q'~
\documentclass[10pt]{article}
\usepackage[sfdefault,light]{roboto}
\usepackage[T1]{fontenc}
\usepackage[spanish,activeacute]{babel}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{fancyhdr}
\usepackage{anysize}
\usepackage{float}
\usepackage{lastpage}
\usepackage[none]{hyphenat} %evitar salto de linea
\papersize{29.7cm}{21.0cm} %para tamao carta, para otros eligieran la correcta
\marginsize{2cm}{2cm}{3cm}{2cm} %\marginsize{Izque}{Derec}{Arrib}{Abajo}
\setlength{\parindent}{0cm} % evita sangrado de prrafos
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt} % grosor de la lnea de la cabecera
\renewcommand{\footrulewidth}{0pt} % grosor de la lnea del pie
\lhead{\begin{picture}(0,0) \put(0,0){\includegraphics[width=0.3\textwidth]{/var/www/html/tea.jpg}} \end{picture}}
\chead{}
\rhead{@exptea}
\lfoot{}
\cfoot{}
\rfoot{pg. \thepage}
\begin{document}
\sloppy %evitar salto de linea
@datos
@lista_liquidaciones
\small
@contenido
\end{document}
~';
-----------------
-- Datos
-----------------
for i in cDatos(vEsmid) loop
vAux:=q'~
\setlength\arrayrulewidth{0.1pt}
Datos de la Reclamacin
\begin{table}[H]
\begin{left}
\begin{tabular}{|l p{0.81\textwidth}|}
\hline
RECURRENTE & \textbf{@recurrente}\\
DOMICILIO & \textbf{@domicilio}\\
PLENO & \textbf{@pleno}\\
EXPEDIENTE TEA & \textbf{@exptea}\\
ASUNTO & \textbf{@asunto}\\
\hline
\end{tabular}
\end{center}
\end{table}
~';
vAux:=replace(vAux,'@recurrente',i.recurrente);
vAux:=replace(vAux,'@domicilio',i.domicilio);
vAux:=replace(vAux,'@pleno',i.pleno);
vAux:=replace(vAux,'@exptea',i.exptea);
vAux:=replace(vAux,'@asunto',i.asunto);
vSalida:=replace(vSalida,'@exptea','Expediente ' || i.exptea);
end loop;
vSalida:=replace(vSalida,'@datos',vAux);
-----------------
-- Liquidaciones
-----------------
vAux:=q'~
\setlength\arrayrulewidth{0.1pt}
Expedientes de Trfico
\begin{table}[H]
\begin{left}
\begin{tabular}{|l l|}
\hline
EXPEDIENTE & \ LIQUIDACIN\\
@liq_lista
\hline
\end{tabular}
\end{center}
\end{table}
~';
vTemp:='';
for i in cLiquidaciones(vEsmid) loop
vTemp:=vTemp || ' ' || i.expte|| ' ' || chr(38) || ' ' || i.liquidacion || '\\';
end loop;
vAux:=replace(vAux,'@liq_lista',vTemp);
vSalida:=replace(vSalida,'@lista_liquidaciones',vAux);
-------------------------
-- Cabecera, Detalle, Pie
-------------------------
vAux:='';
for i in cCabecera(vEsmid) loop
vAux:=vAux || i.res;
end loop;
for i in cDetalle(vEsmid) loop
vAux:=vAux || i.res;
end loop;
for i in cPie(vEsmid) loop
vAux:=vAux || i.res;
end loop;
select depuracion.trml.parametro(vEsmid,null,'expedientes') into vTemp from dual;
vAux:=replace(vAux,'@expedientes',vTemp); vTemp:='';
select depuracion.trml.parametro(vEsmid,null,'estimadas') into vTemp from dual;
vAux:=replace(vAux,'@estimadas',vTemp); vTemp:='';
select depuracion.trml.parametro(vEsmid,null,'desestimadas') into vTemp from dual;
vAux:=replace(vAux,'@desestimadas',vTemp); vTemp:='';
select depuracion.trml.parametro(vEsmid,null,'hoy') into vTemp from dual;
vAux:=replace(vAux,'@hoy',vTemp); vTemp:='';
select depuracion.trml.parametro(vEsmid,null,'recurrente') into vTemp from dual;
vAux:=replace(vAux,'@recurrente',vTemp); vTemp:='';
select depuracion.trml.parametro(vEsmid,null,'domicilio') into vTemp from dual;
vAux:=replace(vAux,'@domicilio',vTemp); vTemp:='';
select depuracion.trml.parametro(vEsmid,null,'pleno') into vTemp from dual;
vAux:=replace(vAux,'@pleno',vTemp); vTemp:='';
select depuracion.trml.parametro(vEsmid,null,'expediente_tea') into vTemp from dual;
vAux:=replace(vAux,'@expediente_tea',vTemp); vTemp:='';
select depuracion.trml.parametro(vEsmid,null,'asunto') into vTemp from dual;
vAux:=replace(vAux,'@asunto',vTemp); vTemp:='';
-----------------
-----------------
vSalida:=replace(vSalida,'@contenido',vAux);
return vSalida;
end;
function informe(vEsmid number) return clob is
cursor cEscrito(vEsmid number) is
select decode(e.tidomid,101,2,1) informe
from alba.escritosmultas e
where e.esmid=vEsmid;
vOut clob:='';
begin
for e in cEscrito(vEsmid) loop
if e.informe=1 then
vOut:=informe1(vEsmid);
elsif e.informe=2 then
vOut:=informe2(vEsmid);
end if;
end loop;
return vOut;
end;
end TRES; | true |
ae48f5bca14d9cee4897000f0bc14c7e7af4425a | SQL | cckmit/wits-frameworks | /DevDocs/dbdesign/bsc_authmngcfg.sql | UTF-8 | 77,166 | 2.71875 | 3 | [] | no_license | /*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2018/12/29 15:21:11 */
/*==============================================================*/
drop table if exists fdb_metam_attr_spec;
drop table if exists fdb_metam_dbinst_schema;
drop table if exists fdb_metam_dbtbl_reldesc;
drop table if exists fdb_metam_dictvalue;
drop table if exists fdb_metam_dictype;
drop table if exists fdb_metam_domain;
drop table if exists fdb_metam_entity_spec;
drop table if exists fdb_metam_field;
drop table if exists fdb_metam_relation_spec;
drop table if exists fdb_metam_table;
drop table if exists fdb_metam_taiji;
drop table if exists fdb_metam_ui_compt;
drop table if exists fdb_metam_ui_view;
drop table if exists fdb_metar_compt_rel;
drop table if exists fdb_metar_dict_dicv;
drop table if exists fdb_metar_dictv_attr;
drop table if exists fdb_metar_dm_entity;
drop table if exists fdb_metar_spec_compt;
drop table if exists fdb_metar_taiji_inter;
drop table if exists fdb_metar_tbl_spec;
drop table if exists fdb_metar_tj_entity;
drop table if exists fdb_metar_view_compt;
drop table if exists fdb_metar_view_inter;
drop table if exists fdb_scam_ciper_mng;
drop table if exists fdb_scam_organization;
drop table if exists fdb_scam_role;
drop table if exists fdb_scam_staff;
drop table if exists fdb_scam_sysres;
drop table if exists fdb_scam_user;
drop table if exists fdb_scam_user_group;
drop table if exists fdb_scam_user_trace;
drop table if exists fdb_scar_ciper_entity;
drop table if exists fdb_scar_org_staff;
drop table if exists fdb_scar_role_operm;
drop table if exists fdb_scar_ugrp_role;
drop table if exists fdb_scar_user_operm;
drop table if exists fdb_scar_user_role;
drop table if exists fdb_scar_user_ugrp;
/*==============================================================*/
/* Table: fdb_metam_attr_spec */
/*==============================================================*/
create table fdb_metam_attr_spec
(
id bigint(20) unsigned not null comment 'id 主键',
rel_spec_id bigint(20) comment '所属实体规格ID',
spec_type varchar(32) comment '所属规格类型,ENTITY RELATION',
rel_dm_id bigint(20) comment '所属域',
attr_name varchar(128) not null comment '名称',
attr_code varchar(128) comment '编码',
espec_icon varchar(64) comment '图标',
attr_type varchar(32) comment '属性类型,表字段TBLFLD,关联依赖1:1 REL1TO1 关联依赖1:N REL1TON',
rel_ettspec_id bigint(20) comment '关联实体规格ID',
rel_tbl_id bigint(20) comment '所属表ID',
rel_tbl_name varchar(64) comment '所属表名称',
rel_fld_id bigint(20) comment '所属字段ID',
rel_fld_name varchar(64) comment '所属字段名称',
attr_code_type varchar(32) comment '类属性类型,对应编程语言类型',
def_value varchar(64) comment '默认值',
rel_dict_id bigint(20) comment '所属字典类型',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_attr_spec comment '元数据-属性规格';
/*==============================================================*/
/* Table: fdb_metam_dbinst_schema */
/*==============================================================*/
create table fdb_metam_dbinst_schema
(
id bigint(20) unsigned not null comment 'id 主键',
parent_id bigint(20) unsigned comment '父ID',
rel_dm_id bigint(20) comment '所属域',
dinst_type varchar(64) comment '数据实例类型,关系型MySQL....',
svr_type varchar(32) comment '服务模式',
svr_role varchar(32) comment '服务角色,主从...',
dinst_name varchar(128) not null comment '名称',
dinst_code varchar(128) comment '编码',
driver_url varchar(512) comment '驱动链接',
req_account varchar(64) comment '访问账号',
req_password varchar(255) comment '访问密码',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_dbinst_schema comment '元数据-数据源模式';
/*==============================================================*/
/* Table: fdb_metam_dbtbl_reldesc */
/*==============================================================*/
create table fdb_metam_dbtbl_reldesc
(
id bigint(20) unsigned not null comment 'id 主键',
rel_dbinst_id bigint(20) comment '所属数据源/模式',
rel_dm_id bigint(20) comment '所属域',
tblrel_type varchar(32) comment '实体关系类型',
src_tbl_id bigint(20) comment '源表ID',
src_tbl_name varchar(64) comment '源表名称',
src_relfld_id bigint(20) comment '源表关联字段ID',
src_relfld_name varchar(64) comment '源表关联字段名称',
mid_tbl_id bigint(20) comment '中间表ID',
mid_tbl_name varchar(64) comment '中间表名',
mid_afld_id bigint(20) comment '中间表A端关联字段ID',
mid_afld_name varchar(64) comment '中间表A端关联字段名称',
mid_zfld_id bigint(20) comment '中间表Z端关联字段ID',
mid_zfld_name varchar(64) comment '中间表Z端关联字段名称',
dst_tbl_id bigint(20) comment '目标表ID',
dst_tbl_name varchar(64) comment '目标表名称',
dst_relfld_id bigint(20) comment '目标表关联字段ID',
dst_relfld_name varchar(64) comment '目标表关联字段名称',
mid_name varchar(128) not null comment '名称',
mid_code varchar(128) comment '编码',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_dbtbl_reldesc comment '元数据-实体表关系描述';
/*==============================================================*/
/* Table: fdb_metam_dictvalue */
/*==============================================================*/
create table fdb_metam_dictvalue
(
ID bigint(20) unsigned not null comment 'id 主键',
parent_id bigint(20) unsigned comment '父ID',
rel_dictype_id bigint(20) comment '所属字典类型',
rel_dm_id bigint(20) comment '所属域',
dicv_name varchar(128) not null comment '名称',
dicv_code varchar(128) comment '编码',
dic_value varchar(64) comment '取值',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_dictvalue comment '字典值表';
/*==============================================================*/
/* Table: fdb_metam_dictype */
/*==============================================================*/
create table fdb_metam_dictype
(
id bigint(20) unsigned not null comment 'id 主键',
parent_id bigint(20) unsigned comment '父ID',
rel_dm_id bigint(20) comment '所属域',
dict_name varchar(128) not null comment '名称',
dict_code varchar(128) comment '编码',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_dictype comment '字典类型表';
/*==============================================================*/
/* Table: fdb_metam_domain */
/*==============================================================*/
create table fdb_metam_domain
(
id bigint(20) unsigned not null comment 'id 主键',
dm_name varchar(128) not null comment '名称',
dm_code varchar(128) comment '编码',
dm_type varchar(32) comment '域类型',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_domain comment ' 元数据配置-领域表';
/*==============================================================*/
/* Table: fdb_metam_entity_spec */
/*==============================================================*/
create table fdb_metam_entity_spec
(
id bigint(20) unsigned not null comment 'id 主键',
rel_dm_id bigint(20) comment '所属域',
espec_name varchar(128) not null comment '名称',
espec_code varchar(128) comment '编码',
espec_icon varchar(64) comment '图标',
rel_modu_name varchar(64) comment '所属模块名',
cls_path varchar(255) comment '类路径',
qry_svr_uri varchar(512) comment '检索服务资源',
data_qry_scripts text comment '数据检索语句',
put_svr_uri2 varchar(512) comment '添加/更新服务资源',
data_put_scripts text comment '数据添加/更新语句',
del_svr_uri varchar(512) comment '删除服务资源',
data_del_scripts text comment '数据删除语句',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_entity_spec comment '元数据-实体规格';
/*==============================================================*/
/* Table: fdb_metam_field */
/*==============================================================*/
create table fdb_metam_field
(
id bigint(20) unsigned not null comment 'id 主键',
rel_tbl_id bigint(20) comment '所属表ID',
rel_dm_id bigint(20) comment '所属域',
fld_name varchar(128) not null comment '名称',
fld_code varchar(128) comment '编码',
fld_type varchar(64) comment '字段类型',
fld_length integer(4) comment '长度',
fld_presision integer(4) comment '精度',
is_null tinyint(1) comment '是否可为空',
def_val varchar(64) comment '默认值',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_field comment '元数据-字段表';
/*==============================================================*/
/* Table: fdb_metam_relation_spec */
/*==============================================================*/
create table fdb_metam_relation_spec
(
id bigint(20) unsigned not null comment 'id 主键',
rel_dm_id bigint(20) comment '所属域',
rspec_name varchar(128) not null comment '名称',
rspec_code varchar(128) comment '编码',
prv_entity_id bigint(20) comment '提供方实体ID',
prv_rel_type varchar(32) comment '提供方关联类型, 1TO1 1TON',
csm_entity_id bigint(20) comment '接收方实体ID',
csm_rel_type varchar(32) comment '接收方关联类型 1TO1 1TON',
rspec_icon varchar(64) comment '图标',
pkg_path varchar(255) comment '包路径',
svr_uri varchar(255) comment '服务资源(REST)',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
qry_svr_uri varchar(512) comment '检索服务资源',
data_qry_scripts text comment '数据检索语句',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_relation_spec comment '元数据-关系规格';
/*==============================================================*/
/* Table: fdb_metam_table */
/*==============================================================*/
create table fdb_metam_table
(
id bigint(20) unsigned not null comment 'id 主键',
parent_id bigint(20) unsigned comment '父ID',
rel_datasrc_id bigint(20) comment '所属数据源',
rel_dm_id bigint(20) comment '所属域',
tbl_name varchar(128) not null comment '名称',
tbl_code varchar(128) comment '编码',
tbl_type varchar(64) comment '表类型',
prik_fld_names varchar(128) comment '主键字段名',
lgtbl_fld_name varchar(128) comment '纵表字段名',
lgtbl_key_fld varchar(128) comment '纵表KEY字段名',
lgtbl_value_fld varchar(128) comment '纵表VALUE字段名',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_table comment '元数据配置-模型表';
/*==============================================================*/
/* Table: fdb_metam_taiji */
/*==============================================================*/
create table fdb_metam_taiji
(
id bigint(20) unsigned not null comment 'id 主键',
tj_name varchar(128) not null comment '名称',
tj_code varchar(128) comment '编码',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_taiji comment '元数据配置——太极';
/*==============================================================*/
/* Table: fdb_metam_ui_compt */
/*==============================================================*/
create table fdb_metam_ui_compt
(
id bigint(20) unsigned not null comment 'id 主键',
parent_id bigint(20) comment '父组件ID',
rel_dm_id bigint(20) comment '所属域',
compt_name varchar(128) not null comment '名称',
compt_code varchar(128) comment '编码',
compt_icon varchar(64) comment '图标',
compt_type varchar(32) comment '组件类型',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_ui_compt comment '元数据-展现组件';
/*==============================================================*/
/* Table: fdb_metam_ui_view */
/*==============================================================*/
create table fdb_metam_ui_view
(
id bigint(20) unsigned not null comment 'id 主键',
parent_id bigint(20) comment '父组件ID',
rel_dm_id bigint(20) comment '所属域',
rel_app_id bigint(20) comment '所属应用ID',
rel_app_name varchar(128) comment '所属应用名称',
rel_svrinst_id bigint(20) comment '所属服务实例ID',
rel_svrinst_name varchar(512) comment '所属服务实例名称',
view_name varchar(128) not null comment '名称',
view_code varchar(128) comment '编码',
view_type varchar(32) comment '界面类型 PAGE LAYOUT',
res_svc_uri varchar(255) comment '资源访问路径',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metam_ui_view comment '元数据-展现界面';
/*==============================================================*/
/* Table: fdb_metar_compt_rel */
/*==============================================================*/
create table fdb_metar_compt_rel
(
id bigint(20) unsigned not null comment 'id 主键',
rel_type varchar(32) comment '关系类型',
vkey_srccompt_id bigint(20) comment '源组件ID',
vkey_tarcompt_id bigint(20) comment '目标组件ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_compt_rel comment '组件-组件组合关系';
/*==============================================================*/
/* Table: fdb_metar_dict_dicv */
/*==============================================================*/
create table fdb_metar_dict_dicv
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_dict_id bigint(20) comment '用户组ID',
vkey_dicv_id bigint(20) comment '角色ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_dict_dicv comment '字典值与字典类型映射';
/*==============================================================*/
/* Table: fdb_metar_dictv_attr */
/*==============================================================*/
create table fdb_metar_dictv_attr
(
id bigint(20) unsigned not null comment 'id 主键',
spec_attr_id bigint(20) comment '规格属性ID',
vkey_dicv_id bigint(20) comment '角色ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_dictv_attr comment '字典值与规格属性关联映射';
/*==============================================================*/
/* Table: fdb_metar_dm_entity */
/*==============================================================*/
create table fdb_metar_dm_entity
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_ugrp_id bigint(20) comment '用户组ID',
vkey_entity_id bigint(20) comment '角色ID',
entity_type varchar(64),
table_name varchar(64) comment '关联表名称',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_dm_entity comment '域与实体对象关系表';
/*==============================================================*/
/* Table: fdb_metar_spec_compt */
/*==============================================================*/
create table fdb_metar_spec_compt
(
id bigint(20) unsigned not null comment 'id 主键',
spec_type varchar(32) comment '规格类型, ENTITY RELATION',
vkey_spec_id bigint(20) comment '规格ID',
vkey_compt_id bigint(20) comment '组件ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_spec_compt comment '组件与规格关联映射';
/*==============================================================*/
/* Table: fdb_metar_taiji_inter */
/*==============================================================*/
create table fdb_metar_taiji_inter
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_src_id bigint(20) comment '源太极ID',
vkey_dst_id bigint(20) comment '目标太极ID',
inter_type varchar(32) comment '交互方式',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_taiji_inter comment '太极之间交互';
/*==============================================================*/
/* Table: fdb_metar_tbl_spec */
/*==============================================================*/
create table fdb_metar_tbl_spec
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_tbl_id bigint(20) comment '表ID',
vkey_spec_id bigint(20) comment '规格ID',
spec_type varchar(32) comment '规格类型',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_tbl_spec comment '规格与表映射关系';
/*==============================================================*/
/* Table: fdb_metar_tj_entity */
/*==============================================================*/
create table fdb_metar_tj_entity
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_tj_id bigint(20) comment '用户组ID',
vkey_entity_id bigint(20) comment '角色ID',
entity_type varchar(64),
table_name varchar(64) comment '关联表名称',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_tj_entity comment '太极与实体对象关系表';
/*==============================================================*/
/* Table: fdb_metar_view_compt */
/*==============================================================*/
create table fdb_metar_view_compt
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_view_id bigint(20) comment '规格ID',
vkey_compt_id bigint(20) comment '组件ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_view_compt comment '界面与组件关联映射';
/*==============================================================*/
/* Table: fdb_metar_view_inter */
/*==============================================================*/
create table fdb_metar_view_inter
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_srcview_id bigint(20) comment '源界面ID',
vkey_dstview_id bigint(20) comment '目标界面ID',
inter_type varchar(32) comment '交互方式',
vkey_srccompt_id bigint(20) comment '源组件ID',
vkey_dstcompt_id bigint(20) comment '目标组件ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_metar_view_inter comment '界面交互映射';
/*==============================================================*/
/* Table: fdb_scam_ciper_mng */
/*==============================================================*/
create table fdb_scam_ciper_mng
(
id bigint(20) unsigned not null comment 'id 主键',
rel_parent_id bigint(20) comment '父节点ID',
ugrp_name varchar(128) comment '名称',
ugrp_code varchar(64) comment '编码',
ciper_type varchar(32) comment '密钥类型',
ciper_key varchar(128) comment '密钥Key',
ciper_salt varchar(64) comment '密钥加盐',
pub_key varchar(512) comment '公钥',
pri_key varchar(4000) comment '私钥',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scam_ciper_mng comment '秘钥管理';
/*==============================================================*/
/* Table: fdb_scam_organization */
/*==============================================================*/
create table fdb_scam_organization
(
id bigint(20) unsigned not null comment 'id 主键',
short_name varchar(255) comment '简称',
org_manager varchar(255) comment '组织正职领导',
vice_manager varchar(255) comment '组织副职领导',
org_status_detail varchar(64) comment '组织机构状态明细',
org_level_code varchar(64) comment '层级编码',
org_status varchar(16) comment '组织机构状态',
is_corp varchar(16) comment '是否公司',
dept_level varchar(32) comment '部门层级',
org_type varchar(32) comment '组织类型',
corp_type varchar(32) comment '公司类型',
dept_type varchar(128) comment '部门类型',
show_num integer(8) comment '排序编号',
parent_corp_code varchar(255) comment '上级公司编码',
parent_corp_name varchar(255) comment '上级公司名称',
parent_dept_code varchar(255) comment '上级部门编码',
parent_dept_name varchar(255) comment '上级部门名称',
parent_org_code varchar(255) comment '上级组织机构编码',
parent_org_name varchar(255) comment '上级组织机构名称',
area_code varchar(255) comment '所属地区编码',
parent_id bigint(20) unsigned comment '父ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scam_organization comment '组织结构表';
/*==============================================================*/
/* Table: fdb_scam_role */
/*==============================================================*/
create table fdb_scam_role
(
id bigint(20) unsigned not null comment 'id 主键',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
role_name varchar(128) comment '名称',
role_code varchar(64) comment '编码',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scam_role comment '系统角色表';
/*==============================================================*/
/* Table: fdb_scam_staff */
/*==============================================================*/
create table fdb_scam_staff
(
id bigint(20) unsigned not null comment 'id 主键',
corp_code varchar(128) comment '公司编码',
user_type varchar(16) comment '员工分类',
card_photo varchar(128) comment '证件照',
born_date datetime comment '出生日期',
identity_num varchar(32) comment '身份证号',
gender varchar(16) comment '性别',
pre_phonenum varchar(16) comment '首选手机号',
work_tellnum varchar(16) comment '办公电话',
emp_status varchar(16) comment '员工状态',
position_name varchar(128) comment '岗位名称',
employ_date datetime comment '入职时间',
posi_sequence varchar(16) comment '岗位序列',
posi_level_type varchar(128) comment '岗位体系',
posi_type varchar(128) comment '基准岗位',
posi_level varchar(16) comment '岗位等级',
posi_layer_type varchar(128) comment '岗位层级体系',
posi_layer varchar(16) comment '岗位层级',
job_title varchar(128) comment '职务',
depat_name varchar(128) comment '所属部门名',
depat_code varchar(128) comment '所属部门编码',
corp_name varchar(128) comment '所属公司名',
posi_emp_type varchar(128) comment '用户任职类型',
area_code varchar(32) comment '所属地区编码',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scam_staff comment '员工信息表';
/*==============================================================*/
/* Table: fdb_scam_sysres */
/*==============================================================*/
create table fdb_scam_sysres
(
id bigint(20) unsigned not null comment 'id 主键',
parent_id bigint(20) unsigned comment '父ID',
res_name varchar(128) not null comment '名称',
res_code varchar(128) comment '编码',
res_type varchar(32) comment '资源类型',
res_uri varchar(255) comment '资源URI,自定义一个表达式,支持界面展现以及数据粒度',
res_icon varchar(128) comment '图标',
res_express varchar(255) comment '表达式',
show_order integer(4) comment '展示顺序',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scam_sysres comment ' 系统资源表';
/*==============================================================*/
/* Table: fdb_scam_user */
/*==============================================================*/
create table fdb_scam_user
(
id bigint(20) unsigned not null comment 'id 主键',
rel_staff_id bigint(20) comment '所属员工ID',
user_account varchar(128) not null comment '用户账号',
bak_account varchar(128) comment '备用账号',
nick_name varchar(64) comment '昵称',
acct_photo varchar(128) comment '帐号头像',
pass_salt varchar(32) comment '加密盐',
user_password varchar(128) not null comment '密码(+盐)',
account_type varchar(32) comment '账号类别',
email varchar(128) not null comment '邮箱地址',
birthday varchar(16) comment '生日',
reg_date datetime comment '注册时间',
reg_ipaddr char(10) comment '注册IP地址',
last_login_time datetime comment '上次登录时间',
last_login_ip char(10) comment '上次登录IP',
last_login_type char(10) comment '登录类型,web桌面,手机端',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段5',
vkp_fld6 varchar(512) comment '保留字段6',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scam_user comment '系统用户表';
/*==============================================================*/
/* Table: fdb_scam_user_group */
/*==============================================================*/
create table fdb_scam_user_group
(
id bigint(20) unsigned not null comment 'id 主键',
rel_parent_id bigint(20) comment '所属父角色组',
ugrp_name varchar(128) comment '名称',
ugrp_code varchar(64) comment '编码',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scam_user_group comment '系统用户组';
/*==============================================================*/
/* Table: fdb_scam_user_trace */
/*==============================================================*/
create table fdb_scam_user_trace
(
id bigint(20) unsigned not null comment 'id 主键',
rel_user_id bigint(20) comment '所属用户ID',
trace_type varchar(32) comment '跟踪类型',
client_ip varchar(32) comment 'IP地址',
mac_addr varchar(32) comment 'MAC地址',
client_dev_info varchar(255) comment '使用设备信息',
inter_token varchar(255) comment '令牌会话',
oper_conts varchar(512) comment '操作内容',
audit_conts varchar(512) comment '审计内容',
ugrp_name varchar(128) comment '名称',
ugrp_code varchar(64) comment '编码',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
vbsc_modifier varchar(128) comment '修改人',
vbsc_modify_date datetime not null default CURRENT_TIMESTAMP comment '新增时同创建时间',
vbsc_use_stat smallint not null default 1 comment '可用状态',
vbsc_busi_type int(8) comment '业务类型状态',
vbsc_uni_version integer(16) not null comment '版本号',
vbsc_uni_timestamp datetime not null default CURRENT_TIMESTAMP comment '时间戳',
vbsc_partition_id integer(8) unsigned comment '分区ID',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_notes varchar(2000) comment '备注',
vkp_fld1 varchar(128) comment '保留字段1',
vkp_fld2 varchar(128) comment '保留字段2',
vkp_fld3 varchar(256) comment '保留字段3',
vkp_fld4 varchar(256) comment '保留字段4',
vkp_fld5 varchar(512) comment '保留字段1',
vkp_fld6 varchar(512) comment '保留字段2',
vdblg_users varchar(512) comment '所属人员,为空则数据均可访问,非空则只有指定人员访问',
vdblg_orgnizations varchar(512) comment '所属组织,非空表示指定组织结构下的人员可以访问',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scam_user_trace comment '系统用户跟踪表';
/*==============================================================*/
/* Table: fdb_scar_ciper_entity */
/*==============================================================*/
create table fdb_scar_ciper_entity
(
ID bigint(20) unsigned not null comment 'id 主键',
entity_tbl_name varchar(64) comment '实体表名称',
vkey_entity_id bigint(20) comment '实体ID',
vkey_ciper_id bigint(20) comment '密钥ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scar_ciper_entity comment '密钥-实体映射关系';
/*==============================================================*/
/* Table: fdb_scar_org_staff */
/*==============================================================*/
create table fdb_scar_org_staff
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_org_id bigint(20) comment '组织机构ID',
vkey_staff_id bigint(20) comment '员工ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scar_org_staff comment '组织-员工关系表';
/*==============================================================*/
/* Table: fdb_scar_role_operm */
/*==============================================================*/
create table fdb_scar_role_operm
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_role_id bigint(20) comment '角色ID',
vkey_res_id bigint(20) comment '资源ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scar_role_operm comment '角色资源操作权限关联表';
/*==============================================================*/
/* Table: fdb_scar_ugrp_role */
/*==============================================================*/
create table fdb_scar_ugrp_role
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_ugrp_id bigint(20) comment '用户组ID',
vkey_role_id bigint(20) comment '角色ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scar_ugrp_role comment '用户组-角色关系表';
/*==============================================================*/
/* Table: fdb_scar_user_operm */
/*==============================================================*/
create table fdb_scar_user_operm
(
ID bigint(20) unsigned not null comment 'id 主键',
vkey_user_id bigint(20) comment '用户ID',
vkey_operm_id bigint(20) comment '操作权限ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scar_user_operm comment '用户-权限-关系表';
/*==============================================================*/
/* Table: fdb_scar_user_role */
/*==============================================================*/
create table fdb_scar_user_role
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_staff_id bigint(20) comment '用户ID',
vkey_role_id bigint(20) comment '角色ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scar_user_role comment '用户-角色关系表';
/*==============================================================*/
/* Table: fdb_scar_user_ugrp */
/*==============================================================*/
create table fdb_scar_user_ugrp
(
id bigint(20) unsigned not null comment 'id 主键',
vkey_user_id bigint(20) comment '用户ID',
vkey_ugrp_id bigint(20) comment '用户组ID',
vbsc_meta_spec integer(16) unsigned comment '元类型-基础字段',
vbsc_mspec_desc varchar(256) comment '元类型描述',
vbsc_partition_id integer(8) unsigned comment '分区id',
vbsc_txid bigint(20) unsigned comment '事务流水号',
vbsc_creator varchar(128) comment '创建者',
vbsc_create_date datetime not null default CURRENT_TIMESTAMP comment '创建时间',
region varchar(255) comment '区域',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
alter table fdb_scar_user_ugrp comment ' 员工-用户组-关系表';
| true |
4cf0997723ed6d8a5014450563e97070c3c5b0d8 | SQL | viniciusmjvm/Dr_Cell1_tcc | /Dr_Cell/Base/relacionamento.sql | UTF-8 | 1,743 | 4.09375 | 4 | [] | no_license |
//=================================================================
/* SELECT DE CONTAS*/
SELECT C.*,
fn.nome as fornecedor
FROM DBO.contas C
INNER JOIN fornecedores FN ON FN.cod_fornecedor = C.cod_fornecedor
ORDER BY C.vencimento
//=================================================================
/* SELECT DE VENDAS*/
select * from vendas
SELECT v.*,
c.nome as cliente
FROM vendas v
INNER JOIN clientes c ON c.cod_cliente = v.cod_cliente
ORDER BY v.num_venda
//==================================================================
/*SELECT DE DESCONTOS DE VENDAS*/
SELECT d.cod_desconto,d.cod_itens_vendas,i.sub_total,d.descr,d.descp, sub_total - descr as total
FROM deescontos d
INNER JOIN itens_vendas i ON i.cod_itens_vendas = d.cod_itens_vendas
ORDER BY d.total
//=================================================================
/* SELECT DE FORNECEDORES*/
select * from fornecedores
SELECT f.*,
ci.nome as cidade
FROM fornecedores f
INNER JOIN cidades ci ON f.cod_cidade = ci.cod_cidade
ORDER BY f.nome
//=================================================================
/* SELECT DE PRODUTOS*/
select * from produtos
select * from unidades
select * from categorias
select * from marcas
SELECT p.*,
u.descricao as unidade,
c.descricao as categoria,
m.nome as marca
FROM produtos p
INNER JOIN unidades u ON p.cod_unidade = u.cod_unidade
INNER JOIN categorias c ON p.cod_unidade = c.cod_categoria
INNER JOIN marcas m ON p.cod_marca = m.cod_marca
ORDER BY p.descricao
//=================================================================
/* SELECT DE REPAROS*/
select * from REPAROS
SELECT R.*,
c.nome as cliente
FROM REPAROS r
INNER JOIN clientes c ON r.cod_cliente = c.cod_cliente
ORDER BY r.data_recebido | true |
a1e01ab19df3a813d6c3ec90bbf3a01ece83782a | SQL | DimitarSamarov07/SoftUni-Software-Engineering | /C# DB/Databases Basics - MS SQL Server/Joins, Subqueries, CTE and Indices - Excercises/02AddressesWithTowns.sql | UTF-8 | 221 | 3.578125 | 4 | [] | no_license | SELECT
TOP (50)
FirstName
,
LastName
,
Name
,
AddressText
FROM Employees
INNER JOIN Addresses A ON Employees.AddressID = A.AddressID
INNER JOIN Towns T ON T.TownID = A.TownID
ORDER BY FirstName, LastName | true |
20d94ea739ac2dcc711feaf36a63a494b3c4de31 | SQL | prabodhaSA/Prabo_IT19176666_PAF_Assignment | /IT19176666/Dump20210514.sql | UTF-8 | 4,088 | 3.0625 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.19, for Win64 (x86_64)
--
-- Host: localhost Database: gadgetbadgetsys
-- ------------------------------------------------------
-- Server version 8.0.19
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `product`
--
DROP TABLE IF EXISTS `product`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `product` (
`productID` varchar(5) NOT NULL,
`productName` varchar(25) NOT NULL,
`category` varchar(45) NOT NULL,
`description` varchar(45) NOT NULL,
`unitPrice` float NOT NULL,
`rID` varchar(5) NOT NULL,
PRIMARY KEY (`productID`),
KEY `rID_idx` (`rID`),
CONSTRAINT `rID` FOREIGN KEY (`rID`) REFERENCES `research` (`rID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `product`
--
LOCK TABLES `product` WRITE;
/*!40000 ALTER TABLE `product` DISABLE KEYS */;
INSERT INTO `product` VALUES ('p0001','sun crackers','biscuits','this a food item',50,'r0002'),('p0002','windy Solor','Cooling fan','Electrical item',3500,'r0005'),('p0004','plastic Slippers','Slippers','description 1',1200,'r0001'),('p0005','Tube light','science','Working great',457.85,'r0001'),('p0006','door','wood','description 3',45000,'r0004');
/*!40000 ALTER TABLE `product` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `research`
--
DROP TABLE IF EXISTS `research`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `research` (
`rID` varchar(5) NOT NULL,
`field` varchar(45) NOT NULL,
`subject` varchar(45) NOT NULL,
`fundTotal` float NOT NULL,
`publishedDate` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`cmpl_stats` varchar(45) NOT NULL,
`approval` varchar(45) DEFAULT NULL,
PRIMARY KEY (`rID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `research`
--
LOCK TABLES `research` WRITE;
/*!40000 ALTER TABLE `research` DISABLE KEYS */;
INSERT INTO `research` VALUES ('','dsksd','eeeeeeeeeeeer',23232,'2021-05-14 14:44:12','2021-05-14 14:43:42',NULL),('r0001','cdf','abcd',3223,'2021-05-08 14:57:05','completed','Not Approved'),('r0002','Covid19','science',444444,'2021-05-08 14:58:07','completed','Not Approved'),('r0003','food','Food Science',25000,'2021-04-22 00:33:18','completed',NULL),('r0004','perfume','cosmatics',4500,'2021-04-22 00:36:40','completed',NULL),('r0005','bottle','plastic',350,'2021-04-22 00:37:56','completed',NULL),('r0007','wwww','wwww',273927,'2021-05-08 14:55:43','not completed','Not Approved'),('r0123','dsksd','dssds',23232,'2021-05-14 14:43:42','xccxf',NULL),('r2387','sdhksjsd','shdgjsgd',237863,'2021-05-14 14:51:49','sddsjkhdksj',NULL),('r6398','rrr','rrr',344,'2021-05-14 14:56:15','ddfd',NULL);
/*!40000 ALTER TABLE `research` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-05-14 16:41:05
| true |
fa8baf13ba630d1e0606d57e6ff90f2242bf5b1c | SQL | rameshv1210/mdm | /src/dbscripts/mysql/mdm_device/sps/saveIosSecurityInfo.sql | UTF-8 | 1,826 | 3.546875 | 4 | [] | no_license | DROP PROCEDURE IF EXISTS `mdm_device`.`saveIosSecurityInfo`;
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `mdm_device`.`saveIosSecurityInfo`(IN `userId` BIGINT(20), IN `deviceUuid` VARCHAR(255), IN `hardwareEncryptionCaps` int,
IN `passcodeCompliant` VARCHAR(10), IN `passcodeCompliantWithProfiles` VARCHAR(10), IN `passcodeLockGracePeriod` int,
IN `passcodeLockGracePeriodEnforced` int, IN `passcodePresent` varchar(10))
BEGIN
SELECT company_guid INTO @companyId FROM user.user WHERE id = userId;
SET @query = CONCAT('SELECT COUNT(*) INTO @count FROM `ios_security_info', @companyId , '` WHERE device_uuid = "', deviceUuid, '"');
PREPARE stmt FROM @query;
EXECUTE stmt;
IF (@count > 0) then
SET @query = CONCAT('UPDATE `ios_security_info', @companyId , '`
SET hardware_encryption_caps = ', hardwareEncryptionCaps , ',
passcode_compliant = ', passcodeCompliant , ',
passcode_compliant_with_profiles = ', passcodeCompliantWithProfiles , ',
passcode_lock_grace_period = ', passcodeLockGracePeriod , ',
passcode_lock_grace_period_enforced = ', passcodeLockGracePeriodEnforced , ',
passcode_present = ', passcodePresent , '
WHERE device_uuid = "', deviceUuid, '"');
PREPARE stmt FROM @query;
EXECUTE stmt;
else
SET @query = CONCAT('INSERT INTO `ios_security_info', @companyId , '` (device_uuid, hardware_encryption_caps,
passcode_compliant, passcode_compliant_with_profiles, passcode_lock_grace_period, passcode_lock_grace_period_enforced, passcode_present)
VALUES ("', deviceUuid, '",', hardwareEncryptionCaps , ',', passcodeCompliant , ',', passcodeCompliantWithProfiles , ',
', passcodeLockGracePeriod , ',', passcodeLockGracePeriodEnforced , ',', passcodePresent , ')');
PREPARE stmt FROM @query;
EXECUTE stmt;
end if;
END$$
DELIMITER ;
| true |
1e5634e5eaa11d16cf95fd587b57fcb9b039b9a7 | SQL | captam3rica/SCCMWMIQueries | /disk_usage_sms_g_logical_disk.sql | UTF-8 | 452 | 2.796875 | 3 | [] | no_license | /*###################################################################
\\ Another Query for Disk Usage just from Logical Disk Table //
###################################################################*/
select distinct
SMS_G_System_LOGICAL_DISK.SystemName,
SMS_G_System_LOGICAL_DISK.ResourceID,
SMS_G_System_LOGICAL_DISK.FreeSpace,
SMS_G_System_LOGICAL_DISK.Size
from SMS_G_System_LOGICAL_DISK
where SMS_G_System_LOGICAL_DISK.DiskID = "C:"
| true |
bd1d9ace32e39dbdf23c92db1be73c31b772bbc6 | SQL | DimitarSamarov07/SoftUni-Software-Engineering | /C# DB/Databases Basics - MS SQL Server/Exam Preparation 2/07StudentsToGo.sql | UTF-8 | 182 | 3.875 | 4 | [] | no_license | SELECT CONCAT(FirstName, ' ', LastName) AS [Full Name]
FROM Students
LEFT JOIN StudentsExams SE ON Students.Id = SE.StudentId
WHERE SE.StudentId IS NULL
ORDER BY [Full Name] | true |
ff38601c1598bcd2c4936b70ec2f2f453df1582e | SQL | bb4321/Startup-Info | /database/database.sql | UTF-8 | 1,853 | 2.9375 | 3 | [] | no_license |
create database startup;
user startup;
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text,
`pass` text,
`email` text,
`mobile` text,
`addr` text,
`dob` text,
`gender` text,
`pin` text,
`location` text,
`imagess` longblob,
`status` text,
`qualification` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
CREATE TABLE `employee` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text,
`pass` text,
`email` text,
`mobile` text,
`addr` text,
`dob` text,
`gender` text,
`pin` text,
`location` text,
`imagess` longblob,
`status` text,
`experience` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
CREATE TABLE `company` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text,
`pass` text,
`email` text,
`mobile` text,
`addr` text,
`dob` text,
`field` text,
`pin` text,
`location` text,
`imagess` longblob,
`status` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
CREATE TABLE `resume` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cname` text,
`jobdes` text,
`name` text,
`email` text,
`phone` text,
`aresume` text,
`status` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
CREATE TABLE `notification` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cname` text,
`field` text,
`jobdes` text,
`email` text,
`location` text,
`lastdate` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
CREATE TABLE `apply` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cname` text,
`jobdes` text,
`field` text,
`name` text,
`email` text,
`phone` text,
`aresume` text,
`status` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
| true |
c6d8cd4b3a0bd628952ab8090e746f7a1bd37390 | SQL | NaGoo/readyassist-mtm | /nagarajan.sql | UTF-8 | 1,046 | 3.09375 | 3 | [] | no_license | CREATE DATABASE readyasssist;
USE readyassist;
CREATE TABLE Candidates
(
id int auto_increment not null primary key,
Candidate_name varchar(25)null,
Candidate_mail varchar(25)null,
Candidate_gender varchar(25)null,
Candidate_age int not null
);
insert into
Candidates(id,candidate_name,candidate_mail,candidate_gender,candidate_age)
values('1','Nagarajan s','nagucse05@gmail.com','male','21');
CREATE TABLE Training
(
id int auto_increment not null primary key,
studymaterials varchar(50) not null,
no_days int not null);
insert into Training(id,studymaterials,no_days)values('1','gitgub','5');
insert into Training(studymaterials,no_days)values('Mysql','3');
use readyassist;
CREATE TABLE Employee
(
id int auto_increment not null primary key,
emp_name varchar(25)null,
emp_city varchar(25)null);
insert into Employee(id,emp_name,emp_city)values('1','nagarajan','ngl');
insert into Employee(emp_name,emp_city)values('abc','ngl');
insert into Employee(emp_name,emp_city)values('xyz','ngl');
select*from Candidates;
select*from Training;
select*from Employee;
| true |
eaf67f52a016d00e0c48e16f323a4af410639c6b | SQL | bukky24/Git-girl-project-2 | /query.py | UTF-8 | 624 | 4.09375 | 4 | [] | no_license | /* query to determine the countries that have the most invoices*/
SELECT BillingCountry, count(*) as Invoices
FROM invoices
GROUP BY BillingCountry
ORDER BY Invoices DESC
/*query that shows the city with the best customer*/
SELECT BillingCity as City, sum(Total) as InvoiceTotals
FROM Invoices
GROUP BY BillingCity
ORDER BY InvoiceTotals desc
LIMIT 1
/*query that shows the best customer*/
SELECT upper(LastName) || ' ' || FirstName as FullName, sum(i.Total) as TotalSpent
FROM Customers c, Invoices i
WHERE c.CustomerId=i.CustomerId
GROUP BY (i.CustomerId)
ORDER BY TotalSpent desc
LIMIT 1
| true |
f3f73b5f68cb6e9346cda17e598773da713a4f07 | SQL | VelizarVeli/SoftUni-Software-Engineering | /03.C#DBFundamentals/01.Databases Basics - MS SQL Server/14.JoinsSubquerieCTEInd/14.JoinsSubquerieCTEInd/11.MinAverageSalary.sql | UTF-8 | 165 | 3.5625 | 4 | [] | no_license | SELECT MIN(AverageSalaryByDepartment) AS MinAverageSalary FROM (
SELECT AVG(Salary) AS AverageSalaryByDepartment FROM Employees
GROUP BY DepartmentID) AS AVGSalaries | true |
947ea2b7655151604a775a066c3af62e158bd410 | SQL | Jahidinsh/Aplikasi-Penjualan-VB.net | /dbpenjualan.sql | UTF-8 | 8,247 | 3.046875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 14 Nov 2021 pada 08.11
-- Versi server: 10.4.21-MariaDB
-- Versi PHP: 7.3.31
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `dbpenjualan`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_admin`
--
CREATE TABLE `tbl_admin` (
`kodeadmin` varchar(15) NOT NULL,
`username` varchar(75) NOT NULL,
`pass` varchar(50) NOT NULL,
`level` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `tbl_admin`
--
INSERT INTO `tbl_admin` (`kodeadmin`, `username`, `pass`, `level`) VALUES
('ADM001', 'Jahidin', '123', 'Admin'),
('ADM002', 'Zili', '123', 'User'),
('ADM003', 'Saep', '123', 'Admin'),
('ADM004', 'JAKI', '124', 'User'),
('ADM005', 'Hinyai', '123', 'Admin'),
('ADM006', 'Yudi', '123', 'ADMIN'),
('ADM007', 'Santri', '123', 'USER');
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_barang`
--
CREATE TABLE `tbl_barang` (
`kodebarang` varchar(20) NOT NULL,
`namabarang` varchar(20) NOT NULL,
`kategori` varchar(25) NOT NULL,
`harga` int(11) NOT NULL,
`stok` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `tbl_barang`
--
INSERT INTO `tbl_barang` (`kodebarang`, `namabarang`, `kategori`, `harga`, `stok`) VALUES
('BRG001', 'Sampurna Mild', 'Rokok', 26000, 10),
('BRG002', 'Sampurna Kretek', 'Rokok', 15000, 7),
('BRG003', 'Kiwi', 'Peralatan RT', 10000, 11),
('BRG004', 'Umild', 'Rokok', 22000, 44),
('BRG005', 'Surya', 'Rokok', 26000, 23),
('BRG006', 'Minyak Sayur 1/4', 'Sembako', 5000, 5),
('BRG007', 'Betadine', 'Obat', 7000, 10),
('BRG008', 'Larutan Botol Besar', 'Minuman', 7000, 5),
('BRG009', 'Roti Roma', 'Makanan', 8000, 5),
('BRG010', 'Teh Pucuk', 'Minuman', 3000, 10),
('BRG011', 'Aqua Sedang', 'Minuman', 3000, 20),
('BRG012', 'Aqua Besar', 'Minuman', 6000, 10);
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_detailjual`
--
CREATE TABLE `tbl_detailjual` (
`nojual` varchar(10) NOT NULL,
`kodebarang` varchar(20) NOT NULL,
`namabarang` varchar(20) NOT NULL,
`hargajual` int(11) NOT NULL,
`jumlahjual` int(11) NOT NULL,
`subtotal` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `tbl_detailjual`
--
INSERT INTO `tbl_detailjual` (`nojual`, `kodebarang`, `namabarang`, `hargajual`, `jumlahjual`, `subtotal`) VALUES
('J211509001', 'BRG001', 'Sampurna Mild', 26000, 12, 312000),
('j212110002', 'BRG001', 'Sampurna Mild', 26000, 12, 312000),
('j212212003', 'BRG003', 'Kiwi', 10000, 2, 20000),
('j212212003', 'BRG004', 'Umild', 22000, 2, 44000),
('J215212004', 'BRG001', 'Sampurna Mild', 26000, 4, 104000),
('J211212005', 'BRG001', 'Sampurna Mild', 26000, 1, 26000),
('J215212005', 'BRG004', 'Umild', 22000, 1, 22000),
('J215212005', 'BRG002', 'Sampurna Kretek', 15000, 3, 45000),
('J210412006', 'BRG001', 'Sampurna Mild', 26000, 2, 52000),
('J210612006', 'BRG003', 'Kiwi', 10000, 1, 10000),
('J213712006', 'BRG002', 'Sampurna Kretek', 15000, 3, 45000),
('J213712006', 'BRG004', 'Umild', 22000, 1, 22000),
('J214012006', 'BRG002', 'Sampurna Kretek', 15000, 1, 15000),
('J214312006', 'BRG001', 'Sampurna Mild', 26000, 469, 12194000),
('J215112006', 'BRG004', 'Umild', 22000, 2, 44000);
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_detailretur`
--
CREATE TABLE `tbl_detailretur` (
`noretur` varchar(10) NOT NULL,
`kodebarang` varchar(6) NOT NULL,
`namabarang` varchar(100) NOT NULL,
`hargajual` int(11) NOT NULL,
`jumlahretur` int(11) NOT NULL,
`subtotal` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_jual`
--
CREATE TABLE `tbl_jual` (
`nojual` varchar(10) NOT NULL,
`tgljual` date NOT NULL,
`jamjual` time NOT NULL,
`itemjual` int(11) NOT NULL,
`totaljual` int(11) NOT NULL,
`dibayar` int(11) NOT NULL,
`kembali` int(11) NOT NULL,
`kodepelanggan` varchar(15) NOT NULL,
`kodeadmin` varchar(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `tbl_jual`
--
INSERT INTO `tbl_jual` (`nojual`, `tgljual`, `jamjual`, `itemjual`, `totaljual`, `dibayar`, `kembali`, `kodepelanggan`, `kodeadmin`) VALUES
('J210412006', '2021-11-12', '00:00:00', 2, 52000, 60000, 8000, 'PLG001', 'ADM001'),
('J210612006', '2021-11-12', '05:07:18', 1, 10000, 10000, 0, 'PLG002', 'ADM004'),
('J211212005', '2021-11-12', '00:00:00', 1, 26000, 50000, 24000, 'PLG001', 'ADM001'),
('J211509001', '2021-11-09', '10:15:31', 12, 312000, 350000, 38000, 'PLG001', 'ADM001'),
('j212110002', '2021-11-10', '06:21:56', 12, 312000, 400000, 88000, 'PLG001', 'ADM001'),
('j212212003', '2021-11-12', '00:00:00', 4, 64000, 70000, 6000, 'PLG002', 'ADM001'),
('J213712006', '2021-11-12', '05:38:04', 4, 67000, 100000, 33000, 'PLG002', 'ADM001'),
('J214012006', '2021-11-12', '05:40:40', 1, 15000, 20000, 5000, 'PLG001', 'ADM001'),
('J214312006', '2021-11-12', '06:46:02', 469, 12194000, 100000000, 87806000, 'PLG001', 'ADM001'),
('J215112006', '2021-11-12', '06:51:49', 2, 44000, 45000, 1000, 'PLG002', 'ADM001'),
('J215212004', '2021-11-12', '00:00:00', 4, 104000, 120000, 16000, 'PLG001', 'ADM001'),
('J215212005', '2021-11-12', '00:00:00', 4, 67000, 100000, 33000, 'PLG002', 'ADM001');
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_pelanggan`
--
CREATE TABLE `tbl_pelanggan` (
`kodepelanggan` varchar(15) NOT NULL,
`nama` varchar(20) NOT NULL,
`alamat` varchar(50) NOT NULL,
`telepon` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `tbl_pelanggan`
--
INSERT INTO `tbl_pelanggan` (`kodepelanggan`, `nama`, `alamat`, `telepon`) VALUES
('PLG001', 'Sayidah Azizah', 'Pasirranji', '081290404994'),
('PLG002', 'Samsul', 'Sogol', '0856724568765'),
('PLG003', 'Saiton', 'Pasirranji', '0875363862386');
-- --------------------------------------------------------
--
-- Struktur dari tabel `tbl_retur`
--
CREATE TABLE `tbl_retur` (
`noretur` varchar(10) NOT NULL,
`nojual` varchar(10) NOT NULL,
`tglretur` date NOT NULL,
`jamretur` time NOT NULL,
`itemretur` int(11) NOT NULL,
`totalretur` int(11) NOT NULL,
`kodepelanggan` varchar(6) NOT NULL,
`kodeadmin` varchar(6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `tbl_admin`
--
ALTER TABLE `tbl_admin`
ADD PRIMARY KEY (`kodeadmin`);
--
-- Indeks untuk tabel `tbl_barang`
--
ALTER TABLE `tbl_barang`
ADD PRIMARY KEY (`kodebarang`);
--
-- Indeks untuk tabel `tbl_detailjual`
--
ALTER TABLE `tbl_detailjual`
ADD KEY `tbl_detailjual_ibfk_1` (`kodebarang`);
--
-- Indeks untuk tabel `tbl_jual`
--
ALTER TABLE `tbl_jual`
ADD PRIMARY KEY (`nojual`),
ADD KEY `tbl_jual_ibfk_1` (`kodeadmin`),
ADD KEY `tbl_jual_ibfk_2` (`kodepelanggan`);
--
-- Indeks untuk tabel `tbl_pelanggan`
--
ALTER TABLE `tbl_pelanggan`
ADD PRIMARY KEY (`kodepelanggan`);
--
-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
--
--
-- Ketidakleluasaan untuk tabel `tbl_detailjual`
--
ALTER TABLE `tbl_detailjual`
ADD CONSTRAINT `tbl_detailjual_ibfk_1` FOREIGN KEY (`kodebarang`) REFERENCES `tbl_barang` (`kodebarang`) ON UPDATE CASCADE;
--
-- Ketidakleluasaan untuk tabel `tbl_jual`
--
ALTER TABLE `tbl_jual`
ADD CONSTRAINT `tbl_jual_ibfk_1` FOREIGN KEY (`kodeadmin`) REFERENCES `tbl_admin` (`kodeadmin`) ON UPDATE CASCADE,
ADD CONSTRAINT `tbl_jual_ibfk_2` FOREIGN KEY (`kodepelanggan`) REFERENCES `tbl_pelanggan` (`kodepelanggan`) ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
79bf1bd6e5ecd45041514fc07da965f01d7111da | SQL | ArshanAlam/sandbox | /databases/postgres/initdb/init.sql | UTF-8 | 284 | 2.828125 | 3 | [] | no_license | CREATE DATABASE db;
-- Connect to the database
\c db;
-- Create tables
CREATE TABLE IF NOT EXISTS users (
id uuid DEFAULT gen_random_uuid (),
email varchar(320) NOT NULL UNIQUE,
PRIMARY KEY (id)
);
-- Insert default values
INSERT INTO users (
email)
VALUES (
'admin@mydomain.io');
| true |
ee4c4bbd344249bed90ffe9fca7dd7a95dfb579c | SQL | cgroane/bartender | /db/search_recipes.sql | UTF-8 | 121 | 2.75 | 3 | [] | no_license | select * from recipes
join ingredient on ingredient.recipe_id = recipes.recipe_id
where LOWER (ingredient.title) like $1; | true |
0dcb15a83c1e91bf7d5adce6360868e7c414fb44 | SQL | flitzmo-hso/flitzmo_agv_control_system | /Dokumentationen/MySQL_Documentation/MySQL_Dump/Dump20210527/ERRORHANDLING_ERRORHANDLING.sql | UTF-8 | 2,586 | 3.046875 | 3 | [
"MIT"
] | permissive | -- MySQL dump 10.13 Distrib 8.0.25, for Linux (x86_64)
--
-- Host: localhost Database: ERRORHANDLING
-- ------------------------------------------------------
-- Server version 8.0.25-0ubuntu0.20.04.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `ERRORHANDLING`
--
DROP TABLE IF EXISTS `ERRORHANDLING`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ERRORHANDLING` (
`ER_ID` int NOT NULL AUTO_INCREMENT,
`ER_TIMESTAMP` varchar(45) NOT NULL DEFAULT 'CURRENT_TIMESTAMP',
`ER_DESC` varchar(300) DEFAULT NULL,
`ER_O_ID` int DEFAULT NULL,
`ER_A_ID` int DEFAULT NULL,
`ER_ES_ID` int NOT NULL,
`ER_ET_ID` int NOT NULL,
PRIMARY KEY (`ER_ID`),
KEY `ER_O_ID_idx` (`ER_O_ID`),
KEY `ER_A_ID_idx` (`ER_A_ID`),
KEY `ER_ES_ID_idx` (`ER_ES_ID`),
KEY `ER_ET_ID_idx` (`ER_ET_ID`),
CONSTRAINT `ER_A_ID` FOREIGN KEY (`ER_A_ID`) REFERENCES `AGV`.`AGV` (`A_ID`),
CONSTRAINT `ER_ES_ID` FOREIGN KEY (`ER_ES_ID`) REFERENCES `ERRORSTATE` (`ES_ID`),
CONSTRAINT `ER_ET_ID` FOREIGN KEY (`ER_ET_ID`) REFERENCES `ERRORTYPE` (`ET_ID`),
CONSTRAINT `ER_O_ID` FOREIGN KEY (`ER_O_ID`) REFERENCES `ORDER`.`ORDER` (`O_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `ERRORHANDLING`
--
LOCK TABLES `ERRORHANDLING` WRITE;
/*!40000 ALTER TABLE `ERRORHANDLING` DISABLE KEYS */;
/*!40000 ALTER TABLE `ERRORHANDLING` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-05-27 2:11:02
| true |
f3f1629b39a1c2e634966023c078af3dcf577ce1 | SQL | quangquyet05t3/CodeIgniter | /code_igniter.sql | UTF-8 | 3,574 | 3.359375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*
SQLyog Ultimate v11.33 (64 bit)
MySQL - 10.1.19-MariaDB : Database - code_igniter
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`code_igniter` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_vietnamese_ci */;
USE `code_igniter`;
/*Table structure for table `br_product` */
DROP TABLE IF EXISTS `br_product`;
CREATE TABLE `br_product` (
`product_id` int(11) NOT NULL AUTO_INCREMENT,
`product_name` varchar(200) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`image1` varchar(500) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`image2` varchar(500) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`image3` varchar(500) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`image4` varchar(500) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`image5` varchar(500) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`image6` varchar(500) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`description` text COLLATE utf8_vietnamese_ci,
`price` double DEFAULT NULL,
`type_id` int(11) DEFAULT NULL,
`size` varchar(255) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`rate` varchar(255) COLLATE utf8_vietnamese_ci DEFAULT NULL,
`active` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`product_id`),
KEY `FK_type_id` (`type_id`),
CONSTRAINT `FK_type_id` FOREIGN KEY (`type_id`) REFERENCES `br_type` (`type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_vietnamese_ci;
/*Data for the table `br_product` */
/*Table structure for table `br_type` */
DROP TABLE IF EXISTS `br_type`;
CREATE TABLE `br_type` (
`type_id` int(11) NOT NULL AUTO_INCREMENT,
`type_name` varchar(200) COLLATE utf8_vietnamese_ci DEFAULT NULL,
PRIMARY KEY (`type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_vietnamese_ci;
/*Data for the table `br_type` */
insert into `br_type`(`type_id`,`type_name`) values (1,'Đầm len'),(2,'Áo len'),(3,'Áo khoác len'),(4,'Sét bộ'),(5,'Đầm hoa'),(6,'Áo sơ mi');
/*Table structure for table `br_user` */
DROP TABLE IF EXISTS `br_user`;
CREATE TABLE `br_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(20) COLLATE utf8_vietnamese_ci NOT NULL,
`pass_word` varchar(20) COLLATE utf8_vietnamese_ci NOT NULL,
PRIMARY KEY (`id`,`pass_word`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_vietnamese_ci;
/*Data for the table `br_user` */
/*Table structure for table `news` */
DROP TABLE IF EXISTS `news`;
CREATE TABLE `news` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(128) COLLATE utf8_vietnamese_ci NOT NULL,
`slug` varchar(128) COLLATE utf8_vietnamese_ci NOT NULL,
`text` text COLLATE utf8_vietnamese_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_vietnamese_ci;
/*Data for the table `news` */
insert into `news`(`id`,`title`,`slug`,`text`) values (8,'new 6','new-6','text 6'),(9,'new 4','new-4','text 4'),(10,'new 10','new-10','text 10');
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
| true |
3b0331fc0b809aa552fa8817d92eedd707e49e11 | SQL | victormerch/Proyecto-7.5 | /Proyecto 7.5 Base de Datos Larios Alex, Gomez Marc i Merchan Victor/Consultas Proyecto_V.Merchan_M.Gomez_A.Larios.sql | UTF-8 | 5,057 | 3.921875 | 4 | [] | no_license | -- 1 Mostrar la Carta inicial más repetida por cada jugador(mostrar nombre jugador y carta).
-- 2 Jugador que realiza la apuesta más alta por partida. (Mostrar nombre jugador).
select nombre,max(apuesta),idpartida from
(select case
when username is not null then usuario.username
else descripcion end
as nombre,max(turnos.apuesta) as apuesta,partida.idpartida as idpartida from jugador
left join bot
on bot.idbot=jugador.idbot
left join usuario
on usuario.idusuario=jugador.idusuario
inner join participante
on jugador.idjugador=participante.id_jugador
inner join turnos
on participante.id_participante=turnos.idparticipante
inner join partida
on turnos.idpartida=partida.idpartida
where turnos.apuesta is not null
group by partida.idpartida,username) tabla
where (apuesta,idpartida) in (select
max(turnos.apuesta),partida.idpartida as apuesta from jugador
left join bot
on bot.idbot=jugador.idbot
left join usuario
on usuario.idusuario=jugador.idusuario
inner join participante
on jugador.idjugador=participante.id_jugador
inner join turnos
on participante.id_participante=turnos.idparticipante
inner join partida
on turnos.idpartida=partida.idpartida
group by partida.idpartida
order by max(turnos.apuesta) desc
)
group by idpartida;
-- 3 Jugador que realiza apuesta más baja por partida. (Mostrar nombre jugador).
select nombre,min(apuesta),idpartida from
(select case
when username is not null then usuario.username
else descripcion end
as nombre,min(turnos.apuesta) as apuesta,partida.idpartida as idpartida from jugador
left join bot
on bot.idbot=jugador.idbot
left join usuario
on usuario.idusuario=jugador.idusuario
inner join participante
on jugador.idjugador=participante.id_jugador
inner join turnos
on participante.id_participante=turnos.idparticipante
inner join partida
on turnos.idpartida=partida.idpartida
where turnos.apuesta is not null
group by partida.idpartida,username) tabla
where (apuesta,idpartida) in (select
min(turnos.apuesta),partida.idpartida as apuesta from jugador
left join bot
on bot.idbot=jugador.idbot
left join usuario
on usuario.idusuario=jugador.idusuario
inner join participante
on jugador.idjugador=participante.id_jugador
inner join turnos
on participante.id_participante=turnos.idparticipante
inner join partida
on turnos.idpartida=partida.idpartida
group by partida.idpartida
order by min(turnos.apuesta) desc
)
group by idpartida;
-- 4 Ratio de turnos ganados por jugador en cada partida (%),mostrar columna Nombre jugador, Nombre partida, nueva columna "porcentaje %".
-- 5 Porcentaje de partidas ganadas Bots en general. Nueva columna "porcentaje %".
select *from ( select round(count(ganador_partida)*100/count(idpartida)) as "Porcentaje %"
from partida p
inner join participante pa
on p.ganador_partida=pa.id_participante
inner join jugador j
on pa.id_jugador=j.idjugador
inner join bot b
on j.idbot=b.idbot
where ganador_partida=pa.id_participante) as contador;
-- 6 Mostrar los datos de los jugadores y el tiempo que han durado sus partidas ganadas cuya puntuación obtenida es mayor que la media puntos de las partidas ganadas totales.
-- 7 Cuántas rondas se ganan en cada partida según el palo. Ejemplo: Partida 1 - 5 rondas - Bastos como carta inicial.
select idpartida as Partida, count(numero_turno) as Rondas_Ganadas, descripcion as Palo from turnos t
left join cartas c
on t.carta_inicial = c.idcartas
left join tipo_carta tc
on c.tipo = tc.idtipo_carta
where puntos_final > puntos_inicio
group by idpartida, Palo;
-- 8 Cuantas rondas gana la banca en cada partida.
select idpartida as Partida,count(numero_turno) as Rondas_Ganadas from turnos t
left join cartas c
on t.carta_inicial = c.idcartas
left join tipo_carta tc
on c.tipo = tc.idtipo_carta
where puntos_final > puntos_inicio and es_banca = 1
group by idpartida;
-- 9 Cuántos usuarios han sido la banca en una partida.
select count(es_banca) as usuario_banca, idpartida
from turnos
where es_banca=1
group by idpartida;
-- 10 Partida con la puntuación más alta final de todos los jugadores, mostrar nombre jugador, nombre partida,así como añadir una columna nueva en la que diga si ha ganado la partida o no.
-- 11 Calcular la apuesta media por partida.
select avg(apuesta) as Apuesta_media, idpartida from turnos
group by idpartida;
-- 12 Mostrar los datos de los usuarios que no son bot, así como cual ha sido su última apuesta en cada partida que ha jugado.
-- 13 Calcular el valor total de las cartas y el numero total de cartas que se han dado inicialmente en las manos en la partida. Por ejemplo, en la partida se han dado 50 cartas y el valor total de las cartas es 47,5.
-- 14 Diferencia de puntos de los participantes de las partidas entre la ronda 1 y 5. Ejemplo: Rafa tenia 20 puntos, en la ronda 5 tiene 15, tiene -5 puntos de diferencia.
select turno5.p2-turno1.p1 Diferencia_puntos
from (select distinct puntos_inicio p1
from turnos t
where numero_turno = 1 group by idpartida) turno1,
( select puntos_inicio p2
from turnos
where numero_turno = 5) turno5;
| true |
3419ce9bf0e1d4c0f594ac6517efe4f1c4bdcda2 | SQL | bertair7/schoolprojects | /cpe365/Lab4/katzenjammer/KATZENJAMMER-info.sql | UTF-8 | 2,035 | 3.96875 | 4 | [] | no_license | -- Ryan Blair rablair@calpoly.edu
-- Tracklist of 'Le Pop'
SELECT s.Title
FROM Albums a, Songs s, Tracklists t
WHERE s.SongId = t.Song
AND a.AId = t.Album
AND a.Title = 'Le Pop'
ORDER BY t.Position;
-- Instruments each performer for 'Rock-Paper-Scissors'
SELECT b.Firsname, i.Instrument
FROM Songs s, Instruments i, Band b
WHERE s.SongId = i.Song
AND b.Id = i.Bandmate
AND s.Title = 'Rock-Paper-Scissors'
ORDER By b.Firsname;
-- All instruments played by 'Anne-Marit' >= once during performances
SELECT DISTINCT i.Instrument
FROM Instruments i, Band b, Performance p
WHERE b.Id = p.Bandmate
AND b.Id = i.Bandmate
AND i.Song = p.Song
AND b.Firsname = 'Anne-Marit'
ORDER BY i.Instrument;
-- All songs with 'ukalele'
SELECT s.Title
FROM Songs s, Instruments i
WHERE s.SongId = i.Song
AND i.Instrument = 'ukalele'
ORDER BY s.Title;
-- Instruments 'Turid' played where she sang lead vocals
SELECT DISTINCT i.Instrument
FROM Instruments i, Band b, Vocals v
WHERE b.Id = i.Bandmate
AND b.Id = v.Bandmate
AND v.Song = i.Song
AND b.Firsname = 'Turid'
AND v.VocalType = 'lead'
ORDER BY i.Instrument;
-- Songs lead vocalist not center stage
SELECT s.Title, b.Firsname, p.StagePosition
FROM Songs s, Band b, Performance p, Vocals v
WHERE s.SongId = p.Song
AND b.Id = p.Bandmate
AND s.SongId = v.Song
AND b.Id = v.Bandmate
AND p.StagePosition != 'center'
AND v.VocalType = 'lead'
ORDER BY s.Title;
-- Songs 'Anne-Marit' plays 3 different instruments
SELECT DISTINCT s.Title
FROM Songs s, Instruments i1, Instruments i2, Instruments i3, Band b
WHERE s.SongId = i1.Song
AND b.Id = i1.Bandmate
AND b.Id = i2.Bandmate
AND b.Id = i3.Bandmate
AND i1.Song = i2.Song
AND i2.Song = i3.Song
AND i1.Song = i3.Song
AND b.Firsname = 'Anne-Marit'
AND i1.Instrument != i2.Instrument
AND i2.Instrument != i3.Instrument
AND i1.Instrument != i3.Instrument;
-- Positioning of band in 'A Bar in Amsterdam' r-c-b-l
SELECT b.Firsname
FROM Band b, Performance p, Songs s
WHERE s.SongId = p.Song
AND b.Id = p.Bandmate
AND s.Title = 'A Bar in Amsterdam'
ORDER BY p.Bandmate DESC;
| true |
b7c60d577dd0a62c197063e731e8a4126b36fcdd | SQL | DudaPereira/senai_sprint_1bd | /sprint-1-bd/exercicios/1.5-exercicio-ecommerce/ecommerce_02_DML.sql | ISO-8859-1 | 1,152 | 2.96875 | 3 | [] | no_license | USE Ecommerce;
INSERT INTO Loja(Nome, Endereco, Telefone, CNPJ)
VALUES ('DudaBeleza', 'Rua Maruara N10', '994982838', '000.567.980/0001-50')
,('LuanaBeleza', 'Rua Baro de Maua N80', '965455454', '000.123.314/0001-24');
INSERT INTO Categoria(NomeCat, idLoja)
VALUES ('Beleza', 2 )
,('Higiene', 1);
INSERT INTO SubCategoria(NomeSub, idCategoria)
VALUES ('Sabonete', 2)
,('Batom', 1);
INSERT INTO Cliente(NomeCliente, RG, CPF, TelefoneC)
VALUES ('Eduarda','12 345 678-9' , '000.000.000-11', '965455454')
,('Nicole', '13 543 876-1', '111.111.111-00', '994982838');
INSERT INTO Pedido(Quantidade, NotaFisc, idCliente)
VALUES ('5', '000.000.011', 2)
,('3', '280.120.130', 1);
INSERT INTO Produto(NomeProd, Preco, Validade, idSubCategoria, idPedido)
VALUES ('BatomMatte', '$17,95', '12/10/2021', 2, 1)
,('SaboneteLiquido', '$6,54', '15/10/2021', 1,2);
INSERT INTO PedidoProduto(idPedido, idProduto)
VALUES (1, 2)
,(2, 1); | true |
3c4e82f7152309bce90838dace0ea5e995b77044 | SQL | daniel-stach/web_przychodnia | /SQL/0_All.sql | UTF-8 | 2,996 | 3.34375 | 3 | [] | no_license | CREATE USER 'SmartMED'@'localhost' IDENTIFIED BY '*gi3q3r*';
CREATE DATABASE SmartMED CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON SmartMED.* TO 'SmartMED'@'localhost';
FLUSH PRIVILEGES;
CREATE TABLE IF NOT EXISTS konta (
id int(11) NOT NULL AUTO_INCREMENT,
login varchar(50) NOT NULL,
haslo varchar(50) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS lekarze (
id int(11) NOT NULL AUTO_INCREMENT,
imie varchar(50) NOT NULL,
nazwisko varchar(50) NOT NULL,
specjalizacja varchar(50) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS pacjenci (
id int(11) NOT NULL AUTO_INCREMENT,
imie varchar(50) NOT NULL,
nazwisko varchar(50) NOT NULL,
email varchar(50) NOT NULL,
pesel varchar(11) NOT NULL,
telefon varchar(11) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS terminy (
id int(11) NOT NULL AUTO_INCREMENT,
data datetime NOT NULL,
id_lekarz int(11) NOT NULL,
id_pacjent int(11) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO konta (id, login, haslo) VALUES (1, 'Beata', 'elo520yo');
INSERT INTO lekarze (imie, nazwisko, specjalizacja) VALUES ('Joanna', 'Kowalska', 'Onkolog');
INSERT INTO lekarze (imie, nazwisko, specjalizacja) VALUES ('Genowefa', 'Pigwa', 'Alergolog');
INSERT INTO lekarze (imie, nazwisko, specjalizacja) VALUES ('Juliana', 'Hurka', 'Ginekolog');
INSERT INTO lekarze (imie, nazwisko, specjalizacja) VALUES ('Zbigniew', 'Wiszniewski', 'Onkolog');
INSERT INTO terminy (data, id_lekarz, id_pacjent) VALUES ('2016-07-21 14:00:00', 1, NULL);
INSERT INTO terminy (data, id_lekarz, id_pacjent) VALUES ('2016-07-21 15:00:00', 1, NULL);
INSERT INTO terminy (data, id_lekarz, id_pacjent) VALUES ('2016-06-26 16:00:00', 1, NULL);
INSERT INTO terminy (data, id_lekarz, id_pacjent) VALUES ('2016-06-13 17:00:00', 2, NULL);
INSERT INTO terminy (data, id_lekarz, id_pacjent) VALUES ('2016-06-21 18:00:00', 2, NULL);
INSERT INTO terminy (data, id_lekarz, id_pacjent) VALUES ('2016-06-22 14:00:00', 3, NULL);
INSERT INTO terminy (data, id_lekarz, id_pacjent) VALUES ('2016-06-24 15:00:00', 3, NULL);
INSERT INTO terminy (data, id_lekarz, id_pacjent) VALUES ('2016-06-25 16:00:00', 3, NULL);
INSERT INTO pacjenci (imie, nazwisko, email, pesel, telefon) VALUES ('Beata', 'Koziol', 'koziol@gmail.com', '01010190876', '098765432');
INSERT INTO pacjenci (imie, nazwisko, email, pesel, telefon) VALUES ('Waldemar', 'Koziol', 'waldek_koziol@gmail.com', '02020290876', '098767732');
INSERT INTO pacjenci (imie, nazwisko, email, pesel, telefon) VALUES ('Zbigniew', 'Szepczak', 'zbychu@gmail.com', '12345678900', '678456765');
INSERT INTO pacjenci (imie, nazwisko, email, pesel, telefon) VALUES ('Stefano', 'Terrazino', 'stefek@tlen.pl', '98567854765', '987123345');
INSERT INTO pacjenci (imie, nazwisko, email, pesel, telefon) VALUES ('Grzegorz', 'Podpalka', 'g_palka@icloud.com', '87020265456', '765456987');
| true |
fe299144917780335130b69961aca35c4a783228 | SQL | Abadila-LTF/Nexteer | /nexteer/Datalayer/our_users.sql | UTF-8 | 5,201 | 2.859375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 03, 2021 at 11:51 PM
-- Server version: 10.4.19-MariaDB
-- PHP Version: 7.4.19
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `our_users`
--
-- --------------------------------------------------------
--
-- Table structure for table `change_his`
--
CREATE TABLE `change_his` (
`id` int(30) NOT NULL,
`id_user` int(30) NOT NULL,
`line` text NOT NULL,
`old_ref_id` int(30) NOT NULL,
`new_ref_id` int(30) NOT NULL,
`date_changed` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `current_reff`
--
CREATE TABLE `current_reff` (
`id` int(30) NOT NULL,
`id_user` int(30) NOT NULL,
`id_ref` int(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `eps_reff`
--
CREATE TABLE `eps_reff` (
`id_eps_ref` int(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `eps_reff`
--
INSERT INTO `eps_reff` (`id_eps_ref`) VALUES
(38213710),
(38216130),
(38219816),
(38226329),
(38226332),
(38231410),
(38236683),
(38236684),
(38245523),
(38245524),
(38245525),
(38245526),
(38245533),
(38245534),
(38260746),
(38268195),
(38268196),
(38272195),
(38272202),
(38272203);
-- --------------------------------------------------------
--
-- Table structure for table `half_shift_ref`
--
CREATE TABLE `half_shift_ref` (
`id_hs_ref` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `half_shift_ref`
--
INSERT INTO `half_shift_ref` (`id_hs_ref`) VALUES
(38241869),
(38241870),
(38246448),
(38246449),
(38246450),
(38246451),
(38246452),
(38246453),
(38246454),
(38246455),
(38255093),
(38255119),
(38260764),
(38261338),
(38261920),
(38261921),
(38264272),
(38266115),
(38266116),
(38266118),
(38266119),
(38266686),
(38273214),
(38273215),
(38273265),
(38273266),
(38273274),
(38277730),
(38278467),
(38278468),
(38286333),
(38286334),
(38288991),
(38292230),
(38292231),
(38292234);
-- --------------------------------------------------------
--
-- Table structure for table `logistic`
--
CREATE TABLE `logistic` (
`id_logistic` int(30) NOT NULL,
`name` text NOT NULL,
`password` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `logistic`
--
INSERT INTO `logistic` (`id_logistic`, `name`, `password`) VALUES
(1, 'Nabila Elkadiry', 'logistic');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id_user` int(11) NOT NULL,
`name` varchar(80) NOT NULL,
`password` varchar(30) NOT NULL,
`line` int(11) NOT NULL,
`zone` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id_user`, `name`, `password`, `line`, `zone`) VALUES
(1, 'Salaheddine Idrissi', 'salaheddine idrissi', 1, 'Machining'),
(2, 'Omar Chfik', 'omar chfik', 1, 'Assist MEC'),
(3, 'El Bassli Brahim', 'el bassli brahim', 2, 'FASS'),
(4, 'Houbari Youssef', 'houbari youssef', 2, 'HOT ZONE');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `change_his`
--
ALTER TABLE `change_his`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `current_reff`
--
ALTER TABLE `current_reff`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `eps_reff`
--
ALTER TABLE `eps_reff`
ADD PRIMARY KEY (`id_eps_ref`);
--
-- Indexes for table `half_shift_ref`
--
ALTER TABLE `half_shift_ref`
ADD PRIMARY KEY (`id_hs_ref`);
--
-- Indexes for table `logistic`
--
ALTER TABLE `logistic`
ADD PRIMARY KEY (`id_logistic`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id_user`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `change_his`
--
ALTER TABLE `change_his`
MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=84;
--
-- AUTO_INCREMENT for table `current_reff`
--
ALTER TABLE `current_reff`
MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=247;
--
-- AUTO_INCREMENT for table `eps_reff`
--
ALTER TABLE `eps_reff`
MODIFY `id_eps_ref` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=38272204;
--
-- AUTO_INCREMENT for table `half_shift_ref`
--
ALTER TABLE `half_shift_ref`
MODIFY `id_hs_ref` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=38292235;
--
-- AUTO_INCREMENT for table `logistic`
--
ALTER TABLE `logistic`
MODIFY `id_logistic` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
e78cefbcaf81384628b5bb00886236f63ce85f19 | SQL | radtek/Oracle-4 | /SQL/Administração/!Script Leandro/Constraints.sql | UTF-8 | 950 | 2.890625 | 3 | [] | no_license | Prompt #############################################################
Prompt # #
Prompt # Lista script disbale/ enable constraint #
Prompt # #
Prompt #############################################################
set feedback off
set heading off
set verify off
set lines 300
accept p_owner prompt "Digite o Owner da Tabela: "
accept p_table prompt "Digite o nome da Tabela: "
accept opcao prompt "Escolha entre Disable ou Enable: "
select 'ALTER TABLE '||OWNER||'.'||TABLE_NAME
|| ' '||'&opcao'||' CONSTRAIMT '||CONSTRAINT_NAME ||';'
FROM ALL_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'R'
AND OWNER = '&P_OWNER'
AND TABLE_NAME = '&P_TABLE'
/
undefine p_name
UNDEFINE p_owner
UNDEFINE OPCAO
set feedback on
set heading on
set verify on
set feedback oN
set heading oN
set verify oN
set lines 100
| true |
49315abd656fb09a8780578bc51e21579c68732b | SQL | mjkubba/PostgresReport | /postgres/sql/sql9.sql | UTF-8 | 352 | 3.28125 | 3 | [] | no_license | SELECT
schemaname, relname,last_vacuum, cast(last_autovacuum as date), cast(last_analyze as date), cast(last_autoanalyze as date),
pg_size_pretty(pg_total_relation_size(table_name)) as table_total_size
from pg_stat_user_tables a, information_schema.tables b where a.relname=b.table_name ORDER BY pg_total_relation_size(table_name) DESC limit 25;
| true |
070f14fe2f8816be2cbe2a62054c61c9b598e8f8 | SQL | safetyh546/NY_RealEstate_Dashboard | /Resources/Data/Testing.sql | UTF-8 | 1,499 | 4.0625 | 4 | [] | no_license | select count(*) ,min(cast(gross_square_feet as int) ), max(cast(gross_square_feet as int) )
from sales
where gross_square_feet <> ' - '
and cast(gross_square_feet as int) > 0
--order by sale_price
select borough_name, ROUND((sale_price/cast(gross_square_feet as money))::numeric,2) , sale_price, gross_square_feet
--sale_price/cast(gross_square_feet as money),2)
from sales
where gross_square_feet <> ' - '
and cast(gross_square_feet as int) > 0
select borough_name, AVG(prie_per_gross_square_foot)
from sales
where prie_per_gross_square_foot > cast(0.00 as money)
group by borough_name
select case
when cast(gross_square_feet as int) <= 1000 then '1000 or less'
when cast(gross_square_feet as int) >1000 and cast(gross_square_feet as int) <= 3000 then '>1000 and <= 3000'
when cast(gross_square_feet as int) >3000 and cast(gross_square_feet as int) <= 5000 then '>3000 and less than 5000'
when cast(gross_square_feet as int) >5000 then '>5000'
else 'test' end,
count(*),
min(sale_price),
max(sale_price)
from sales
where gross_square_feet <> ' - '
and cast(gross_square_feet as int) > 0
group by case
when cast(gross_square_feet as int) <= 1000 then '1000 or less'
when cast(gross_square_feet as int) >1000 and cast(gross_square_feet as int) <= 3000 then '>1000 and <= 3000'
when cast(gross_square_feet as int) >3000 and cast(gross_square_feet as int) <= 5000 then '>3000 and less than 5000'
when cast(gross_square_feet as int) >5000 then '>5000'
else 'test' end
| true |
0b12e6e11f0a8f14365a7f69358fc7a460e834de | SQL | cronox5790/UNIDAD-4-ACTIVIDAD-2 | /rolesdeusuario.sql | UTF-8 | 4,097 | 3.078125 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS `rolesdeusuario` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `rolesdeusuario`;
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: localhost Database: rolesdeusuario
-- ------------------------------------------------------
-- Server version 5.7.18-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `alumno`
--
DROP TABLE IF EXISTS `alumno`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `alumno` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`NumControl` varchar(9) NOT NULL,
`Nombre` varchar(45) NOT NULL,
`IdMaestro` int(11) NOT NULL,
PRIMARY KEY (`Id`),
KEY `fk_IdMaestro_idx` (`IdMaestro`),
CONSTRAINT `fk_IdMaestro` FOREIGN KEY (`IdMaestro`) REFERENCES `maestro` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `alumno`
--
LOCK TABLES `alumno` WRITE;
/*!40000 ALTER TABLE `alumno` DISABLE KEYS */;
INSERT INTO `alumno` VALUES (2,'171G0574','Adolfo Hitler Editado 2',1),(3,'171G0573','Luis Aguilar',2);
/*!40000 ALTER TABLE `alumno` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `director`
--
DROP TABLE IF EXISTS `director`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `director` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`NumControl` int(11) NOT NULL,
`Nombre` varchar(45) NOT NULL,
`Clave` varchar(100) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `director`
--
LOCK TABLES `director` WRITE;
/*!40000 ALTER TABLE `director` DISABLE KEYS */;
INSERT INTO `director` VALUES (2,50799,'Luis Antonio Aguilar','03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4');
/*!40000 ALTER TABLE `director` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `maestro`
--
DROP TABLE IF EXISTS `maestro`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `maestro` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Clave` varchar(100) NOT NULL,
`Nombre` varchar(45) NOT NULL,
`Activo` bit(1) DEFAULT b'1',
`NumControl` int(11) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `maestro`
--
LOCK TABLES `maestro` WRITE;
/*!40000 ALTER TABLE `maestro` DISABLE KEYS */;
INSERT INTO `maestro` VALUES (1,'20f3765880a5c269b747e1e906054a4b4a3a991259f1e16b5dde4742cec2319a','Juan Sifuente Garcia','',12345),(2,'5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5','luis Aguilar','',45678);
/*!40000 ALTER TABLE `maestro` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping events for database 'rolesdeusuario'
--
--
-- Dumping routines for database 'rolesdeusuario'
--
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-01-06 17:55:53
| true |
ed0fa7327bd0fad70e020e293d72d03f03c3e3f8 | SQL | bracealround/Online_Judge_Solved-Problems | /Hackerrank/Weather Observation Station 17.sql | UTF-8 | 79 | 3.109375 | 3 | [] | no_license | SELECT ROUND(LONG_W,4) FROM STATION WHERE LAT_N>38.7880 ORDER BY LAT_N LIMIT 1; | true |
6cad61fe233c477200293208c28c50cbe5fbefcc | SQL | gopi158/Sample | /FinaoDb/Stored Procedures/whotofollow.sql | UTF-8 | 4,482 | 3.953125 | 4 | [] | no_license | DELIMITER //
DROP PROCEDURE IF EXISTS whotofollow //
CREATE PROCEDURE `whotofollow`(IN u_name VARCHAR(256) )
BEGIN
/********************************************************************************************************
--------------------VARIABLE DECLARATION---------------section START-----------------------------------
*********************************************************************************************************/
DECLARE counter INT;
DECLARE total INT;
DECLARE uniqueuserid INT;
DECLARE totalinspired INT;
DECLARE totaltiles INT;
DECLARE totalfinaos INT;
DECLARE user_id INT;
/********************************************************************************************************
--------------------VARIABLE DECLARATION---------------section END-----------------------------------
*********************************************************************************************************/
/********************************************************************************************************
----------------------- TEMP TABLE DECLARATION---------------section START-----------------------------
*********************************************************************************************************/
CREATE TEMPORARY TABLE IF NOT EXISTS whotofollowusers
(
id serial
, userid INT
, username VARCHAR(256)
, usrname VARCHAR(255)
, image VARCHAR(255)
, tiles INT
, finaos INT
, inspired INT
);
TRUNCATE TABLE whotofollowusers;
/********************************************************************************************************
----------------------- TEMP TABLE DECLARATION---------------section END-----------------------------
*********************************************************************************************************/
IF u_name > 0
THEN
SET user_id := u_name;
ELSE
SELECT userid FROM fn_users WHERE uname = u_name INTO user_id;
END IF;
IF EXISTS (SELECT userid FROM fn_user_finao_tile WHERE userid = user_id)
THEN
INSERT INTO whotofollowusers
( userid
, username
, usrname
, image
)
SELECT DISTINCT
user.userid
, user.uname
, CONCAT_WS (' ',user.fname, user.lname) AS name
, profile.profile_image
FROM fn_users AS user
INNER JOIN fn_user_profile profile ON user.userid = profile.user_id
INNER JOIN fn_user_finao_tile tile ON tile.userid = user.userid
INNER JOIN fn_tilesinfo track ON track.tilename = tile.tile_name AND user.userid NOT IN (SELECT userid
FROM userfollowers
WHERE followerid = user_id
)
WHERE user.userid != user_id
ORDER BY user.userid;
SELECT COUNT(id)
FROM whotofollowusers NOLOCK INTO total;
SET counter:= 1;
WHILE (counter <= total) DO
SELECT userid
FROM whotofollowusers NOLOCK
WHERE id = COUNTER INTO uniqueuserid;
SELECT COUNT(ip.inspiringpostid)
FROM inspiringpost ip
INNER JOIN fn_uploaddetails upload
ON ip.userpostid = upload.uploaddetail_id
WHERE ip.inspireduserid = uniqueuserid INTO totalinspired;
SELECT COUNT(DISTINCT fn_tilesinfo.tile_id )
FROM fn_user_finao_tile
INNER JOIN fn_tilesinfo ON
fn_user_finao_tile.tile_id= fn_tilesinfo.tile_id
WHERE fn_user_finao_tile.STATUS = 1
And fn_user_finao_tile.userid = uniqueuserid
AND fn_tilesinfo.STATUS = 1 INTO totaltiles;
SELECT COUNT(finao.user_finao_id)
FROM fn_user_finao finao
INNER JOIN fn_user_finao_tile ftile ON finao.user_finao_id = ftile.finao_id
INNER JOIN fn_tilesinfo tile ON tile.tile_id = ftile.tile_id
WHERE finao.finao_activestatus = 1
AND tile.status = 1
AND finao.userid = uniqueuserid
AND finao.finao_status_Ispublic = 1 INTO totalfinaos;
UPDATE whotofollowusers
SET tiles = totaltiles
, finaos = totalfinaos
, inspired = totalinspired
WHERE id = counter;
SET counter := counter + 1;
END WHILE;
SELECT *
FROM whotofollowusers ORDER BY inspired DESC, finaos DESC, tiles DESC LIMIT 3;
ELSE
SIGNAL SQLSTATE '45001' SET
MYSQL_ERRNO = 2001;
END IF;
DROP TABLE IF EXISTS whotofollowusers;
END //
DELIMITER // | true |
4dbdad52aa68888a1cb2205e9f4bdb472d3c7915 | SQL | jenobpj/BootcampX | /1_queries/nonGmailStudents.sql | UTF-8 | 97 | 2.84375 | 3 | [] | no_license | SELECT name,email,id,cohort_id
FROM students
WHERE email NOT LIKE '%gmail.com'
AND phone IS NULL; | true |
2be21b207c6da9f5cf32b92dd710b3c3a3cc3550 | SQL | lancebrown42/SQLIntro | /placeholder.sql | UTF-8 | 3,053 | 3.109375 | 3 | [] | no_license | CREATE TABLE TEventCorporateSponsorshipTypes
(
intEventCorporateSponsorshipTypeID INTEGER NOT NULL
,intCorporateSponsorID INTEGER NOT NULL
,intEventID INTEGER NOT NULL
,dblSponsorshipCost DECIMAL NOT NULL
,blnSponsorshipAvailable BOOLEAN NOT NULL
,CONSTRAINT TEventCorporateSponsorshipTypes_PK PRIMARY KEY (intEventCorporateSponsorshipTypeID)
)
CREATE TABLE TEventCorporateSponsorshipTypeCorporateSponsors
(
intEventCorporateSponsorshipTypeCorporateSponsorID INTEGER NOT NULL
,intCorporateSponsorshipTypeID INTEGER NOT NULL
,intCorporateSponsorID INTEGER NOT NULL
,CONTRAINT TEventCorporateSponsorshipTypeCorporateSponsors_PK PRIMARY KEY ( intEventCorporateSponsorshipTypeCorporateSponsorID)
)
CREATE TABLE TCorporateSponsorshipTypes
(
intCorporateSponsorshipTypeID INTEGER NOT NULL
,intCorporateSponsorshipTypeID INTEGER NOT NULL
,CONTRAINT TCorporateSponsorshipTypes_PK PRIMARY KEY ( intCorporateSponsorshipTypeID)
)
CREATE TABLE TEventGolferSponsors
(
intEventGolferSponsorID INTEGER NOT NULL
,intEventGolferID INTEGER NOT NULL
,intSponsorID INTEGER NOT NULL
,dtmPledgeDate DATETIME NOT NULL
,dblPledgePerHole DECIMAL NOT NULL
,intPaymentTypeID INTEGER NOT NULL
,intPaymentStatuseID INTEGER NOT NULL
,CONTRAINT TEventGolferSponsors_PK PRIMARY KEY ( intEventGolferSponsorID)
)
CREATE TABLE TEventGolferTeamAndClubs
(
intEventGolferTeamAndClubID INTEGER NOT NULL
,intEventGolferID INTEGER NOT NULL
,intTeamAndClubID INTEGER NOT NULL
,CONTRAINT TEventGolferTeamAndClubs_PK PRIMARY KEY ( intEventGolferTeamAndClubID)
)
CREATE TABLE TTeamAndClubs
(
intTeamAndClubID INTEGER NOT NULL
,intTypesOfTeamID INTEGER NOT NULL
,intLevelOfTeamID INTEGER NOT NULL
,intGenderID INTEGER NOT NULL
,CONTRAINT TTeamAndClubs_PK PRIMARY KEY ( intTeamAndClubID)
)
CREATE TABLE TShirtSizes
(
intShirtSizeID INTEGER NOT NULL
,strShirtSize VARCHAR(255) NOT NULL
,CONTRAINT TShirtSizes_PK PRIMARY KEY ( intShirtSizeID)
)
CREATE TABLE TTypesOfTeams
(
intTypesOfTeamID INTEGER NOT NULL
,strType INTEGER NOT NULL
,CONTRAINT TTypesOfTeams_PK PRIMARY KEY ( intTypesOfTeamID)
)
CREATE TABLE TLevelOfTeams
(
intLevelOfTeamID INTEGER NOT NULL
,strLevel VARCHAR(255) NOT NULL
,CONTRAINT TLevelOfTeams_PK PRIMARY KEY ( intLevelOfTeamID)
)
CREATE TABLE TPaymentTypes
(
intPaymentTypeID INTEGER NOT NULL
,strPaymentType VARCHAR(255) NOT NULL
,CONTRAINT TPaymentTypes_PK PRIMARY KEY ( intPaymentTypeID)
)
CREATE TABLE TPaymentStatuses
(
intPaymentStatuseID INTEGER NOT NULL
,strPaymentStatus INTEGER NOT NULL
,CONTRAINT TPaymentStatuses_PK PRIMARY KEY ( intPaymentStatuseID)
)
1xs
2s
3m
4l
5xl
6xxl | true |
b2b7cb8789ec0043583501f8663ddfc0ffd00ccf | SQL | smartcodev/dw_smartco | /dw_smartco/database/Database/DDL.sql | UTF-8 | 2,615 | 3.3125 | 3 | [] | no_license | ALTER TABLE SMARTCO.MIS_TF001_PORTA_BLOQUEADA
DROP CONSTRAINT MIS_PB_TF001_PORTA_BLOQUE_FK1;
ALTER TABLE SMARTCO.MIS_TF001_PORTA_BLOQUEADA
DROP CONSTRAINT MIS_PB_TF001_PORTA_BLOQUE_FK2;
ALTER TABLE SMARTCO.MIS_TF001_PORTA_BLOQUEADA
DROP CONSTRAINT MIS_PB_TF001_PORTA_BLOQUE_FK3;
DROP TABLE SMARTCO.MIS_TF001_PORTA_BLOQUEADA CASCADE CONSTRAINTS;
DROP TABLE SMARTCO.MIS_TD003_LOCALIDADE CASCADE CONSTRAINTS;
DROP TABLE SMARTCO.MIS_TD001_DETALHE_BLOQ CASCADE CONSTRAINTS;
CREATE TABLE SMARTCO.MIS_TD001_DETALHE_BLOQ
(
ID NUMBER GENERATED ALWAYS AS IDENTITY NOT NULL
, PRODUTO VARCHAR2(50)
, MOTIVO VARCHAR2(50) NOT NULL
, SUBMOTIVO VARCHAR2(50) NOT NULL
, DATE_FROM DATE
, DATE_TO DATE
, VERSION NUMBER
, CONSTRAINT MIS_PB_TD001_DETALHE_BLOQU_PK PRIMARY KEY
(
ID
)
ENABLE
);
CREATE TABLE SMARTCO.MIS_TD003_LOCALIDADE
(
ID NUMBER
, ARMARIO VARCHAR2(11 BYTE)
, REGIONAL VARCHAR2(12 BYTE)
, CIDADE VARCHAR2(30 BYTE)
, ESTADO VARCHAR2(2 BYTE)
, DATE_FROM DATE
, DATE_TO DATE
, VERSION NUMBER
);
CREATE TABLE SMARTCO.MIS_TF001_PORTA_BLOQUEADA
(
ID NUMBER GENERATED ALWAYS AS IDENTITY NOT NULL
, ID_PORTA_VOZ VARCHAR2(50) NOT NULL
, LOCALIDADE_FK NUMBER NOT NULL
, DETALHE_BLOQUEIO_FK NUMBER NOT NULL
, DATA_BLOQUEIO_FK DATE NOT NULL
, CONSTRAINT MIS_PB_TF001_PORTA_BLOQUEA_PK PRIMARY KEY
(
ID
)
ENABLE
);
CREATE BITMAP INDEX SMARTCO.IDX_MIS_TD003_LOCALIDADE_TK ON SMARTCO.MIS_TD003_LOCALIDADE (ID ASC)
LOGGING
TABLESPACE REPOSITORY
PCTFREE 10
INITRANS 2
STORAGE
(
INITIAL 4194304
NEXT 4194304
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
NOPARALLEL;
CREATE INDEX SMARTCO.IDX_MIS_TD003_LOC_LOOKUP ON SMARTCO.MIS_TD003_LOCALIDADE (ARMARIO ASC)
LOGGING
TABLESPACE REPOSITORY
PCTFREE 10
INITRANS 2
STORAGE
(
INITIAL 4194304
NEXT 4194304
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
NOPARALLEL;
ALTER TABLE SMARTCO.MIS_TF001_PORTA_BLOQUEADA
ADD CONSTRAINT MIS_PB_TF001_PORTA_BLOQUE_FK1 FOREIGN KEY
(
ID
)
REFERENCES SMARTCO.MIS_TD001_DETALHE_BLOQ
(
ID
)
ENABLE;
ALTER TABLE SMARTCO.MIS_TF001_PORTA_BLOQUEADA
ADD CONSTRAINT MIS_PB_TF001_PORTA_BLOQUE_FK2 FOREIGN KEY
(
LOCALIDADE_FK
)
REFERENCES SMARTCO.MIS_TD003_LOCALIDADE
(
ID
)
ENABLE;
ALTER TABLE SMARTCO.MIS_TF001_PORTA_BLOQUEADA
ADD CONSTRAINT MIS_PB_TF001_PORTA_BLOQUE_FK3 FOREIGN KEY
(
DATA_BLOQUEIO_FK
)
REFERENCES SMARTCO.MIS_TD002_TEMPO
(
DAY_ID
)
ENABLE;
| true |
40b68cb117b911f0ef1d95e7f67a7dad4f0fe6d4 | SQL | julito2000/DAM1 | /BD/BD04/Tarea BD04/Datos.sql | UTF-8 | 3,680 | 3.171875 | 3 | [] | no_license | CREATE TABLE CENTRO(
codcentro number(2) not null,
direccion varchar2(30) not null,
localidad varchar2(20) not null);
insert into centro values (01,'Rambla Nova','Tarragona');
insert into centro values (02,'Alcala','Madrid');
insert into centro values (03,'Sierpes','Sevilla');
alter table centro add constraints pk_codcentro primary key (codcentro);
CREATE TABLE DPTO(
coddpto number(2) not null,
denominacion varchar2(20) not null,
codcentro number(2) not null,
coddptodepende number(2),
codemplejefe number(3) not null,
tipo char(1) not null,
presupuesto number(8,2) not null);
insert into dpto values (01, 'DIRECCION',01,NULL,01,'P',100000);
insert into dpto values (02, 'ADMINISTRACION',01,01,03,'F',50000);
insert into dpto values (03, 'RECURSOS HUMANOS',01,01,05,'P',30000);
insert into dpto values (05, 'CENTRAL COMERCIAL',01,01,07,'P',100000);
insert into dpto values (06, 'COMERCIAL CENTRO',02,05,02,'F',5000);
insert into dpto values (07, 'COMERCIAL SUR',03,05,04,'F',40000);
CREATE TABLE EMPLEADO(
codemple number(3) not null,
ape1 varchar2(20) not null,
ape2 varchar2(20) not null,
nombre varchar2(15) not null,
direccion varchar2(25) not null,
localidad varchar2(25) not null,
telef varchar(9),
coddpto number(2) not null,
codcate number(2) not null,
fechaingreso date not null,
salario number(6,2) not null,
comision number(6,2));
insert into empleado values(01,'LOPEZ', 'GARCIA','ANA','C/ ANAS','MADRID', 666666666,01,01,'01/02/2000',3000,NULL);
insert into empleado values(02,'FERNANDEZ', 'MORON','JUAN','C/FUENTE','TARRAGONA', 7777777,01,02,'01/02/2002',2000,NULL);
insert into empleado values(03,'CORTES', 'LOPEZ','ANGEL','C/CIFUENTES','BARACALDO', 888888,02,01,'01/03/2003',2000,NULL);
insert into empleado values(04,'SANCHEZ', 'LUZ','FABIOLA','C/CARDON','SEVILLA', 99999999,03,02,'21/05/2001',2500,NULL);
insert into empleado values(05,'RAJOY', 'AZNAR','PAZ','C/MAR','JAEN', 88888888,03,01,'23/02/2000',2000,130);
insert into empleado values(06,'ZAPATERO', 'GALLARDON','ANGUSTIAS','C/SUR','MADRID', 78787878,05,03,'01/02/2000',2000,NULL);
insert into empleado values(07,'FLOR', 'LUZ','BLANCA','C/TECLA','SEVILLA', 7777777,06,01,'01/02/2000',3000,130);
insert into empleado values(08,'ROS', 'SANTON','ALFONSO','C/ LUZ','MADRID', 888888,07,03,'01/02/2003',2000,NULL);
insert into empleado values(09,'LOPEZ', 'ITURRIALDE','GANDI','C/OASIS','TARRAGONA', 777777,05,01,'01/02/1998',1500,210);
insert into empleado values(10,'JAZMIN', 'EXPOSITO','MARIA','C/MANDRAGORA','MADRID', 888888,05,03,'01/03/2001',1000,200);
ALTER TABLE dpto add constraints pk_coddpto primary key (coddpto);
ALTER TABLE dpto add constraints fk_codcentro foreign key (codcentro) references centro (codcentro);
ALTER TABLE dpto add constraints fk_coddptodepende foreign key (coddptodepende) references dpto(coddpto);
ALTER TABLE dpto add constraints chk_tipo check(tipo in('P','F'));
ALTER TABLE empleado add constraints pk_codemple primary key(codemple);
ALTER TABLE dpto add constraints fk_codemplejefe foreign key (codemplejefe) references empleado(codemple);
ALTER TABLE empleado add constraints fk_coddpto foreign key (coddpto) references dpto(coddpto);
CREATE TABLE CATEGORIA(
codcate number(2) not null,
denom varchar2(20) not null,
julio number (6,2) not null,
diciembre number(6,2) not null);
insert into categoria values(1,'ALTOS DIRECTIVOS',6000,5000);
insert into categoria values(2,'DIRECTIVOS',3000,2000);
insert into categoria values(3,'ADMINISTRATIVOS',2000,1500);
ALTER TABLE categoria add constraints pk_codcate primary key(codcate);
alter table empleado add constraints fk_codcate foreign key(codcate) references categoria(codcate);
| true |
a7ff570b57e4132902821224572216d5d50a313a | SQL | JavaTeam2/Foodmart | /FoodHouse/food.sql | UTF-8 | 11,037 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | CREATE TABLE IF NOT EXISTS `food` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` nvarchar(45) COLLATE utf8_bin NOT NULL,
`price` double NOT NULL,
`price_promotion` double NOT NULL,
`kindOfFood` nvarchar(100),
`image` varchar(500) NOT NULL,
`description` nvarchar(1000) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY(`id`)
);
INSERT INTO `food` (`id`, `name`, `price`, `price_promotion`, `kindOfFood`, `image`, `description`) VALUES
-- Starters--
(1, 'Blue Cheese Salad', 15, 13, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/blue-cheese-salad-super-salads.jpg', 'Special'),
(2, 'Donec', 35, 30, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/donec.jpg', ''),
(3, 'Ens Banting', 21, 15, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/ens-banting.jpg', ''),
(4, 'Fusce', 17, 12, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/fusce.jpg', 'Special'),
(5, 'Ipsum', 24, 21, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/ipsum.jpg', ''),
(6, 'Kitchen Stuff ', 55, 43, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/kitchen-stuff-chorizo.jpg', ''),
(7, 'Lorem', 42, 40, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/lorem.jpg', ''),
(8, 'Nullam', 32, 30, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/Nullam.jpg', 'Special'),
(9, 'Spier Kitchen Stuff', 44, 38, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/spier-kitchen-stuff.jpg', ''),
(10, 'Tempura Batter ', 70, 60, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/tempura-batter-filipino-recipes.jpg', ''),
(11, 'Tempura Green Beans', 32, 21, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/tempura-green-beans.jpg', ''),
(12, 'Vivamus', 55, 44, 'Starters', 'http://localhost:8080/FoodHouse/images/food/starters/vivamus.jpg', 'Special'),
-- //Starters--
-- Main Course --
(13, 'Bistecca Tonno', 15, 13, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/BisteccaTonno.jpg', ''),
(14, 'Bourbon Glazed', 88, 65, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/bourbon-glazed-salmon.jpg', ''),
(15, 'Chile Brined Ham', 65, 47, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/chile-brined-ham.jpg', ''),
(16, 'Grigliata', 50, 45, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/Grigliata.jpg', ''),
(17, 'Lamb Chops ', 78, 57, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/lamb-chops-rosemary-xlg.jpg', 'Special'),
(18, 'Maple Sugar Ginger', 68, 65, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/maple-sugar-ginger-roast-pork.jpg', ''),
(19, 'Pasta Soup', 87, 66, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/pasta-soup-good-housekeeping.jpg', ''),
(20, 'Prime Rib Roast', 24, 20, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/prime-rib-roast.jpg', ''),
(21, 'Roast Duck Citrus', 36, 24, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/roast-duck-citrus-xlg.jpg', 'Special'),
(22, 'Salmone Ferri', 70, 50, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/SalmoneFerri.jpg', 'Special'),
(23, 'Tagliata Carne', 36, 30, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/Tagliata-Carne.jpg', ''),
(24, 'Zuppa Oceanica', 54, 50, 'Main Course', 'http://localhost:8080/FoodHouse/images/food/main course/ZuppaOceanica.jpg', ''),
-- //Main Course --
-- Salads --
(25, 'Greek Quinoa', 36, 25, 'Salads', 'http://localhost:8080/FoodHouse/images/food/salads/Greek_Quinoa_Salad.jpg', ''),
(26, 'Grilled Nectarine', 32, 30, 'Salads', 'http://localhost:8080/FoodHouse/images/food/salads/Grilled_Nectarine_Salad.jpg', 'Special'),
(27, 'Lamb Kebabs', 66, 57, 'Salads', 'http://localhost:8080/FoodHouse/images/food/salads/Lamb_Kebabs.jpg', ''),
(28, 'Madeleine Recipes', 50, 44, 'Salads', 'http://localhost:8080/FoodHouse/images/food/salads/Madeleine_Recipes_Feta_raisin_salad.jpg', ''),
(29, 'Recipes Chicken', 33, 21, 'Salads', 'http://localhost:8080/FoodHouse/images/food/salads/Recipes_watermelon_salad.jpg', ''),
(30, 'Sesame Crusted', 44, 41, 'Salads', 'http://localhost:8080/FoodHouse/images/food/salads/Sesame_Crusted_Salmon.jpg', 'Special'),
(31, 'Verggie Nori Wraps', 21, 15, 'Salads', 'http://localhost:8080/FoodHouse/images/food/salads/VERGGIE_NORI_WRAPS.jpg', ''),
(32, 'Recipes Watermelon', 25, 21, 'Salads', 'http://localhost:8080/FoodHouse/images/food/salads/Recipes_watermelon_salad.jpg', ''),
-- //Salads
-- Desserts --
(33, 'Pink Snail', 44, 40, 'Desserts', 'http://localhost:8080/FoodHouse/images/food/desserts/Pink Snail.jpeg', ''),
(34, 'Birds milk', 31, 29, 'Desserts', 'http://localhost:8080/FoodHouse/images/food/desserts/Birds milk.jpeg', 'Special'),
(35, 'Crumbs', 33, 20, 'Desserts', 'http://localhost:8080/FoodHouse/images/food/desserts/Crumbs.jpeg', 'Special'),
(36, 'Niger Smile', 12, 10, 'Desserts', 'http://localhost:8080/FoodHouse/images/food/desserts/Niger Smile.jpeg', '');
-- //Desserts --
CREATE TABLE IF NOT EXISTS `users` (
`username` varchar(45) NOT NULL,
`password` varchar(45) NOT NULL,
`name` nvarchar(45) COLLATE utf8_bin NOT NULL,
`phone` varchar(15) NOT NULL,
PRIMARY KEY(`username`)
);
INSERT INTO `users`(`username`, `password`, `name`, `phone`) VALUES
-- Customer --
('customer', '123456', 'Ashe', '0989112153'),
-- Manager --
('manager', '123456', 'Blitzcrank', '0988391293'),
-- Admin --
('admin', '123456', 'Corki', '01639103218');
CREATE TABLE IF NOT EXISTS `user_roles`(
`user_role_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(45) NOT NULL,
`role` varchar(45) NOT NULL,
PRIMARY KEY(`user_role_id`),
UNIQUE KEY `uni_username_role` (`username`, `role`),
KEY `fk_username_idx` (`username`),
CONSTRAINT `fk_username`
FOREIGN KEY (`username`)
REFERENCES `users`(`username`)
);
INSERT INTO `user_roles`(`username`, `role`) VALUES
('customer', 'ROLE_CUSTOMER'),
('manager', 'ROLE_MANAGER'),
('admin', 'ROLE_ADMIN');
CREATE TABLE IF NOT EXISTS `branch` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` nvarchar(45) COLLATE utf8_bin NOT NULL,
`address` nvarchar(1000) COLLATE utf8_bin NOT NULL,
`province` nvarchar(45) COLLATE utf8_bin NOT NULL,
`image` varchar(500) NOT NULL,
`phone` varchar(15) NOT NULL,
`numOfTable` int(10) unsigned NOT NULL,
`infoTable` nvarchar(500) COLLATE utf8_bin NOT NULL,
PRIMARY KEY(`id`)
);
INSERT INTO `branch` (`id`, `name`, `address`, `province`, `image`, `phone`, `numOfTable`, `infoTable`) VALUES
-- TP HCM --
(1, 'Food Mart - Q.1', '59 Tran Hung Dao', 'TP HCM', 'http://localhost:8080/FoodHouse/images/branches/TP HCM Q1.jpg', '028112153', 15, ''),
(2, 'Food Mart - Q.3', '124 Cao Thang', 'TP HCM', 'http://localhost:8080/FoodHouse/images/branches/TP HCM Q3.jpg', '028391293', 12, ''),
(3, 'Food Mart - Q.7', '256 Nguyen Van Linh', 'TP HCM', 'http://localhost:8080/FoodHouse/images/branches/TP HCM Q7.jpg', '028195100', 18, ''),
(4, 'Food Mart - Q.8', '159 Hung Phu', 'TP HCM', 'http://localhost:8080/FoodHouse/images/branches/TP HCM Q8.jpg', '0289103218', 20, ''),
(5, 'Food Mart - Q. Thu Duc', '255 Vo Van Ngan', 'TP HCM', 'http://localhost:8080/FoodHouse/images/branches/TP HCM Thu duc.jpg', '028786241', 20, ''),
-- //TP HCM --
-- Ha Noi --
(6, 'Food Mart - Q.Ba Dinh','33 Tran Phu', 'Ha Noi', 'http://localhost:8080/FoodHouse/images/branches/Ha noi-Ba dinh.jpg', '024112153', 15, ''),
(7, 'Food Mart - Q.Dong Da','259 Ton Duc Thang', 'Ha Noi', 'http://localhost:8080/FoodHouse/images/branches/Ha Noi-Dong Da.jpg', '024391293', 12, ''),
(8, 'Food Mart - Q.Hoan Kiem','11 Thai Ha', 'Ha Noi', 'http://localhost:8080/FoodHouse/images/branches/Ha noi-Hoan kiem.jpg', '024195100', 18, ''),
(9, 'Food Mart - Q.Tay Ho','534 Vo Chi Cong', 'Ha Noi', 'http://localhost:8080/FoodHouse/images/branches/Ha noi-Tay Ho.jpg', '0249103218', 11, ''),
-- //Ha Noi --
-- Da Nang --
(10, 'Food Mart - Nguyen Trai','20 Nguyen Trai', 'Da Nang', 'http://localhost:8080/FoodHouse/images/branches/Da Nang1.jpg', '0236112153', 12, ''),
(11, 'Food Mart - An Duong Vuong','99 An Duong Vuong', 'Da Nang', 'http://localhost:8080/FoodHouse/images/branches/Da Nang2.jpg', '0236391293', 14, ''),
(12, 'Food Mart - Nguyen Van Cu','987 Nguyen Van Cu', 'Da Nang', 'http://localhost:8080/FoodHouse/images/branches/Da nang3.jpg', '02369103218', 17, ''),
(13, 'Food Mart - Cao Thang','578 Cao Thang', 'Da Nang', 'http://localhost:8080/FoodHouse/images/branches/Da Nang4.jpg', '02369103218', 17, ''),
-- //Da Nang --
-- Nha Trang --
(14, 'Food Mart - Quang Trung','195 Quang Trung', 'Nha Trang', 'http://localhost:8080/FoodHouse/images/branches/Nha Trang - 1.jpg', '0258112153', 18, ''),
(15, 'Food Mart - Ly Thuong Kiet','36 Ly Thuong Kiet', 'Nha Trang', 'http://localhost:8080/FoodHouse/images/branches/Nha Trang - 2.jpg', '0258391293', 12, '');
-- //Nha Trang --
CREATE TABLE IF NOT EXISTS `order`(
`customer_username` varchar(45) NOT NULL,
`orderDate` date NOT NULL,
`status` nvarchar(45) COLLATE utf8_bin NOT NULL,
`note` nvarchar(1000) COLLATE utf8_bin DEFAULT NULL,
`totalMoney` double NOT NULL,
PRIMARY KEY(`customer_username`, `orderDate`),
CONSTRAINT `fk_order_customer` FOREIGN KEY (`customer_username`)
REFERENCES `users`(`username`)
);
CREATE TABLE IF NOT EXISTS `order_lines` (
`order_customer_username` varchar(45) NOT NULL,
`order_orderDate` date NOT NULL,
`food_id` int(10) unsigned NOT NULL,
`quantity` int(10) unsigned NOT NULL,
`unitSalePrice` double NOT NULL,
PRIMARY KEY(`order_customer_username`, `order_orderDate`, `food_id`),
CONSTRAINT `fk_order_lines_food`
FOREIGN KEY(`food_id`)
REFERENCES `food`(`id`),
CONSTRAINT `fk_order_lines_order`
FOREIGN KEY(`order_customer_username`,`order_orderDate`)
REFERENCES `order`(`customer_username`, `orderDate`)
);
CREATE TABLE IF NOT EXISTS `branch_has_food` (
`branch_id` int(10) unsigned NOT NULL,
`food_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`branch_id`, `food_id`),
CONSTRAINT `fk_branch_has_food_branch`
FOREIGN KEY (`branch_id`)
REFERENCES `branch`(`id`),
CONSTRAINT `fk_branch_has_food_food`
FOREIGN KEY (`food_id`)
REFERENCES `food`(`id`)
);
CREATE TABLE IF NOT EXISTS `costs-incurred-month` (
`branch_id` int(10) unsigned NOT NULL,
`month` int(10) unsigned NOT NULL,
`totalCost` double NOT NULL,
PRIMARY KEY (`branch_id`, `month`),
CONSTRAINT `fk_costs-incurred-month_branch`
FOREIGN KEY (`branch_id`)
REFERENCES `branch`(`id`)
);
CREATE TABLE IF NOT EXISTS `costs-incurred-day` (
`branch_id` int(10) unsigned NOT NULL,
`day` int(10) unsigned NOT NULL,
`cost` double NOT NULL,
PRIMARY KEY (`branch_id`, `day`),
CONSTRAINT `fk_costs-incurred-day_branch`
FOREIGN KEY (`branch_id`)
REFERENCES `branch`(`id`)
); | true |
3a580d0f1f8f43bdb7a28573991e58eb78857e4b | SQL | jlemonis/myhotel | /hotel.sql | UTF-8 | 2,102 | 2.8125 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : localhost_3306
Source Server Version : 50710
Source Host : localhost:3306
Source Database : hotel
Target Server Type : MYSQL
Target Server Version : 50710
File Encoding : 65001
Date: 2016-01-30 13:40:53
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for room2
-- ----------------------------
DROP TABLE IF EXISTS `room2`;
CREATE TABLE `room2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
`view` varchar(255) NOT NULL,
`service` varchar(255) NOT NULL,
`checkin` varchar(255) NOT NULL,
`date` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of room2
-- ----------------------------
INSERT INTO `room2` VALUES ('15', 'Άκης Παπαδόπουλος', 'Μονοκλυνο', 'null', 'OK', 'OK', '12/01/2016-13/01/2016');
INSERT INTO `room2` VALUES ('16', 'Μάνος Γεωργίου', 'Δίκλυνο', 'OK', 'OK', 'null', '12/01/2016-15/01/2016');
INSERT INTO `room2` VALUES ('17', 'Μάνος Αποστόλου', 'Μονοκλυνο', 'null', 'OK', 'null', '20/01/2016-22/01/2016');
INSERT INTO `room2` VALUES ('18', 'Στράτος Διονυσίου', 'Δίκλυνο', 'null', 'OK', 'OK', '20/01/2016-22/01/2016');
INSERT INTO `room2` VALUES ('19', 'Μάρκος Βαμβακάρης', 'Τετράκλυνο', 'null', 'null', 'null', '22/01/2016-24/01/2016');
INSERT INTO `room2` VALUES ('20', 'Βασίλης Τσιτσάνης', 'Δίκλυνο', 'OK', 'null', 'null', '23/01/2016-24/01/2016');
INSERT INTO `room2` VALUES ('21', 'Ιωάννης Λεμονής', 'Μονοκλυνο', 'OK', 'null', 'OK', '23/01/2016-27/01/2016');
INSERT INTO `room2` VALUES ('22', 'Ιωάννης Παππαιωάννου', 'Δίκλυνο', 'null', 'null', 'OK', '21/01/2016-27/01/2016');
INSERT INTO `room2` VALUES ('23', 'Γιώργος Ζαμπέτας', 'Τετράκλυνο', 'OK', 'OK', 'OK', '12/02/2016-23/02/2016');
| true |
1704ec6da6dfa6073f7665d00ede3be46e6c612c | SQL | andrehertwig/admintool | /admin-tools-security/admin-tools-security-dbuser/src/main/resources/sql/postgres/TableInitialization_DDL.sql | UTF-8 | 4,091 | 3.78125 | 4 | [
"MIT"
] | permissive | CREATE TABLE "at_client"
(
uuid varchar(40) PRIMARY KEY NOT NULL,
created timestamp NOT NULL,
created_by varchar(255),
modified timestamp,
modified_by varchar(255),
jpaversion int NOT NULL,
active bool NOT NULL,
description varchar(255),
display_name varchar(255),
name varchar(255) NOT NULL
)
;
CREATE TABLE "at_role"
(
uuid varchar(40) PRIMARY KEY NOT NULL,
created timestamp NOT NULL,
created_by varchar(255),
modified timestamp,
modified_by varchar(255),
jpaversion int NOT NULL,
active bool NOT NULL,
description varchar(255),
display_name varchar(255),
name varchar(255) NOT NULL
)
;
CREATE TABLE "at_user"
(
uuid varchar(40) PRIMARY KEY NOT NULL,
created timestamp NOT NULL,
created_by varchar(255),
modified timestamp,
modified_by varchar(255),
jpaversion int NOT NULL,
acc_exp_since timestamp,
acc_lock_since timestamp,
acc_non_exp bool NOT NULL,
acc_non_lock bool NOT NULL,
cred_exp_since timestamp,
cred_non_exp bool NOT NULL,
email varchar(255),
firstname varchar(255),
last_login timestamp,
last_login_attempt timestamp,
lastname varchar(255),
locale varchar(5) NOT NULL,
login_attempts int NOT NULL,
password varchar(255) NOT NULL,
password_date timestamp,
pwd_link_created timestamp,
pwd_link_hash varchar(255),
phone varchar(255),
timezone varchar(255) NOT NULL,
username varchar(255) NOT NULL
)
;
CREATE TABLE "at_user_clients"
(
user_uuid varchar(40) NOT NULL,
client_uuid varchar(40) NOT NULL,
CONSTRAINT at_user_clients_pkey PRIMARY KEY (user_uuid,client_uuid)
)
;
CREATE TABLE "at_user_group"
(
uuid varchar(40) PRIMARY KEY NOT NULL,
created timestamp NOT NULL,
created_by varchar(255),
modified timestamp,
modified_by varchar(255),
jpaversion int NOT NULL,
active bool NOT NULL,
description varchar(255),
display_name varchar(255),
name varchar(255) NOT NULL
)
;
CREATE TABLE "at_user_usergroups"
(
user_uuid varchar(40) NOT NULL,
usergroup_uuid varchar(40) NOT NULL,
CONSTRAINT at_user_usergroups_pkey PRIMARY KEY (user_uuid,usergroup_uuid)
)
;
CREATE TABLE "at_usergroups_roles"
(
usergroup_uuid varchar(40) NOT NULL,
role_uuid varchar(40) NOT NULL,
CONSTRAINT at_usergroups_roles_pkey PRIMARY KEY (usergroup_uuid,role_uuid)
)
;
CREATE UNIQUE INDEX IDX_AT_CLIENT_NAME ON "at_client"(name)
;
CREATE UNIQUE INDEX IDX_AT_CLIENT_UUID ON "at_client"(uuid)
;
CREATE UNIQUE INDEX IDX_AT_ROLE_UUID ON "at_role"(uuid)
;
CREATE UNIQUE INDEX IDX_AT_ROLE_NAME ON "at_role"(name)
;
CREATE UNIQUE INDEX IDX_AT_USER_USERNAME ON "at_user"(username)
;
CREATE UNIQUE INDEX IDX_AT_USER_UUID ON "at_user"(uuid)
;
ALTER TABLE "at_user_clients"
ADD CONSTRAINT FK_AT_USER_CLIENTS_USER
FOREIGN KEY (user_uuid)
REFERENCES "at_user"(uuid)
;
ALTER TABLE "at_user_clients"
ADD CONSTRAINT FK_AT_USER_CLIENTS_CLIENT
FOREIGN KEY (client_uuid)
REFERENCES "at_client"(uuid)
;
CREATE UNIQUE INDEX IDX_AT_USER_CLIENTS ON "at_user_clients"
(
user_uuid,
client_uuid
)
;
CREATE UNIQUE INDEX IDX_AT_USERGROUP_NAME ON "at_user_group"(name)
;
CREATE UNIQUE INDEX IDX_AT_USERGROUP_UUID ON "at_user_group"(uuid)
;
ALTER TABLE "at_user_usergroups"
ADD CONSTRAINT FK_AT_USER_USERGROUPS_USER
FOREIGN KEY (user_uuid)
REFERENCES "at_user"(uuid)
;
ALTER TABLE "at_user_usergroups"
ADD CONSTRAINT FK_AT_USER_USERGROUPS_UG
FOREIGN KEY (usergroup_uuid)
REFERENCES "at_user_group"(uuid)
;
CREATE UNIQUE INDEX IDX_AT_USER_USERGROUP ON "at_user_usergroups"
(
user_uuid,
usergroup_uuid
)
;
ALTER TABLE "at_usergroups_roles"
ADD CONSTRAINT FK_AT_USERGROUPS_ROLES_ROLE
FOREIGN KEY (role_uuid)
REFERENCES "at_role"(uuid)
;
ALTER TABLE "at_usergroups_roles"
ADD CONSTRAINT FK_AT_USERGROUPS_ROLES_UG
FOREIGN KEY (usergroup_uuid)
REFERENCES "at_user_group"(uuid)
;
CREATE UNIQUE INDEX IDX_AT_USERGROUP_ROLES ON "at_usergroups_roles"
(
usergroup_uuid,
role_uuid
)
;
| true |
e25fef17df3d6e38aa92e886256d0fd0172d8ee0 | SQL | edigonzales-dumpster/agi_mopublic_20190424 | /postscript.sql | UTF-8 | 3,200 | 2.828125 | 3 | [
"MIT"
] | permissive | COMMENT ON SCHEMA
agi_mopublic_pub
IS
'Vereinfachtes Datenmodell der Daten der amtlichen Vermessung. Fragen: stefan.ziegler@bd.so.ch'
;
GRANT USAGE ON SCHEMA agi_mopublic_pub TO public, ogc_server, sogis_service, gretl;
GRANT SELECT ON ALL TABLES IN SCHEMA agi_mopublic_pub TO public, ogc_server, sogis_service;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA agi_mopublic_pub TO gretl;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA agi_mopublic_pub TO gretl;
CREATE INDEX mopublic_bodenbedeckung_art_txt_idx ON agi_mopublic_pub.mopublic_bodenbedeckung USING btree (art_txt);
CREATE INDEX mopublic_bodenbedeckung_bfsnr_idx ON agi_mopublic_pub.mopublic_bodenbedeckung USING btree (bfs_nr);
CREATE INDEX mopublic_einzelobjekt_flaeche_art_txt_idx ON agi_mopublic_pub.mopublic_einzelobjekt_flaeche USING btree (art_txt);
CREATE INDEX mopublic_einzelobjekt_flaeche_bfsnr_idx ON agi_mopublic_pub.mopublic_einzelobjekt_flaeche USING btree (bfs_nr);
CREATE INDEX mopublic_einzelobjekt_linie_art_txt_idx ON agi_mopublic_pub.mopublic_einzelobjekt_linie USING btree (art_txt);
CREATE INDEX mopublic_einzelobjekt_linie_bfsnr_idx ON agi_mopublic_pub.mopublic_einzelobjekt_linie USING btree (bfs_nr);
CREATE INDEX mopublic_einzelobjekt_punkt_art_txt_idx ON agi_mopublic_pub.mopublic_einzelobjekt_punkt USING btree (art_txt);
CREATE INDEX mopublic_einzelobjekt_punkt_bfsnr_idx ON agi_mopublic_pub.mopublic_einzelobjekt_punkt USING btree (bfs_nr);
CREATE INDEX mopublic_mopublic_fixpunkt_typ_txt_idx ON agi_mopublic_pub.mopublic_fixpunkt USING btree (typ_txt);
CREATE INDEX mopublic_mopublic_fixpunkt_punktzeichen_txt_idx ON agi_mopublic_pub.mopublic_fixpunkt USING btree (punktzeichen_txt);
CREATE INDEX mopublic_mopublic_fixpunkt_bfsnr_idx ON agi_mopublic_pub.mopublic_fixpunkt USING btree (bfs_nr);
CREATE INDEX mopublic_mopublic_flurname_bfsnr_idx ON agi_mopublic_pub.mopublic_flurname USING btree (bfs_nr);
CREATE INDEX mopublic_mopublic_gelaendename_bfsnr_idx ON agi_mopublic_pub.mopublic_gelaendename USING btree (bfs_nr);
CREATE INDEX mopublic_mopublic_gebaeudeadresse_bfsnr_idx ON agi_mopublic_pub.mopublic_gebaeudeadresse USING btree (bfs_nr);
CREATE INDEX mopublic_mopublic_gemeindegrenze_bfsnr_idx ON agi_mopublic_pub.mopublic_gemeindegrenze USING btree (bfs_nr);
CREATE INDEX mopublic_mopublic_grenzpunkt_punktzeichen_txt_idx ON agi_mopublic_pub.mopublic_grenzpunkt USING btree (punktzeichen_txt);
CREATE INDEX mopublic_mopublic_grenzpunkt_bfsnr_idx ON agi_mopublic_pub.mopublic_grenzpunkt USING btree (bfs_nr);
CREATE INDEX mopublic_grundstueck_art_txt_idx ON agi_mopublic_pub.mopublic_grundstueck USING btree (art_txt);
CREATE INDEX mopublic_grundstueck_bfsnr_idx ON agi_mopublic_pub.mopublic_grundstueck USING btree (bfs_nr);
CREATE INDEX mopublic_grundstueck_grundbuch_idx ON agi_mopublic_pub.mopublic_grundstueck USING btree (grundbuch);
CREATE INDEX mopublic_grundstueck_gemeinde_idx ON agi_mopublic_pub.mopublic_grundstueck USING btree (gemeinde);
CREATE INDEX mopublic_strassenachse_strassenname_idx ON agi_mopublic_pub.mopublic_strassenachse USING btree (strassenname);
CREATE INDEX mopublic_strassenachse_bfsnr_idx ON agi_mopublic_pub.mopublic_strassenachse USING btree (bfs_nr);
| true |
b898c8bf65555db6b08b3ddcf1315c676d96a9b5 | SQL | furkon/example | /db_example.sql | UTF-8 | 2,468 | 3.109375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 15, 2019 at 05:32 AM
-- Server version: 10.1.36-MariaDB
-- PHP Version: 5.6.38
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `db_example`
--
-- --------------------------------------------------------
--
-- Table structure for table `t_rek`
--
CREATE TABLE `t_rek` (
`id_rek` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`no_rek` int(11) NOT NULL,
`nama_rek` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `t_rek`
--
INSERT INTO `t_rek` (`id_rek`, `id_user`, `no_rek`, `nama_rek`) VALUES
(14, 1, 888, 'rek to example'),
(15, 2, 777, 'rek test');
-- --------------------------------------------------------
--
-- Table structure for table `t_user`
--
CREATE TABLE `t_user` (
`id_user` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(200) NOT NULL,
`nama` varchar(50) NOT NULL,
`alamat` text NOT NULL,
`no_tlp` varchar(13) NOT NULL,
`email` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `t_user`
--
INSERT INTO `t_user` (`id_user`, `username`, `password`, `nama`, `alamat`, `no_tlp`, `email`) VALUES
(1, 'example', '098f6bcd4621d373cade4e832627b4f6', 'namae_example', 'alamat_example', '822344211131', 'example@gmail.com'),
(2, 'test', '098f6bcd4621d373cade4e832627b4f6', 'test_name', 'test_address', '817877978887', 'test@gmail.com');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `t_rek`
--
ALTER TABLE `t_rek`
ADD PRIMARY KEY (`id_rek`);
--
-- Indexes for table `t_user`
--
ALTER TABLE `t_user`
ADD PRIMARY KEY (`id_user`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `t_rek`
--
ALTER TABLE `t_rek`
MODIFY `id_rek` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT for table `t_user`
--
ALTER TABLE `t_user`
MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
a4bd82e99c4c175b150c16d00c162c0310a12549 | SQL | ddc67cd/database-scripts | /to_sort/oracle_apps/GL/gl_code_combinations_query.sql | UTF-8 | 1,253 | 2.859375 | 3 | [] | no_license | SELECT code_combination_id
, chart_of_accounts_id
, account_type
, segment1||'-'||segment2||'-'||segment3||'-'||segment4||'-'||segment5||'-'||segment6 ccid
, case
when to_char(last_update_date,'yyyy')= '2013' then
'Y'
else
'N'
end updated_2013
, gl_flexfields_pkg.get_description_sql
(gccl.chart_of_accounts_id,
1,
gccl.segment1
) seg1_desc
, gl_flexfields_pkg.get_description_sql
(gccl.chart_of_accounts_id,
2,
gccl.segment2
) seg2_desc
, gl_flexfields_pkg.get_description_sql
(gccl.chart_of_accounts_id,
3,
gccl.segment3
) seg3_desc
, gl_flexfields_pkg.get_description_sql
(gccl.chart_of_accounts_id,
4,
gccl.segment4
) seg4_desc
, gl_flexfields_pkg.get_description_sql
(gccl.chart_of_accounts_id,
5,
gccl.segment5
) seg5_desc
, gl_flexfields_pkg.get_description_sql
(gccl.chart_of_accounts_id,
6,
gccl.segment6
) seg6_desc
FROM gl_code_combinations gccl; | true |
a5ff63abbda494ab36153bdbabc4b4a11dbbc68e | SQL | shevchu/sql | /drivers.sql | UTF-8 | 260 | 4.1875 | 4 | [] | no_license | SELECT driver.last_name, COUNT(car.brand)
FROM driver
JOIN car_driver ON driver.id = car_driver.driver_id
JOIN car ON car.id = car_driver.car_id
WHERE YEAR(driver.birth_date) >= 1995
AND car.brand LIKE 'Honda'
GROUP BY car.brand
HAVING COUNT(car.brand) >= 2; | true |
c5938acd18655ffd44cb38053060523403ce6308 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/high/day21/select0008.sql | UTF-8 | 178 | 2.59375 | 3 | [] | no_license |
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-20T00:08:00Z' AND timestamp<'2017-11-21T00:08:00Z' AND temperature>=18 AND temperature<=80
| true |
7f3bd28e417948f88a84747480dcea88a2ed268a | SQL | Tair111/gastronomy | /gastronomy.sql | UTF-8 | 5,475 | 3.15625 | 3 | [
"BSD-3-Clause"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Хост: 127.0.0.1
-- Время создания: Апр 04 2017 г., 18:28
-- Версия сервера: 10.1.21-MariaDB
-- Версия PHP: 7.1.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- База данных: `gastronomy`
--
CREATE DATABASE IF NOT EXISTS `gastronomy` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `gastronomy`;
-- --------------------------------------------------------
--
-- Структура таблицы `dish`
--
CREATE TABLE `dish` (
`id` int(11) NOT NULL,
`name` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `dish`
--
INSERT INTO `dish` (`id`, `name`) VALUES
(1, 'Olivie'),
(2, 'Soup'),
(3, 'Salad'),
(4, 'Compote'),
(5, 'Soup2'),
(6, 'Autogenerated dish #0'),
(7, 'Autogenerated dish #1'),
(8, 'Autogenerated dish #2'),
(9, 'Autogenerated dish #3'),
(10, 'Autogenerated dish #4'),
(11, 'Autogenerated dish #5'),
(12, 'Autogenerated dish #6'),
(13, 'Autogenerated dish #7'),
(14, 'Autogenerated dish #8'),
(15, 'Autogenerated dish #9'),
(16, 'Autogenerated dish #10'),
(17, 'Autogenerated dish #11'),
(18, 'Autogenerated dish #12'),
(19, 'Autogenerated dish #13'),
(20, 'Autogenerated dish #14'),
(21, 'Autogenerated dish #15'),
(22, 'Autogenerated dish #16'),
(23, 'Autogenerated dish #17'),
(24, 'Autogenerated dish #18'),
(25, 'Autogenerated dish #19');
-- --------------------------------------------------------
--
-- Структура таблицы `dishingredientlink`
--
CREATE TABLE `dishingredientlink` (
`id` int(11) NOT NULL,
`dish_id` int(11) NOT NULL,
`ingredient_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `dishingredientlink`
--
INSERT INTO `dishingredientlink` (`id`, `dish_id`, `ingredient_id`) VALUES
(18, 1, 4),
(19, 1, 5),
(20, 1, 8),
(21, 1, 9),
(22, 1, 12),
(23, 1, 13),
(24, 1, 16),
(25, 3, 1),
(26, 3, 8),
(27, 3, 12),
(28, 2, 2),
(29, 2, 3),
(30, 2, 14),
(31, 2, 15),
(41, 4, 6),
(42, 4, 7),
(43, 4, 14),
(44, 5, 2),
(45, 5, 3),
(46, 5, 5),
(47, 5, 14),
(48, 6, 1),
(49, 6, 16),
(50, 7, 13),
(51, 7, 16),
(52, 8, 2),
(53, 8, 13),
(54, 9, 4),
(55, 9, 16),
(56, 9, 14),
(57, 10, 13),
(58, 11, 2),
(59, 11, 15),
(60, 11, 7),
(61, 11, 3),
(62, 12, 13),
(63, 12, 10),
(64, 12, 3),
(65, 13, 3),
(66, 13, 3),
(67, 13, 14),
(68, 14, 1),
(69, 14, 4),
(70, 14, 13),
(71, 14, 5),
(72, 15, 6),
(73, 15, 2),
(74, 15, 12),
(75, 16, 11),
(76, 16, 2),
(77, 17, 1),
(78, 17, 10),
(79, 17, 6),
(80, 18, 1),
(81, 19, 3),
(82, 19, 13),
(83, 19, 3),
(84, 19, 12),
(85, 20, 7),
(86, 20, 8),
(87, 20, 9),
(88, 20, 3),
(89, 21, 12),
(90, 21, 9),
(91, 22, 8),
(92, 22, 15),
(93, 22, 11),
(94, 23, 9),
(95, 24, 7),
(96, 24, 13),
(97, 24, 14),
(98, 25, 10),
(99, 25, 13);
-- --------------------------------------------------------
--
-- Структура таблицы `ingredient`
--
CREATE TABLE `ingredient` (
`id` int(11) NOT NULL,
`name` text NOT NULL,
`is_hidden` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `ingredient`
--
INSERT INTO `ingredient` (`id`, `name`, `is_hidden`) VALUES
(1, 'tomato', 1),
(2, 'cabbage', 0),
(3, 'potato', 0),
(4, 'onion', 0),
(5, 'carrot', 0),
(6, 'apple', 0),
(7, 'berries', 0),
(8, 'cucumber', 0),
(9, 'peas', 0),
(10, 'corn', 0),
(11, 'rice', 0),
(12, 'mayonnaise', 0),
(13, 'sausage', 0),
(14, 'water', 0),
(15, 'meat', 0),
(16, 'egg', 0);
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `dish`
--
ALTER TABLE `dish`
ADD PRIMARY KEY (`id`);
--
-- Индексы таблицы `dishingredientlink`
--
ALTER TABLE `dishingredientlink`
ADD PRIMARY KEY (`id`),
ADD KEY `dish_id` (`dish_id`),
ADD KEY `ingredient_id` (`ingredient_id`);
--
-- Индексы таблицы `ingredient`
--
ALTER TABLE `ingredient`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `id` (`id`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `dish`
--
ALTER TABLE `dish`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;
--
-- AUTO_INCREMENT для таблицы `dishingredientlink`
--
ALTER TABLE `dishingredientlink`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=100;
--
-- AUTO_INCREMENT для таблицы `ingredient`
--
ALTER TABLE `ingredient`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
--
-- Ограничения внешнего ключа сохраненных таблиц
--
--
-- Ограничения внешнего ключа таблицы `dishingredientlink`
--
ALTER TABLE `dishingredientlink`
ADD CONSTRAINT `dishingredientlink_ibfk_1` FOREIGN KEY (`dish_id`) REFERENCES `dish` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `dishingredientlink_ibfk_2` FOREIGN KEY (`ingredient_id`) REFERENCES `ingredient` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
52648097da33bd93158ac7fd23c923cf0cb23a9b | SQL | EvgeniyKevbrin/otus | /HW_8/HW8_2.sql | UTF-8 | 961 | 3.375 | 3 | [] | no_license | /*
2. Для всех клиентов с именем, в котором есть Tailspin Toys
вывести все адреса, которые есть в таблице, в одной колонке
Пример результатов
CustomerName AddressLine
Tailspin Toys (Head Office) Shop 38
Tailspin Toys (Head Office) 1877 Mittal Road
Tailspin Toys (Head Office) PO Box 8975
Tailspin Toys (Head Office) Ribeiroville
*/
SELECT CustomerName
,CustomerAddress
,AddressInfo
FROM (
SELECT CustomerName
,DeliveryAddressLine1
,DeliveryAddressLine2
,PostalAddressLine1
,PostalAddressLine2
FROM [Sales].[Customers] c
INNER JOIN [Sales].[Invoices] i ON i.CustomerID = c.CustomerID
WHERE CustomerName LIKE 'Tailspin Toys%') a
UNPIVOT(
CustomerAddress FOR AddressInfo IN ( DeliveryAddressLine1
,DeliveryAddressLine2
,PostalAddressLine1
,PostalAddressLine2)
)upv
| true |
281d3c9f8129bb58b43ded3768a9f0a5c2bde930 | SQL | mswertz/molgenis-maven-experimental | /molgenis-auth/src/main/generated-sources/count_per_table.sql | UTF-8 | 1,104 | 2.59375 | 3 | [] | no_license | SELECT 'MolgenisRole' AS entity, count(*) AS count FROM molgenisRole
UNION
SELECT 'MolgenisGroup' AS entity, count(*) AS count FROM molgenisGroup
UNION
SELECT 'MolgenisRoleGroupLink' AS entity, count(*) AS count FROM molgenisRoleGroupLink
UNION
SELECT 'Person' AS entity, count(*) AS count FROM person
UNION
SELECT 'Institute' AS entity, count(*) AS count FROM institute
UNION
SELECT 'MolgenisUser' AS entity, count(*) AS count FROM molgenisUser
UNION
SELECT 'MolgenisPermission' AS entity, count(*) AS count FROM molgenisPermission
UNION
SELECT 'OntologyTerm' AS entity, count(*) AS count FROM ontologyTerm
UNION
SELECT 'Ontology' AS entity, count(*) AS count FROM ontology
UNION
SELECT 'MolgenisFile' AS entity, count(*) AS count FROM molgenisFile
UNION
SELECT 'RuntimeProperty' AS entity, count(*) AS count FROM runtimeProperty
UNION
SELECT 'Publication' AS entity, count(*) AS count FROM publication
UNION
SELECT 'UseCase' AS entity, count(*) AS count FROM useCase
UNION
SELECT 'MolgenisEntity' AS entity, count(*) AS count FROM molgenisEntity
; | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.