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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
35783257fd8d327b7c3348b5fc2ce009385c8dfb | SQL | bradeac/dockerized-web-app | /src/structure sql/structure.sql | UTF-8 | 713 | 2.703125 | 3 | [] | no_license | CREATE DATABASE PROIECT_CAMIL;
CREATE TABLE ANGAJATI
(
ID INT PRIMARY KEY auto_increment,
NUME VARCHAR(64),
PRENUME VARCHAR(64),
FUNCTIE VARCHAR(64),
SALAR_NEGOCIAT INT,
SALAR_REALIZAT INT,
VECHIME INT,
SPOR INT,
PREMII_BRUTE INT,
COMPENSATIE INT,
TOTAL_BRUT INT,
BRUT_IMPOZABIL INT,
IMPOZIT INT,
CAS INT,
SOMAJ INT,
SANATATE INT,
AVANS INT,
RETINERI INT,
REST_PLATA INT
)
CREATE TABLE PROCENTE
(
ID INT PRIMARY KEY auto_increment,
CAS DECIMAL(5,2),
SANATATE DECIMAL(5,2),
SOMAJ DECIMAL(5,2),
IMPOZIT DECIMAL(5,2),
PAROLA VARCHAR(64)
)
INSERT INTO PROCENTE
(
CAS,
SANATATE,
SOMAJ,
IMPOZIT,
PAROLA
)
VALUES
(
0.105,
0.055,
0.005,
0.16,
'39d7ddbfb15a980fffe7d7f15617a988'
) | true |
5dd067febd372d641ac6f9f08731937837523b1a | SQL | mirunachindea/Databases | /ASSIGNMENT3/Queries/query1.sql | UTF-8 | 350 | 3.78125 | 4 | [] | no_license | select lines.name, lines.type, route.direction, route.start, route.stop, neighborhood.name
from ( assignment3.lines join route on lines.name = route.bus) join neighborhood on lines.name = neighborhood.busline
where neighborhood.name = 'Center'
group by lines.name, route.direction, route.start, route.stop, neighborhood.name
order by lines.name desc; | true |
1b15aebff644f235ad249278a0aa0d0a07b7d932 | SQL | bellmit/origin | /family_order/sql/TF_F_USER_DISCNT/INS_ALL_NOUSER.sql | UTF-8 | 520 | 2.515625 | 3 | [] | no_license | INSERT INTO tf_f_user_discnt(partition_id,user_id,user_id_a,product_id,relation_type_code,inst_id,package_id,discnt_code,spec_tag,start_date,end_date,update_time,update_staff_id,update_depart_id)
SELECT MOD(a.user_id, 10000),a.user_id,user_id_a,product_id,relation_type_code,inst_id,package_id,discnt_code,spec_tag,start_date,end_date,sysdate,update_staff_id,update_depart_id
FROM tf_b_trade_discnt a
WHERE trade_id = TO_NUMBER(:TRADE_ID)
AND accept_month = TO_NUMBER(SUBSTR(:TRADE_ID,5,2))
AND modify_tag = '0' | true |
0633fda8e46e57445767d4db3f1a06d9ede984e2 | SQL | equipe-tetris/ConsultCAR | /Scripts/Views_API.sql | UTF-8 | 10,694 | 2.734375 | 3 | [] | no_license | -- VIEWS
-- Tabela com todos os municípios inseridos até o momento no banco de dados.
CREATE VIEW municipios_cadastrados AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de SAO PAULO cadastrados
CREATE VIEW sao_paulo AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'SP'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado do ACRE cadastrados
CREATE VIEW acre AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'AC'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de RONDONIA cadastrados
CREATE VIEW rondonia AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'RO'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de AMAZONAS cadastrados
CREATE VIEW amazonas AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'AM'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de RORAIMA cadastrados
CREATE VIEW roraima AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'RR'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado do PARÁ cadastrados
CREATE VIEW para AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'PA'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de AMAPÁ cadastrados
CREATE VIEW amapa AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'AP'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de TOCANTINS cadastrados
CREATE VIEW tocantins AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'TO'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado do MARANHÃO cadastrados
CREATE VIEW maranhao AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'MA'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de PIAUÍ cadastrados
CREATE VIEW piaui AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'PI'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de CEARÁ cadastrados
CREATE VIEW ceara AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'CE'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de RIO GRANDE DO NORTE cadastrados
CREATE VIEW rio_grande_do_norte AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'RN'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado do PARAÍBA cadastrados
CREATE VIEW paraiba AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'PB'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de PERNAMBUCO cadastrados
CREATE VIEW pernambuco AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'PE'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de ALAGOAS cadastrados
CREATE VIEW alagoas AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'AL'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de SERGIPE cadastrados
CREATE VIEW sergipe AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'SE'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado da BAHIA cadastrados
CREATE VIEW bahia AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'BA'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de MINAS GERIAS cadastrados
CREATE VIEW minas_gerais AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'MG'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado do ESPÍRTO SANTO cadastrados
CREATE VIEW espirito_santo AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'ES'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado do PARANÁ cadastrados
CREATE VIEW parana AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'PR'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de SANTA CATARINA cadastrados
CREATE VIEW santa_catarina AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'SC'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de RIO GRANDE DO SUL cadastrados
CREATE VIEW rio_grande_do_sul AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'RS'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de MATO GROSSO DO SUL cadastrados
CREATE VIEW mato_grosso_do_sul AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'MS'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de MATO GROSSO cadastrados
CREATE VIEW mato_grosso AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'MT'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de GOIAS cadastrados
CREATE VIEW goias AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'GO'
ORDER BY nom_munici;
-- Tabela com todos os municípios do Estado de DISTRITO FEDERAL cadastrados
CREATE VIEW distrito_federal AS
SELECT
cod_imovel AS codigo_imovel,
num_area AS area,
cod_estado AS estado,
nom_munici AS municipio,
num_modulo AS modulo,
tipo_imove AS tipo_imovel,
situacao,
condicao_i AS condicao,
geom AS poligono
FROM municipios_br
WHERE cod_estado = 'DF'
ORDER BY nom_munici;
| true |
1ea2f61c6e1857b396a8674666a2421c2be6ff84 | SQL | SugihartonoTri24/MTAL2018 | /mahasiswa.sql | UTF-8 | 2,405 | 2.984375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.5.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 04, 2018 at 05:18 AM
-- Server version: 5.5.25a
-- PHP Version: 5.4.4
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 utf8 */;
--
-- Database: `mahasiswa`
--
-- --------------------------------------------------------
--
-- Table structure for table `biodata`
--
CREATE TABLE IF NOT EXISTS `biodata` (
`nim` varchar(14) NOT NULL,
`nama` varchar(50) NOT NULL,
`prodi` varchar(25) NOT NULL,
PRIMARY KEY (`nim`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `biodata`
--
INSERT INTO `biodata` (`nim`, `nama`, `prodi`) VALUES
('09112000', 'setiawan', 'manajemen informatika'),
('0911500077', 'HUSNAN', 'TEKNIK INFORMATIKA'),
('1111500054', 'Salsabila', 'Teknik Informatika'),
('1111500065', 'Tri Sugihartono', 'Teknik Informatika'),
('1111500069', 'husnan', 'teknik informatika'),
('1111500078', 'Alex', 'Sistem Informasi'),
('11546900', 'salsa', 'sistem informasi'),
('1522500084', 'regi asvika', 'sistem informasi'),
('194480943', 'rizky', 'teknik informatika'),
('458679', 'bila', 'Manajemen Informatika'),
('7879799', 'dddg', 'kjljlkl'),
('845989854', 'novi', 'kskek'),
('893893894', 'kemi', 'dalil'),
('934083', 'rendi', 'teknik informatika'),
('942049', 'tomi', 'teknik informatika'),
('9854898534', 'yohanes', 'gfdfsgf'),
('9897979', 'dian', 'sjhfvjshfd'),
('9899', 'jhnkn', 'bjhjb');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_user`
--
CREATE TABLE IF NOT EXISTS `tbl_user` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`username` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL,
`keterangan` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `tbl_user`
--
INSERT INTO `tbl_user` (`id`, `username`, `password`, `keterangan`) VALUES
(1, 'admin', 'admin', 'admin');
/*!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 |
9f5b89b84723c5e587d5f798f9cd30ec4f873e74 | SQL | MarceloSilvarolla/YFM-Database-and-Fusion-Guide | /Query database and create temporary tables/createCardsThatBeat.sql | UTF-8 | 508 | 3.578125 | 4 | [] | no_license | DROP TABLE IF EXISTS CardsThatBeat;
CREATE TEMPORARY TABLE CardsThatBeat AS
SELECT C1.CardName, C1.GuardianStar1, C1.GuardianStar2, C1.CardType, C1.CardSecTypes, C1.Attack, C1.Defense
FROM Cards AS C1
JOIN Cards AS C2
WHERE C2.CardName = 'Twin-headed Thunder Dragon' AND (
MAX(C1.Attack, C1.Defense) >= C2.Attack OR (
( (C1.GuardianStar1, C2.GuardianStar1) IN GSBeats OR (C1.GuardianStar2, C2.GuardianStar1) IN GSBeats) AND
MAX(C1.Attack, C1.Defense) >= C2.Attack - 500
)
); | true |
aa424fb3a09a5550f321e66c9010fd6fcce99e0e | SQL | h3kker/tearDrop | /db/master_schema.sql | UTF-8 | 3,703 | 3.34375 | 3 | [
"Artistic-2.0"
] | permissive | DROP TABLE IF EXISTS projects CASCADE;
CREATE TABLE projects (
name text primary key,
title text not null unique,
description text,
forskalle_group text not null,
status text
);
DROP TABLE IF EXISTS db_sources CASCADE;
CREATE TABLE db_sources (
id serial primary key,
name text not null unique,
description text not null unique,
dbtype text,
url text,
version text,
downloaded timestamp,
path text
);
INSERT INTO db_sources (name, description, dbtype, url, version, downloaded, path) VALUES
('refset_fungi', 'RefSeq Fungi', 'blastp', 'ftp://ftp.ncbi.nlm.nih.gov/refseq/release/fungi', '67', '2014-10-01', '/groups/csf-ngs/data/blast/refseq_fungi.fasta'),
('refset_plant', 'RefSeq Plant', 'blastp', 'ftp://ftp.ncbi.nlm.nih.gov/refseq/release/fungi', '67', '2014-10-01', '/groups/csf-ngs/data/blast/refseq_plant.fasta'),
('brachy_cyc', 'BrachyCyc', 'blastp', 'ftp://ftp.plantcyc.org/Pathways/BLAST_sets/brachypodiumcyc_enzymes.fasta', 'unknown', '2014-10-23', '/groups/csf-ngs/data/blast/brachypodiumcyc_enzymes.fasta'),
('plant_cyc', 'PlantCyc', 'blastp', 'ftp://ftp.plantcyc.org/Pathways/BLAST_sets/reference_enzymes.3.0.fasta', '3.0', '2014-10-23', '/groups/csf-ngs/data/blast/plantcyc_enzymes.fasta'),
('tair10_prot', 'TAIR10 Proteins', 'blastp', 'ftp://ftp.arabidopsis.org/home/tair/Sequences/blast_datasets/TAIR10_blastsets/TAIR10_pep_20101214_updated', '20101214', '2014-10-23', '/groups/csf-ngs/data/blast/TAIR10_pep_20101214_updated.fasta'),
('ncbi_cdd', 'NCBI Conserved Domain Database', 'rpsblast', 'ftp://ftp.ncbi.nih.gov/pub/mmdb/cdd/cdd.tar.gz', '3.12', '2014-10-24', '/groups/csf-ngs/data/blast/cdd/Cdd')
;
DROP TABLE IF EXISTS workqueue CASCADE;
CREATE TABLE workqueue (
id serial primary key,
project text not null references projects(name),
pid integer,
submit_date timestamp default current_timestamp,
start_date timestamp,
stop_date timestamp,
status text not null default 'queued',
batch boolean default false,
errmsg text,
class text not null,
task_object text not null
);
DROP TABLE IF EXISTS organisms CASCADE;
CREATE TABLE organisms (
name text primary key,
scientific_name text not null,
genome_version text not null,
genome_path text
);
DROP TABLE IF EXISTS gene_models CASCADE;
CREATE TABLE gene_models (
id serial primary key,
organism text references organisms(name),
name text not null unique,
description text,
sha1 text,
imported boolean default false,
path text NOT NULL
);
DROP TABLE IF EXISTS tags CASCADE;
CREATE TABLE tags (
tag text primary key,
category text not null default 'general',
level text not null default 'info'
);
INSERT INTO tags (tag, category, level) VALUES
('bad assembly', 'general', 'danger'),
('good assembly', 'general', 'success'),
('interesting', 'general', 'success'),
('possible chimera', 'general', 'danger'),
('possible fusion', 'general', 'danger'),
('short', 'general', 'warning'),
('good coverage', 'coverage', 'success'),
('low overall', 'coverage', 'warning'),
('low 5p', 'coverage', 'warning'),
('low 3p', 'coverage', 'warning'),
('dip', 'coverage', 'warning'),
('multiple dips', 'coverage', 'warning'),
('uneven', 'coverage', 'warning'),
('very uneven', 'coverage', 'warning'),
('many errors', 'coverage', 'warning'),
('good homologs', 'homology', 'success'),
('bad homolog support', 'homology', 'warning'),
('no annotations', 'homology', 'warning'),
('no homologs', 'homology', 'danger'),
('maybe intron', 'mapping', 'warning'),
('unmapped', 'mapping', 'danger'),
('lots of mappings', 'mapping', 'warning'),
('many orthologs', 'mapping', 'info'),
('bad mapping', 'mapping', 'danger')
;
| true |
574304b6ed164a9743c61f2a9b8ca6199d9b3cc0 | SQL | M4th3m4tic4l/wow-emulator-archive | /WoWD - 03.2006/wowd-sql/accounts.sql | UTF-8 | 926 | 2.71875 | 3 | [] | no_license | SET FOREIGN_KEY_CHECKS=0;
#----------------------------
# Table structure for accounts
#----------------------------
CREATE TABLE `accounts` (
`acct` bigint(20) NOT NULL auto_increment,
`login` varchar(255) NOT NULL default '',
`password` varchar(28) NOT NULL default '',
`s` longtext NOT NULL,
`v` longtext NOT NULL,
`gm` tinyint(1) NOT NULL default '0',
`sessionkey` longtext NOT NULL,
`email` varchar(50) NOT NULL default '',
`joindate` timestamp(14) NOT NULL,
`banned` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`acct`),
UNIQUE KEY `acct` (`acct`)
) TYPE=MyISAM COMMENT='InnoDB free: 11264 kB; InnoDB free: 18432 kB';
#----------------------------
# Records for table accounts
#----------------------------
insert into accounts values
(1, 'WOWD', 'WOWD', '', '', 4, '40DD52ACED674EE6155B750D21ABE2FA9DD6D3D257702C40E470D279A21D04E7D1FE75498A644B95', '', '20050727071223', 0);
| true |
47a27a2939c80ae14ca005739ceca4c553beea30 | SQL | shurun19851206/framework | /jtademo/src/sql/init.sql | UTF-8 | 538 | 2.609375 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS `jta1` DEFAULT CHARACTER SET utf8;
CREATE DATABASE IF NOT EXISTS `jta2` DEFAULT CHARACTER SET utf8;
use jta1;
DROP TABLE IF EXISTS `jtatest`;
CREATE TABLE `jtatest` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
use jta2;
DROP TABLE IF EXISTS `jtatest`;
CREATE TABLE `jtatest` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | true |
3927e35bba976eb092009c91ba6a3ad6c1409906 | SQL | daniloef/strangemetrics | /app/database/schema.sql | UTF-8 | 5,294 | 2.984375 | 3 | [] | no_license | # ************************************************************
# Sequel Pro SQL dump
# Version 4499
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 127.0.0.1 (MySQL 5.5.46-0ubuntu0.14.04.2)
# Database: strangemetricsorg
# Generation Time: 2017-05-14 22:43:52 +0000
# ************************************************************
/*!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 */;
/*!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 */;
# Dump of table accounts
# ------------------------------------------------------------
CREATE TABLE `accounts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`created` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table analysis
# ------------------------------------------------------------
CREATE TABLE `analysis` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL,
`tracking_platform_settings_id` int(11) NOT NULL,
`name` varchar(100) DEFAULT NULL,
`created` datetime NOT NULL,
`updated` datetime DEFAULT NULL,
`last_run` datetime DEFAULT NULL,
`run_every_hours` int(4) DEFAULT NULL,
`status` enum('on','off') NOT NULL DEFAULT 'on',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table cases
# ------------------------------------------------------------
CREATE TABLE `cases` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL,
`tracking_platform_advertiser_id` int(11) DEFAULT NULL,
`tracking_platform_offer_id` int(11) DEFAULT NULL,
`tracking_platform_source_id` int(11) DEFAULT NULL,
`analysis_id` int(11) NOT NULL,
`status` enum('open','settled') NOT NULL DEFAULT 'open',
`offer_lifetime_data_at` datetime DEFAULT NULL,
`offer_impressions` int(11) DEFAULT NULL,
`offer_clicks` int(11) DEFAULT NULL,
`offer_conversions` int(11) DEFAULT NULL,
`offer_revenue` int(11) DEFAULT NULL,
`offer_cost` int(11) DEFAULT NULL,
`case_impressions` int(11) DEFAULT NULL,
`case_clicks` int(11) DEFAULT NULL,
`case_conversions` int(11) DEFAULT NULL,
`case_revenue` float DEFAULT NULL,
`case_cost` float DEFAULT NULL,
`settled_date` date DEFAULT NULL,
`settled_impressions` int(11) DEFAULT NULL,
`settled_clicks` int(11) DEFAULT NULL,
`settled_conversions` int(11) DEFAULT NULL,
`settled_revenue` float DEFAULT NULL,
`settled_cost` float DEFAULT NULL,
`synced_conversions` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table settings
# ------------------------------------------------------------
CREATE TABLE `settings` (
`account_id` int(11) NOT NULL,
`object` varchar(100) NOT NULL DEFAULT '',
`entity_id` varchar(100) NOT NULL DEFAULT '',
`key` varchar(100) NOT NULL DEFAULT '',
`value` text,
PRIMARY KEY (`account_id`,`object`,`entity_id`,`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table static_reports
# ------------------------------------------------------------
CREATE TABLE `static_reports` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL,
`analysis_id` int(11) NOT NULL,
`data_path` varchar(255) NOT NULL DEFAULT '',
`analysis_settings_path` varchar(255) DEFAULT NULL,
`analysed` datetime DEFAULT NULL,
`has_flags` tinyint(1) DEFAULT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table tracking_platforms
# ------------------------------------------------------------
CREATE TABLE `tracking_platforms` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL,
`platform` enum('hasoffers','affise','cake') NOT NULL DEFAULT 'hasoffers',
`name` varchar(100) NOT NULL DEFAULT '',
`status` enum('on','off') NOT NULL DEFAULT 'on',
`created` datetime NOT NULL,
`updated` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table users
# ------------------------------------------------------------
CREATE TABLE `users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) NOT NULL,
`email` varchar(255) NOT NULL DEFAULT '',
`password` varchar(255) NOT NULL DEFAULT '',
`created` datetime NOT NULL,
`modified` datetime DEFAULT NULL,
`status` enum('on','off') NOT NULL DEFAULT 'on',
`is_account_owner` tinyint(1) DEFAULT NULL,
`email_is_verified` tinyint(1) DEFAULT NULL,
`last_login` datetime DEFAULT NULL,
`last_login_ip` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_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 */;
| true |
6426a5da43fff207a051b59d24230a1d29d87880 | SQL | escalantegc/mupumchoto | /sql/mupum.sql | UTF-8 | 44,481 | 2.828125 | 3 | [] | no_license | --
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.12
-- Dumped by pg_dump version 9.5.12
-- Started on 2018-05-28 20:27:53 -03
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- TOC entry 1 (class 3079 OID 12435)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 2429 (class 0 OID 0)
-- Dependencies: 1
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 217 (class 1259 OID 60360)
-- Name: afiliacion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.afiliacion (
idafiliacion integer NOT NULL,
idpersona integer NOT NULL,
idtipo_socio integer NOT NULL,
idestado integer NOT NULL,
fecha_solicitud date,
fecha_alta date,
fecha_baja date,
activa boolean DEFAULT false NOT NULL
);
ALTER TABLE public.afiliacion OWNER TO postgres;
--
-- TOC entry 216 (class 1259 OID 60358)
-- Name: afiliacion_idafiliacion_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.afiliacion_idafiliacion_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.afiliacion_idafiliacion_seq OWNER TO postgres;
--
-- TOC entry 2430 (class 0 OID 0)
-- Dependencies: 216
-- Name: afiliacion_idafiliacion_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.afiliacion_idafiliacion_seq OWNED BY public.afiliacion.idafiliacion;
--
-- TOC entry 213 (class 1259 OID 60344)
-- Name: bolsita_escolar; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.bolsita_escolar (
idpersona integer NOT NULL,
idpersona_familia integer NOT NULL,
idparentesco integer NOT NULL,
idnivel_estudio integer NOT NULL,
anio character varying NOT NULL,
idestado integer NOT NULL
);
ALTER TABLE public.bolsita_escolar OWNER TO postgres;
--
-- TOC entry 199 (class 1259 OID 60279)
-- Name: categoria; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.categoria (
idcategoria integer NOT NULL,
descripcion character varying(100) NOT NULL,
monto_permitido double precision NOT NULL
);
ALTER TABLE public.categoria OWNER TO postgres;
--
-- TOC entry 182 (class 1259 OID 60209)
-- Name: categoria_estado; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.categoria_estado (
idcategoria_estado integer NOT NULL,
descripcion character varying(50) NOT NULL
);
ALTER TABLE public.categoria_estado OWNER TO postgres;
--
-- TOC entry 181 (class 1259 OID 60207)
-- Name: categoria_estado_idcategoria_estado_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.categoria_estado_idcategoria_estado_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.categoria_estado_idcategoria_estado_seq OWNER TO postgres;
--
-- TOC entry 2431 (class 0 OID 0)
-- Dependencies: 181
-- Name: categoria_estado_idcategoria_estado_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.categoria_estado_idcategoria_estado_seq OWNED BY public.categoria_estado.idcategoria_estado;
--
-- TOC entry 198 (class 1259 OID 60277)
-- Name: categoria_idcategoria_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.categoria_idcategoria_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.categoria_idcategoria_seq OWNER TO postgres;
--
-- TOC entry 2432 (class 0 OID 0)
-- Dependencies: 198
-- Name: categoria_idcategoria_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.categoria_idcategoria_seq OWNED BY public.categoria.idcategoria;
--
-- TOC entry 186 (class 1259 OID 60226)
-- Name: categoria_motivo; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.categoria_motivo (
idcategoria_motivo integer NOT NULL,
descripcion character varying(50) NOT NULL
);
ALTER TABLE public.categoria_motivo OWNER TO postgres;
--
-- TOC entry 185 (class 1259 OID 60224)
-- Name: categoria_motivo_idcategoria_motivo_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.categoria_motivo_idcategoria_motivo_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.categoria_motivo_idcategoria_motivo_seq OWNER TO postgres;
--
-- TOC entry 2433 (class 0 OID 0)
-- Dependencies: 185
-- Name: categoria_motivo_idcategoria_motivo_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.categoria_motivo_idcategoria_motivo_seq OWNED BY public.categoria_motivo.idcategoria_motivo;
--
-- TOC entry 203 (class 1259 OID 60295)
-- Name: comercio; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.comercio (
idcomercio integer NOT NULL,
nombre character varying(100) NOT NULL,
direccion character varying(100) NOT NULL,
idlocalidad integer NOT NULL
);
ALTER TABLE public.comercio OWNER TO postgres;
--
-- TOC entry 202 (class 1259 OID 60293)
-- Name: comercio_idcomercio_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.comercio_idcomercio_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.comercio_idcomercio_seq OWNER TO postgres;
--
-- TOC entry 2434 (class 0 OID 0)
-- Dependencies: 202
-- Name: comercio_idcomercio_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.comercio_idcomercio_seq OWNED BY public.comercio.idcomercio;
--
-- TOC entry 184 (class 1259 OID 60221)
-- Name: configuracion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.configuracion (
edad_maxima_bolsita_escolar integer NOT NULL,
dias_confirmacion_reserva integer NOT NULL
);
ALTER TABLE public.configuracion OWNER TO postgres;
--
-- TOC entry 204 (class 1259 OID 60301)
-- Name: convenio; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.convenio (
idcategoria integer NOT NULL,
idcomercio integer NOT NULL,
monto_permitido double precision NOT NULL,
fecha_alta date NOT NULL,
fecha_baja date
);
ALTER TABLE public.convenio OWNER TO postgres;
--
-- TOC entry 194 (class 1259 OID 60258)
-- Name: estado; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.estado (
idestado integer NOT NULL,
descripcion character varying(50) NOT NULL,
idcategoria_estado integer NOT NULL
);
ALTER TABLE public.estado OWNER TO postgres;
--
-- TOC entry 219 (class 1259 OID 70034)
-- Name: estado_civil; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.estado_civil (
idestado_civil integer NOT NULL,
descripcion character varying(50) NOT NULL
);
ALTER TABLE public.estado_civil OWNER TO postgres;
--
-- TOC entry 218 (class 1259 OID 70032)
-- Name: estado_civil_idestado_civil_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.estado_civil_idestado_civil_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.estado_civil_idestado_civil_seq OWNER TO postgres;
--
-- TOC entry 2435 (class 0 OID 0)
-- Dependencies: 218
-- Name: estado_civil_idestado_civil_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.estado_civil_idestado_civil_seq OWNED BY public.estado_civil.idestado_civil;
--
-- TOC entry 193 (class 1259 OID 60256)
-- Name: estado_idestado_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.estado_idestado_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.estado_idestado_seq OWNER TO postgres;
--
-- TOC entry 2436 (class 0 OID 0)
-- Dependencies: 193
-- Name: estado_idestado_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.estado_idestado_seq OWNED BY public.estado.idestado;
--
-- TOC entry 212 (class 1259 OID 60339)
-- Name: familia; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.familia (
idpersona integer NOT NULL,
idpersona_familia integer NOT NULL,
idparentesco integer NOT NULL,
fecha_relacion date NOT NULL
);
ALTER TABLE public.familia OWNER TO postgres;
--
-- TOC entry 196 (class 1259 OID 60266)
-- Name: instalacion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.instalacion (
idinstalacion integer NOT NULL,
nombre character varying(50) NOT NULL,
cantidad_maxima_personas integer NOT NULL
);
ALTER TABLE public.instalacion OWNER TO postgres;
--
-- TOC entry 195 (class 1259 OID 60264)
-- Name: instalacion_idinstalacion_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.instalacion_idinstalacion_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.instalacion_idinstalacion_seq OWNER TO postgres;
--
-- TOC entry 2437 (class 0 OID 0)
-- Dependencies: 195
-- Name: instalacion_idinstalacion_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.instalacion_idinstalacion_seq OWNED BY public.instalacion.idinstalacion;
--
-- TOC entry 201 (class 1259 OID 60287)
-- Name: localidad; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.localidad (
idlocalidad integer NOT NULL,
idprovincia integer NOT NULL,
descripcion character varying(100) NOT NULL
);
ALTER TABLE public.localidad OWNER TO postgres;
--
-- TOC entry 200 (class 1259 OID 60285)
-- Name: localidad_idlocalidad_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.localidad_idlocalidad_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.localidad_idlocalidad_seq OWNER TO postgres;
--
-- TOC entry 2438 (class 0 OID 0)
-- Dependencies: 200
-- Name: localidad_idlocalidad_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.localidad_idlocalidad_seq OWNED BY public.localidad.idlocalidad;
--
-- TOC entry 188 (class 1259 OID 60234)
-- Name: motivo; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.motivo (
idmotivo integer NOT NULL,
idcategoria_motivo integer NOT NULL,
descripcion character varying(50) NOT NULL
);
ALTER TABLE public.motivo OWNER TO postgres;
--
-- TOC entry 187 (class 1259 OID 60232)
-- Name: motivo_idmotivo_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.motivo_idmotivo_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.motivo_idmotivo_seq OWNER TO postgres;
--
-- TOC entry 2439 (class 0 OID 0)
-- Dependencies: 187
-- Name: motivo_idmotivo_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.motivo_idmotivo_seq OWNED BY public.motivo.idmotivo;
--
-- TOC entry 183 (class 1259 OID 60215)
-- Name: nivel_estudio_idnivel_estudio_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.nivel_estudio_idnivel_estudio_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.nivel_estudio_idnivel_estudio_seq OWNER TO postgres;
--
-- TOC entry 190 (class 1259 OID 60242)
-- Name: pais; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.pais (
idpais integer NOT NULL,
descripcion character varying(50) NOT NULL
);
ALTER TABLE public.pais OWNER TO postgres;
--
-- TOC entry 189 (class 1259 OID 60240)
-- Name: pais_idpais_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.pais_idpais_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.pais_idpais_seq OWNER TO postgres;
--
-- TOC entry 2440 (class 0 OID 0)
-- Dependencies: 189
-- Name: pais_idpais_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.pais_idpais_seq OWNED BY public.pais.idpais;
--
-- TOC entry 206 (class 1259 OID 60308)
-- Name: parentesco; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.parentesco (
idparentesco integer NOT NULL,
descripcion character varying(50) NOT NULL,
bolsita_escolar boolean DEFAULT false NOT NULL
);
ALTER TABLE public.parentesco OWNER TO postgres;
--
-- TOC entry 205 (class 1259 OID 60306)
-- Name: parentesco_idparentesco_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.parentesco_idparentesco_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.parentesco_idparentesco_seq OWNER TO postgres;
--
-- TOC entry 2441 (class 0 OID 0)
-- Dependencies: 205
-- Name: parentesco_idparentesco_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.parentesco_idparentesco_seq OWNED BY public.parentesco.idparentesco;
--
-- TOC entry 209 (class 1259 OID 60323)
-- Name: persona; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.persona (
idpersona integer NOT NULL,
idtipo_documento integer NOT NULL,
nro_documento character varying(9) NOT NULL,
cuil character varying(11),
legajo character varying(6),
apellido character varying(50) NOT NULL,
nombres character varying(100) NOT NULL,
correo character varying(100),
cbu character varying(22),
fecha_nacimiento date,
idlocalidad integer NOT NULL,
calle character varying(50),
altura character varying(6),
piso character varying(2),
depto character varying(2),
idestado_civil integer
);
ALTER TABLE public.persona OWNER TO postgres;
--
-- TOC entry 197 (class 1259 OID 60272)
-- Name: provincia; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.provincia (
idprovincia integer NOT NULL,
descripcion character varying(50) NOT NULL,
idpais integer NOT NULL
);
ALTER TABLE public.provincia OWNER TO postgres;
--
-- TOC entry 211 (class 1259 OID 60333)
-- Name: solicitud_reserva; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.solicitud_reserva (
idsolicitud_reserva integer NOT NULL,
idpersona integer NOT NULL,
fecha date NOT NULL,
idinstalacion integer NOT NULL,
idestado integer NOT NULL,
idmotivo integer NOT NULL,
nro_personas integer NOT NULL
);
ALTER TABLE public.solicitud_reserva OWNER TO postgres;
--
-- TOC entry 210 (class 1259 OID 60331)
-- Name: solicitud_reserva_idsolicitud_reserva_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.solicitud_reserva_idsolicitud_reserva_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.solicitud_reserva_idsolicitud_reserva_seq OWNER TO postgres;
--
-- TOC entry 2442 (class 0 OID 0)
-- Dependencies: 210
-- Name: solicitud_reserva_idsolicitud_reserva_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.solicitud_reserva_idsolicitud_reserva_seq OWNED BY public.solicitud_reserva.idsolicitud_reserva;
--
-- TOC entry 220 (class 1259 OID 70089)
-- Name: telefono_por_persona; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.telefono_por_persona (
idtipo_telefono integer NOT NULL,
idpersona integer NOT NULL,
nro_telefono character(10) NOT NULL
);
ALTER TABLE public.telefono_por_persona OWNER TO postgres;
--
-- TOC entry 208 (class 1259 OID 60317)
-- Name: tipo_documento; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.tipo_documento (
idtipo_documento integer NOT NULL,
sigla character varying(10) NOT NULL,
descripcion character varying(50) NOT NULL
);
ALTER TABLE public.tipo_documento OWNER TO postgres;
--
-- TOC entry 207 (class 1259 OID 60315)
-- Name: tipo_documento_idtipo_documento_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.tipo_documento_idtipo_documento_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.tipo_documento_idtipo_documento_seq OWNER TO postgres;
--
-- TOC entry 2443 (class 0 OID 0)
-- Dependencies: 207
-- Name: tipo_documento_idtipo_documento_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.tipo_documento_idtipo_documento_seq OWNED BY public.tipo_documento.idtipo_documento;
--
-- TOC entry 215 (class 1259 OID 60352)
-- Name: tipo_socio; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.tipo_socio (
idtipo_socio integer NOT NULL,
descripcion character varying(50) NOT NULL
);
ALTER TABLE public.tipo_socio OWNER TO postgres;
--
-- TOC entry 214 (class 1259 OID 60350)
-- Name: tipo_socio_idtipo_socio_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.tipo_socio_idtipo_socio_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.tipo_socio_idtipo_socio_seq OWNER TO postgres;
--
-- TOC entry 2444 (class 0 OID 0)
-- Dependencies: 214
-- Name: tipo_socio_idtipo_socio_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.tipo_socio_idtipo_socio_seq OWNED BY public.tipo_socio.idtipo_socio;
--
-- TOC entry 192 (class 1259 OID 60250)
-- Name: tipo_telefono; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.tipo_telefono (
idtipo_telefono integer NOT NULL,
descripcion character varying(50) NOT NULL
);
ALTER TABLE public.tipo_telefono OWNER TO postgres;
--
-- TOC entry 191 (class 1259 OID 60248)
-- Name: tipo_telefono_idtipo_telefono_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.tipo_telefono_idtipo_telefono_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.tipo_telefono_idtipo_telefono_seq OWNER TO postgres;
--
-- TOC entry 2445 (class 0 OID 0)
-- Dependencies: 191
-- Name: tipo_telefono_idtipo_telefono_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.tipo_telefono_idtipo_telefono_seq OWNED BY public.tipo_telefono.idtipo_telefono;
--
-- TOC entry 2195 (class 2604 OID 60363)
-- Name: idafiliacion; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.afiliacion ALTER COLUMN idafiliacion SET DEFAULT nextval('public.afiliacion_idafiliacion_seq'::regclass);
--
-- TOC entry 2187 (class 2604 OID 60282)
-- Name: idcategoria; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categoria ALTER COLUMN idcategoria SET DEFAULT nextval('public.categoria_idcategoria_seq'::regclass);
--
-- TOC entry 2180 (class 2604 OID 60212)
-- Name: idcategoria_estado; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categoria_estado ALTER COLUMN idcategoria_estado SET DEFAULT nextval('public.categoria_estado_idcategoria_estado_seq'::regclass);
--
-- TOC entry 2181 (class 2604 OID 60229)
-- Name: idcategoria_motivo; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categoria_motivo ALTER COLUMN idcategoria_motivo SET DEFAULT nextval('public.categoria_motivo_idcategoria_motivo_seq'::regclass);
--
-- TOC entry 2189 (class 2604 OID 60298)
-- Name: idcomercio; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comercio ALTER COLUMN idcomercio SET DEFAULT nextval('public.comercio_idcomercio_seq'::regclass);
--
-- TOC entry 2185 (class 2604 OID 60261)
-- Name: idestado; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.estado ALTER COLUMN idestado SET DEFAULT nextval('public.estado_idestado_seq'::regclass);
--
-- TOC entry 2197 (class 2604 OID 70037)
-- Name: idestado_civil; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.estado_civil ALTER COLUMN idestado_civil SET DEFAULT nextval('public.estado_civil_idestado_civil_seq'::regclass);
--
-- TOC entry 2186 (class 2604 OID 60269)
-- Name: idinstalacion; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.instalacion ALTER COLUMN idinstalacion SET DEFAULT nextval('public.instalacion_idinstalacion_seq'::regclass);
--
-- TOC entry 2188 (class 2604 OID 60290)
-- Name: idlocalidad; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.localidad ALTER COLUMN idlocalidad SET DEFAULT nextval('public.localidad_idlocalidad_seq'::regclass);
--
-- TOC entry 2182 (class 2604 OID 60237)
-- Name: idmotivo; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.motivo ALTER COLUMN idmotivo SET DEFAULT nextval('public.motivo_idmotivo_seq'::regclass);
--
-- TOC entry 2183 (class 2604 OID 60245)
-- Name: idpais; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.pais ALTER COLUMN idpais SET DEFAULT nextval('public.pais_idpais_seq'::regclass);
--
-- TOC entry 2190 (class 2604 OID 60311)
-- Name: idparentesco; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.parentesco ALTER COLUMN idparentesco SET DEFAULT nextval('public.parentesco_idparentesco_seq'::regclass);
--
-- TOC entry 2193 (class 2604 OID 60336)
-- Name: idsolicitud_reserva; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.solicitud_reserva ALTER COLUMN idsolicitud_reserva SET DEFAULT nextval('public.solicitud_reserva_idsolicitud_reserva_seq'::regclass);
--
-- TOC entry 2192 (class 2604 OID 60320)
-- Name: idtipo_documento; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tipo_documento ALTER COLUMN idtipo_documento SET DEFAULT nextval('public.tipo_documento_idtipo_documento_seq'::regclass);
--
-- TOC entry 2194 (class 2604 OID 60355)
-- Name: idtipo_socio; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tipo_socio ALTER COLUMN idtipo_socio SET DEFAULT nextval('public.tipo_socio_idtipo_socio_seq'::regclass);
--
-- TOC entry 2184 (class 2604 OID 60253)
-- Name: idtipo_telefono; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tipo_telefono ALTER COLUMN idtipo_telefono SET DEFAULT nextval('public.tipo_telefono_idtipo_telefono_seq'::regclass);
--
-- TOC entry 2417 (class 0 OID 60360)
-- Dependencies: 217
-- Data for Name: afiliacion; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.afiliacion (idafiliacion, idpersona, idtipo_socio, idestado, fecha_solicitud, fecha_alta, fecha_baja, activa) FROM stdin;
\.
--
-- TOC entry 2446 (class 0 OID 0)
-- Dependencies: 216
-- Name: afiliacion_idafiliacion_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.afiliacion_idafiliacion_seq', 1, false);
--
-- TOC entry 2413 (class 0 OID 60344)
-- Dependencies: 213
-- Data for Name: bolsita_escolar; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.bolsita_escolar (idpersona, idpersona_familia, idparentesco, idnivel_estudio, anio, idestado) FROM stdin;
\.
--
-- TOC entry 2399 (class 0 OID 60279)
-- Dependencies: 199
-- Data for Name: categoria; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.categoria (idcategoria, descripcion, monto_permitido) FROM stdin;
\.
--
-- TOC entry 2382 (class 0 OID 60209)
-- Dependencies: 182
-- Data for Name: categoria_estado; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.categoria_estado (idcategoria_estado, descripcion) FROM stdin;
\.
--
-- TOC entry 2447 (class 0 OID 0)
-- Dependencies: 181
-- Name: categoria_estado_idcategoria_estado_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.categoria_estado_idcategoria_estado_seq', 1, false);
--
-- TOC entry 2448 (class 0 OID 0)
-- Dependencies: 198
-- Name: categoria_idcategoria_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.categoria_idcategoria_seq', 1, false);
--
-- TOC entry 2386 (class 0 OID 60226)
-- Dependencies: 186
-- Data for Name: categoria_motivo; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.categoria_motivo (idcategoria_motivo, descripcion) FROM stdin;
\.
--
-- TOC entry 2449 (class 0 OID 0)
-- Dependencies: 185
-- Name: categoria_motivo_idcategoria_motivo_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.categoria_motivo_idcategoria_motivo_seq', 1, false);
--
-- TOC entry 2403 (class 0 OID 60295)
-- Dependencies: 203
-- Data for Name: comercio; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.comercio (idcomercio, nombre, direccion, idlocalidad) FROM stdin;
\.
--
-- TOC entry 2450 (class 0 OID 0)
-- Dependencies: 202
-- Name: comercio_idcomercio_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.comercio_idcomercio_seq', 1, false);
--
-- TOC entry 2384 (class 0 OID 60221)
-- Dependencies: 184
-- Data for Name: configuracion; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.configuracion (edad_maxima_bolsita_escolar, dias_confirmacion_reserva) FROM stdin;
\.
--
-- TOC entry 2404 (class 0 OID 60301)
-- Dependencies: 204
-- Data for Name: convenio; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.convenio (idcategoria, idcomercio, monto_permitido, fecha_alta, fecha_baja) FROM stdin;
\.
--
-- TOC entry 2394 (class 0 OID 60258)
-- Dependencies: 194
-- Data for Name: estado; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.estado (idestado, descripcion, idcategoria_estado) FROM stdin;
\.
--
-- TOC entry 2419 (class 0 OID 70034)
-- Dependencies: 219
-- Data for Name: estado_civil; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.estado_civil (idestado_civil, descripcion) FROM stdin;
1 SOLTERO
2 CASADO
\.
--
-- TOC entry 2451 (class 0 OID 0)
-- Dependencies: 218
-- Name: estado_civil_idestado_civil_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.estado_civil_idestado_civil_seq', 6, true);
--
-- TOC entry 2452 (class 0 OID 0)
-- Dependencies: 193
-- Name: estado_idestado_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.estado_idestado_seq', 1, false);
--
-- TOC entry 2412 (class 0 OID 60339)
-- Dependencies: 212
-- Data for Name: familia; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.familia (idpersona, idpersona_familia, idparentesco, fecha_relacion) FROM stdin;
\.
--
-- TOC entry 2396 (class 0 OID 60266)
-- Dependencies: 196
-- Data for Name: instalacion; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.instalacion (idinstalacion, nombre, cantidad_maxima_personas) FROM stdin;
\.
--
-- TOC entry 2453 (class 0 OID 0)
-- Dependencies: 195
-- Name: instalacion_idinstalacion_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.instalacion_idinstalacion_seq', 1, false);
--
-- TOC entry 2401 (class 0 OID 60287)
-- Dependencies: 201
-- Data for Name: localidad; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.localidad (idlocalidad, idprovincia, descripcion) FROM stdin;
\.
--
-- TOC entry 2454 (class 0 OID 0)
-- Dependencies: 200
-- Name: localidad_idlocalidad_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.localidad_idlocalidad_seq', 1, false);
--
-- TOC entry 2388 (class 0 OID 60234)
-- Dependencies: 188
-- Data for Name: motivo; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.motivo (idmotivo, idcategoria_motivo, descripcion) FROM stdin;
\.
--
-- TOC entry 2455 (class 0 OID 0)
-- Dependencies: 187
-- Name: motivo_idmotivo_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.motivo_idmotivo_seq', 1, false);
--
-- TOC entry 2456 (class 0 OID 0)
-- Dependencies: 183
-- Name: nivel_estudio_idnivel_estudio_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.nivel_estudio_idnivel_estudio_seq', 1, false);
--
-- TOC entry 2390 (class 0 OID 60242)
-- Dependencies: 190
-- Data for Name: pais; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.pais (idpais, descripcion) FROM stdin;
\.
--
-- TOC entry 2457 (class 0 OID 0)
-- Dependencies: 189
-- Name: pais_idpais_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.pais_idpais_seq', 1, false);
--
-- TOC entry 2406 (class 0 OID 60308)
-- Dependencies: 206
-- Data for Name: parentesco; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.parentesco (idparentesco, descripcion, bolsita_escolar) FROM stdin;
\.
--
-- TOC entry 2458 (class 0 OID 0)
-- Dependencies: 205
-- Name: parentesco_idparentesco_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.parentesco_idparentesco_seq', 1, false);
--
-- TOC entry 2409 (class 0 OID 60323)
-- Dependencies: 209
-- Data for Name: persona; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.persona (idpersona, idtipo_documento, nro_documento, cuil, legajo, apellido, nombres, correo, cbu, fecha_nacimiento, idlocalidad, calle, altura, piso, depto, idestado_civil) FROM stdin;
\.
--
-- TOC entry 2397 (class 0 OID 60272)
-- Dependencies: 197
-- Data for Name: provincia; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.provincia (idprovincia, descripcion, idpais) FROM stdin;
\.
--
-- TOC entry 2411 (class 0 OID 60333)
-- Dependencies: 211
-- Data for Name: solicitud_reserva; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.solicitud_reserva (idsolicitud_reserva, idpersona, fecha, idinstalacion, idestado, idmotivo, nro_personas) FROM stdin;
\.
--
-- TOC entry 2459 (class 0 OID 0)
-- Dependencies: 210
-- Name: solicitud_reserva_idsolicitud_reserva_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.solicitud_reserva_idsolicitud_reserva_seq', 1, false);
--
-- TOC entry 2420 (class 0 OID 70089)
-- Dependencies: 220
-- Data for Name: telefono_por_persona; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.telefono_por_persona (idtipo_telefono, idpersona, nro_telefono) FROM stdin;
\.
--
-- TOC entry 2408 (class 0 OID 60317)
-- Dependencies: 208
-- Data for Name: tipo_documento; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.tipo_documento (idtipo_documento, sigla, descripcion) FROM stdin;
1 DNI DOCUMENTO NACIONAL DE IDENTIDAD
\.
--
-- TOC entry 2460 (class 0 OID 0)
-- Dependencies: 207
-- Name: tipo_documento_idtipo_documento_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.tipo_documento_idtipo_documento_seq', 2, true);
--
-- TOC entry 2415 (class 0 OID 60352)
-- Dependencies: 215
-- Data for Name: tipo_socio; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.tipo_socio (idtipo_socio, descripcion) FROM stdin;
1 TITULAR
4 JUBILIDADO
\.
--
-- TOC entry 2461 (class 0 OID 0)
-- Dependencies: 214
-- Name: tipo_socio_idtipo_socio_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.tipo_socio_idtipo_socio_seq', 5, true);
--
-- TOC entry 2392 (class 0 OID 60250)
-- Dependencies: 192
-- Data for Name: tipo_telefono; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.tipo_telefono (idtipo_telefono, descripcion) FROM stdin;
\.
--
-- TOC entry 2462 (class 0 OID 0)
-- Dependencies: 191
-- Name: tipo_telefono_idtipo_telefono_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.tipo_telefono_idtipo_telefono_seq', 1, false);
--
-- TOC entry 2247 (class 2606 OID 60366)
-- Name: idafiliacion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.afiliacion
ADD CONSTRAINT idafiliacion PRIMARY KEY (idafiliacion);
--
-- TOC entry 2221 (class 2606 OID 60284)
-- Name: idcategoria; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categoria
ADD CONSTRAINT idcategoria PRIMARY KEY (idcategoria);
--
-- TOC entry 2199 (class 2606 OID 60214)
-- Name: idcategoria_estado; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categoria_estado
ADD CONSTRAINT idcategoria_estado PRIMARY KEY (idcategoria_estado);
--
-- TOC entry 2202 (class 2606 OID 60231)
-- Name: idcategoria_motivo; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.categoria_motivo
ADD CONSTRAINT idcategoria_motivo PRIMARY KEY (idcategoria_motivo);
--
-- TOC entry 2226 (class 2606 OID 60300)
-- Name: idcomercion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comercio
ADD CONSTRAINT idcomercion PRIMARY KEY (idcomercio);
--
-- TOC entry 2228 (class 2606 OID 60305)
-- Name: idconvenio; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.convenio
ADD CONSTRAINT idconvenio PRIMARY KEY (idcategoria, idcomercio);
--
-- TOC entry 2213 (class 2606 OID 60263)
-- Name: idestado; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.estado
ADD CONSTRAINT idestado PRIMARY KEY (idestado);
--
-- TOC entry 2250 (class 2606 OID 70039)
-- Name: idestado_civil; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.estado_civil
ADD CONSTRAINT idestado_civil PRIMARY KEY (idestado_civil);
--
-- TOC entry 2242 (class 2606 OID 60343)
-- Name: idfamilia; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.familia
ADD CONSTRAINT idfamilia PRIMARY KEY (idpersona, idpersona_familia, idparentesco);
--
-- TOC entry 2216 (class 2606 OID 60271)
-- Name: idinstalacion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.instalacion
ADD CONSTRAINT idinstalacion PRIMARY KEY (idinstalacion);
--
-- TOC entry 2223 (class 2606 OID 60292)
-- Name: idlocalidad; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.localidad
ADD CONSTRAINT idlocalidad PRIMARY KEY (idlocalidad);
--
-- TOC entry 2205 (class 2606 OID 60239)
-- Name: idmotivo; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.motivo
ADD CONSTRAINT idmotivo PRIMARY KEY (idmotivo);
--
-- TOC entry 2207 (class 2606 OID 60247)
-- Name: idpais; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.pais
ADD CONSTRAINT idpais PRIMARY KEY (idpais);
--
-- TOC entry 2230 (class 2606 OID 60314)
-- Name: idparentesco; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.parentesco
ADD CONSTRAINT idparentesco PRIMARY KEY (idparentesco);
--
-- TOC entry 2236 (class 2606 OID 60327)
-- Name: idpersona; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.persona
ADD CONSTRAINT idpersona PRIMARY KEY (idpersona);
--
-- TOC entry 2218 (class 2606 OID 60276)
-- Name: idprovincia; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.provincia
ADD CONSTRAINT idprovincia PRIMARY KEY (idprovincia);
--
-- TOC entry 2240 (class 2606 OID 60338)
-- Name: idsolicitud_reserva; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.solicitud_reserva
ADD CONSTRAINT idsolicitud_reserva PRIMARY KEY (idsolicitud_reserva);
--
-- TOC entry 2233 (class 2606 OID 60322)
-- Name: idtipo_documento; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tipo_documento
ADD CONSTRAINT idtipo_documento PRIMARY KEY (idtipo_documento);
--
-- TOC entry 2244 (class 2606 OID 60357)
-- Name: idtipo_socio; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tipo_socio
ADD CONSTRAINT idtipo_socio PRIMARY KEY (idtipo_socio);
--
-- TOC entry 2210 (class 2606 OID 60255)
-- Name: idtipo_telefono; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.tipo_telefono
ADD CONSTRAINT idtipo_telefono PRIMARY KEY (idtipo_telefono);
--
-- TOC entry 2253 (class 2606 OID 70103)
-- Name: telefono_por_persona_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.telefono_por_persona
ADD CONSTRAINT telefono_por_persona_pkey PRIMARY KEY (idtipo_telefono, idpersona, nro_telefono);
--
-- TOC entry 2248 (class 1259 OID 70073)
-- Name: idx_afiliacion; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_afiliacion ON public.afiliacion USING btree (idpersona, idtipo_socio) WHERE (activa = false);
--
-- TOC entry 2200 (class 1259 OID 70074)
-- Name: idx_categoria_estado; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_categoria_estado ON public.categoria_estado USING btree (descripcion);
--
-- TOC entry 2203 (class 1259 OID 70075)
-- Name: idx_categoria_motivo; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_categoria_motivo ON public.categoria_motivo USING btree (descripcion);
--
-- TOC entry 2237 (class 1259 OID 70056)
-- Name: idx_documento; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_documento ON public.persona USING btree (idtipo_documento, nro_documento);
--
-- TOC entry 2214 (class 1259 OID 70076)
-- Name: idx_estado; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_estado ON public.estado USING btree (descripcion);
--
-- TOC entry 2251 (class 1259 OID 70040)
-- Name: idx_estado_civil; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_estado_civil ON public.estado_civil USING btree (descripcion);
--
-- TOC entry 2238 (class 1259 OID 70057)
-- Name: idx_legajo; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_legajo ON public.persona USING btree (legajo);
--
-- TOC entry 2224 (class 1259 OID 70077)
-- Name: idx_localidad; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_localidad ON public.localidad USING btree (descripcion);
--
-- TOC entry 2208 (class 1259 OID 70078)
-- Name: idx_pais; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_pais ON public.pais USING btree (descripcion);
--
-- TOC entry 2231 (class 1259 OID 70079)
-- Name: idx_parentesco; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_parentesco ON public.parentesco USING btree (descripcion);
--
-- TOC entry 2219 (class 1259 OID 70080)
-- Name: idx_provincia; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_provincia ON public.provincia USING btree (descripcion);
--
-- TOC entry 2234 (class 1259 OID 70081)
-- Name: idx_tipo_documento; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_tipo_documento ON public.tipo_documento USING btree (sigla);
--
-- TOC entry 2245 (class 1259 OID 70104)
-- Name: idx_tipo_socio; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_tipo_socio ON public.tipo_socio USING btree (descripcion);
--
-- TOC entry 2211 (class 1259 OID 70083)
-- Name: idx_tipo_telefono; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX idx_tipo_telefono ON public.tipo_telefono USING btree (descripcion);
--
-- TOC entry 2255 (class 2606 OID 60368)
-- Name: categoria_estado_estado_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.estado
ADD CONSTRAINT categoria_estado_estado_fk FOREIGN KEY (idcategoria_estado) REFERENCES public.categoria_estado(idcategoria_estado);
--
-- TOC entry 2254 (class 2606 OID 60373)
-- Name: categoria_motivo_motivo_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.motivo
ADD CONSTRAINT categoria_motivo_motivo_fk FOREIGN KEY (idcategoria_motivo) REFERENCES public.categoria_motivo(idcategoria_motivo);
--
-- TOC entry 2262 (class 2606 OID 70068)
-- Name: familia_idparentesco_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.familia
ADD CONSTRAINT familia_idparentesco_fkey FOREIGN KEY (idparentesco) REFERENCES public.parentesco(idparentesco) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2263 (class 2606 OID 70063)
-- Name: familia_idpersona_familia_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.familia
ADD CONSTRAINT familia_idpersona_familia_fkey FOREIGN KEY (idpersona_familia) REFERENCES public.persona(idpersona) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2264 (class 2606 OID 70058)
-- Name: familia_idpersona_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.familia
ADD CONSTRAINT familia_idpersona_fkey FOREIGN KEY (idpersona) REFERENCES public.persona(idpersona) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2257 (class 2606 OID 70084)
-- Name: localidad_idprovincia_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.localidad
ADD CONSTRAINT localidad_idprovincia_fkey FOREIGN KEY (idprovincia) REFERENCES public.provincia(idprovincia) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2261 (class 2606 OID 60378)
-- Name: motivo_solicitud_reserva_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.solicitud_reserva
ADD CONSTRAINT motivo_solicitud_reserva_fk FOREIGN KEY (idmotivo) REFERENCES public.motivo(idmotivo);
--
-- TOC entry 2256 (class 2606 OID 60383)
-- Name: pais_provincia_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.provincia
ADD CONSTRAINT pais_provincia_fk FOREIGN KEY (idpais) REFERENCES public.pais(idpais);
--
-- TOC entry 2260 (class 2606 OID 70041)
-- Name: persona_idestado_civil_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.persona
ADD CONSTRAINT persona_idestado_civil_fkey FOREIGN KEY (idestado_civil) REFERENCES public.estado_civil(idestado_civil) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2259 (class 2606 OID 70046)
-- Name: persona_idlocalidad_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.persona
ADD CONSTRAINT persona_idlocalidad_fkey FOREIGN KEY (idlocalidad) REFERENCES public.localidad(idlocalidad) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2258 (class 2606 OID 70051)
-- Name: persona_idtipo_documento_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.persona
ADD CONSTRAINT persona_idtipo_documento_fkey FOREIGN KEY (idtipo_documento) REFERENCES public.tipo_documento(idtipo_documento) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2265 (class 2606 OID 70097)
-- Name: telefono_por_persona_idpersona_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.telefono_por_persona
ADD CONSTRAINT telefono_por_persona_idpersona_fkey FOREIGN KEY (idpersona) REFERENCES public.persona(idpersona) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2266 (class 2606 OID 70092)
-- Name: telefono_por_persona_idtipo_telefono_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.telefono_por_persona
ADD CONSTRAINT telefono_por_persona_idtipo_telefono_fkey FOREIGN KEY (idtipo_telefono) REFERENCES public.tipo_telefono(idtipo_telefono) ON UPDATE CASCADE ON DELETE RESTRICT;
--
-- TOC entry 2428 (class 0 OID 0)
-- Dependencies: 6
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
-- Completed on 2018-05-28 20:27:54 -03
--
-- PostgreSQL database dump complete
--
| true |
64a3a41960543004a498642bfc9cf70db68ce719 | SQL | muratsungu/Kodluyoruz-MSSQL-Oracle-SQL-Studies | /Oracle/Murat Süngü Kodluyoruz Week2 Oracle Query Ödevi.sql | ISO-8859-9 | 7,137 | 3.859375 | 4 | [] | no_license | --Kodluyoruz SQL W2 devi
--Murat Sng
--Banking sorular cevaplar
--***************************
--Yln 4. aylarnda en ok hangi amala kredi ekilmitir? ----Banking emas iin
SELECT PURPOSE,COUNT(*) FROM LOANS WHERE MONTH=4 GROUP BY PURPOSE;
-- Bankann 50 ve ya 51 yanda kadn mterilerinden ayn isme sahip olan mterisi/mterileri var m? Varsa isimleri neler?----Banking emas iin
select count(*),first from clients where age in (50,51) and sex='Female' group by first order by count(*) desc;
--Hangi yllarda ka hesap almtr?----Banking emas iin
select count(*),year from accounts group by year order by year;
-- lemlerin tiplerine gre toplam saylarnn bykten ke sralamas nedir?----Banking emas iin
select count(*),operation from transactions group by operation order by count(*) desc;
-- lemlerin tiplerine gre toplam tutarlarnn bykten ke sralamas nedir?----Banking emas iin
select sum(amount),operation from transactions group by operation order by sum(amount) desc;
--Sales sorular cevaplar
--***************************
-- Birim fiyat 150'den byk olan order_itemlar bulunuz. ----Sales emas iin
select * from order_items where unit_price>150;
-- e alm tarihi Mays 2016 olan alanlar bulunuz. ----Sales emas iin
select * from employees where hire_date between '01.05.2016' and '31.05.2016';
-- Ad Charlie ya da Charlsie olan contactlar bulunuz. ----Sales emas iin
select * from contacts where first_name in ('Charlie','Charlsie');
-- Adet says 10dan byk 50den kk envanterleri bulunuz. ----Sales emas iin
select * from inventories where quantity<50 and quantity>10;
-- Bir siparite toplam 100.0000'den fazla cret deyen emirler nedir? ----Sales emas iin
select * from order_items where quantity*unit_price>100000;
-- Manager' olmayan alanlar hangileridir? ----Sales emas iin
select * from employeEs where manager_id IS NULL;
-- State bilgisi bo olan lokasyonlar bulunuz.----Sales emas iin
select * from locations where state is null;
-- Durumu iptal olan ve satclar olmayan emirler hangileridir? ----Sales emas iin
select * from orders where status='Canceled' and salesman_id is null;
-- Ocak 2016 ile Haziran 2016 arasnda verilen sipariler hangileridir? ----Sales emas iin
select * from orders where order_date between '01.01.2016' and '30.06.2016';
-- Unvan 'S' ile balamayan alanlar bulunuz. ----Sales emas iin
select * from employeEs where job_ttle not like 'S%' ;
-- Herhangi bir eit Intel Xeon rnler hangileridir? ----Sales emas iin
select * from products where product_name like 'Intel Xeon%';
-- smi 'C' ile balayan kontaklar hangileridir? Soyadna gre alfabetik sra ile sralayalm. ----Sales emas iin
select * from contacts where frst_name like 'C%' order by last_name;
-- rn ad 'Asus' ile balayan ve liste fiyat standart cretinden kk olan rnleri bulunuz. ----Sales emas iin
select * from products where product_name like 'Asus%' and standard_cost>list_price ;
-- 1,2,4,5 id'li kategorilerin bilgilerini bulunuz. ----Sales emas iin
select * from product_categories where category_d in (1,2,3,4,5);
-- Sipari durumu 'Shipped'den farkl olan mterilerin bilgilerini bulunuz. ----Sales emas iin
select * from customers join orders on orders.status not like 'Shipped' ;
-- Adet says 100e eit olan envanterlerin product bilgisini bulunuz. ----Sales emas iin
select * from products join inventories on quantity=100 ;
-- Beijing (8 numaral warehouse)'da ka farkl envanter vardr? ----Sales emas iin
select count(*) from inventories join warehouses on warehouses.warehouse_id=8 ;
-- Liste fiyati 1000 ile 3000 arasinda olan ka product var?----Sales emas iin
select count(*) from products where list_price between 1000 and 3000;
--Telco sorular cevaplar
--***************************
-- Kotas limitsiz olan rnler hangileridir? ----Telco emas iin
SELECT PRODUCT_NAME FROM PRODUCT WHERE QUOTA='LIMITLESS';
-- Stats 'Initial' olan mterileri bulunuz. ----Telco emas iin
SELECT CUSTOMER_NUM,NAME,surname FROM CUSTOMER WHERE STATUS='INITIAL';
-- ehir bilgisi 'ISTANBUL' olan adresleri bulunuz. ----Telco emas iin
SELECT * FROM address WHERE CITY='Istanbul' or cty='Istanbu';
-- Birincil iletiim bilgisi olmayan telefon numaralarn bulunuz. ----Telco emas iin
select cnt_value from contact where is_primary=0 and cnt_type='PHONE';
-- Hesap deme ekli nakit olmayan hesaplar hangileridir? ----Telco emas iin
SELECT * FROM ACCOUNT WHERE payment_type NOT IN ('CASH');
-- Stats deaktif olan mterilerin balant kesim tarihleri nedir? ----Telco emas iin
SELECT DISCONNECTION_DATE FROM CUSTOMER WHERE STATUS='DEACTIVE' ;
-- Hesap kapan tarihi dolu olan hesaplar bulunuz. ----Telco emas iin
SELECT * FROM ACCOUNT WHERE account_closng_date IS NOT NULL;
-- Elektronik fatura mail adresi (E_bill_email) olan hesaplar hangileridir? ----Telco emas iin
SELECT * FROM ACCOUNT WHERE bll_presentaton_type='EBILL' ;
-- Szleme biti tarihi 1 Ocak 2000'den byk , 1 Ocak 2005'ten kk olan szlemeleri bulunuz. ----Telco emas iin
SELECT * FROM AGREEMENT WHERE commtment_end_date BETWEEN '01.01.2000' AND '01.01.2005';
-- 2005 ylndan nce yaplan ve hala aktif olan subscriptionlar hangileridir? ----Telco emas iin
SELECT * FROM SUBSCRIPTION WHERE create_date<'01.01.2005' AND STATUS='ACTIVE';
-- Szleme balang tarihi Ocak 2010'dan byk olan szlemeleri bulunuz. ----Telco emas iin
SELECT * FROM AGREEMENT WHERE commtment_start_date>'31.01.2010' ;
-- smi E ile balayan mterileri bulunuz. ----Telco emas iin
SELECT * FROM CUSTOMER WHERE NAME LIKE 'E%' ;
-- Product tipi 'DSL' ile biten rnleri bulunuz. ----Telco emas iin
SELECT * FROM PRODUCT WHERE PRODUCT_TYPE LIKE '%DSL';
-- sminde ya da soyisminde '' harfi geen mteriler hangileridir? ----Telco emas iin
SELECT * FROM CUSTOMER WHERE NAME LIKE '%%' OR SURNAME LIKE '%%' ;
-- lke kodu UK ve AU olan adresleri bulunuz.----Telco emas iin
SELECT * FROM ADDRESS WHERE country_cd IN ('UK','AU');
-- Taahht sresi 240 ve 120 ay olan btn szlemeleri bulmak istiyoruz.----Telco emas iin
SELECT * FROM AGREEMENT WHERE commtment_duraton IN ('120 MONTHS','240 MONTHS');
-- Szleme alt tipi MAIN olan ka tane szleme vardr?----Telco emas iin
SELECT COUNT(*) FROM AGREEMENT WHERE SUBTYPE='MAIN';
-- Deaktif mterilerin saysn bulunuz.----Telco emas iin
SELECT COUNT(*) FROM CUSTOMER WHERE status='DEACTIVE';
-- letiim tipi olarak email ve statusu kullanmda olan ka mteri var?----Telco emas iin
SELECT * FROM CUSTOMER JOIN contact ON contact.cnt_type='EMAIL' AND customer.status='ACTIVE';
| true |
217a40c7458bad1887ee8c38ce4d304a6c8bc045 | SQL | 2Nifty/PFC | /_My Workorders/_Closed/WO 1028 - Nav5.0 Integration Task - CustomerMaster Update/NV-MissingFields.sql | UTF-8 | 5,258 | 3.09375 | 3 | [] | no_license | select
'' AS [Notification Process Code],
3 AS [Queue Priority], --This appears to be populated with other values in 3.7
0 AS [FQA Required],
0 AS [Cert Required],
'' AS [Rebate Group],
0 AS [Backorder], --This appears to be populated with other values in 3.7
'' AS [Delivery Route],
'' AS [Delivery Stop],
0 AS [EDI Invoice], --This appears to be populated with other values in 3.7
'' AS [E-Ship Agent Service], --This appears to be populated with other values in 3.7
0 AS [Free Freight], --This appears to be populated with other values in 3.7
0 AS [Residential Delivery],
'' AS [IRS EIN Number],
0 AS [Blind Shipment],
0 AS [Double Blind Shipment],
'' AS [Double Blind Ship-from Cust No],
0 AS [No Free Freight Lines on Order],
0 AS [Shipping Payment Type], --This appears to be populated with other values in 3.7
0 AS [Shipping Insurance],
'' AS [External No_],
'' AS [Default Ship-for Code], --This appears to be populated with other values in 3.7
'' AS [Packing Rule Code], --This appears to be populated with other values in 3.7
'' AS [E-Mail Rule Code],
GETDATE() AS [E-Mail Cust_ Stat_ Send Date],
0 AS [Use E-Mail Rule for ShipToAddr],
15 AS [Review Days], --This appears to be populated with other values in 3.7
25 AS [Call Days], --This appears to be populated with other values in 3.7
35 AS [Hold Days], --This appears to be populated with other values in 3.7
'' AS [Default Ship-To Code], --This appears to be populated with other values in 3.7
0 AS [Purchase Order Required], --This appears to be populated with other values in 3.7
'' AS [Broker_Agent Code],
0 AS [Tool Repair Priority],
'' AS [Tool Repair Tech], *
select [No_], [Queue Priority],
select [No_], [Backorder],
select [No_], [EDI Invoice],
select [No_], [E-Ship Agent Service],
select [No_], [Free Freight],
select [No_], [Shipping Payment Type],
[Default Ship-for Code],
[Packing Rule Code],
[Review Days],
[Call Days],
[Hold Days],
[Default Ship-To Code],
[Purchase Order Required], *
from [Porteous$Customer]
WHERE
[Queue Priority]<>3 OR --This appears to be populated with other values in 3.7
[Backorder]<>0 OR --This appears to be populated with other values in 3.7
[EDI Invoice]<>0 OR --This appears to be populated with other values in 3.7
[E-Ship Agent Service]<>'' OR --This appears to be populated with other values in 3.7
[Free Freight]<>0 OR --This appears to be populated with other values in 3.7
[Shipping Payment Type]<>0 OR --This appears to be populated with other values in 3.7
[Default Ship-for Code]<>'' OR --This appears to be populated with other values in 3.7
[Packing Rule Code]<>'' OR --This appears to be populated with other values in 3.7
[Review Days]<>15 OR --This appears to be populated with other values in 3.7
[Call Days]<>25 OR --This appears to be populated with other values in 3.7
[Hold Days]<>35 OR --This appears to be populated with other values in 3.7
[Default Ship-To Code]<>'' OR --This appears to be populated with other values in 3.7
[Purchase Order Required]<>0 --This appears to be populated with other values in 3.7
--select [Shipping Insurance], * from [Porteous$Customer] where [No_]='201073'
select [Use E-Mail Rule for ShipToAddr],* from [Porteous$Customer] where [Use E-Mail Rule for ShipToAddr]<>0
select [No_], [Queue Priority]
from [Porteous$Customer]
WHERE [Queue Priority]<>3 --This appears to be populated with other values in 3.7
select [No_], [Backorder]
from [Porteous$Customer]
WHERE [Backorder]<>0 --This appears to be populated with other values in 3.7
select [No_], [EDI Invoice]
from [Porteous$Customer]
WHERE [EDI Invoice]<>0 --This appears to be populated with other values in 3.7
select [No_], [E-Ship Agent Service]
from [Porteous$Customer]
WHERE [E-Ship Agent Service]<>'' --This appears to be populated with other values in 3.7
select [No_], [Free Freight]
from [Porteous$Customer]
WHERE [Free Freight]<>0 --This appears to be populated with other values in 3.7
select [No_], [Shipping Payment Type]
from [Porteous$Customer]
WHERE [Shipping Payment Type]<>0 --This appears to be populated with other values in 3.7
select [No_], [Default Ship-for Code]
from [Porteous$Customer]
WHERE [Default Ship-for Code]<>'' --This appears to be populated with other values in 3.7
select [No_], [Packing Rule Code]
from [Porteous$Customer]
WHERE [Packing Rule Code]<>'' --This appears to be populated with other values in 3.7
select [No_], [Review Days]
from [Porteous$Customer]
WHERE [Review Days]<>15 --This appears to be populated with other values in 3.7
select [No_], [Call Days]
from [Porteous$Customer]
WHERE [Call Days]<>25 --This appears to be populated with other values in 3.7
select [No_], [Hold Days]
from [Porteous$Customer]
WHERE [Hold Days]<>35 --This appears to be populated with other values in 3.7
select [No_], [Default Ship-To Code]
from [Porteous$Customer]
WHERE [Default Ship-To Code]<>'' --This appears to be populated with other values in 3.7
select [No_], [Purchase Order Required]
from [Porteous$Customer]
WHERE [Purchase Order Required]<>0 --This appears to be populated with other values in 3.7
| true |
a46990ad1b758a5d63394c447d2751fd6ab868ca | SQL | micktusker/shiny-server | /gene_lookup/schema.sql | UTF-8 | 1,474 | 2.765625 | 3 | [] | no_license | CREATE TABLE hgnc_genes(
hgnc_id TEXT NOT NULL,
symbol TEXT,
name TEXT,
locus_group TEXT,
locus_type TEXT,
status TEXT,
location TEXT,
location_sortable TEXT,
alias_symbol TEXT,
alias_name TEXT,
prev_symbol TEXT,
prev_name TEXT,
gene_family TEXT,
gene_family_id TEXT,
date_approved_reserved TEXT,
date_symbol_changed TEXT,
date_name_changed TEXT,
date_modified TEXT,
entrez_id TEXT,
ensembl_gene_id TEXT,
vega_id TEXT,
ucsc_id TEXT,
ena TEXT,
refseq_accession TEXT,
ccds_id TEXT,
uniprot_ids TEXT,
pubmed_id TEXT,
mgd_id TEXT,
rgd_id TEXT,
lsdb TEXT,
cosmic TEXT,
omim_id TEXT,
mirbase TEXT,
homeodb TEXT,
snornabase TEXT,
bioparadigms_slc TEXT,
orphanet TEXT,
"pseudogene.org" TEXT,
horde_id TEXT,
merops TEXT,
imgt TEXT,
iuphar TEXT,
kznf_gene_catalog TEXT,
"mamit-trnadb" TEXT,
cd TEXT,
lncrnadb TEXT,
enzyme_id TEXT,
intermediate_filament_db TEXT,
CONSTRAINT hgnc_genes_pk PRIMARY KEY (hgnc_id)
);
CREATE UNIQUE INDEX hgnc_genes_gene_symbol_idx ON hgnc_genes(symbol);
CREATE TABLE gene_names_lookup(
gene_name_lookup_id INTEGER,
hgnc_id TEXT,
gene_identifier TEXT,
identifier_type TEXT,
tsv TEXT,
CONSTRAINT gene_names_lookup_pkey PRIMARY KEY (gene_name_lookup_id)
);
CREATE INDEX gene_names_lu_idx ON gene_names_lookup(hgnc_id, gene_identifier);
| true |
ba738831d11597ee752ec80eb01f0a72b2857222 | SQL | Afrostream/afrostream-api-stats | /sql/issue-#0-build.sql | UTF-8 | 2,666 | 3.4375 | 3 | [] | no_license | -- db structure
CREATE DATABASE cdnselector;
-- custom types
CREATE TYPE event_types AS ENUM
('bandwidthIncrease',
'bandwidthDecrease',
'error',
'buffering',
'start',
'stop');
-- ALTER TYPE event_types OWNER TO postgres;
CREATE TYPE uri_scheme AS ENUM
('http',
'https');
-- ALTER TYPE uri_scheme OWNER TO postgres;
-- drop table event; drop table event_bandwidth; drop table event_error; drop table event_start; drop table event_stop;
-- table
CREATE TABLE event
(
id bigserial NOT NULL,
user_id integer NOT NULL,
ip cidr NOT NULL,
fqdn character varying(255) NOT NULL,
type event_types NOT NULL,
country character(2) NOT NULL,
asn integer NOT NULL,
date timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT event_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
-- ALTER TABLE event OWNER TO postgres;
CREATE TABLE event_bandwidth
(
id bigserial NOT NULL,
event_id bigint NOT NULL,
video_bitrate integer NOT NULL,
audio_bitrate integer NOT NULL,
CONSTRAINT event_bandwidth_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
-- ALTER TABLE event_bandwidth OWNER TO postgres;
CREATE TABLE event_error
(
id bigserial NOT NULL,
event_id bigint NOT NULL,
number smallint NOT NULL,
message character varying(2048) NOT NULL,
CONSTRAINT event_error_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
-- ALTER TABLE event_error OWNER TO postgres;
CREATE TABLE event_start
(
id bigserial NOT NULL,
event_id bigint NOT NULL,
os character varying(256) NOT NULL DEFAULT ''::character varying,
os_version character varying(64) NOT NULL DEFAULT ''::character varying,
web_browser character varying(256) NOT NULL DEFAULT ''::character varying,
web_browser_version character varying(64) NOT NULL DEFAULT ''::character varying,
user_agent character varying(255) NOT NULL DEFAULT ''::character varying,
resolution_size character varying(32) NOT NULL DEFAULT ''::character varying,
flash_version character varying(32) NOT NULL DEFAULT ''::character varying,
html5_video boolean NOT NULL DEFAULT false,
relative_url character varying(255) NOT NULL,
protocol uri_scheme NOT NULL DEFAULT 'https'::uri_scheme,
video_bitrate integer NOT NULL default 0,
audio_bitrate integer NOT NULL default 0,
CONSTRAINT event_start_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
-- ALTER TABLE event_start OWNER TO postgres;
CREATE TABLE event_stop
(
id bigserial NOT NULL,
event_id bigint NOT NULL,
timeout boolean NOT NULL DEFAULT false,
frames_dropped integer NOT NULL DEFAULT 0,
CONSTRAINT event_stop_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
-- ALTER TABLE event_stop OWNER TO postgres; | true |
3c7a98e86d243b677008e9e42483929927a1d93b | SQL | troazz/nodejs_simple_api | /database.sql | UTF-8 | 5,156 | 3.03125 | 3 | [] | no_license | SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for categories
-- ----------------------------
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`description` text,
`parent` int(11) DEFAULT NULL,
`createdAt` datetime DEFAULT NULL,
`updatedAt` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `parent` (`parent`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of categories
-- ----------------------------
INSERT INTO `categories` VALUES ('1', 'Komputer & Laptop', 'List semua komputer dan laptop', '0', '2016-03-22 13:34:50', '2016-03-22 13:34:50');
INSERT INTO `categories` VALUES ('2', 'Komputer', 'List semua tipe komputer', '1', '2016-03-22 13:36:13', '2016-03-22 13:36:13');
INSERT INTO `categories` VALUES ('3', 'Laptop', 'List semua tipe laptop', '1', '2016-03-22 13:36:21', '2016-03-22 13:36:21');
INSERT INTO `categories` VALUES ('4', 'All in One', 'Paket PC lengkap', '2', '2016-03-22 13:36:53', '2016-03-22 13:36:53');
INSERT INTO `categories` VALUES ('5', 'Desktop + Monitor', 'Paket PC dan Monitor', '2', '2016-03-22 13:37:25', '2016-03-22 13:37:25');
INSERT INTO `categories` VALUES ('6', 'Desktop', 'Paket CPU', '2', '2016-03-22 13:37:35', '2016-03-22 13:37:35');
INSERT INTO `categories` VALUES ('7', 'Laptop Gaming', 'Laptop untuk kebutuhan gaming', '3', '2016-03-22 13:37:53', '2016-03-22 13:45:09');
INSERT INTO `categories` VALUES ('8', 'Laptop Multimedia', 'Laptop untuk kebutuhan multimedia', '3', '2016-03-22 13:38:06', '2016-03-22 13:38:06');
INSERT INTO `categories` VALUES ('9', 'Ultrabook', 'Laptop yang mengedepankan mobilitas', '3', '2016-03-22 13:38:36', '2016-03-22 13:38:36');
INSERT INTO `categories` VALUES ('10', 'Laptop Bisnis', 'Laptop yang digunakan untuk bisnis', '3', '2016-03-22 13:38:54', '2016-03-22 13:38:54');
INSERT INTO `categories` VALUES ('11', 'Tablet & Smartphone', 'List dari table ataupun smartphone', '0', '2016-03-22 13:41:45', '2016-03-22 13:41:45');
INSERT INTO `categories` VALUES ('12', 'Android', 'List dari table ataupun smartphone yang ber OS Android', '11', '2016-03-22 13:42:00', '2016-03-22 13:42:00');
INSERT INTO `categories` VALUES ('13', 'IOS', 'List dari table ataupun smartphone yang ber OS IOS', '11', '2016-03-22 13:42:09', '2016-03-22 13:42:09');
INSERT INTO `categories` VALUES ('14', 'Windows Phone', 'List dari table ataupun smartphone yang ber OS Windows', '11', '2016-03-22 13:42:21', '2016-03-22 13:42:21');
-- ----------------------------
-- Table structure for products
-- ----------------------------
DROP TABLE IF EXISTS `products`;
CREATE TABLE `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`description` text,
`category_id` int(11) DEFAULT NULL,
`stock` int(11) DEFAULT NULL,
`cost` double DEFAULT NULL,
`price` double(255,0) DEFAULT NULL,
`createdAt` datetime DEFAULT NULL,
`updatedAt` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `category_id` (`category_id`),
CONSTRAINT `products_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records of products
-- ----------------------------
INSERT INTO `products` VALUES ('1', 'ASUS ROG GL552VX-DM044T-BTO03 Black', 'Intel Core i7 6700HQ-2.6Ghz Turbo 3.5Ghz, RAM 8GB DDR4, HDD 512GB SSD (SuperFast & AntiShock), DVD/RW, VGA nVidia GTX950-2GB up to 6GB, Screen 15.6” FHD, Windows 10', '7', '10', '12499000', '14499000', '2016-03-22 15:14:43', '2016-03-22 15:14:43');
INSERT INTO `products` VALUES ('2', 'LENOVO IdeaPad Y50-70-4710HQ Black', 'Intel Core i7 4710HQ-2.5Ghz Turbo 3.5Ghz, RAM 8GB, HDD 1TB, VGA nVidia GTX860M-4GB, Screen 15.6\" FHD , Windows 8.1 (FREE upgrade Windows 10)', '7', '3', '9299000', '10899000', '2016-03-22 15:16:10', '2016-03-22 15:47:20');
INSERT INTO `products` VALUES ('3', 'HP Envy 13-6200U-8GB Silver', 'Intel Core i5 6200U-2.3Ghz Turbo 2.8Ghz, RAM 8GB, HDD 128GB SSD, VGA Intel HD 520 Graphics, Screen 13\" FHD, Windows 10', '9', '5', '9299000', '10899000', '2016-03-22 15:35:23', '2016-03-22 15:35:48');
INSERT INTO `products` VALUES ('4', 'APPLE iPad Mini 4 Retina Wifi Cellular 128GB - Silver', 'Apple A8 DualCore-1.5Ghz, RAM 2GB, Storage 128GB, Cam (F) 1.2MP, (B)8MP, GSM, WiFi, BT, Display 7.9\", Battery 5100 mAh, iOS 9', '13', '5', '9099000', '10199000', '2016-03-22 15:47:30', '2016-03-22 15:47:30');
INSERT INTO `products` VALUES ('5', 'APPLE iPhone 5S 32GB Grey', 'DualCore A7 - 1.3Ghz, RAM 1GB, Storage 32GB, Cam (F)1.2MP, (B)8.0MP, UMTS/HSDPA/GSM/EDGE, Wi-Fi, BT 4.0, A-GPS, 4\", iOS 7', '13', '30', '3000000', '3500000', '2016-03-22 15:49:00', '2016-03-22 15:49:00');
INSERT INTO `products` VALUES ('6', 'APPLE iPhone 4-32GB White - Refurbished Grade A', 'Cortex A8-1Ghz, RAM 512MB, Storage 32GB, Cam (F)VGA, (B)5.0MP, GSM, Wifi, Bluetooth, Layar 3.5\", Battery 1420 mAh, iOS 4 upgradable to iOS 7', '13', '100', '1100000', '1450000', '2016-03-22 15:49:36', '2016-03-22 15:49:36');
| true |
c6c19a39d756d8d49bef0d0cd89c337d12df0e6e | SQL | chelunike/Clase2111DAWM | /BD/Examenes/Examen2/Jose Luis Montes Ramon .sql | ISO-8859-1 | 1,826 | 3.796875 | 4 | [
"MIT"
] | permissive |
--Actividad 1
--Actividad 2
create database BDA2Donantes
use BDADonantes
create table persona(
idper int identity(1,1) primary key,
nombre varchar(40)
)
insert into persona
values --('David Castro'),
('Juan Lopez'),
('Elena Ruiz'),
('Jesus Sanchez'),
('Ana Fernandez'),
('Luis Bueno'),
('Miguel Cara'),
('Dolores Dumas')
create table libro(
nombre varchar(40) primary key,
donadoPor int references persona
)
insert into libro
values ('Biblia',1),
('Corn',2),
('Buscon',3),
('Lazarillo',5),
('Celestina',4),
('Yerma',6),
('Crepsculo',8),
('Amanece',null)
select * from persona
--2.a , 2.b
--2.c
select idper, nombre,
(select COUNT(donadoPor) from libro where externa.idper = donadoPor)
from persona as externa
where idper in (select donadoPor from libro)
-- 2.d
select idper, nombre from persona
where not idper in (select donadoPor from libro)
-- Actividad 3
create database BDA3Prestamos
use BDA3Prestamos
--3.a 3.b
--3.c
create table persona(
idper int identity(1,1) primary key,
nombre varchar(40)
)
create table libro(
nombre varchar(40) primary key,
donadoPor int references persona
)
create table prestamo(
nombreLibro varchar(40) references libro(nombre),
prestadoA int references persona(idper),
fechaPresta date
)
-- 3.d
insert into persona
values ('Gloria Fuertes'),
--('David Castro'),
('Juan Lopez'),
('Elena Ruiz'),
('Jesus Sanchez'),
('Ana Fernandez'),
('Luis Bueno'),
('Miguel Cara'),
('Dolores Dumas')
insert into libro
values ('Biblia',1),
('Corn',2),
('Buscon',3),
('Lazarillo',4),
('Celestina',4),
('Yerma',6),
('Crepsculo',8),
('Amanece',null)
insert into prestamo
values ('Biblia',1,'13-1-2010'),
('Biblia',1,'13-2-2011'),
('Biblia',1,'1-5-2011'),
('Biblia',1,'3-9-2012'),
('Biblia',1,'22-1-2009'),
('Biblia',1,'25-1-2009'),
('Biblia',1,'28-1-2010'),
('Biblia',1,'1-1-2011')
--3.e
| true |
9aa8dabfc90b47d24ec8c9f161021af16a3fe38e | SQL | unica-open/siacdbimpl | /src/plsql/function/execute_fnc_siac_valorizza_tbe_movSpesa.sql | UTF-8 | 10,383 | 3.171875 | 3 | [] | no_license | /*
*SPDX-FileCopyrightText: Copyright 2020 | CSI Piemonte
*SPDX-License-Identifier: EUPL-1.2
*/
select * from fnc_siac_valorizza_tbe_movSpesa(18,'batch_tbe','N')
select * from log_fnc_siac_valorizza_tbe_movSpesa where ente_proprietario_id = 18
-- elenco movimenti di USCITA da aggiornare
select * from siac_d_movgest_tipo where movgest_tipo_code = 'I' and ente_proprietario_id=18
-- 5 regione
Select ts.movgest_ts_id,elem.elem_id, m.movgest_id, tsTipo.movgest_ts_tipo_code
from siac_t_movgest m,siac_t_movgest_ts ts, siac_r_movgest_bil_elem elem
, siac_d_movgest_ts_tipo tsTipo
where m.ente_proprietario_id=18
and m.movgest_tipo_id = 32
and m.movgest_id=elem.movgest_id
and elem.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',elem.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',elem.validita_fine)
or elem.validita_fine is null)
and ts.movgest_id=m.movgest_id
and tstipo.movgest_ts_tipo_id=ts.movgest_ts_tipo_id
order by m.movgest_id, tsTipo.movgest_ts_tipo_code desc
--482
-- elenco dei classificatori definiti per accertamenti
select r.movgest_ts_id,d.classif_tipo_code, c.classif_code, c.classif_desc, r.login_operazione
from siac_r_movgest_class r, siac_t_class c, siac_d_class_tipo d, siac_d_movgest_tipo tipo, siac_t_movgest_ts ts, siac_t_movgest t
where r.ente_proprietario_id=18
and r.classif_id = c.classif_id
and c.classif_tipo_id = d.classif_tipo_id
and d.classif_tipo_code in ('PDC_V','GRUPPO_COFOG','TRANSAZIONE_UE_SPESA','SIOPE_SPESA_I','RICORRENTE_SPESA','PERIMETRO_SANITARIO_SPESA','POLITICHE_REGIONALI_UNITARIE')
and r.data_cancellazione is null
--and r.movgest_ts_id=45327
and ts.movgest_ts_id = r.movgest_ts_id
and t.movgest_id=ts.movgest_id
and t.movgest_tipo_id=tipo.movgest_tipo_id
and tipo.movgest_tipo_code='I'
order by r.movgest_ts_id, d.classif_tipo_code
--371
-- dopo fnc 1817
select r.movgest_ts_id, count(*)
from siac_r_movgest_class r, siac_t_class c, siac_d_class_tipo d, siac_d_movgest_tipo tipo, siac_t_movgest_ts ts, siac_t_movgest t
where r.ente_proprietario_id=18
and r.classif_id = c.classif_id
and c.classif_tipo_id = d.classif_tipo_id
and d.classif_tipo_code in ('PDC_V','GRUPPO_COFOG','TRANSAZIONE_UE_SPESA','SIOPE_SPESA_I','RICORRENTE_SPESA','PERIMETRO_SANITARIO_SPESA','POLITICHE_REGIONALI_UNITARIE')
and r.data_cancellazione is null
--and r.movgest_ts_id=45327
and ts.movgest_ts_id = r.movgest_ts_id
and t.movgest_id=ts.movgest_id
and t.movgest_tipo_id=tipo.movgest_tipo_id
and tipo.movgest_tipo_code='I'
group by r.movgest_ts_id
having count(*)>3
-- classificatori per movimento e capitolo (in join) (solo i validi)
select tipoClass.classif_tipo_code,
c.classif_id idXmov, c.classif_code codeXmov, c.classif_desc descXmov,r.login_operazione,r.movgest_classif_id,
c1.classif_id idXcap, c1.classif_code codeXcap, c1.classif_desc descXcap, r1.login_operazione, r1.elem_classif_id
from
siac_t_movgest_ts ts, siac_r_movgest_bil_elem cap,
siac_r_movgest_class r, siac_t_class c
, siac_r_bil_elem_class r1, siac_t_class c1
, siac_d_class_tipo tipoClass
where ts.movgest_ts_id=45668
and r.movgest_ts_id= ts.movgest_ts_id
and r.classif_id = c.classif_id
and c.classif_tipo_id=tipoClass.classif_tipo_id
and r.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',r.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',r.validita_fine)
or r.validita_fine is null)
and c.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',c.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',c.validita_fine)
or c.validita_fine is null)
and ts.movgest_id=cap.movgest_id
and r1.elem_id = cap.elem_id
and r1.classif_id = c1.classif_id
and c1.classif_tipo_id=tipoClass.classif_tipo_id
and r1.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',r1.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',r1.validita_fine)
or r1.validita_fine is null)
and c1.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',c1.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',c1.validita_fine)
or c1.validita_fine is null)
and
(tipoClass.classif_tipo_code = 'PDC_V'
or tipoClass.classif_tipo_code = 'GRUPPO_COFOG'
or tipoClass.classif_tipo_code = 'TRANSAZIONE_UE_SPESA'
or tipoClass.classif_tipo_code = 'SIOPE_SPESA_I'
or tipoClass.classif_tipo_code = 'RICORRENTE_SPESA'
or tipoClass.classif_tipo_code = 'PERIMETRO_SANITARIO_SPESA'
or tipoClass.classif_tipo_code = 'POLITICHE_REGIONALI_UNITARIE'
)
and tipoClass.ente_proprietario_id=18
and tipoClass.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',tipoClass.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',tipoClass.validita_fine)
or tipoClass.validita_fine is null);
-- classificatori per movgest_ts (solo i validi)
select tipoClass.classif_tipo_code, r1.classif_id idXmov, c1.classif_code codeXmov, c1.classif_desc descXliq, r1.login_operazione
from
siac_r_movgest_class r1, siac_t_class c1
, siac_d_class_tipo tipoClass
where r1.movgest_ts_id=9192
and r1.classif_id = c1.classif_id
and c1.classif_tipo_id=tipoClass.classif_tipo_id
and r1.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',r1.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',r1.validita_fine)
or r1.validita_fine is null)
and c1.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',c1.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',c1.validita_fine)
or c1.validita_fine is null)
and
(tipoClass.classif_tipo_code = 'PDC_V'
or tipoClass.classif_tipo_code = 'GRUPPO_COFOG'
or tipoClass.classif_tipo_code = 'TRANSAZIONE_UE_SPESA'
or tipoClass.classif_tipo_code = 'SIOPE_SPESA_I'
or tipoClass.classif_tipo_code = 'RICORRENTE_SPESA'
or tipoClass.classif_tipo_code = 'PERIMETRO_SANITARIO_SPESA'
or tipoClass.classif_tipo_code = 'POLITICHE_REGIONALI_UNITARIE'
)
and tipoClass.ente_proprietario_id=2
and tipoClass.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',tipoClass.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',tipoClass.validita_fine)
or tipoClass.validita_fine is null);
-- classificatori per capitolo legato al movimento ts (solo i validi)
select tipoClass.classif_tipo_code, r1.classif_id idXcap, c1.classif_code codeXcap, c1.classif_desc descXcap
from
siac_T_movgest_ts ts,siac_r_movgest_bil_elem cap, siac_r_bil_elem_class r1
, siac_t_class c1, siac_d_class_tipo tipoClass
where ts.movgest_ts_id=9192
and ts.movgest_id=cap.movgest_id
and r1.elem_id=cap.elem_id
and r1.classif_id = c1.classif_id
and c1.classif_tipo_id=tipoClass.classif_tipo_id
and r1.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',r1.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',r1.validita_fine)
or r1.validita_fine is null)
and c1.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',c1.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',c1.validita_fine)
or c1.validita_fine is null)
and
(tipoClass.classif_tipo_code = 'PDC_V'
or tipoClass.classif_tipo_code = 'GRUPPO_COFOG'
or tipoClass.classif_tipo_code = 'TRANSAZIONE_UE_SPESA'
or tipoClass.classif_tipo_code = 'SIOPE_SPESA_I'
or tipoClass.classif_tipo_code = 'RICORRENTE_SPESA'
or tipoClass.classif_tipo_code = 'PERIMETRO_SANITARIO_SPESA'
or tipoClass.classif_tipo_code = 'POLITICHE_REGIONALI_UNITARIE'
)
and tipoClass.ente_proprietario_id=2
and tipoClass.data_cancellazione is null and
date_trunc('day',now())>=date_trunc('day',tipoClass.validita_inizio) and
(date_trunc('day',now())<=date_trunc('day',tipoClass.validita_fine)
or tipoClass.validita_fine is null);
-- classificatori per movimento ts (tutti anche quelli non piu validi)
select tipo.classif_tipo_code, c.classif_code, c.classif_desc, r.validita_inizio, r.validita_fine, r.data_cancellazione, r.login_operazione
from siac_r_movgest_class r, siac_t_class c, siac_d_class_tipo tipo
where r.movgest_ts_id = 9192
and r.classif_id=c.classif_id
and c.classif_tipo_id=tipo.classif_tipo_id
and tipo.classif_tipo_code in
('PDC_V','GRUPPO_COFOG','TRANSAZIONE_UE_SPESA','SIOPE_SPESA_I','RICORRENTE_SPESA','PERIMETRO_SANITARIO_SPESA','POLITICHE_REGIONALI_UNITARIE')
order by tipo.classif_tipo_code, r.validita_inizio,r.validita_fine
-- capitoli senza SIOPE DEFINITO
select * from siac_t_bil_elem elem, siac_d_bil_elem_tipo tipo
where elem.ente_proprietario_id=18
and tipo.elem_tipo_code in ('CAP-UP', 'CAP-UG')
and elem.elem_tipo_id=tipo.elem_tipo_id
and not exists (select 1 from siac_r_bil_elem_class r, siac_t_class c, siac_d_class_tipo tipo
where r.elem_id=elem.elem_id
and r.classif_id=c.classif_id
and c.classif_tipo_id=tipo.classif_tipo_id
and tipo.classif_tipo_code = 'SIOPE_SPESA_I')
--273
-- count(*) dei capitoli
select * from siac_t_bil_elem elem, siac_d_bil_elem_tipo tipo
where elem.ente_proprietario_id=18
and tipo.elem_tipo_code in ('CAP-UP', 'CAP-UG')
and elem.elem_tipo_id=tipo.elem_tipo_id
--640
select * from siac_r_migr_capitolo_entrata_bil_elem where elem_id = 21991
select * from siac_r_migr_capitolo_uscita_bil_elem where elem_id = 21388
select * from migr_capitolo_uscita_scarto where migr_capusc_id = 13691
-- 11.01.2016
--caso di prova:
--elem_id = 4166
--movgest = 9157
--movgest_ts = 9192
--liq_id 53
select d.elem_tipo_code, b.* from siac_t_bil_elem b, siac_d_bil_elem_tipo d
where b.elem_id = 4166
and d.elem_tipo_id=b.elem_tipo_id | true |
b1651b6416ed1b82591d1270430dc48eae6e95ab | SQL | ZucchiniZe/til | /src/clj/til/db/sql/tils.sql | UTF-8 | 863 | 4.375 | 4 | [] | no_license | -- :name create-tils-table :! :raw
-- :doc create the table for the tils
CREATE TABLE IF NOT EXISTS tils (
id serial PRIMARY KEY,
title varchar(100),
body varchar(2000),
tags text,
user_id integer,
created_at timestamp,
FOREIGN KEY(user_id) REFERENCES users (id)
);
-- :name create-sql :! :n
-- :doc insert one til into the database
INSERT INTO tils (title, body, tags, user_id, created_at)
VALUES (:title, :body, :tags, :user_id, current_timestamp)
-- :name get-by-id :? :1
-- :doc gets a til by it's id
SELECT * FROM tils WHERE id = :id;
-- :name get-20-recent :? :*
-- :doc gets all of the tils
SELECT * FROM tils ORDER BY created_at DESC LIMIT 20;
-- :name all :? :*
-- :doc gets all of the tils
SELECT * FROM tils;
-- :name get-count :? :*
-- :doc gets the total count of tils
SELECT count(*) FROM tils;
| true |
dab50802d48df767b1cb432451fa477a7d62f088 | SQL | jmarcelletti/jazzhands | /database/ddl/views/create_v_limited_users.sql | UTF-8 | 2,760 | 3.390625 | 3 | [] | no_license | -- Copyright (c) 2005-2010, Vonage Holdings Corp.
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- THIS SOFTWARE IS PROVIDED BY VONAGE HOLDINGS CORP. ''AS IS'' AND ANY
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL VONAGE HOLDINGS CORP. BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
--
-- $Id$
--
-- This was for gsievers, so he could query data directly, versus using web tools, due to vision issues/ease of use
CREATE OR REPLACE VIEW v_limited_users (account_id,
external_hr_id,
payroll_id,
login,
first_name,
middle_name,
last_name,
name_suffix,
preferred_first_name,
preferred_last_name,
account_status,
account_type,
employee_id,
position_title,
person_company_id,
person_company_code,
person_company_name,
badge_id,
gender,
hire_date,
termination_date,
dept_id,
dept_code,
cost_center,
dept_company_id,
dept_company_code,
dept_company_name,
reporting_type,
dept_name,
dept_start_date,
dept_finish_date,
dn_name,
manager_account_id
)
AS
SELECT SYSTEM_USER_ID, EXTERNAL_HR_ID, PAYROLL_ID, LOGIN,
FIRST_NAME,
MIDDLE_NAME, LAST_NAME, NAME_SUFFIX, PREFERRED_FIRST_NAME,
PREFERRED_LAST_NAME, SYSTEM_USER_STATUS, SYSTEM_USER_TYPE,
EMPLOYEE_ID, POSITION_TITLE, PERSON_COMPANY_ID,
PERSON_COMPANY_CODE, PERSON_COMPANY_NAME, BADGE_ID, GENDER,
HIRE_DATE, TERMINATION_DATE, DEPT_ID, DEPT_CODE,
COST_CENTER, DEPT_COMPANY_ID, DEPT_COMPANY_CODE,
DEPT_COMPANY_NAME, REPORTING_TYPE, DEPT_NAME,
DEPT_START_DATE, DEPT_FINISH_DATE, DN_NAME,
MANAGER_SYSTEM_USER_ID
FROM v_account
WHERE account_type IN ('employee', 'contractor', 'vendor');
-- GRANT SELECT ON V_LIMITED_USERS TO RO_ROLE;
| true |
9426bc1e3bc5a8af336e943440e259338a35473d | SQL | igorsitdikov/senla-courses | /task-10/task-1/queries.sql | UTF-8 | 4,659 | 4.21875 | 4 | [] | no_license | -- task 1
SELECT model, speed, hd
FROM pc
WHERE price < 500;
-- task 2
SELECT DISTINCT maker
FROM product
WHERE type = 'Printer';
-- task 3
SELECT model, ram, screen
FROM laptop
WHERE price > 1000;
-- task 4
SELECT code, model, color, type, price
FROM printer
WHERE color = 'y';
-- task 5
SELECT model, speed, ram
FROM pc
WHERE cd IN ('12x', '24x')
AND price < 600;
-- task 6
SELECT DISTINCT maker, speed
FROM laptop
JOIN product AS p
ON p.model = laptop.model
WHERE hd >= 100;
-- task 7
SELECT pc.model, price
FROM pc
JOIN product p
ON p.model = pc.model
WHERE maker = 'B'
UNION
SELECT l.model, price
FROM laptop AS l
JOIN product AS p
ON p.model = l.model
WHERE maker = 'B'
UNION
SELECT pr.model, price
FROM printer pr
JOIN product p
ON p.model = pr.model
WHERE maker = 'B';
-- task 8
SELECT DISTINCT maker
FROM product
WHERE type = 'PC'
AND maker NOT IN
(SELECT maker
FROM product
WHERE type = 'Laptop');
-- task 9
SELECT DISTINCT maker
FROM product AS p
JOIN pc
ON pc.model = p.model
WHERE type = 'PC'
AND speed >= 450;
-- task 10
SELECT model, price
FROM printer
WHERE price = (
SELECT MAX(price)
FROM printer);
-- task 11
SELECT AVG(speed) AS avg_speed
FROM pc;
-- task 12
SELECT AVG(speed) AS avg_speed
FROM laptop
WHERE price > 1000;
-- task 13
SELECT AVG(speed) AS avg_speed
FROM pc
JOIN product p
ON pc.model = p.model
WHERE maker = 'A';
-- task 14
SELECT speed, AVG(price)
FROM pc
GROUP BY speed;
-- task 15
SELECT hd
FROM pc
GROUP BY hd
HAVING COUNT(model) >= 2;
-- task 16
SELECT DISTINCT A.model AS model_1, B.model AS model_2, A.speed, A.ram
FROM pc AS A, pc B
WHERE A.speed = B.speed
AND A.ram = B.ram
AND A.model > B.model;
-- task 17
SELECT DISTINCT type, laptop.model, laptop.speed
FROM product, laptop
WHERE type = 'Laptop'
AND laptop.speed < ALL (
SELECT pc.speed
FROM pc);
-- task 18
SELECT DISTINCT maker, price
FROM product
JOIN printer
ON printer.model = product.model
WHERE printer.price = (
SELECT MIN(printer.price)
FROM printer
WHERE printer.color = 'y')
AND printer.color = 'y';
-- task 19
SELECT maker, AVG(screen)
FROM product
JOIN laptop
ON laptop.model = product.model
GROUP BY maker;
-- task 20
SELECT maker, COUNT(model)
FROM product
WHERE type = 'PC'
GROUP BY product.maker
HAVING COUNT(DISTINCT model) >= 3;
-- task 21
SELECT DISTINCT maker, MAX(pc.price)
FROM product
JOIN pc
ON pc.model = product.model
GROUP BY maker;
-- task 22
SELECT speed, AVG(price)
FROM pc
WHERE speed > 600
GROUP BY speed;
--task 23
SELECT p.maker
FROM product AS p
JOIN laptop AS l
ON l.model = p.model
AND l.speed >= 750
WHERE p.maker IN (
SELECT maker
FROM product AS p
JOIN pc
ON pc.model = p.model
AND pc.speed >= 750
GROUP BY maker)
GROUP BY p.maker;
--task 24
SELECT p1.model
FROM product AS p1
JOIN (
SELECT model, price
FROM laptop
UNION
SELECT model, price
FROM pc
UNION
SELECT model, price
FROM printer
) AS p2
ON p1.model = p2.model
WHERE p2.price = (
SELECT MAX(p.price)
FROM (
SELECT MAX(p2.price) AS price
FROM product AS p1
JOIN pc p2
ON p2.model = p1.model
UNION
SELECT MAX(p2.price) AS price
FROM product AS p1
JOIN laptop p2
ON p2.model = p1.model
UNION
SELECT MAX(p2.price) AS price
FROM product AS p1
JOIN printer p2
ON p2.model = p1.model
) AS p)
GROUP BY p1.model;
--task 25
SELECT maker
FROM product AS p2
WHERE p2.type
LIKE 'Printer'
AND p2.maker IN
(SELECT p.maker
FROM product AS p
WHERE p.model IN
(SELECT pc.model
FROM pc
WHERE pc.speed = (
SELECT MAX(speed)
FROM pc
WHERE ram = (
SELECT MIN(ram)
FROM pc))
AND pc.ram = (
SELECT MIN(ram)
FROM pc)
GROUP BY pc.model)
GROUP BY maker)
GROUP BY maker
| true |
ddcdf8521d29fdab19925344f10b8cdcc85bf5c5 | SQL | santlalvishwakarma/RootBranch | /PortalBase/database/mysql/store_procedures/retail/modules/registerationpanel/sp_retail_register_user.sql | UTF-8 | 2,449 | 3.53125 | 4 | [] | no_license | DELIMITER $$
DROP PROCEDURE IF EXISTS sp_retail_register_user $$
CREATE PROCEDURE sp_retail_register_user(
IN p_login_name VARCHAR(100),
IN p_first_name VARCHAR(50),
IN p_last_name VARCHAR(50),
IN p_primary_email_id VARCHAR(100),
IN p_conditions_accepted TINYINT(1),
IN p_password VARCHAR(50),
IN p_primary_phone_no VARCHAR(50),
OUT p_error_code VARCHAR(25),
OUT p_error_message VARCHAR(255)
)
MODIFIES SQL DATA
DETERMINISTIC
BEGIN
DECLARE v_success_flag VARCHAR(1) ;
DECLARE v_error_message VARCHAR(100);
DECLARE v_row_count INT(4) DEFAULT 0;
DECLARE v_parameter_yes_id INT;
DECLARE v_user_id INT;
DECLARE v_billing_id INT;
DECLARE v_shipping_id INT;
INSERT INTO core_user_master(user_login, login_password, first_name, last_name, primary_email_id, primary_phone_number,
condition_accepted, newsletter_subscription, sms_alert_subscription,
is_admin, is_active, created_by, created_date, modified_by, modified_date)
VALUES(p_login_name, MD5(p_password), p_first_name, p_last_name, p_primary_email_id, p_primary_phone_no,
p_conditions_accepted, 0, 0, 0, 1, 'system', NOW(), 'system', NOW());
SELECT last_insert_id() INTO v_user_id;
IF v_user_id IS NOT NULL THEN
INSERT INTO core_users_roles_mapping(users_roles_mapping_id, user_id, role_id, created_by, created_date, modified_by, modified_date)
VALUES(NULL, v_user_id, (SELECT role_id from core_role_master where role_code = 'RETAIL_USER'),
p_login_name, NOW(), p_login_name, NOW());
INSERT INTO core_billing_address(created_by, created_date, modified_by, modified_date)
VALUES(p_login_name, NOW(), p_login_name, NOW());
SELECT last_insert_id() INTO v_billing_id;
INSERT INTO core_shipping_address(created_by, created_date, modified_by, modified_date)
VALUES(p_login_name, NOW(), p_login_name, NOW());
SELECT last_insert_id() INTO v_shipping_id;
UPDATE core_user_master
SET billing_address_id = v_billing_id,
shipping_address_id = v_shipping_id
WHERE user_id = v_user_id;
END IF;
SELECT ROW_COUNT() INTO v_row_count;
IF v_user_id IS NOT NULL AND v_row_count != 0 THEN
SET p_error_code = NULL;
ELSE
SET p_error_code = 'User Registration Failed at insert';
SET p_error_message = 'Not able to create user';
END IF;
select v_user_id, p_error_code, p_error_message;
END $$
DELIMITER ;
| true |
886417df1860ccc33a879833b32db7180be308bc | SQL | grodak/SQL | /RHTPensionDeductionFile.sql | UTF-8 | 1,127 | 3.640625 | 4 | [] | no_license | SELECT cov.PEFROMDT, Trim(med.G7USEDF7) AS G7USEDF7, par.GPLAST, par.GPFIRST, par.GPMI, Trim(Left(cov.PECOVCAT,3)) AS COV1, Trim(Mid(cov.PECOVCAT,4,3)) AS COV2, Trim(Mid(cov.PECOVCAT,7,3)) AS COV3,
Trim(Mid(cov.PECOVCAT,10,3)) AS COV4, Trim(Left(cov.PEPLAN,20)) AS PLAN1, Trim(Mid(cov.PEPLAN,21,20)) AS PLAN2, Trim(Mid(cov.PEPLAN,41,20)) AS PLAN3,
Trim(Mid(cov.PEPLAN,61,20)) AS PLAN4, Left(cov.PEENRLEV,3) AS ENR1, Mid(cov.PEENRLEV,4,3) AS ENR2, Mid(cov.PEENRLEV,7,3) AS ENR3, Mid(cov.PEENRLEV,10,3) AS ENR4, Trim(med.G7USEDF1) AS SPOUSE, cov.PETODATE INTO RHTPayrDedFile
FROM (PARTICIP par INNER JOIN PARTCOVG cov ON (par.GPGROUP = cov.PEGROUP) AND (par.GPPARTIC = cov.PEPARTIC))
INNER JOIN PARTMEDC med ON (cov.PEPARTIC = med.G7PARTIC) AND (cov.PEGROUP = med.G7GROUP)
WHERE (((cov.PEFROMDT)<=Format(DateSerial(Year(Now()),Month(Now())+1,1),"yyyymmdd"))
AND ((cov.PETODATE)>=Format(DateSerial(Year(Now()),Month(Now())+1,1),"yyyymmdd"))
AND ((par.GPGROUP)="RHT")
AND ((Len(Trim(cov.PECOVCAT)))>0)
AND ((cov.PEGROUP)="RHT")
AND ((med.G7GROUP)="RHT")
AND ((par.GPDIV)<>"0501"))
ORDER BY cov.PETODATE DESC;
| true |
0941c21d9258854d3836bc422004d3f1b2f0aea2 | SQL | GoogleCloudParaProgramadores/TaskListDB | /tasks-table.sql | UTF-8 | 258 | 2.859375 | 3 | [] | no_license | CREATE TABLE `TASKS` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`TITLE` TEXT NULL,
`DESCRIPTION` TEXT NULL,
`STATUS` INT(11) NULL DEFAULT NULL,
`DATE` TEXT NULL,
PRIMARY KEY (`ID`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=1210
; | true |
58fc1d03d1a45ffc08839e1fe6a76439cd5b8e5d | SQL | Zeldorine/pfe_aqs | /sql/script_creation.sql | UTF-8 | 4,513 | 3.609375 | 4 | [] | no_license | ----------------------------------------- Suppression des tables et contraintes si existantes ---------------------------------------
DROP TABLE IF EXISTS Entreprise CASCADE;
DROP TABLE IF EXISTS Utilisateur CASCADE;
DROP TABLE IF EXISTS Audit CASCADE;
DROP TABLE IF EXISTS Formulaire CASCADE;
---------------------------------------------------------------------------------------------------------------------
------------------------------------------------ Creation des tables ------------------------------------------------
CREATE TABLE public.Entreprise (
id serial NOT NULL PRIMARY KEY,
nom VARCHAR(20) NOT NULL,
mission text NOT NULL,
dateCreation timestamp NOT NULL,
niveauApprobation smallint NOT NULL
);
CREATE TABLE public.Utilisateur (
id serial NOT NULL PRIMARY KEY,
nom_utilisateur varchar(100) NOT NULL,
nom varchar(100) NOT NULL,
prenom varchar(100) NOT NULL,
mot_de_passe text ,
courriel varchar(100) NOT NULL,
id_entreprise integer NOT NULL,
actif bool NOT NULL,
role smallint NOT NULL
);
CREATE TABLE public.Audit (
id serial NOT NULL PRIMARY KEY,
date timestamp NOT NULL,
audit_type integer NOT NULL,
utilisateur integer NOT NULL,
objet text NOT NULL
);
CREATE TABLE public.Formulaire (
id serial NOT NULL PRIMARY KEY,
nom varchar(100) NOT NULL,
date_creation timestamp NOT NULL,
version varchar(100) NOT NULL,
id_template integer NOT NULL,
contenu text NOT NULL,
createur integer NOT NULL,
approbation smallint NOT NULL
);
---------------------------------------------------------------------------------------------------------------------
----------------------------------------------------- FOREGIN KEY ---------------------------------------------------
ALTER TABLE public.Utilisateur ADD CONSTRAINT fk_id_entreprise
FOREIGN KEY (id_entreprise) REFERENCES public.Entreprise(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE public.Audit ADD CONSTRAINT fk_id_utilisateur
FOREIGN KEY (utilisateur) REFERENCES public.Utilisateur(id) ON UPDATE CASCADE ON DELETE CASCADE;
--------------------------------------------------- Creation index --------------------------------------------------
CREATE UNIQUE INDEX UK_FORMULAIRE ON public.Formulaire (id, version);
CREATE UNIQUE INDEX UK_NOM_UTILISATEUR ON public.Utilisateur (nom_utilisateur);
---------------------------------------------------------------------------------------------------------------------
--------------------------------------------------- Creation Contrainte ---------------------------------------------
ALTER TABLE public.Utilisateur ADD UNIQUE (courriel);
---------------------------------------------------------------------------------------------------------------------
--------------------------------------------------- SCHEMA TEST ---------------------------------------------
CREATE TABLE test.Entreprise (
id serial NOT NULL PRIMARY KEY,
nom VARCHAR(20) NOT NULL,
mission text NOT NULL,
dateCreation timestamp NOT NULL,
niveauApprobation smallint NOT NULL
);
CREATE TABLE test.Utilisateur (
id serial NOT NULL PRIMARY KEY,
nom_utilisateur varchar(100) NOT NULL,
nom varchar(100) NOT NULL,
prenom varchar(100) NOT NULL,
mot_de_passe text ,
courriel varchar(100) NOT NULL,
id_entreprise integer NOT NULL,
actif integer NOT NULL,
role smallint NOT NULL
);
CREATE TABLE test.Audit (
id serial NOT NULL PRIMARY KEY,
date timestamp NOT NULL,
audit_type integer NOT NULL,
utilisateur integer NOT NULL,
objet text NOT NULL
);
CREATE TABLE test.Formulaire (
id serial NOT NULL PRIMARY KEY,
nom varchar(100) NOT NULL,
date_creation timestamp NOT NULL,
version varchar(100) NOT NULL,
id_template integer NOT NULL,
contenu text NOT NULL,
createur integer NOT NULL,
approbation smallint NOT NULL
);
ALTER TABLE test.Utilisateur ADD CONSTRAINT fk_id_entreprise
FOREIGN KEY (id_entreprise) REFERENCES test.Entreprise(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE test.Audit ADD CONSTRAINT fk_id_utilisateur
FOREIGN KEY (utilisateur) REFERENCES test.Utilisateur(id) ON UPDATE CASCADE ON DELETE CASCADE;
CREATE UNIQUE INDEX UK_FORMULAIRE ON test.Formulaire (id, version);
CREATE UNIQUE INDEX UK_NOM_UTILISATEUR ON test.Utilisateur (nom_utilisateur);
ALTER TABLE test.Utilisateur ADD UNIQUE (courriel);
| true |
0783d03d259c3c6b803a4a834cca62159bdd1ee2 | SQL | gladieschanggoodluck/SQL-question-sets-and-query | /index/index.sql | UTF-8 | 532 | 4 | 4 | [] | no_license | ## index
## 100,000, 000 records
## no index
SELECT COUNT(*)
FROM person;
## create index
CREATE INDEX person_first_name_idx
ON person(first_name);
SELECT COUNT(*)
FROM person
WHERE first_name = 'Julia';
SELECT COUNT(*)
FROM person
WHERE last_name = 'Smith';
## multicolumn indexes
CREATE INDEX person_first_name_last_name_idx
ON person(last_name, first_name);
SELECT COUNT(*)
FROM person
WHERE last_name = "Juila"
AND first_name = "Andrew";
## Index is not free, use them wisely | true |
a4e86d442e7bdbd409d6636f852fdddc1b3308cf | SQL | emeraldjava/bhaa-zend | /sql/bhaa_racestandard.sql | UTF-8 | 6,371 | 4.1875 | 4 | [] | no_license |
DROP TABLE IF EXISTS `racestandard`;
CREATE TABLE IF NOT EXISTS `racestandard` (
`race` int(8) NOT NULL,
`standard` int(3) NOT NULL,
`runners` int(4) NOT NULL,
`expected` time NOT NULL,
`min` time NOT NULL,
`avg` time NOT NULL,
`max` time NOT NULL,
`std` double NOT NULL,
`diff` double NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- populate the standard data for a race
INSERT INTO racestandard(race,standard,runners,expected,min,avg,max,std,diff)
select
race.id as race,
rr.standard as standard,
count(rr.runner) as runners,
SEC_TO_TIME((oneKmTimeInSecs + (getRaceDistanceKM(race.distance,race.unit)*slopefactor))) as expected,
min(rr.paceKM) as min,
SEC_TO_TIME(avg(TIME_TO_SEC(rr.paceKM))) as avg,
max(rr.paceKM) as max,
STD(rr.paceKM) as std,
((oneKmTimeInSecs + (getRaceDistanceKM(race.distance,race.unit)*slopefactor)) - avg(TIME_TO_SEC(rr.paceKM))) as diff
from race as race
join raceresult rr on race.id=rr.race
join runner r on rr.runner=r.id
join standard sd on rr.standard = sd.standard
where rr.race > 1
group by rr.standard;
INSERT INTO racestandard(race,standard,runners,expected,min,avg,max,std,diff)
select
race.id as race,
rr.standard as standard,
count(rr.runner) as runners,
SEC_TO_TIME((oneKmTimeInSecs + (getRaceDistanceKM(race.distance,race.unit)*slopefactor))) as expected,
min(rr.paceKM) as min,
SEC_TO_TIME(avg(TIME_TO_SEC(rr.paceKM))) as avg,
max(rr.paceKM) as max,
STD(rr.paceKM) as std,
((oneKmTimeInSecs + (getRaceDistanceKM(race.distance,race.unit)*slopefactor)) - avg(TIME_TO_SEC(rr.paceKM))) as diff
from raceresult rr
left join race as race on race.id=rr.race
join runner r on rr.runner=r.id
join standard sd on rr.standard = sd.standard
where race.id=20102
group by rr.standard;
-- army 35, rte:34
select * from racestandard where race=20103;
-- compare individual race result to the race standarddata
select runner,rr.standard,paceKM,
(select expected from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as expected,
(select min from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as min,
(select avg from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as avg,
(select max from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as max,
(select std from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as std,
(TIME_TO_SEC(paceKM) -
TIME_TO_SEC((select avg from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard))) /
(select std from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) AS numdevs
from raceresult as rr
where rr.race=20101 and rr.standard is not null order by numdevs;
select runner,rr.standard,paceKM,
(select expected from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as expected,
(select min from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as min,
(select avg from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as avg,
(select max from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as max,
(select std from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) as std,
(TIME_TO_SEC(paceKM) -
TIME_TO_SEC((select avg from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard))) /
(select std from racestandard as rs where rs.race=rr.race and rs.standard=rr.standard) AS numdevs
from raceresult as rr
join standard as s where
where rr.race=35 and rr.standard is not null order by numdevs;
select
rr.runner, rr.standard, rr.position, rr.paceKM,
rs.expected, rs.min, rs.avg, rs.max,
TIME_TO_SEC(rr.paceKM)-TIME_TO_SEC(rs.avg) as diff,
rs.std,
(TIME_TO_SEC(rr.paceKM)-TIME_TO_SEC(rs.avg))/rs.std as numdev
from raceresult as rr
join racestandard as rs on rs.race=rr.race and rs.standard=rr.standard
where rr.race=35 order by numdev;
select race.id as race, r.standard, count(runner) as runners,
SEC_TO_TIME((oneKmTimeInSecs + (getRaceDistanceKM(race.distance,race.unit)*slopefactor))) as expected,
min(rr.paceKM) as minpacekm,
SEC_TO_TIME(avg(TIME_TO_SEC(rr.paceKM))) as avgpacekm,
max(rr.paceKM) as maxpacekm,
STD(rr.paceKM) as std,
((oneKmTimeInSecs + (getRaceDistanceKM(race.distance,race.unit)*slopefactor)) - avg(TIME_TO_SEC(rr.paceKM))) as diff
from raceresult rr
join race race on race.id=rr.race
join runner r on rr.runner=r.id
join standard sd on r.standard = sd.standard
where rr.race=17
group by r.standard order by numdevs;
select
r.standard,
max(rr.paceKM) as maxpacekm,
min(rr.paceKM) as minpacekm,
SEC_TO_TIME(avg(TIME_TO_SEC(rr.paceKM))) as avgpacekm,
fourMileTime as 4mTime,
(TIME_TO_SEC(fourMileTime)) as 4mPace,
SEC_TO_TIME(TIME_TO_SEC(fourMileTime)/(4*1.6)) as expectedpacekm
from raceresult rr
join runner r on rr.runner=r.id
join standarddata sd on r.standard = sd.standard
where rr.race=35 and r.standard > 0
group by r.standard;
select
r.standard,
max(rr.paceKM) as maxpacekm,
min(rr.paceKM) as minpacekm,
SEC_TO_TIME(avg(TIME_TO_SEC(rr.paceKM))) as avgpacekm,
SEC_TO_TIME(TIME_TO_SEC(fourMileTime)/(4*1.6)) as expectedpacekm
from raceresult rr
join runner r on rr.runner=r.id
join standarddata sd on r.standard = sd.standard
where rr.race=35 and r.standard > 0
group by r.standard;
select * from standarddata where standard=4;
select
standard,fourMileTime,slopeFactor,
SEC_TO_TIME( TIME_TO_SEC(fourMileTime)/(4*1.6) ) as pacePer1Km,
SEC_TO_TIME( TIME_TO_SEC(halfMarathonTime)/(13.1*1.6)) as pacePer21Km
from standarddata where standard=4;
select
r.standard,
min(rr.paceKM) as minpacekm,
SEC_TO_TIME(avg(TIME_TO_SEC(rr.paceKM))) as avgpacekm,
max(rr.paceKM) as maxpacekm,
SEC_TO_TIME(TIME_TO_SEC(fourMileTime)/(4*1.6)) as expectedpacekm,
SEC_TO_TIME(avg(TIME_TO_SEC(rr.paceKM))) - SEC_TO_TIME(TIME_TO_SEC(fourMileTime)/(4*1.6)) as diff
from raceresult rr
join runner r on rr.runner=r.id
join standarddata sd on r.standard = sd.standard
where rr.race=72 and r.standard > 0
group by r.standard;
select * from raceresult where race=72;
select standard from standard;
select count(runner) from raceresult where race=72 and standard=4;
describe tblMembership;
select * from tblMembership where MembNo=9946;
| true |
924af8abf1bdf87f11ee3fd425e89ad46a7e1f83 | SQL | meetyourmm/book-store | /src/main/resources/db/test.sql | UTF-8 | 1,980 | 3.265625 | 3 | [] | no_license | /*
Navicat Premium Data Transfer
Source Server : 192.168.1.128-vm
Source Server Type : MySQL
Source Server Version : 50719
Source Host : 192.168.1.128:3306
Source Schema : test
Target Server Type : MySQL
Target Server Version : 50719
File Encoding : 65001
Date: 27/02/2019 13:25:20
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for t_book
-- ----------------------------
DROP TABLE IF EXISTS `t_book`;
CREATE TABLE `t_book` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
`price` decimal(10, 2) NULL DEFAULT NULL COMMENT '价格',
`url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图片地址',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_book
-- ----------------------------
INSERT INTO `t_book` VALUES (1, 'java编程', 99.99, NULL);
INSERT INTO `t_book` VALUES (2, 'book', 10.00, NULL);
-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`account` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账号',
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '姓名',
`password` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码MD5',
`gender` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
| true |
a0b0f223a29296957b030966272be3cd4326245e | SQL | paux86/Databases | /FinalProject/sql/sp_customerBilled.sql | UTF-8 | 176 | 2.703125 | 3 | [] | no_license | use project;
DELIMITER //
create procedure customerBilled(IN inv_id int)
BEGIN
update customer_invoice set invoice_billed = now() where invoice_id = inv_id;
END //
DELIMITER ; | true |
4410aaebab64e67a8a2a997cbdc6c3a41517fbb1 | SQL | derMacon/workshop-organizer-docker | /spring-project/src/main/resources/schema.sql | UTF-8 | 1,782 | 3.765625 | 4 | [] | no_license | create table if not exists app_user
(
user_id serial primary key,
username varchar(500) unique not null,
password varchar(5000) not null,
role varchar(5000) not null
);
create table if not exists persistent_logins
(
username varchar(500) not null,
series varchar(64) primary key,
token varchar(64) not null,
last_used timestamp not null
);
create table if not exists person
(
person_id serial primary key,
firstname varchar(500) not null,
surname varchar(500) not null,
email varchar(500) not null,
user_id integer not null,
foreign key (user_id) references app_user (user_id)
);
create table if not exists course
(
course_id serial primary key,
host_id integer not null,
foreign key (host_id) references person(person_id),
course_name varchar(100) not null,
course_summary varchar(5000),
course_description varchar(5000),
max_participant_count integer
);
create table if not exists announcement
(
announcement_id serial primary key,
title varchar(100) not null,
content varchar(5000),
publishing_date date not null,
course_id integer not null,
foreign key (course_id) references course (course_id)
);
create table if not exists course_person
(
course_id integer not null,
person_id integer not null,
foreign key (course_id) references course(course_id),
foreign key (person_id) references person(person_id),
CONSTRAINT bill_product_pkey PRIMARY KEY (course_id, person_id)
);
create table if not exists meeting(
meeting_id serial primary key,
meeting_date date not null,
address varchar(100) not null,
course_id integer not null,
foreign key (course_id) references course(course_id)
);
| true |
7b47ca29776bca527c7f60dc9a507f213f4416ca | SQL | jfishy/Galleries-and-Gigs | /art.sql | UTF-8 | 1,877 | 2.6875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 02, 2016 at 12:20 PM
-- Server version: 5.5.24-log
-- PHP Version: 5.4.3
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 utf8 */;
--
-- Database: `josh fish`
--
-- --------------------------------------------------------
--
-- Table structure for table `art`
--
CREATE TABLE IF NOT EXISTS `art` (
`uname` varchar(20) NOT NULL,
`artwork` varchar(100) NOT NULL,
`pagepic` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `art`
--
INSERT INTO `art` (`uname`, `artwork`, `pagepic`) VALUES
('lulu', 'Shona-Sculpture_reference.jpg', ''),
('lulu', 'download.jpg', ''),
('lulu', 'gold-kate-moss-sculpture-sold-for-900k__oPt.jpg', ''),
('luke', '19001294a602335879473fb125a57f16.jpg', ''),
('luke', 'darth-red-hong-yi-starwars-shadows-640x360.jpg', ''),
('luke', 'download1.jpg', ''),
('oscar', 'download3.jpg', ''),
('Sasha', 'tumblr_mdpex5t4Uc1rv7uqoo1_500.jpg', ''),
('Sasha', 'download2.jpg', 'show'),
('damn', '5613167d010bb86dad56130c7ce39634.jpg', 'show'),
('lulu', 'Bronze+Horse+Sculpture+by+John+Maisano.jpg', 'show'),
('luke', 'star-wars-sculptures-01.jpg', 'show'),
('oscar', 'landscape_paintings_1.jpg', 'show'),
('josh ', 'soc.jpg', ''),
('josh', 'tides.mp3', 'nah'),
('josh', '7_years_lukas_graham.mp3', 'show'),
('josh', 'one_dance.mp3', 'nah'),
('josh', 'Desert.jpg', 'nah');
/*!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 |
c6f538d43bfb8c4ed68bfebb9e745d17e66821cf | SQL | George97/TotalizatorWebApp | /TotalizatorWebApp.Database/Scripts/INSERT.sql | UTF-8 | 2,153 | 2.71875 | 3 | [] | no_license |
INSERT INTO Leagues (Name) VALUES ('Premier League'),('Champions League')
INSERT INTO Stages (Name,MatchDay,LeagueId)
VALUES ('Round',34,1),('Quarter-Final',8,2),('Semi-Final',9,2),('Round',36,1);
INSERT INTO Teams (Name)
VALUES ('Chelsea FC'),('Tottenham Hotspur FC'),('Liverpool FC'),('Manchester City FC'),
('Manchester United FC'),('Everton FC'),('Arsenal FC'),('West Bromwich Albion FC'),
('Southampton FC'),('Watford FC'),('Stoke City FC'),('AFC Bournemouth'),('West Ham United FC'),
('Leicester City FC'),('Burnley FC'),('Crystal Palace FC'),('Hull City FC'),('Swansea City FC'),
('Middlesbrough FC'),('Sunderland AFC');
INSERT INTO Matches (HomeTeamID,GuestTeamID,Date,StageId)
VALUES (12,19,'2017-04-22 17:00',1),(17,10,'2017-04-22 17:00',1),(18,11,'2017-04-22 17:00',1),
(13,6,'2017-04-22 17:00',1),(15,5,'2017-04-23 16:15',1),(3,16,'2017-04-23 18:30',1),
(1,9,'2017-04-25 21:45',1),(7,20,'2017-05-16 21:45',1),(4,8,'2017-05-16 22:00',1),(14,2,'2017-05-18 21:45',1);
INSERT INTO Users (FullName,Login,Password,Points,Roles,isBanned)
VALUES ('Yura Maluga','admin','777',0,'Admin',0)
INSERT INTO Users (FullName,Login,Password,Points,isBanned)
VALUES ('Matsko Vova' , 'Nilan','1111',0,0),('Fai Vasia','lasaV','1111',0,0),('Peleh Bohdan','Batia','1111',0,0),
('Olia Solar','o_Soliar','1111',0,0),('Diana Kruskuw','DianaDiana','1111',0,0),('Vladik Bug','vladik','1111',0,0);
INSERT INTO Users (FullName,Login,Password,Points,isBanned)
VALUES ('Katia Fedak','k_Fedak','1111',0,0),('Nina Piatenko','n_5enko','1111',0,0)
INSERT INTO Teams (Name)
VALUES ('Real Madrid CF'),('Club Atlético de Madrid'),('AS Monaco FC'),('Juventus Turin'),('Leicester City FC'),('FC Bayern München'),
('FC Barcelona'),('Borussia Dortmund')
INSERT INTO Matches (HomeTeamID,GuestTeamID,Date,StageId)
VALUES (25,22,'2017-04-18 21:45',2),(21,26,'2017-04-18 21:45',2),
(27,24,'2017-04-19 21:45',2),(23,28,'2017-04-19 21:45',2),
(21,22,'2017-05-02 21:45',3),(23,24,'2017-05-03 21:45',3)
INSERT INTO Matches (HomeTeamID,GuestTeamID,Date,StageId)
VALUES (13,2,'2017-05-05 22:00',4),(4,16,'2017-05-06 14:30',4),(3,9,'2017-05-07 15:30',4),
(7,5,'2017-05-07 18:00',4)
| true |
f5ccddf50a523a8d041588a035613037bcf994aa | SQL | TakeActionNow/OSM | /Ronin/Database1/contact/Tables/contact_displayname_rel.sql | UTF-8 | 674 | 3.671875 | 4 | [] | no_license | CREATE TABLE [contact].[contact_displayname_rel] (
[contact_displayname_id] INT IDENTITY (1, 1) NOT NULL,
[contact_id] INT NOT NULL,
[displayname_id] INT NOT NULL,
[create_date] DATETIME NULL,
[modify_date] DATETIME NULL,
[delete_date] DATETIME NULL,
PRIMARY KEY CLUSTERED ([contact_displayname_id] ASC),
CONSTRAINT [FK_contact_displayname_rel_contact] FOREIGN KEY ([contact_id]) REFERENCES [contact].[contact] ([contact_id]),
CONSTRAINT [FK_contact_displayname_rel_displayname] FOREIGN KEY ([displayname_id]) REFERENCES [global].[displayname] ([displayname_id])
);
| true |
d9044b63794ef0545ef7fc96970b2e4df1e15448 | SQL | krishnamohankaruturi/secret | /aart-web-dependencies/db/ddl/388.sql | UTF-8 | 754 | 3.28125 | 3 | [] | no_license |
-- 388.sql
drop table testcutscores;
CREATE TABLE testcutscores
(
id bigserial NOT NULL,
schoolyear bigint NOT NULL,
assessmentprogram bigint NOT NULL,
subject bigint NOT NULL,
grade bigint NOT NULL,
testid1 bigint,
testid2 bigint,
level bigint not null,
levelLowCutScore character varying(100),
levelHighCutScore character varying(100),
batchuploadid bigint NOT NULL,
createddate timestamp with time zone NOT NULL DEFAULT now(),
createduser bigint,
activeflag boolean DEFAULT true,
CONSTRAINT testcutscores_id_fk PRIMARY KEY (id),
CONSTRAINT testcutscores_batchuploadid_fk FOREIGN KEY (batchuploadid)
REFERENCES batchupload (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
); | true |
42b68e29c51628a72dba2f1a317b3f7863792621 | SQL | lozanovictor/banco_imagens_2018 | /banco_imagens.sql | UTF-8 | 10,539 | 2.84375 | 3 | [] | no_license | psql -U ibm18g3 -h dcmshare.ffclrp.usp.br centroimg
2340
-- -----------------------------------------------------
-- Table Funcionario
-- -----------------------------------------------------
DROP TABLE IF EXISTS Funcionario CASCADE;
CREATE TABLE Funcionario (
idFuncionario INTEGER NOT NULL,
CPF VARCHAR(11) NOT NULL,
RG VARCHAR(9) NOT NULL,
nome VARCHAR(60) NOT NULL,
sexo VARCHAR(1) NOT NULL,
salário FLOAT NOT NULL,
dta_nascimento DATE NOT NULL,
cargo VARCHAR(45) NOT NULL,
Recepcionista_Funcionario_idFuncionario INTEGER NOT NULL,
PRIMARY KEY (idFuncionario));
-- -----------------------------------------------------
-- Table Recepcionista
-- -----------------------------------------------------
DROP TABLE IF EXISTS Recepcionista CASCADE;
CREATE TABLE Recepcionista (
departamento VARCHAR(60) NOT NULL,
Funcionario_idFuncionario INTEGER NOT NULL,
PRIMARY KEY (Funcionario_idFuncionario),
FOREIGN KEY (Funcionario_idFuncionario) REFERENCES Funcionario (idFuncionario));
--------------------------------------------------------
ALTER TABLE Funcionario
ADD FOREIGN KEY (Recepcionista_Funcionario_idFuncionario) REFERENCES Recepcionista (Funcionario_idFuncionario);
-- -----------------------------------------------------
-- Table Enfermeiro
-- -----------------------------------------------------
DROP TABLE IF EXISTS Enfermeiro ;
CREATE TABLE Enfermeiro (
departamento VARCHAR(60) NOT NULL,
Funcionario_idFuncionario INTEGER NOT NULL,
PRIMARY KEY (Funcionario_idFuncionario),
FOREIGN KEY (Funcionario_idFuncionario) REFERENCES Funcionario (idFuncionario));
-- -----------------------------------------------------
-- Table Medico
-- -----------------------------------------------------
DROP TABLE IF EXISTS Medico ;
CREATE TABLE Medico (
CRM VARCHAR(10) NOT NULL,
especialidade VARCHAR(45) NOT NULL,
Funcionario_idFuncionario INTEGER NOT NULL,
PRIMARY KEY (Funcionario_idFuncionario),
FOREIGN KEY (Funcionario_idFuncionario) REFERENCES Funcionario (idFuncionario));
-- -----------------------------------------------------
-- Table Tecnico
-- -----------------------------------------------------
DROP TABLE IF EXISTS Tecnico ;
CREATE TABLE Tecnico (
reg_Tecnico VARCHAR(10) NOT NULL,
Funcionario_idFuncionario INTEGER NOT NULL,
PRIMARY KEY (Funcionario_idFuncionario),
FOREIGN KEY (Funcionario_idFuncionario) REFERENCES Funcionario (idFuncionario));
-- -----------------------------------------------------
-- Table Paciente
-- -----------------------------------------------------
DROP TABLE IF EXISTS Paciente ;
CREATE TABLE Paciente (
idPaciente INTEGER NOT NULL,
CPF VARCHAR(11) NOT NULL,
RG VARCHAR(9) NOT NULL,
nome VARCHAR(60) NOT NULL,
sexo VARCHAR(1) NOT NULL,
status INTEGER NOT NULL,
dta_nascimento DATE NOT NULL,
Recepcionista_Funcionario_idFuncionario INTEGER NOT NULL,
Enfermeiro_Funcionario_idFuncionario INTEGER NOT NULL,
PRIMARY KEY (idPaciente),
FOREIGN KEY (Recepcionista_Funcionario_idFuncionario) REFERENCES Recepcionista (Funcionario_idFuncionario),
FOREIGN KEY (Enfermeiro_Funcionario_idFuncionario) REFERENCES Enfermeiro (Funcionario_idFuncionario)
);
-- -----------------------------------------------------
-- Table Clinica Conveniada
-- -----------------------------------------------------
DROP TABLE IF EXISTS Clinica_Conveniada ;
CREATE TABLE Clinica_Conveniada (
idClinica INTEGER NOT NULL,
codANS VARCHAR(20) NOT NULL,
nome VARCHAR(60) NOT NULL,
endereço VARCHAR(60) NOT NULL,
PRIMARY KEY (idClinica));
-- -----------------------------------------------------
-- Table Tipo Exame
-- -----------------------------------------------------
DROP TABLE IF EXISTS Tipo_Exame ;
CREATE TABLE Tipo_Exame (
idTipo_Exame INTEGER NOT NULL,
custo FLOAT NOT NULL,
material VARCHAR(60) NOT NULL,
tipo_maquina VARCHAR(50) NOT NULL,
PRIMARY KEY (idTipo Exame));
-- -----------------------------------------------------
-- Table Exame
-- -----------------------------------------------------
DROP TABLE IF EXISTS Exame ;
CREATE TABLE IF NOT EXISTS Exame (
seqExame INTEGER NOT NULL,
status INTEGER NOT NULL,
laudo VARCHAR(400) NOT NULL,
local VARCHAR(45) NOT NULL,
dta_exame DATE NOT NULL,
imagem BYTEA NOT NULL,
hora_exame TIME NOT NULL,
Paciente_idPaciente INTEGER NOT NULL,
Tipo_Exame_idTipo_Exame INTEGER NOT NULL,
Tecnico_Funcionario_idFuncionario INTEGER NOT NULL,
Clinica_Conveniada_idClinica INTEGER NOT NULL,
Medico_Funcionario_idFuncionario INTEGER NOT NULL,
orientação VARCHAR(45) NOT NULL,
PRIMARY KEY (seqExame, Paciente_idPaciente),
FOREIGN KEY (Paciente_idPaciente) REFERENCES Paciente (idPaciente),
FOREIGN KEY (Tipo_Exame_idTipo_Exame) REFERENCES Tipo_Exame (idTipo_Exame),
FOREIGN KEY (Tecnico_Funcionario_idFuncionario) REFERENCES Tecnico (Funcionario_idFuncionario),
FOREIGN KEY (Clinica_Conveniada_idClinica) REFERENCES Clinica_Conveniada (idClinica),
FOREIGN KEY (Medico_Funcionario_idFuncionario) REFERENCES Medico (Funcionario_idFuncionario));
-- -----------------------------------------------------
-- Table Atendimento
-- -----------------------------------------------------
DROP TABLE IF EXISTS Atendimento ;
CREATE TABLE IF NOT EXISTS Atendimento (
seqAtendimento INTEGER NOT NULL,
dados VARCHAR(200) NOT NULL,
data DATE NOT NULL,
horário TIME NOT NULL,
Paciente_idPaciente INTEGER NOT NULL,
Medico_Funcionario_idFuncionario INTEGER NOT NULL,
Exame_seqExame INTEGER NOT NULL,
PRIMARY KEY (seqAtendimento, Paciente_idPaciente),
FOREIGN KEY (Paciente_idPaciente) REFERENCES Paciente (idPaciente),
FOREIGN KEY (Medico_Funcionario_idFuncionario) REFERENCES Medico (Funcionario_idFuncionario));
ALTER TABLE Atendimento
ADD FOREIGN KEY (Exame_seqExame) REFERENCES Exame (seqExame)
-- -----------------------------------------------------
-- Table Raio-X
-- -----------------------------------------------------
DROP TABLE IF EXISTS RaioX ;
CREATE TABLE RaioX (
dose_rad INTEGER NOT NULL,
Exame_seqExame INTEGER NOT NULL,
PRIMARY KEY (Exame_seqExame));
-- -----------------------------------------------------
-- Table Angiografia
-- -----------------------------------------------------
DROP TABLE IF EXISTS Angiografia ;
CREATE TABLE Angiografia (
região_cateterismo VARCHAR(45) NOT NULL,
Exame_seqExame INTEGER NOT NULL,
PRIMARY KEY (Exame_seqExame));
-- -----------------------------------------------------
-- Table Tomografia
-- -----------------------------------------------------
DROP TABLE IF EXISTS Tomografia ;
CREATE TABLE Tomografia (
dose_rad INTEGER NOT NULL,
Exame_seqExame INTEGER NOT NULL,
PRIMARY KEY (Exame_seqExame));
-- -----------------------------------------------------
-- Table Mamografia
-- -----------------------------------------------------
DROP TABLE IF EXISTS Mamografia ;
CREATE TABLE Mamografia (
tipo_mamografia VARCHAR(100) NOT NULL,
dose_rad INTEGER NOT NULL,
Exame_seqExame INTEGER NOT NULL,
PRIMARY KEY (Exame_seqExame));
-- -----------------------------------------------------
-- Table Ultrassonografia
-- -----------------------------------------------------
DROP TABLE IF EXISTS Ultrassonografia ;
CREATE TABLE Ultrassonografia (
região VARCHAR(100) NOT NULL,
tipo_ultrassonografia VARCHAR(100) NOT NULL,
Exame_seqExame INTEGER NOT NULL,
PRIMARY KEY (Exame_seqExame));
-- -----------------------------------------------------
-- Table Ressonancia Magnética
-- -----------------------------------------------------
DROP TABLE IF EXISTS Ressonancia_Magnetica ;
CREATE TABLE Ressonancia_Magnetica (
região VARCHAR(100) NOT NULL,
tipo_ressonancia VARCHAR(100) NOT NULL,
Exame_seqExame INTEGER NOT NULL,
PRIMARY KEY (Exame_seqExame));
-- -----------------------------------------------------
-- Table Clinica Conveniada_has_Medico
-- -----------------------------------------------------
DROP TABLE IF EXISTS Clinica_Conveniada_has_Medico ;
CREATE TABLE Clinica_Conveniada_has_Medico (
Clinica_Conveniada_idClinica INTEGER NOT NULL,
Medico_Funcionario_idFuncionario INTEGER NOT NULL);
-- -----------------------------------------------------
-- Table Fone Funcionario
-- -----------------------------------------------------
DROP TABLE IF EXISTS Fone_Funcionario ;
CREATE TABLE Fone_Funcionario (
fone VARCHAR(11) NOT NULL,
Funcionario_idFuncionario INTEGER NOT NULL,
PRIMARY KEY (Funcionario_idFuncionario, fone),
FOREIGN KEY (Funcionario_idFuncionario) REFERENCES Funcionario (idFuncionario));
-- -----------------------------------------------------
-- Table Fone Paciente
-- -----------------------------------------------------
DROP TABLE IF EXISTS Fone_Paciente ;
CREATE TABLE Fone_Paciente (
fone VARCHAR(13) NOT NULL,
Paciente_idPaciente INTEGER NOT NULL,
PRIMARY KEY (Paciente_idPaciente, fone),
FOREIGN KEY (Paciente_idPaciente) REFERENCES Paciente (idPaciente));
-- -----------------------------------------------------
-- Table Fone Clinica
-- -----------------------------------------------------
DROP TABLE IF EXISTS Fone_Clinica ;
CREATE TABLE Fone_Clinica (
fone VARCHAR(13) NOT NULL,
Clinica Conveniada_idClinica INTEGER NOT NULL,
PRIMARY KEY (Clinica Conveniada_idClinica, fone),
FOREIGN KEY (Clinica_Conveniada_idClinica) REFERENCES Clinica_Conveniada (idClinica));
--------------------------------------------------------------------------------
-----FALTOU TERMINAR PQ A PORRA DA INTERNET CAIU -------------------------------
ALTER TABLE Clinica_Conveniada_has_Medico
ADD FOREIGN KEY (Clinica_Conveniada_idClinica) REFERENCES Clinica_Conveniada (idClinica),
ADD FOREIGN KEY (Medico_Funcionario_idFuncionario) REFERENCES Medico (Funcionario_idFuncionario);
--------------------------------------------------------------------------
--------ALTER TABLES COM CONFLITO DE UNICIDADE DA TABELA EXAME------------
ALTER TABLE Exame
DROP seqExame;
ALTER TABLE Exame
ADD seqExame INTEGER NOT NULL,
ADD FOREIGN KEY (seqExame);
ALTER TABLE Ressonancia_Magnetica
ADD FOREIGN KEY (Exame_seqExame) REFERENCES Exame (seqExame);
ALTER TABLE Ultrassonografia
ADD FOREIGN KEY (Exame_seqExame) REFERENCES Exame (seqExame);
ALTER TABLE Mamografia
ADD FOREIGN KEY (Exame_seqExame) REFERENCES Exame (seqExame);
ALTER TABLE Tomografia
ADD FOREIGN KEY (Exame_seqExame) REFERENCES Exame (seqExame);
ALTER TABLE RaioX
ADD FOREIGN KEY (Exame_seqExame) REFERENCES Exame (seqExame);
ALTER TABLE Angiografia
ADD FOREIGN KEY (Exame_seqExame) REFERENCES Exame (seqExame);
| true |
930901c9a7c9e964b8c0680be4ffe99d0b459cfe | SQL | npatta01/datasci_course_materials | /assignment2/multiply.sql | UTF-8 | 298 | 2.921875 | 3 | [] | no_license | SELECT a.row_num, b.col_num, SUM(a.value * b.value)
FROM a, b
WHERE a.col_num = b.row_num
GROUP BY a.row_num, b.col_num;
A=[[0 0 0 55 78];[19 0 21 3 81];[0 48 50 1 0];[0 0 33 0 67];[95 0 0 0 31]];
B=[[0 73 0 0 42];[0 0 82 0 0];[83 13 0 57 0];[48 85 18 24 0];[98 7 0 0 3]];
C=A*B; | true |
657f1bcdb323ef58b00893d6f6013650e2bcb161 | SQL | AngusAllen/udacity-tournament | /tournament.sql | UTF-8 | 776 | 3.734375 | 4 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | -- Author: Angus Allen.
-- Date: 13 July 2016.
-- Summary: Creates database, database schema and tables for thd tournament project.
-- Note: Queries on database are run from the file tournament.py
-- Start with statements: create database tournament; \c tournament; \i tournament.sql.
DROP DATABASE IF EXISTS tournament;
CREATE DATABASE tournament;
\c tournament
DROP TABLE IF EXISTS players;
CREATE TABLE players(
player_id SERIAL PRIMARY KEY,
player_name VARCHAR (25) NOT NULL
);
DROP TABLE IF EXISTS matches;
CREATE TABLE matches(
match_id SERIAL PRIMARY KEY,
-- winner_id is the serial_id of the winning player
winner_id INTEGER REFERENCES players(player_id),
-- loser_id is the serial_id of the losing player
loser_id INTEGER REFERENCES players(player_id)
);
| true |
d8ad79b8b3ed0ec69f4847e579ef5bbad8a463dd | SQL | SolomonWorku/rentalSystem | /db/pk_ims.sql | UTF-8 | 6,761 | 2.953125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jul 31, 2017 at 06:04 PM
-- 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: `pk_ims`
--
-- --------------------------------------------------------
--
-- Table structure for table `borrowdetails`
--
CREATE TABLE `borrowdetails` (
`b_id` int(11) NOT NULL,
`b_inv_id` int(5) NOT NULL,
`b_tech_id` int(5) NOT NULL,
`date` date NOT NULL,
`b_tquantity` int(10) NOT NULL,
`b_return_status` varchar(20) NOT NULL,
`b_return_quantity` int(10) NOT NULL,
`b_timestamp` varchar(25) NOT NULL,
`b_rec_id` int(10) NOT NULL,
`r_date` date NOT NULL,
`r_timestamp` varchar(20) NOT NULL,
`b_status` varchar(32) NOT NULL,
`total_cost` int(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `borrowdetails`
--
INSERT INTO `borrowdetails` (`b_id`, `b_inv_id`, `b_tech_id`, `date`, `b_tquantity`, `b_return_status`, `b_return_quantity`, `b_timestamp`, `b_rec_id`, `r_date`, `r_timestamp`, `b_status`, `total_cost`) VALUES
(1, 1, 2, '2017-06-27', 10, 'Pending', 10, '2017-06-27 23:42:47', 1, '2017-06-27', '2017-06-27 23:43:00', 'ARCHIVED', 2500),
(2, 2, 2, '2017-06-27', 10, 'Pending', 5, '2017-06-27 23:42:47', 1, '2017-06-27', '2017-06-27 23:43:33', 'ACTIVE', 4520),
(3, 1, 3, '2017-06-29', 2, 'Pending', 2, '2017-06-29 07:57:16', 2, '2017-06-29', '2017-06-29 08:07:39', 'ACTIVE', 500),
(4, 2, 3, '2017-06-29', 3, 'Pending', 2, '2017-06-29 08:07:11', 3, '2017-06-29', '2017-06-29 08:07:27', 'ACTIVE', 1356);
-- --------------------------------------------------------
--
-- Table structure for table `inventory`
--
CREATE TABLE `inventory` (
`inv_id` int(11) NOT NULL,
`inv_title` varchar(32) NOT NULL,
`inv_dealer` varchar(32) NOT NULL,
`inv_model` varchar(32) NOT NULL,
`inv_tquantity` int(5) NOT NULL,
`inv_lquantity` int(5) NOT NULL,
`inv_cost` int(10) NOT NULL,
`inv_status` varchar(64) NOT NULL,
`timestamp` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `inventory`
--
INSERT INTO `inventory` (`inv_id`, `inv_title`, `inv_dealer`, `inv_model`, `inv_tquantity`, `inv_lquantity`, `inv_cost`, `inv_status`, `timestamp`) VALUES
(1, 'keyboard', 'sony', 'H12', 12, 0, 250, 'ARCHIVED', '2017-06-23 20:20:52'),
(2, 'mouse', 'matrix', 'M11', 54, 0, 452, 'ACTIVE', '2017-06-23 20:21:28');
-- --------------------------------------------------------
--
-- Table structure for table `receipt`
--
CREATE TABLE `receipt` (
`rec_id` int(11) NOT NULL,
`r_timestamp` varchar(20) NOT NULL,
`added` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `receipt`
--
INSERT INTO `receipt` (`rec_id`, `r_timestamp`, `added`) VALUES
(1, '', 'Added'),
(2, '', 'Added'),
(3, '', 'Added');
-- --------------------------------------------------------
--
-- Table structure for table `technician`
--
CREATE TABLE `technician` (
`tech_id` int(11) NOT NULL,
`tech_name` varchar(64) NOT NULL,
`tech_address` varchar(250) NOT NULL,
`tech_contact` varchar(10) NOT NULL,
`tech_acontact` varchar(10) NOT NULL,
`tech_status` varchar(20) NOT NULL,
`tech_uid` varchar(250) NOT NULL,
`timestamp` varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `technician`
--
INSERT INTO `technician` (`tech_id`, `tech_name`, `tech_address`, `tech_contact`, `tech_acontact`, `tech_status`, `tech_uid`, `timestamp`) VALUES
(1, 'Krishna Bharambe', 'BULDANA 443001', '9011365788', '9850364846', 'ACTIVE', '123', '2017-06-23 02:39:33'),
(2, 'Atul Patil', 'Sunderkhed buldana', '9657055120', '8899663322', 'Archived', '986532', '2017-06-23 13:17:39'),
(3, 'pratik', 'buldanan', '9850364846', '9865231470', 'ACTIVE', '123456879', '2017-06-29 07:56:31');
-- --------------------------------------------------------
--
-- Table structure for table `temp_trans`
--
CREATE TABLE `temp_trans` (
`temp_trans_id` int(11) NOT NULL,
`temp_inv_id` int(8) NOT NULL,
`temp_borrower_tech_id` int(5) NOT NULL,
`temp_issueing_quantity` int(10) NOT NULL,
`timestamp` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`admin_id` int(11) NOT NULL,
`admin_firstname` varchar(32) NOT NULL,
`admin_lastname` varchar(32) NOT NULL,
`username` varchar(32) NOT NULL,
`password` varchar(64) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`admin_id`, `admin_firstname`, `admin_lastname`, `username`, `password`) VALUES
(1, 'krishna', 'bharambe', 'admin', 'admin');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `borrowdetails`
--
ALTER TABLE `borrowdetails`
ADD PRIMARY KEY (`b_id`);
--
-- Indexes for table `inventory`
--
ALTER TABLE `inventory`
ADD PRIMARY KEY (`inv_id`);
--
-- Indexes for table `receipt`
--
ALTER TABLE `receipt`
ADD PRIMARY KEY (`rec_id`);
--
-- Indexes for table `technician`
--
ALTER TABLE `technician`
ADD PRIMARY KEY (`tech_id`);
--
-- Indexes for table `temp_trans`
--
ALTER TABLE `temp_trans`
ADD PRIMARY KEY (`temp_trans_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`admin_id`),
ADD UNIQUE KEY `username` (`username`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `borrowdetails`
--
ALTER TABLE `borrowdetails`
MODIFY `b_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `inventory`
--
ALTER TABLE `inventory`
MODIFY `inv_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `receipt`
--
ALTER TABLE `receipt`
MODIFY `rec_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `technician`
--
ALTER TABLE `technician`
MODIFY `tech_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `temp_trans`
--
ALTER TABLE `temp_trans`
MODIFY `temp_trans_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `admin_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
/*!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 |
7cd9b0a58a93559104ef5652caae12f7d3a736bc | SQL | BigG1947/record_book | /src/testData.sql | UTF-8 | 28,301 | 2.765625 | 3 | [] | no_license | DELETE from marks;
ALTER TABLE marks AUTO_INCREMENT=0;
DELETE FROM loads;
ALTER TABLE loads AUTO_INCREMENT=0;
DELETE FROM discipline;
ALTER TABLE discipline AUTO_INCREMENT=0;
DELETE FROM sensitive_data;
ALTER TABLE sensitive_data AUTO_INCREMENT=0;
DELETE FROM student;
ALTER TABLE student AUTO_INCREMENT=0;
DELETE FROM employee;
ALTER TABLE employee AUTO_INCREMENT=0;
DELETE FROM accession;
ALTER TABLE accession AUTO_INCREMENT=0;
DELETE FROM people;
ALTER TABLE people AUTO_INCREMENT=0;
DELETE FROM speciality;
ALTER TABLE speciality AUTO_INCREMENT=0;
DELETE FROM direction;
ALTER TABLE direction AUTO_INCREMENT=0;
DELETE FROM cathedra;
ALTER TABLE cathedra AUTO_INCREMENT=0;
DELETE FROM faculty;
ALTER TABLE faculty AUTO_INCREMENT=0;
DELETE FROM institute;
ALTER TABLE institute AUTO_INCREMENT=0;
-- DELETE FROM ranks;
-- ALTER TABLE ranks AUTO_INCREMENT=0;
DELETE FROM groups;
ALTER TABLE groups AUTO_INCREMENT=0;
-- DELETE FROM status;
-- ALTER TABLE status AUTO_INCREMENT=0;
INSERT INTO institute(name) VALUES ("institute1");
INSERT INTO institute(name) VALUES ("institute2");
INSERT INTO faculty(name, id_institute) VALUES ("faculty1", 1);
INSERT INTO faculty(name, id_institute) VALUES ("faculty2", 1);
INSERT INTO faculty(name, id_institute) VALUES ("faculty3", 2);
INSERT INTO faculty(name, id_institute) VALUES ("faculty4", 2);
INSERT INTO cathedra(name, id_faculty) VALUES ("cathedra1", 1);
INSERT INTO cathedra(name, id_faculty) VALUES ("cathedra2", 1);
INSERT INTO cathedra(name, id_faculty) VALUES ("cathedra3", 2);
INSERT INTO cathedra(name, id_faculty) VALUES ("cathedra4", 2);
INSERT INTO cathedra(name, id_faculty) VALUES ("cathedra5", 3);
INSERT INTO cathedra(name, id_faculty) VALUES ("cathedra6", 3);
INSERT INTO cathedra(name, id_faculty) VALUES ("cathedra7", 4);
INSERT INTO cathedra(name, id_faculty) VALUES ("cathedra8", 4);
INSERT INTO direction(name, id_cathedra) VALUES ("direction1", 1);
INSERT INTO direction(name, id_cathedra) VALUES ("direction2", 1);
INSERT INTO direction(name, id_cathedra) VALUES ("direction3", 2);
INSERT INTO direction(name, id_cathedra) VALUES ("direction4", 2);
INSERT INTO direction(name, id_cathedra) VALUES ("direction5", 3);
INSERT INTO direction(name, id_cathedra) VALUES ("direction6", 3);
INSERT INTO direction(name, id_cathedra) VALUES ("direction7", 4);
INSERT INTO direction(name, id_cathedra) VALUES ("direction8", 4);
INSERT INTO direction(name, id_cathedra) VALUES ("direction9", 5);
INSERT INTO direction(name, id_cathedra) VALUES ("direction10", 5);
INSERT INTO direction(name, id_cathedra) VALUES ("direction11", 6);
INSERT INTO direction(name, id_cathedra) VALUES ("direction12", 6);
INSERT INTO direction(name, id_cathedra) VALUES ("direction13", 7);
INSERT INTO direction(name, id_cathedra) VALUES ("direction14", 7);
INSERT INTO direction(name, id_cathedra) VALUES ("direction15", 8);
INSERT INTO direction(name, id_cathedra) VALUES ("direction16", 8);
INSERT INTO speciality(name, id_direction) VALUES ("speciality1", 1);
INSERT INTO speciality(name, id_direction) VALUES ("speciality2", 1);
INSERT INTO speciality(name, id_direction) VALUES ("speciality3", 2);
INSERT INTO speciality(name, id_direction) VALUES ("speciality4", 2);
INSERT INTO speciality(name, id_direction) VALUES ("speciality5", 3);
INSERT INTO speciality(name, id_direction) VALUES ("speciality6", 3);
INSERT INTO speciality(name, id_direction) VALUES ("speciality7", 4);
INSERT INTO speciality(name, id_direction) VALUES ("speciality8", 4);
INSERT INTO speciality(name, id_direction) VALUES ("speciality9", 5);
INSERT INTO speciality(name, id_direction) VALUES ("speciality10", 5);
INSERT INTO speciality(name, id_direction) VALUES ("speciality11", 6);
INSERT INTO speciality(name, id_direction) VALUES ("speciality12", 6);
INSERT INTO speciality(name, id_direction) VALUES ("speciality13", 7);
INSERT INTO speciality(name, id_direction) VALUES ("speciality14", 7);
INSERT INTO speciality(name, id_direction) VALUES ("speciality15", 8);
INSERT INTO speciality(name, id_direction) VALUES ("speciality16", 8);
INSERT INTO speciality(name, id_direction) VALUES ("speciality17", 9);
INSERT INTO speciality(name, id_direction) VALUES ("speciality18", 9);
INSERT INTO speciality(name, id_direction) VALUES ("speciality19", 10);
INSERT INTO speciality(name, id_direction) VALUES ("speciality20", 10);
INSERT INTO speciality(name, id_direction) VALUES ("speciality21", 11);
INSERT INTO speciality(name, id_direction) VALUES ("speciality22", 11);
INSERT INTO speciality(name, id_direction) VALUES ("speciality23", 12);
INSERT INTO speciality(name, id_direction) VALUES ("speciality24", 12);
INSERT INTO speciality(name, id_direction) VALUES ("speciality25", 13);
INSERT INTO speciality(name, id_direction) VALUES ("speciality26", 13);
INSERT INTO speciality(name, id_direction) VALUES ("speciality27", 14);
INSERT INTO speciality(name, id_direction) VALUES ("speciality28", 14);
INSERT INTO speciality(name, id_direction) VALUES ("speciality29", 15);
INSERT INTO speciality(name, id_direction) VALUES ("speciality30", 15);
INSERT INTO speciality(name, id_direction) VALUES ("speciality31", 16);
INSERT INTO speciality(name, id_direction) VALUES ("speciality32", 16);
-- INSERT INTO ranks(name) VALUES ("rank1");
-- INSERT INTO ranks(name) VALUES ("rank2");
-- INSERT INTO ranks(name) VALUES ("rank3");
-- INSERT INTO ranks(name) VALUES ("rank4");
-- INSERT INTO ranks(name) VALUES ("rank5");
-- INSERT INTO ranks(name) VALUES ("rank6");
--
-- INSERT INTO status(name) VALUES ("status1");
-- INSERT INTO status(name) VALUES ("status2");
-- INSERT INTO status(name) VALUES ("status3");
-- INSERT INTO status(name) VALUES ("status4");
-- INSERT INTO status(name) VALUES ("status5");
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("Степул Артем Мартиросовчи", "1997-06-12", 1, "/photo/default.png", "Поет, учавствует в студ. клубе", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380999999999", "artem.stepul@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("Луценко Артем Геннадиевич", "1997-03-16", 1, "/photo/default.png", "Заместитель главы студенчиского совета факультета", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380333333333", "artem.lucenko@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("Иванов Иван Иванович", "1979-09-17", 1, "/photo/default.png", "", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380444444444", "admin@admin.com", 3, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("st3", "1997-06-12", 1, "/photo/default.png", "Поет, учавствует в студ. клубе", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380999999999", "st3@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("st4", "1997-03-16", 1, "/photo/default.png", "Заместитель главы студенчиского совета факультета", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380333333333", "st4@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("empl2", "1979-09-17", 1, "/photo/default.png", "", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380444444444", "empl2@admin.com", 3, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("st5", "1997-06-12", 1, "/photo/default.png", "Поет, учавствует в студ. клубе", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380999999999", "st5@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("st6", "1997-03-16", 1, "/photo/default.png", "Заместитель главы студенчиского совета факультета", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380333333333", "st6@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("empl3", "1979-09-17", 1, "/photo/default.png", "", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380444444444", "empl3@admin.com", 3, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("st7", "1997-06-12", 1, "/photo/default.png", "Поет, учавствует в студ. клубе", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380999999999", "st7@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("st8", "1997-03-16", 1, "/photo/default.png", "Заместитель главы студенчиского совета факультета", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380333333333", "st8@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("empl4", "1979-09-17", 1, "/photo/default.png", "", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380444444444", "empl4@admin.com", 3, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("st9", "1997-06-12", 1, "/photo/default.png", "Поет, учавствует в студ. клубе", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380999999999", "st9@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("st10", "1997-03-16", 1, "/photo/default.png", "Заместитель главы студенчиского совета факультета", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "+380333333333", "st10@gmail.com", 1, 1);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("old student", "1970-01-01", "1", "/photo/default.png", "Старый студент", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "нету у него телефона", "st15@gmail.com", 7, 0);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("old student2", "1970-01-01", "1", "/photo/default.png", "Старый студент", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "нету у него телефона", "st16@gmail.com", 7, 0);
INSERT INTO people(fio, birthday, gender, img, comment, password, phone_number, email, id_status, have_access)
VALUES ("old student3", "1970-01-01", "1", "/photo/default.png", "Старый студент", "$2a$10$oqygBXUWPKkdL.wdac68n.GtjRGxk8LnaqxpTcNvZGWxRTtRHE0TK", "нету у него телефона", "st17@gmail.com", 2, 0);
INSERT INTO employee(id_people, date_invite, id_cathedra, id_rank)
VALUES (3, "2007-07-22", 1, 1);
INSERT INTO employee(id_people, date_invite, id_cathedra, id_rank)
VALUES (6, "2007-07-22", 1, 1);
INSERT INTO employee(id_people, date_invite, id_cathedra, id_rank)
VALUES (9, "2007-07-22", 1, 1);
INSERT INTO employee(id_people, date_invite, id_cathedra, id_rank)
VALUES (12, "2007-07-22", 1, 1);
INSERT INTO groups(id_employee, name, id_direction) VALUES (3, "group1", 1);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group2", 1);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group3", 2);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group4", 2);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group5", 3);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group6", 3);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group7", 4);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group8", 4);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group9", 5);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group10", 5);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group11", 6);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group12", 6);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group13", 7);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group14", 7);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group15", 8);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group16", 8);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group17", 9);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group18", 9);
INSERT INTO groups(id_employee, name, id_direction) VALUES (3, "group19", 10);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group20", 10);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group21", 11);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group22", 11);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group23", 12);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group24", 12);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group25", 13);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group26", 13);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group27", 14);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group28", 14);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group29", 15);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group30", 15);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group31", 16);
INSERT INTO groups(id_employee, name, id_direction) VALUES (NULL, "group32", 1);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (1, "2017-09-01", 1, 1, 4, 1);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (2, "2017-09-01", 1, 1, 4, 1);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (4, "2017-09-01", 1, 1, 4, 1);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (5, "2017-09-01", 1, 1, 4, 1);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (7, "2017-09-01", 1, 1, 4, 1);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (8, "2017-09-01", 1, 1, 4, 1);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (10, "2017-09-01", 1, 1, 4, 2);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (11, "2017-09-01", 1, 1, 4, 2);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (13, "2017-09-01", 1, 1, 4, 2);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (14, "2017-09-01", 1, 1, 4, 2);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (15, "2000-09-01", 1, 0, 10, 32);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (16, "2000-09-01", 1, 0, 10, 32);
INSERT INTO student(id_people, date_admission, is_full_time, is_cut, semester, id_group)
VALUES (17, "2000-09-01", 1, 0, 10, 32);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (2, 1, 0, 1, 0, 0, 1, 1, 0, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (3, 1, 1, 1, 1, 1, 1, 1, 1, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (4, 1, 0, 1, 0, 1, 0, 1, 0, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (5, 0, 1, 0, 1, 0, 1, 0, 1, 0);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (6, 1, 1, 1, 1, 1, 1, 1, 1, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (7, 0, 1, 0, 1, 0, 1, 0, 1, 0);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (8, 0, 0, 0, 0, 0, 1, 1, 1, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (9, 1, 1, 1, 1, 1, 1, 1, 1, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (10, 1, 1, 1, 1, 0, 0, 0, 0, 0);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (11, 0, 0, 1, 1, 1, 1, 0, 0, 0);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (12, 1, 1, 1, 1, 1, 1, 1, 1, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (13, 0, 0, 1, 1, 1, 0, 0, 1, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (14, 0, 1, 1, 0, 1, 0, 1, 0, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (15, 0, 1, 1, 0, 1, 0, 1, 0, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (16, 0, 1, 1, 0, 1, 0, 1, 0, 1);
INSERT INTO accession(id_people, edit_access, set_absence, get_absence, set_mark, set_event, get_sensitive, set_sensitive, get_ylist, manage_academ)
VALUES (17, 0, 1, 1, 0, 1, 0, 1, 0, 1);
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (1, "122fasf2", "214124124", "ул. Пушкина, дом Колатушкина, квартира 25", "ком214124");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (2, "214124124", "122fasf2", "ул. Пушкина, дом Колатушкина, квартира 12", "ыфафаы251512");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (3, "цйкйкf2", "2141фафыафыа", "ул. Пушкина, дом Колатушкина, квартира 36", "пддждхзз215251аыф");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (4, "122fasf2", "214124124", "ул. Пушкина, дом Колатушкина, квартира 25", "ком214124");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (5, "214124124", "122fasf2", "ул. Пушкина, дом Колатушкина, квартира 12", "ыфафаы251512");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (6, "цйкйкf2", "2141фафыафыа", "ул. Пушкина, дом Колатушкина, квартира 36", "пддждхзз215251аыф");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (7, "122fasf2", "214124124", "ул. Пушкина, дом Колатушкина, квартира 25", "ком214124");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (8, "214124124", "122fasf2", "ул. Пушкина, дом Колатушкина, квартира 12", "ыфафаы251512");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (9, "цйкйкf2", "2141фафыафыа", "ул. Пушкина, дом Колатушкина, квартира 36", "пддждхзз215251аыф");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (10, "122fasf2", "214124124", "ул. Пушкина, дом Колатушкина, квартира 25", "ком214124");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (11, "214124124", "122fasf2", "ул. Пушкина, дом Колатушкина, квартира 12", "ыфафаы251512");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (12, "цйкйкf2", "2141фафыафыа", "ул. Пушкина, дом Колатушкина, квартира 36", "пддждхзз215251аыф");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (13, "122fasf2", "214124124", "ул. Пушкина, дом Колатушкина, квартира 25", "ком214124");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (14, "214124124", "122fasf2", "ул. Пушкина, дом Колатушкина, квартира 12", "ыфафаы251512");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (15, "фыафыафыа", "122fаыфафыаasf2", "ул. фыафыа, дом Колатушафыафыакина, кварафыафыатира 12", "ыфафааыфафыаы251512");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (16, "122fasf2", "214124124", "ул. Пушкина, дом Колатушкина, квартира 25", "ком214124");
INSERT INTO sensitive_data(id_people, passport_code, rntrs, reg_address, military_id)
VALUES (17, "214124124", "122fasf2", "ул. Пушкина, дом Колатушкина, квартира 12", "ыфафаы251512");
INSERT INTO discipline(name) VALUES ("discipline1");
INSERT INTO discipline(name) VALUES ("discipline2");
INSERT INTO discipline(name) VALUES ("discipline3");
INSERT INTO discipline(name) VALUES ("discipline4");
INSERT INTO discipline(name) VALUES ("discipline5");
INSERT INTO discipline(name) VALUES ("discipline6");
INSERT INTO discipline(name) VALUES ("discipline7");
INSERT INTO discipline(name) VALUES ("discipline8");
INSERT INTO discipline(name) VALUES ("discipline9");
INSERT INTO discipline(name) VALUES ("discipline10");
INSERT INTO discipline(name) VALUES ("discipline11");
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (1, 3, 1, 1, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (2, 6, 1, 2, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (3, 9, 1, 3, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (4, 12, 1, 4, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (5, 3, 1, 5, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (6, 6, 1, 6, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (7, 6, 1, 7, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (8, 9, 1, 8, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (9, 12, 1, 9, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (10, 3, 1, 10, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (11, 6, 1, 11, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (1, 3, 32, 11, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (2, 3, 1, 4, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (1, 6, 2, 4, 6);
INSERT INTO loads(id_discipline, id_employee, id_group, semester, id_assistant) VALUES (2, 6, 2, 4, 6);
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (1, 1, 3, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (2, 1, 3, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (4, 1, 3, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (5, 1, 3, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (7, 1, 3, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (8, 1, 3, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (1, 2, 3, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (2, 2, 3, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (4, 2, 3, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (5, 2, 3, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (7, 2, 3, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (8, 2, 3, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (10, 1, 6, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (11, 1, 6, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (13, 1, 6, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (14, 1, 6, 59, "неуд", 1, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (10, 2, 6, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (11, 2, 6, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (13, 2, 6, 59, "неуд", 0, 4, "2018-09-05");
INSERT INTO marks(id_student, id_discipline, id_employee, value, national_value, is_exam, semester, date)
VALUES (14, 2, 6, 59, "неуд", 0, 4, "2018-09-05"); | true |
3c5be7cc04630a619029199d8da0e8d90722ef2f | SQL | JianChi8/BookMarket | /docs/sql/tables_sql/ums_member_tag.sql | UTF-8 | 858 | 3 | 3 | [
"LicenseRef-scancode-mulanpsl-1.0-en"
] | permissive | /*
Navicat MySQL Data Transfer
Source Server : localhost_root
Source Server Version : 100137
Source Host : localhost:3306
Source Database : bookmarket
Target Server Type : MYSQL
Target Server Version : 100137
File Encoding : 65001
Date: 2020-02-23 19:31:10
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for ums_member_tag
-- ----------------------------
DROP TABLE IF EXISTS `ums_member_tag`;
CREATE TABLE `ums_member_tag` (
`id` bigint(20) NOT NULL COMMENT '会员标签编号',
`name` varchar(100) DEFAULT NULL COMMENT '标签名称',
`finish_order_count` int(11) DEFAULT NULL COMMENT '完成订单数量',
`finish_order_amount` decimal(10,2) DEFAULT NULL COMMENT '完成订单金额',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户标签表';
| true |
eaf05612d0e09322cbbde38cb45a54f9352be551 | SQL | OHDSI/WebAPI | /src/main/resources/db/migration/oracle/V2.6.0.20181001200021__estimation_prediction.sql | UTF-8 | 1,428 | 3.625 | 4 | [
"Apache-2.0"
] | permissive | -- Estimation
CREATE SEQUENCE ${ohdsiSchema}.estimation_seq;
CREATE TABLE ${ohdsiSchema}.estimation
(
estimation_id NUMBER(19),
name VARCHAR(255) NOT NULL,
type VARCHAR(255) NOT NULL,
description VARCHAR(1000),
specification CLOB NOT NULL,
created_by_id INTEGER,
created_date TIMESTAMP,
modified_by_id INTEGER,
modified_date TIMESTAMP,
CONSTRAINT pk_estimation PRIMARY KEY (estimation_id)
);
ALTER TABLE ${ohdsiSchema}.estimation
ADD CONSTRAINT fk_estimation_ser_user_creator FOREIGN KEY (created_by_id)
REFERENCES ${ohdsiSchema}.sec_user (id);
ALTER TABLE ${ohdsiSchema}.estimation
ADD CONSTRAINT fk_estimation_ser_user_updater FOREIGN KEY (modified_by_id)
REFERENCES ${ohdsiSchema}.sec_user (id);
-- Prediction
CREATE SEQUENCE ${ohdsiSchema}.prediction_seq;
CREATE TABLE ${ohdsiSchema}.prediction
(
prediction_id NUMBER(19),
name VARCHAR(255) NOT NULL,
description VARCHAR(1000),
specification CLOB NOT NULL,
created_by_id INTEGER,
created_date TIMESTAMP,
modified_by_id INTEGER,
modified_date TIMESTAMP,
CONSTRAINT pk_prediction PRIMARY KEY (prediction_id)
);
ALTER TABLE ${ohdsiSchema}.prediction
ADD CONSTRAINT fk_prediction_ser_user_creator FOREIGN KEY (created_by_id)
REFERENCES ${ohdsiSchema}.sec_user (id);
ALTER TABLE ${ohdsiSchema}.prediction
ADD CONSTRAINT fk_prediction_ser_user_updater FOREIGN KEY (modified_by_id)
REFERENCES ${ohdsiSchema}.sec_user (id); | true |
3347fb8e8a3a5e7ea8464a5709fe25c3913f6936 | SQL | abzamer/bamazon | /bamazonSchema.sql | UTF-8 | 959 | 3.15625 | 3 | [] | no_license | CREATE DATABASE bamazon_db;
USE bamazon_db;
-- item_id (unique id for each product)
-- product_name (Name of product)
-- department_name
-- price (cost to customer)
-- stock_quantity (how much of the product is available in stores)
CREATE TABLE products (
item_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
product_name VARCHAR(60) NOT NULL,
department_name VARCHAR(40) NOT NULL,
price INT NOT NULL,
stock_quantity INT NOT NULL
);
INSERT INTO products (product_name, department_name, price, stock_quantity)
VALUES("diapers", "baby", 20, 1000),
("Nintendo Switch", "Electronics", 300, 30),
("Halloween wreath", "home decor", 30, 25),
("Mrs. Meyer's Everyday Cleaner", "Cleaning", 6, 123),
("lightbulb", "home improvement", 5, 331),
("baby wipes", "baby", 6, 21),
("Advil", "Health", 4, 56),
("Hand Sanitizer", "Health", 2, 89),
("Canned air", "Office", 6, 1000),
("necklace", "jewelry", 14, 60),
("Coffee maker", "Kitchen", 40, 34);
SELECT * FROM products; | true |
09358a442ebacb6087ec0dd73959265aca054d01 | SQL | MarijnvandenHeuvel/Tutorials | /21-Databases/3-SomeMoreQueries/subqueries-solutions.sql | UTF-8 | 2,745 | 3.953125 | 4 | [] | no_license | -- 1.
SELECT last_name , salary
FROM employees
WHERE salary > (SELECT salary
FROM employees
WHERE employee_id = 103)
-- 2.
SELECT department_id , department_name
FROM departments
WHERE location_id = (SELECT location_id
FROM departments
WHERE department_id = 90)
-- 3.
SELECT last_name , hire_date
FROM employees
WHERE hire_date > (SELECT hire_date
FROM employees
WHERE employee_id = 101)
-- 4.
SELECT first_name , last_name , department_id
FROM employees
WHERE department_id = (SELECT department_id
FROM departments
WHERE department_name = 'Sales')
-- 5.
SELECT department_id , department_name
FROM departments
WHERE location_id = (SELECT location_id
FROM locations
WHERE city = 'Toronto')
-- 6.
SELECT first_name , last_name , salary , department_id
FROM employees
WHERE department_id = (SELECT department_id
FROM employees
WHERE employee_id = 124)
AND employee_id <> 124
-- 7.
SELECT first_name , last_name , salary , department_id
FROM employees
WHERE salary > (SELECT AVG(salary)
FROM employees )
-- 8.
SELECT first_name , last_name , salary , department_id
FROM employees
WHERE salary IN (SELECT salary
FROM employees
WHERE department_id = 20)
-- 9.
SELECT first_name , last_name , salary , department_id
FROM employees
WHERE salary > ALL (SELECT salary
FROM employees
WHERE department_id = 50)
-- 10.
SELECT first_name , last_name , salary , department_id
FROM employees
WHERE salary > ANY (SELECT salary
FROM employees
WHERE department_id = 60)
-- 11.
SELECT first_name , last_name , salary , department_id
FROM employees
WHERE salary < ALL (SELECT salary
FROM employees
WHERE department_id = 90)
-- 12.
SELECT first_name , last_name , salary , department_id
FROM employees
WHERE department_id IN (SELECT department_id
FROM departments
WHERE location_id = (SELECT location_id
FROM locations
WHERE city = 'Seattle'))
-- 13.
SELECT first_name , last_name , salary , department_id
FROM employees
WHERE salary < (SELECT AVG(salary)
FROM employees )
AND department_id = (SELECT department_id
FROM employees
WHERE first_name = 'Kevin') | true |
4624280de8b13d886f56fb3fc7ad9399b8efd8b5 | SQL | nianglao/leetcode | /183.customers-who-never-order.sql | UTF-8 | 187 | 3.296875 | 3 | [] | no_license | # Write your MySQL query statement below
select distinct Customers.Name as `Customers`
from Customers
left join Orders on Customers.Id = Orders.CustomerId
where Orders.CustomerId is null | true |
170b158d3d09603ea263bfdb417f8d07048a981b | SQL | mmcgoldr/DAT5_BOS_students | /mmcgoldr/mmcgoldr_hwc4_code.sql | UTF-8 | 3,151 | 4.5 | 4 | [] | no_license | --Megan McGoldrick
--GA Data Science Class 4 HW
--Average at bats among Yankees players who began their second season on/after 1980 = 197.7
--STEPS:
--A. Find first year played for Yankees
--B. Find second year played for Yankees
--C. Exludes players with: 1) only one season 2) second Yankees season before 1980 (assumes second Yankee season may not be same as second career season)
--D. Pull in all At Bats with Yankees for these players and calcuate average (excludes At Bats for other teams)
select avg(d.ab) as NYA_AB_season2_after1979
from
(select b.playerid, a.first_year_NYA, min(b.yearid) as second_year_NYA
from
(select playerid, min(yearid) as first_year_NYA from batting where teamid = 'NYA' group by playerid) a
inner join
(select playerid, yearid from batting where teamid = 'NYA') b
on a.playerid = b.playerid and a.first_year_NYA != b.yearid
group by b.playerid
having second_year_NYA >= 1980) c
inner join
(select playerid, ab from batting where teamid = 'NYA') d
on c.playerid = d.playerid
--Which teams have had the highest number of unique players play in an allstar game in last 10 years?
--Answer: DET, SLN, TEX (18 each)
select teamid, count(distinct playerid) as distinct_players
from allstarfull
where yearid > 2003 and gp = 1
group by teamid
order by distinct_players desc
--Name the player who has won the most number of World Series
--Answer: Yogi Berra (10 wins)
select e.playerid, g.nameFirst, g.nameLast, count(*) as ws_wins
from
(select teamid, yearid from teams where wswin = 'Y' order by yearid desc) f
left join
(select d.teamid, d.yearid, d.playerid
from
(select a.* from (select playerid, yearid, teamid from batting group by playerid, yearid, teamid) a
union all
select b.* from (select playerid, yearid, teamid from pitching group by playerid, yearid, teamid) b
union all
select c.* from (select playerid, yearid, teamid from fielding group by playerid, yearid, teamid) c) d
group by d.teamid, d.yearid, d.playerid) e
on f.teamid = e.teamid and f.yearid = e.yearid
left join
master g
on e.playerid = g.playerid
group by e.playerid
order by ws_wins desc
--Does pitching performance differ by throwing hand (left or right)?
--Answer: On average, right-handed pitchers have slighter higher wins and just slightly lower ERA than left-handed pitchers
select m.throws, avg(g) as avg_g, avg(gs) as avg_gs, avg(w) as avg_wins, avg(era) as avg_era
from pitching p
left join master m
on p.playerid = m.playerid
where p.era IS NOT NULL and m.throws IS NOT NULL
group by m.throws
--How does pitching performance differ among frequent vs infrequent starters?
--Average ERA is about 20% better among frequent starts (3.98) vs infrequent starter (5.02)
select c.frequent_gs, avg(c.era) as avg_era
from
(select a.playerid, case when a.starts_per_year > 20 then 1 else 0 end as frequent_gs, b.w, b.era
from
(select playerid, sum(gs)/count(distinct yearid) as starts_per_year
from pitching
group by playerid
having starts_per_year > 1) a
left join
pitching b
on a.playerid = b.playerid) c
group by c.frequent_gs | true |
3f3010127b373a3611810a308fd08691360beb56 | SQL | Lucsanro/sql-classes | /ddl-create-2.sql | UTF-8 | 588 | 3.390625 | 3 | [] | no_license | -- DDL (ALTER)
-- (ALTER - ADD / MODIFY)
-- ALTER ADD
ALTER TABLE tbalunos
ADD sexo CHAR(1)
AFTER nome;
USE faculdade;
SHOW TABLES;
SELECT * FROM tbalunos;
-- ALTER MODIFY
ALTER TABLE tbalunos
MODIFY sexo CHAR(1) NOT NULL
AFTER nome;
-- INSERT IN tbalunos
INSERT INTO tbalunos
(rgm, nome, sexo, email, dtnascto)
VALUES
(202, "Pedro Souza", "M", "pedro@uol.com.br","1999-09-14");
SELECT * FROM faculdade.tbalunos;
-- CREATE table cursos
CREATE TABLE cursos (
idCurso int auto_increment primary key,
nome varchar(50) not null,
duracao int not null,
periodo varchar(30) not null
); | true |
f48e601937d5124bed2a3c7e6ad75704f3b4dbf8 | SQL | JenBroz/SQL_Challenge | /SQL_queries/FrequencyLN.sql | UTF-8 | 197 | 3.71875 | 4 | [] | no_license | --In descending order, list frequency of employee last names
SELECT employees.last_name, COUNT(employees.last_name) as frequency
from employees
group by last_name
order by
count (last_name) DESC;
| true |
480dfd106dd16dafc6a3dc132e769246c871b400 | SQL | xiaoningzhao/cartpool | /DB_DDL.sql | UTF-8 | 9,007 | 3.640625 | 4 | [] | no_license | DROP DATABASE IF EXISTS cartpool;
CREATE DATABASE cartpool;
USE cartpool;
CREATE TABLE cart_pool (
id INTEGER NOT NULL AUTO_INCREMENT,
pool_id VARCHAR(50) UNIQUE NOT NULL,
name VARCHAR(100) NOT NULL,
neighborhood VARCHAR(100) NOT NULL,
description VARCHAR(500),
zip VARCHAR(5) NOT NULL,
leader INTEGER NOT NULL,
creation_time DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE TABLE user (
id INTEGER NOT NULL AUTO_INCREMENT,
email VARCHAR(128) UNIQUE NOT NULL,
password VARCHAR(500) NOT NULL,
screen_name VARCHAR(50) UNIQUE NOT NULL,
nickname VARCHAR(50) UNIQUE NOT NULL,
pool_id INTEGER,
pool_status VARCHAR(50) DEFAULT 'INIT',
contribution INTEGER DEFAULT 0,
role VARCHAR(20) NOT NULL,
active BOOLEAN DEFAULT FALSE,
token VARCHAR(32) UNIQUE,
creation_time DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (pool_id)
REFERENCES cart_pool (id)
ON DELETE SET NULL ON UPDATE CASCADE
);
CREATE TABLE store (
id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(50) UNIQUE NOT NULL,
street VARCHAR(100),
city VARCHAR(50),
state VARCHAR(50),
zip VARCHAR(5),
PRIMARY KEY (id)
);
CREATE TABLE product (
id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
description VARCHAR(500),
image_url VARCHAR(255),
brand VARCHAR(50),
category VARCHAR(50),
unit VARCHAR(50),
price DOUBLE PRECISION,
PRIMARY KEY (id)
);
CREATE TABLE inventory (
store_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
quantity INTEGER NOT NULL,
PRIMARY KEY (store_id, product_id),
FOREIGN KEY (store_id)
REFERENCES store (id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (product_id)
REFERENCES product (id)
ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE user_order (
id INTEGER NOT NULL AUTO_INCREMENT,
user_id INTEGER NOT NULL,
pool_id INTEGER,
store_id INTEGER,
amount DOUBLE PRECISION NOT NULL,
status VARCHAR(10) NOT NULL,
pickup_method VARCHAR(10) NOT NULL,
pickup_user INTEGER,
street VARCHAR(100) NOT NULL,
city VARCHAR(50) NOT NULL,
state VARCHAR(50) NOT NULL,
zip VARCHAR(5) NOT NULL,
creation_time DATETIME DEFAULT CURRENT_TIMESTAMP,
checkout_time DATETIME,
due_time DATETIME,
pickup_time DATETIME,
delivered_time DATETIME,
update_time DATETIME,
PRIMARY KEY (id),
FOREIGN KEY (user_id)
REFERENCES user (id)
ON DELETE RESTRICT ON UPDATE CASCADE,
FOREIGN KEY (pool_id)
REFERENCES cart_pool (id)
ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (store_id)
REFERENCES store (id)
ON DELETE SET NULL ON UPDATE CASCADE
);
CREATE TABLE order_details (
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
quantity INTEGER NOT NULL,
tax_fee DOUBLE PRECISION,
price DOUBLE PRECISION,
PRIMARY KEY (order_id, product_id),
FOREIGN KEY (order_id)
REFERENCES user_order (id)
ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('milk', 'milk desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'acd', 'd', 'L', '9.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('egg', 'egg desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'ddd', 'd', 'L', '12.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('tea', 'tea desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'aaa', 'm', 'L', '5.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('milk2', 'milk desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'acd', 'd', 'L', '9.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('egg2', 'egg desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'ddd', 'd', 'L', '12.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('tea2', 'tea desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'aaa', 'm', 'L', '5.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('milk3', 'milk desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'acd', 'd', 'L', '9.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('egg3', 'egg desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'ddd', 'd', 'L', '12.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('tea3', 'tea desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'aaa', 'm', 'L', '5.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('milk4', 'milk desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'acd', 'd', 'L', '9.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('egg4', 'egg desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'ddd', 'd', 'L', '12.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('tea4', 'tea desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'aaa', 'm', 'L', '5.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('milk5', 'milk desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'acd', 'd', 'L', '9.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('egg5', 'egg desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'ddd', 'd', 'L', '12.99');
INSERT INTO `cartpool`.`product` (`name`, `description`, `image_url`, `brand`, `category`, `unit`, `price`) VALUES ('tea5', 'tea desc', 'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png', 'aaa', 'm', 'L', '5.99');
INSERT INTO `cartpool`.`store` (`name`, `street`, `city`, `state`, `zip`) VALUES ('STORE1', '123 street', 'city1', 'CA', '99999');
INSERT INTO `cartpool`.`store` (`name`, `street`, `city`, `state`, `zip`) VALUES ('STORE2', '567 ave', 'city2', 'CA', '88888');
INSERT INTO `cartpool`.`store` (`name`, `street`, `city`, `state`, `zip`) VALUES ('STORE3', '333 street', 'city1', 'CA', '77777');
INSERT INTO `cartpool`.`cart_pool` (`id`,`pool_id`,`name`,`neighborhood`,`description`,`zip`,`leader`,`creation_time`) VALUES (1,'pool1','Mypool','abc def','dwwd','33333',1,NULL);
INSERT INTO `cartpool`.`inventory` (`store_id`,`product_id`,`quantity`) VALUES (1,1,0);
INSERT INTO `cartpool`.`inventory` (`store_id`,`product_id`,`quantity`) VALUES (1,2,0);
INSERT INTO `cartpool`.`inventory` (`store_id`,`product_id`,`quantity`) VALUES (1,3,0);
INSERT INTO `cartpool`.`inventory` (`store_id`,`product_id`,`quantity`) VALUES (2,1,0);
INSERT INTO `cartpool`.`inventory` (`store_id`,`product_id`,`quantity`) VALUES (2,3,0);
INSERT INTO `cartpool`.`inventory` (`store_id`,`product_id`,`quantity`) VALUES (2,10,1);
INSERT INTO `cartpool`.`user` (`id`,`email`,`password`,`screen_name`,`nickname`,`pool_id`,`pool_status`,`contribution`,`role`,`active`,`token`,`creation_time`) VALUES (1,'test1@abc.com','$2a$10$qgsBp9ORd9O3EgUGumVcEeXElkG0sbr89C4euaB.jtz8yWBCZOlye','test1','test1',1,'ACTIVE',0,'ROLE_USER',1,NULL,'2020-05-15 11:06:18');
INSERT INTO `cartpool`.`user` (`id`,`email`,`password`,`screen_name`,`nickname`,`pool_id`,`pool_status`,`contribution`,`role`,`active`,`token`,`creation_time`) VALUES (2,'test2@abc.com','$2a$10$GQSUYZbfpImrdh72QHdVouVNbEWTqFsTt.ki86euSm1aFUFAjcSAa','test2','test2',NULL,NULL,0,'ROLE_USER',1,NULL,'2020-05-15 11:06:51');
INSERT INTO `cartpool`.`user` (`id`,`email`,`password`,`screen_name`,`nickname`,`pool_id`,`pool_status`,`contribution`,`role`,`active`,`token`,`creation_time`) VALUES (3,'test3@abc.com','$2a$10$giidPuvZ0OEBc1T5XWIVdOuv9cPK/rlhV82JBe49.JL/efoxAnIu2','test3','test3',NULL,NULL,0,'ROLE_USER',1,NULL,'2020-05-15 11:07:23');
INSERT INTO `cartpool`.`user` (`id`,`email`,`password`,`screen_name`,`nickname`,`pool_id`,`pool_status`,`contribution`,`role`,`active`,`token`,`creation_time`) VALUES (4,'admin@sjsu.edu','$2a$10$mQXSfLBX7HAW.MxEJpdq0OCPyhM5aiwscZt4p/JhVcHdALdp5kiHy','admin','admin',NULL,'INIT',0,'ROLE_ADMIN',1,NULL,'2020-05-15 11:15:58');
| true |
cce8ae19d24df249d617d5cc8d014332e4b05e08 | SQL | merq-rodriguez/Proyecto-Tuberculosis | /src/config/bdv4.sql | UTF-8 | 28,182 | 3.515625 | 4 | [] | no_license | CREATE DATABASE IF NOT EXISTS tuberculosis;
USE tuberculosis;
CREATE TABLE IF NOT EXISTS departamento(
idDepartamento INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS municipio(
idMunicipio INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
fkDepartamento INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkDepartamento) REFERENCES departamento(idDepartamento)
);
CREATE TABLE IF NOT EXISTS rol(
idRol INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
nombre VARCHAR(255),
descripcion TEXT,
estado CHAR(1) DEFAULT 1
);
INSERT INTO rol VALUES(1, 'ADMINISTRADOR', 'Se encarga de administrar todo el sistema', 1);
INSERT INTO rol VALUES(2, 'MEDICO', 'Es el encargado de llevar los casos de tuberculosis', 1);
INSERT INTO rol VALUES(3, 'SUPERVISOR', 'Es el enfermero/a que hace seguimiento de los casos de tuberculosis', 1);
INSERT INTO rol VALUES(4, 'PACIENTE', 'Es un paciente del proceso', 1);
CREATE TABLE IF NOT EXISTS condicion_ingreso(
idIngreso INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
descripcion TEXT,
estado CHAR(1) DEFAULT 1
);
INSERT INTO condicion_ingreso VALUES(1, 'Paciente nuevo', 'Paciente que nunca ha sido tratado por tuberculosis o que ha recibido medicamentos anti tuberculoso por menos de un mes.',1);
INSERT INTO condicion_ingreso VALUES(2, 'Tras recaída', 'paciente que ha sido previamente tratado por tuberculosis, fue declarado curado o tratamiento terminado al final de su último ciclo de tratamiento, y ahora es diagnosticado con un episodio recurrente de tuberculosis (ya sea una verdadera recaída o un nuevo episodio de tuberculosis causado por reinfección).',1);
INSERT INTO condicion_ingreso VALUES(3, 'Tras fracaso', 'paciente previamente tratado por tuberculosis, cuyo tratamiento fracasó.',1);
INSERT INTO condicion_ingreso VALUES(4, 'Recuperado tras pérdida de seguimiento', 'paciente que ha sido tratado previa-mente por tuberculosis y declarado pérdida al seguimiento al final de su tratamiento más reciente.',1);
INSERT INTO condicion_ingreso VALUES(5, 'Otros pacientes previamente tratados', 'son aquellos que han sido previamente tratados por tuberculosis, pero cuyo resultado después del tratamiento más reciente es desconocido o indocumentado.',1);
CREATE TABLE IF NOT EXISTS genero(
idGenero INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
INSERT INTO genero VALUES (1, 'MASCULINO', 1);
INSERT INTO genero VALUES (2, 'FEMENINO', 1);
CREATE TABLE IF NOT EXISTS tipodocumento(
idTipodoc INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
INSERT INTO tipodocumento VALUES (1, 'CEDULA DE CIUDADANIA', 1);
INSERT INTO tipodocumento VALUES (2, 'TARGETA DE IDENTIDAD', 1);
INSERT INTO tipodocumento VALUES (3, 'PASAPORTE', 1);
CREATE TABLE IF NOT EXISTS ips(
idIps INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1)
);
CREATE TABLE IF NOT EXISTS grupo_etnico(
idEtnico INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1)
);
INSERT INTO grupo_etnico(nombre) VALUES('AFRODECENDIENTE');
INSERT INTO grupo_etnico(nombre) VALUES('PUEBLOS INDIGENAS');
INSERT INTO grupo_etnico(nombre) VALUES('RAIZALES');
INSERT INTO grupo_etnico(nombre) VALUES('ROM');
CREATE TABLE IF NOT EXISTS grupo_poblacional(
idPoblacional INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1)
);
CREATE TABLE IF NOT EXISTS regimen_salud(
idRegimen INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1)
);
CREATE TABLE IF NOT EXISTS pueblo_indigeno(
idPueblo_indigeno INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1)
);
CREATE TABLE IF NOT EXISTS persona(
doc_identificacion INT PRIMARY KEY NOT NULL,
nombres VARCHAR(255),
apellidos VARCHAR(255),
ocupacion VARCHAR(255),
telefono VARCHAR(12),
fechanacimiento DATE,
fkregimen INT,
fkPueblo_indigeno INT,
fkIPS INT,
fkGrupo_poblacional INT,
fkPertenencia_etnica INT,
fkLugarnacimiento INT,
fkTipodocumento INT,
fkGenero INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkLugarnacimiento) REFERENCES municipio(idMunicipio),
FOREIGN KEY(fkTipodocumento) REFERENCES tipodocumento(idTipodoc),
FOREIGN KEY(fkIPS) REFERENCES ips(idIps),
FOREIGN KEY(fkGrupo_poblacional) REFERENCES grupo_poblacional(idPoblacional),
FOREIGN KEY(fkPertenencia_etnica) REFERENCES grupo_etnico(idEtnico),
FOREIGN KEY(fkGenero) REFERENCES genero(idGenero),
FOREIGN KEY(fkregimen) REFERENCES regimen_salud(idRegimen),
FOREIGN KEY(fkPueblo_indigeno) REFERENCES pueblo_indigeno(idPueblo_indigeno)
);
CREATE TABLE IF NOT EXISTS direccion(
idDireccion INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
prefijo VARCHAR(20),
numero VARCHAR(50),
sufijo VARCHAR(50),
barrio VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS lugar_residencia(
idResidencia INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fecha DATE,
fkLugar INT,
fkDireccion INT,
fkPersona INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkLugar) REFERENCES municipio(idMunicipio),
FOREIGN KEY(fkPersona) REFERENCES persona(doc_identificacion),
FOREIGN KEY(fkDireccion) REFERENCES direccion(idDireccion)
);
CREATE TABLE IF NOT EXISTS paciente(
idPaciente INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
imc FLOAT,
estatura FLOAT,
peso INT,
talla INT,
fkPersona INT UNIQUE,
fkCondicion_ingreso INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkPersona) REFERENCES persona(doc_identificacion),
FOREIGN KEY(fkCondicion_ingreso) REFERENCES condicion_ingreso(idIngreso)
);
CREATE TABLE IF NOT EXISTS condicion_clinica(
idCondicion_clinica INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
descripcion TEXT,
estado CHAR(1) DEFAULT 1
);
INSERT INTO condicion_clinica VALUES(1, 'Enfermedad Renal', '',1);
INSERT INTO condicion_clinica VALUES(2, 'Enfermedad Hepática', '',1);
INSERT INTO condicion_clinica VALUES(3, 'VIH/SIDA', '',1);
INSERT INTO condicion_clinica VALUES(4, 'Diabetes Mellitus', '',1);
INSERT INTO condicion_clinica VALUES(5, 'Silicosis', '',1);
INSERT INTO condicion_clinica VALUES(6, 'Desnutricion', '',1);
INSERT INTO condicion_clinica VALUES(7, 'Alcoholismo', '',1);
INSERT INTO condicion_clinica VALUES(8, 'Farmacodependencia', '',1);
INSERT INTO condicion_clinica VALUES(9, 'Embarazo', '',1);
INSERT INTO condicion_clinica VALUES(10, 'Tabaquismo', '',1);
CREATE TABLE IF NOT EXISTS ingreso_paciente(
idIngreso_paciente INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fkCondicion_ingreso INT,
fkPaciente INT,
fecha_ingreso DATE,
hora_ingreso TIME,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkCondicion_ingreso) REFERENCES condicion_ingreso(idIngreso),
FOREIGN KEY(fkPaciente) REFERENCES paciente (idPaciente)
);
CREATE TABLE condicionclinica_paciente(
fkCondicion_clinica INT,
fkIngreso_paciente INT,
estado CHAR(1) DEFAULT 1,
PRIMARY KEY(fkCondicion_clinica, fkIngreso_paciente),
FOREIGN KEY(fkIngreso_paciente) REFERENCES ingreso_paciente(idIngreso_paciente),
FOREIGN KEY(fkCondicion_clinica) REFERENCES condicion_clinica(idCondicion_clinica)
);
CREATE TABLE IF NOT EXISTS lugartrabajo(
idtrabajo INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
fecha DATE,
telefono VARCHAR(12),
fkPersona INT,
fkLugar INT,
fkDireccion INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkPersona) REFERENCES persona(doc_identificacion),
FOREIGN KEY(fkLugar) REFERENCES municipio(idMunicipio),
FOREIGN KEY(fkDireccion) REFERENCES direccion(idDireccion)
);
CREATE TABLE IF NOT EXISTS localizacion(
idLocalizacion INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
latitud VARCHAR(255),
longitud VARCHAR(255),
fkDireccion INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkDireccion) REFERENCES direccion(idDireccion)
);
CREATE TABLE IF NOT EXISTS usuario(
idUsuario INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(255) UNIQUE,
email VARCHAR(255) UNIQUE,
password VARCHAR(255),
fkPersona INT UNIQUE,
fkRol INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkRol) REFERENCES rol(idRol),
FOREIGN KEY(fkPersona) REFERENCES persona(doc_identificacion)
);
CREATE TABLE IF NOT EXISTS gestacion(
idGestacion INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
semanas INT,
fecha_inicio DATE,
fkPersona INT,
estado char(1) DEFAULT 1,
FOREIGN KEY(fkPersona) REFERENCES persona(doc_identificacion)
);
CREATE TABLE IF NOT EXISTS cuestionario(
idCuestionario INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
INSERT INTO cuestionario(idCuestionario, nombre) VALUES(1, 'Datos de laboratorio');
INSERT INTO cuestionario(idCuestionario, nombre) VALUES(2, 'Ayudas diagnósticas utilizadas para la configuración de caso');
CREATE TABLE IF NOT EXISTS tipo_pregunta(
idTipo_pregunta INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
INSERT INTO tipo_pregunta(nombre) VALUES('ABIERTA');
INSERT INTO tipo_pregunta(nombre) VALUES('CERRADA');
INSERT INTO tipo_pregunta(nombre) VALUES('OPCION MULTIPLE');
INSERT INTO tipo_pregunta(nombre) VALUES('NUMERICA');
CREATE TABLE IF NOT EXISTS pregunta(
idPregunta INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
fkTipo_pregunta INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkTipo_pregunta) REFERENCES tipo_pregunta(idTipo_pregunta)
);
#POner un tipo a las preguntas
#Tipos de pregunta: cerrada, abierta.
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (1, '¿Tiene cicatriz de vacuna BCG?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (2, '¿Tiene vacuna BCG registrada en carné?', 2);
#Informacion Adicion (NOMBRE DEL CUSTIONARIO)
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (3, '¿Es trabajador de la salud?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (4, '¿Sí en el punto anterior marco sí escriba la ocupación en salud.', 1);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (5, '¿Presenta diagnóstico previo de VIH?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (6, '¿Se realizó asesoría pre-test de VIH?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (7, '¿Se realizó prueba para diagnóstico de VIH?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (8, '¿Hay coinfección tuberculosis - VIH/sida?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (9, '¿Terapia preventiva con Trimetropin sulfa/cotrimoxazol?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (10, '¿Recibe tratamiento antiretroviral?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (11, '¿Inicio tratamiento?', 2);
#Datos de laboratorio (NOMBRE DEL CUESTIONARIO)
#Hay que tener en cuenta que muchas de estas preguntas se solucionan
#Con las demas tablas.
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (12, '¿Se utilizó prueba molecular para la confirmación del caso?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (13, '¿Baciloscopia?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (14, '¿Cultivo?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (15, '¿Histopatología?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (16, '¿Cuadro clínico?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (17, '¿Nexo epidemiológico?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (18, '¿Radiológico?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (19, '¿Adenosina deaminasa (ADA)?', 2);
INSERT INTO pregunta(idPregunta, nombre, fkTipo_pregunta) VALUES (20, '¿Tuberculina?', 2);
CREATE TABLE IF NOT EXISTS pregunta_cuestionario(
fkPregunta INT,
fkCuestionario INT,
estado CHAR(1) DEFAULT 1,
PRIMARY KEY(fkPregunta, fkCuestionario),
FOREIGN KEY (fkPregunta) REFERENCES pregunta(idPregunta),
FOREIGN KEY (fkCuestionario) REFERENCES cuestionario(idCuestionario)
);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (1, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (2, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (3, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (4, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (5, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (6, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (7, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (8, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (9, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (10, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (11, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (12, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (13, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (14, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (15, 1);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (16, 2);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (17, 2);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (18, 2);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (19, 2);
INSERT INTO pregunta_cuestionario(fkPregunta, fkCuestionario) VALUES (20, 2);
|
CREATE TABLE IF NOT EXISTS respuesta_persona(
fkPersona INT,
fkCuestionario INT,
fkPregunta INT,
respuesta VARCHAR(255),
estado CHAR(1) DEFAULT 1,
PRIMARY key(fkPersona, fkCuestionario, fkPregunta),
FOREIGN KEY(fkCuestionario) REFERENCES cuestionario(idCuestionario),
FOREIGN KEY(fkPregunta) REFERENCES pregunta(idPregunta),
FOREIGN KEY(fkPersona) REFERENCES persona(doc_identificacion)
);
CREATE TABLE IF NOT EXISTS nivelexposicion(
idNivelexpocicion INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
descripcion TEXT,
estado CHAR(1) DEFAULT 1
);
INSERT INTO nivelexposicion(nombre, descripcion) VALUES('NIVEL I', 'Convivientes habituales del paciente tuberculoso.');
INSERT INTO nivelexposicion(nombre, descripcion) VALUES('NIVEL II', 'Contacto frecuente.');
INSERT INTO nivelexposicion(nombre, descripcion) VALUES('NIVEL III', 'Contacto ocasional con un enfermo bacilífero.');
CREATE TABLE IF NOT EXISTS tiporelacion(
idTiporelacion INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
INSERT INTO tiporelacion VALUES(1, 'RELACION DE AMISTAD', 1);
INSERT INTO tiporelacion VALUES(2, 'RELACION AMOROSA', 1);
INSERT INTO tiporelacion VALUES(3, 'RELACION DE TRABAJO', 1);
INSERT INTO tiporelacion VALUES(4, 'RELACION DEPORTIVA', 1);
INSERT INTO tiporelacion VALUES(5, 'RELACION ACADEMICA', 1);
CREATE TABLE IF NOT EXISTS cadenacontacto( #Personas que han tenido contacto con el paciente
idContacto INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
estadosalud VARCHAR(255),
duracioncontacto TIME,
fechacontacto DATE,
contexto VARCHAR(255),
fkPersona INT,
fkLugarcontacto INT,
fkDireccioncontacto INT,
fkTiporelacion INT,
fkNivelexposicion INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkPersona) REFERENCES persona(doc_identificacion),
FOREIGN KEY(fkLugarcontacto) REFERENCES municipio(idMunicipio),
FOREIGN KEY(fkDireccioncontacto) REFERENCES direccion(idDireccion),
FOREIGN KEY(fkTiporelacion) REFERENCES tiporelacion(idTiporelacion),
FOREIGN KEY(fkNivelexposicion) REFERENCES nivelexposicion(idNivelexpocicion)
);
CREATE TABLE IF NOT EXISTS paciente_cadenacontacto(
fkPaciente INT,
fkCadenacontacto INT,
estado CHAR(1) DEFAULT 1,
PRIMARY key(fkPaciente, fkCadenacontacto),
FOREIGN KEY(fkPaciente) REFERENCES paciente(idPaciente),
FOREIGN KEY(fkCadenacontacto) REFERENCES cadenacontacto(idContacto)
);
CREATE TABLE IF NOT EXISTS sintoma(
idSintoma INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
fechainicio DATE,
tiposintomas VARCHAR(255), #Tener en cuenta la duracion.
fkPaciente INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY (fkPaciente) REFERENCES paciente(idPaciente)
);
CREATE TABLE IF NOT EXISTS nivel_laboratorio(
idNivellaboratorio INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
descripcion TEXT,
estado CHAR(1) DEFAULT 1
);
INSERT INTO nivel_laboratorio VALUES(1, 'LABORATORIOS CLINICOS NIVEL I', 'Realizan bacilos copia, algunos inoculan muestras de esputo y remiten a otro nivel para el proceso de incubación.', 1);
INSERT INTO nivel_laboratorio VALUES(2, 'LABORATORIOS CLINICOS NIVEL II', 'Realizan baciloscopia, algunos inoculan la muestra de esputo y remiten a otro nivel para el proceso de incubación, aquellos que tienen área de microbiología hacen el proceso completo del cultivo.', 1);
INSERT INTO nivel_laboratorio VALUES(3, 'LABORATORIOS CLINICOS NIVEL III', 'Realizan baciloscopia y cultivo de muestras pulmonares y extrapulmonares, aquellos con capacidad e infraestructura realizan pruebas moleculares', 1);
CREATE TABLE IF NOT EXISTS medicamento(
idMedicamento INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
descripcion TEXT,
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS fase(
idFase INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
fkFase INT,
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS dosis_medicamento(
idDosis INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
cantidad FLOAT,
fecha DATE,
fkMedicamento INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY (fkMedicamento) REFERENCES medicamento(idMedicamento)
);
CREATE TABLE IF NOT EXISTS tratamiento(
codigo INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1)
);
CREATE TABLE IF NOT EXISTS tratamiento_paciente(
idTrataPaciente INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fkDosisMedicamento INT,
fkTratamiento INT,
fkPaciente INT,
fkFase INT,
fecha DATE,
estado CHAR(1),
FOREIGN KEY (fkFase) REFERENCES fase(idFase),
FOREIGN KEY (fkTratamiento) REFERENCES tratamiento(codigo),
FOREIGN KEY (fkPaciente) REFERENCES paciente(idPaciente),
FOREIGN KEY (fkDosisMedicamento) REFERENCES dosis_medicamento(idDosis)
);
CREATE TABLE IF NOT EXISTS tuberculosis(
idTuberculosis INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(100),
descripcion TEXT,
estado char(1) DEFAULT 1
);
INSERT INTO tuberculosis(nombre, descripcion) VALUES('TUBERCULOSIS PULMONAR', 'lorem');
INSERT INTO tuberculosis(nombre, descripcion) VALUES('TUBERCULOSIS EXTRAPULMONAR', 'lorem');
CREATE TABLE IF NOT EXISTS naturaleza_tuberculosis(
idNatu_tuberculosis INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(100),
descripcion TEXT
);
INSERT INTO naturaleza_tuberculosis(nombre, descripcion) VALUES('TUBERCULOSIS RESISTENTE', 'lorem');
INSERT INTO naturaleza_tuberculosis(nombre, descripcion) VALUES('TUBERCULOSIS SENSIBLE', 'lorem');
CREATE TABLE IF NOT EXISTS localizacion_extrapulmonar(
idLocalizacion_extrapul INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
INSERT INTO localizacion_extrapulmonar VALUES (1, 'PLEURAL', 1);
INSERT INTO localizacion_extrapulmonar VALUES (2, 'MININGEA', 1);
INSERT INTO localizacion_extrapulmonar VALUES (3, 'PERITONEAL', 1);
INSERT INTO localizacion_extrapulmonar VALUES (4, 'GANGLIONAR', 1);
INSERT INTO localizacion_extrapulmonar VALUES (5, 'RENAL', 1);
INSERT INTO localizacion_extrapulmonar VALUES (6, 'INTESTINAL', 1);
INSERT INTO localizacion_extrapulmonar VALUES (7, 'OSTEOARTICULAR', 1);
INSERT INTO localizacion_extrapulmonar VALUES (8, 'GENITOURINARIA', 1);
INSERT INTO localizacion_extrapulmonar VALUES (9, 'PERICARDICA', 1);
INSERT INTO localizacion_extrapulmonar VALUES (10, 'CUTANEA', 1);
INSERT INTO localizacion_extrapulmonar VALUES (11, 'OTRO', 1);
CREATE TABLE IF NOT EXISTS detalle_extrapulmonar(
idDetalle_extrapulmonar INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
descripcion TEXT,
fkLocalizacion_extra INT,
fkTuberculosis INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkLocalizacion_extra)
REFERENCES localizacion_extrapulmonar(idLocalizacion_extrapul),
FOREIGN KEY(fkTuberculosis) REFERENCES tuberculosis(idTuberculosis)
);
CREATE TABLE IF NOT EXISTS muestra(
idMuestra INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
#Tipos de muestras:
#(+) Para muestras de orina, líquido seminal, flujo menstrual, materia fecal y
#sangre, serán recolectadas según indicaciones del laboratorio
#(+) Pueden ser (líquidos: cefalorraquídeo, pleural, pericárdico, ascítico y sinovial, biopsias)
CREATE TABLE IF NOT EXISTS conservacionmuestra(
idtransporte INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
duracionhoras INT,
temperatura INT,#grados Centigrados
fkMuestra INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkMuestra) REFERENCES muestra(idMuestra)
);
CREATE TABLE IF NOT EXISTS laboratorio(
idLaboratorio INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
fecha DATE,
fkNivel_laboratorio INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkNivel_laboratorio) REFERENCES nivel_laboratorio(idNivellaboratorio)
);
CREATE TABLE IF NOT EXISTS diagnostico_laboratorio(
idDetalle_labo INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fkPaciente INT,
fkMedico INT,
fkTuberculosis INT,
fkNaturaleza_tuberculosis INT,
fkLaboratorio INT,
observaciones TEXT,
estado CHAR(1),
FOREIGN KEY (fkMedico) REFERENCES usuario(idUsuario),
FOREIGN KEY (fkPaciente) REFERENCES paciente(idPaciente),
FOREIGN KEY (fkTuberculosis) REFERENCES tuberculosis(idTuberculosis),
FOREIGN KEY (fkNaturaleza_tuberculosis) REFERENCES naturaleza_tuberculosis(idNatu_tuberculosis),
FOREIGN KEY (fkLaboratorio) REFERENCES laboratorio(idLaboratorio)
);
CREATE TABLE metodo_diagnostico(
idMetodo_diagnostico INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
descripcion TEXT,
estado CHAR(1) DEFAULT 1
);
CREATE TABLE detalle_laboratorio_metodo(
fkLaboratorio INT,
fkMetodo INT,
estado CHAR(1) DEFAULT 1,
PRIMARY KEY(fkLaboratorio, fkMetodo),
FOREIGN KEY(fkLaboratorio) REFERENCES laboratorio(idLaboratorio),
FOREIGN KEY(fkMetodo) REFERENCES metodo_diagnostico(idMetodo_diagnostico)
);
#===================================================================================
# PRUEBAS LABORATORIO
#===================================================================================
CREATE TABLE IF NOT EXISTS resultado_bk(
idResultado_bk INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS detalle_resultado_bk(
idDetalle_resultado_bk INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fecha_resultado DATE,
fkMetodo INT,
fkMuestra INT,
fkResultado_bk INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkResultado_bk) REFERENCES resultado_bk(idResultado_bk),
FOREIGN KEY(fkMetodo) REFERENCES metodo_diagnostico(idMetodo_diagnostico),
FOREIGN KEY(fkMuestra) REFERENCES muestra(idMuestra)
);
CREATE TABLE IF NOT EXISTS resultadoprueba_sensibilidad_farmaco(
idResultado_pru_sensibilidad_farmaco INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS detalle_resultado_prueba_farmaco(
idDetalle_resultado_farmaco INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fecha_resultado DATE,
fkMetodo INT,
fkMuestra INT,
fkResultado_farmaco INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkResultado_farmaco) REFERENCES resultadoprueba_sensibilidad_farmaco(idResultado_pru_sensibilidad_farmaco),
FOREIGN KEY(fkMetodo) REFERENCES metodo_diagnostico(idMetodo_diagnostico),
FOREIGN KEY(fkMuestra) REFERENCES muestra(idMuestra)
);
CREATE TABLE IF NOT EXISTS resultado_basiloscopia(
idResultado_basilo INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS detalle_resultado_basiloscopia(
idDetalle_resultado_basiloscopia INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fecha_resultado DATE,
fkMetodo INT,
fkMuestra INT,
fkResultado_basiloscopia INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkResultado_basiloscopia) REFERENCES resultado_basiloscopia(idResultado_basilo),
FOREIGN KEY(fkMetodo) REFERENCES metodo_diagnostico(idMetodo_diagnostico),
FOREIGN KEY(fkMuestra) REFERENCES muestra(idMuestra)
);
CREATE TABLE IF NOT EXISTS resultado_reportecultivo(
idReportecultivo INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
INSERT INTO resultado_reportecultivo VALUES(1, 'Positivo entre 1-20 colonias BAAR', 1);
INSERT INTO resultado_reportecultivo VALUES(2, '(+) 21 a 100 colonias BAAR', 1);
INSERT INTO resultado_reportecultivo VALUES(3, '(++) Más de 100 colonias BAAR', 1);
INSERT INTO resultado_reportecultivo VALUES(4, '(+++) Colonias BAAR confluentes', 1);
INSERT INTO resultado_reportecultivo VALUES(5, 'Cultivo negativo', 1);
INSERT INTO resultado_reportecultivo VALUES(6, 'Contaminado', 1);
INSERT INTO resultado_reportecultivo VALUES(7, 'En proceso', 1);
CREATE TABLE IF NOT EXISTS especie(
idEspecie INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS detalle_resultado_cultivo(
idDetalle_resultado_cultivo INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fecha_resultado DATE,
fkMetodo INT,
fkMuestra INT,
fkEspecie INT,
fkResultado_cultivo INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY (fkResultado_cultivo) REFERENCES resultado_reportecultivo(idReportecultivo),
FOREIGN KEY (fkMuestra) REFERENCES muestra(idMuestra),
FOREIGN KEY (fkEspecie) REFERENCES especie(idEspecie),
FOREIGN KEY(fkMetodo) REFERENCES metodo_diagnostico(idMetodo_diagnostico)
);
CREATE TABLE IF NOT EXISTS resultado_prueba_molecular(
idResultado_prueba_molecular INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS tipoprueba_molecular(
idTipo_pruebamolecular INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
INSERT INTO tipoprueba_molecular(idTipo_pruebamolecular, nombre, estado) VALUES(1, 'Sist. cerrado PCR tiempo real',1);
INSERT INTO tipoprueba_molecular(idTipo_pruebamolecular, nombre, estado) VALUES(2,'Amplificación e hibridación de sondas en línea',1);
INSERT INTO tipoprueba_molecular(idTipo_pruebamolecular, nombre, estado) VALUES(3, 'Amplificación e hibridación de sondas en línea',1);
INSERT INTO tipoprueba_molecular(idTipo_pruebamolecular, nombre, estado) VALUES(4, 'Otro', 1);
CREATE TABLE IF NOT EXISTS detalle_resultado_pruebamolecular(
idDetalle_resultado_molecular INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fecha_resultado DATE,
fkMetodo INT,
fkMuestra INT,
fkTipo_prueba_molecular INT,
fkResultado_molecular INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY(fkMetodo) REFERENCES metodo_diagnostico(idMetodo_diagnostico),
FOREIGN KEY (fkResultado_molecular) REFERENCES resultado_prueba_molecular(idResultado_prueba_molecular),
FOREIGN KEY (fkMuestra) REFERENCES muestra(idMuestra),
FOREIGN KEY (fkTipo_prueba_molecular) REFERENCES tipoprueba_molecular(idTipo_pruebamolecular)
);
CREATE TABLE IF NOT EXISTS resultado_biopsia(
idResultado_biopsia INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
nombre VARCHAR(255),
estado CHAR(1) DEFAULT 1
);
CREATE TABLE IF NOT EXISTS detalle_resultado_biopcia(
idDetalle_resultado_molecular INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
fecha_resultado DATE,
fkMetodo INT,
fkMuestra INT,
fkResultado_biopsia INT,
estado CHAR(1) DEFAULT 1,
FOREIGN KEY (fkResultado_biopsia) REFERENCES resultado_biopsia(idResultado_biopsia),
FOREIGN KEY (fkMuestra) REFERENCES muestra(idMuestra),
FOREIGN KEY(fkMetodo) REFERENCES metodo_diagnostico(idMetodo_diagnostico)
);
| true |
db2d94b490247bb983c300844303c6fa2209b8b7 | SQL | babynus/projeqtor | /branches/V4.2/projeqtor/db/projeqtor_V4.2.0.sql | UTF-8 | 19,314 | 3.171875 | 3 | [] | no_license | -- ///////////////////////////////////////////////////////////
-- // PROJECTOR //
-- //-------------------------------------------------------//
-- // Version : 4.2.0 //
-- // Date : 2014-01-11 //
-- ///////////////////////////////////////////////////////////
ALTER TABLE `${prefix}resource` ADD COLUMN `cookieHash` varchar(400) null,
ADD COLUMN `passwordChangeDate` date DEFAULT NULL;
CREATE TABLE `${prefix}checklistdefinition` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100),
`idChecklistable` int(12) unsigned DEFAULT NULL,
`nameChecklistable` varchar(100),
`idType` int(12) unsigned DEFAULT NULL,
`lineCount` int(3) DEFAULT 0,
`idle` int(1) unsigned DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE INDEX checklistdefinitionChecklistable ON `${prefix}checklistdefinition` (idChecklistable);
CREATE INDEX checklistdefinitionNameChecklistable ON `${prefix}checklistdefinition` (nameChecklistable);
CREATE INDEX checklistdefinitionType ON `${prefix}checklistdefinition` (idType);
CREATE TABLE `${prefix}checklistdefinitionline` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`idChecklistDefinition` int(12) unsigned DEFAULT NULL,
`name` varchar(100),
`title` varchar(1000),
`check01` varchar(100) DEFAULT NULL,
`check02` varchar(100) DEFAULT NULL,
`check03` varchar(100) DEFAULT NULL,
`check04` varchar(100) DEFAULT NULL,
`check05` varchar(100) DEFAULT NULL,
`title01` varchar(1000) DEFAULT NULL,
`title02` varchar(1000) DEFAULT NULL,
`title03` varchar(1000) DEFAULT NULL,
`title04` varchar(1000) DEFAULT NULL,
`title05` varchar(1000) DEFAULT NULL,
`sortOrder` int(3) DEFAULT 0,
`exclusive` int(1) unsigned DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE INDEX checklistdefinitionlineChecklistDefinition ON `${prefix}checklistdefinitionline` (idChecklistDefinition);
CREATE TABLE `${prefix}checklist` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`idChecklistDefinition` int(12) unsigned DEFAULT NULL,
`refType` varchar(100),
`refId` int(12) unsigned DEFAULT NULL,
`checkCount` int(3) DEFAULT 0,
`comment` varchar(4000),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE INDEX checklistReference ON `${prefix}checklist` (refType, refId);
CREATE INDEX checklistChecklistDefinition ON `${prefix}checklist` (idChecklistDefinition);
CREATE TABLE `${prefix}checklistline` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`idChecklist` int(12) unsigned DEFAULT NULL,
`idChecklistDefinitionLine` int(12) unsigned DEFAULT NULL,
`value01` int(1) unsigned DEFAULT '0',
`value02` int(1) unsigned DEFAULT '0',
`value03` int(1) unsigned DEFAULT '0',
`value04` int(1) unsigned DEFAULT '0',
`value05` int(1) unsigned DEFAULT '0',
`idUser` int(12) unsigned DEFAULT NULL,
`checkTime` datetime DEFAULT NULL,
`comment` varchar(4000),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
CREATE INDEX checklistlineChecklist ON `${prefix}checklistline` (idChecklist);
CREATE INDEX checklistlineChecklistDefinitionLine ON `${prefix}checklistline` (idChecklistDefinitionLine);
UPDATE `${prefix}menu` SET idMenu=0 where id=88;
UPDATE `${prefix}menu` SET idMenu=88 where id=116;
UPDATE `${prefix}menu` SET sortOrder=10 where id=1;
UPDATE `${prefix}menu` SET idMenu=20 where id=16;
UPDATE `${prefix}menu` SET idMenu=30 where id=102;
INSERT INTO `${prefix}menu` (`id`, `name`, `idMenu`, `type`, `sortOrder`, `level`, `idle`) VALUES
(130, 'menuChecklistDefinition', '88', 'object', '630', null, 0);
INSERT INTO `${prefix}habilitation` (`idProfile`, `idMenu`, `allowAccess`) VALUES
(1, 130, 1),
(2, 130, 0),
(3, 130, 0),
(4, 130, 0),
(5, 130, 0),
(6, 130, 0),
(7, 130, 0);
INSERT INTO `${prefix}referencable` (`name`, `idle`) VALUES
('Opportunity',0);
CREATE TABLE `${prefix}checklistable` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100),
`idle` int(1) unsigned DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
INSERT INTO `${prefix}checklistable` (`name`, `idle`) VALUES
('Ticket',0),
('Activity',0),
('Milestone',0),
('Risk',0),
('Action',0),
('Issue',0),
('Meeting',0),
('Decision',0),
('Question',0),
('Document',0),
('Requirement',0),
('TestCase',0),
('TestSession',0),
('Command',0),
('Opportunity',0),
('Project',0);
INSERT INTO `${prefix}habilitationother` (`idProfile`, `scope`, `rightAccess`) VALUES
(1, 'checklist', 1),
(2, 'checklist', 1),
(3, 'checklist', 1),
(4, 'checklist', 1),
(6, 'checklist', 2),
(7, 'checklist', 2),
(5, 'checklist', 2);
CREATE TABLE `${prefix}quotation` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`idProject` int(12) unsigned DEFAULT NULL,
`idQuotationType` int(12) unsigned DEFAULT NULL,
`name` varchar(100) DEFAULT NULL,
`description` varchar(4000) DEFAULT NULL,
`creationDate` datetime DEFAULT NULL,
`idUser` int(12) unsigned DEFAULT NULL,
`idStatus` int(12) unsigned DEFAULT NULL,
`idResource` int(12) unsigned DEFAULT NULL,
`idClient` int(12) unsigned DEFAULT NULL,
`idContact` int(12) unsigned DEFAULT NULL,
`additionalInfo` varchar(4000) DEFAULT NULL,
`initialEndDate` date DEFAULT NULL,
`initialWork` decimal(12,2) DEFAULT '0.00',
`initialPricePerDayAmount` decimal(12,2) DEFAULT '0.00',
`initialAmount` decimal(12,2) DEFAULT '0.00',
`comment` varchar(4000) DEFAULT NULL,
`idle` int(1) unsigned DEFAULT '0',
`done` int(1) unsigned DEFAULT '0',
`cancelled` int(1) unsigned DEFAULT '0',
`idleDate` date DEFAULT NULL,
`doneDate` date DEFAULT NULL,
`handled` int(1) unsigned DEFAULT '0',
`handledDate` date DEFAULT NULL,
`reference` varchar(100) DEFAULT NULL,
`sendDate` date DEFAULT NULL,
`validityEndDate` date DEFAULT NULL,
`idActivityType` int(12) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX quotationProject ON `${prefix}quotation` (idProject);
CREATE INDEX quotationUser ON `${prefix}quotation` (idUser);
CREATE INDEX quotationResource ON `${prefix}quotation` (idResource);
CREATE INDEX quotationStatus ON `${prefix}quotation` (idStatus);
CREATE INDEX quotationType ON `${prefix}quotation` (idQuotationType);
CREATE INDEX quotationClient ON `${prefix}quotation` (idClient);
CREATE INDEX quotationContact ON `${prefix}quotation` (idContact);
INSERT INTO `${prefix}type` (`scope`, `name`, `sortOrder`, `idle`, `idWorkflow`, `mandatoryDescription`, `mandatoryResultOnDone`, `mandatoryResourceOnHandled`, `lockHandled`, `lockDone`, `lockIdle`, `code`) VALUES
('Quotation', 'Fixe Price', '10', '0', '1', '0', '0', '0', '0', '1', '1', '');
INSERT INTO `${prefix}type` (`scope`, `name`, `sortOrder`, `idle`, `idWorkflow`, `mandatoryDescription`, `mandatoryResultOnDone`, `mandatoryResourceOnHandled`, `lockHandled`, `lockDone`, `lockIdle`, `code`) VALUES
('Quotation', 'Per day', '20', '0', '1', '0', '0', '0', '0', '1', '1', '');
INSERT INTO `${prefix}type` (`scope`, `name`, `sortOrder`, `idle`, `idWorkflow`, `mandatoryDescription`, `mandatoryResultOnDone`, `mandatoryResourceOnHandled`, `lockHandled`, `lockDone`, `lockIdle`, `code`) VALUES
('Quotation', 'Per month', '30', '0', '1', '0', '0', '0', '0', '1', '1', '');
INSERT INTO `${prefix}type` (`scope`, `name`, `sortOrder`, `idle`, `idWorkflow`, `mandatoryDescription`, `mandatoryResultOnDone`, `mandatoryResourceOnHandled`, `lockHandled`, `lockDone`, `lockIdle`, `code`) VALUES
('Quotation', 'Per year', '40', '0', '1', '0', '0', '0', '0', '1', '1', '');
INSERT INTO `${prefix}type` (`scope`, `name`, `sortOrder`, `idle`, `idWorkflow`, `mandatoryDescription`, `mandatoryResultOnDone`, `mandatoryResourceOnHandled`, `lockHandled`, `lockDone`, `lockIdle`, `code`) VALUES
('Command', 'Per month', '30', '0', '1', '0', '0', '0', '0', '1', '1', '');
INSERT INTO `${prefix}type` (`scope`, `name`, `sortOrder`, `idle`, `idWorkflow`, `mandatoryDescription`, `mandatoryResultOnDone`, `mandatoryResourceOnHandled`, `lockHandled`, `lockDone`, `lockIdle`, `code`) VALUES
('Command', 'Per year', '40', '0', '1', '0', '0', '0', '0', '1', '1', '');
INSERT INTO `${prefix}menu` (`id`, `name`, `idMenu`, `type`, `sortOrder`, `level`, `idle`) VALUES
(131,'menuQuotation', '74', 'object', '225', 'Project', 0);
INSERT INTO `${prefix}menu` (`id`, `name`, `idMenu`, `type`, `sortOrder`, `idle`) VALUES
(132, 'menuQuotationType', '79', 'object', '824', 0);
INSERT INTO `${prefix}habilitation` (`idProfile`, `idMenu`, `allowAccess`) VALUES
(1, 131, 1),
(2, 131, 1),
(3, 131, 1),
(4, 131, 0),
(5, 131, 0),
(6, 131, 0),
(7, 131, 0);
INSERT INTO `${prefix}habilitation` (`idProfile`, `idMenu`, `allowAccess`) VALUES
(1, 132, 1),
(2, 132, 0),
(3, 132, 0),
(4, 132, 0),
(5, 132, 0),
(6, 132, 0),
(7, 132, 0);
INSERT INTO `${prefix}accessright` (`idProfile`, `idMenu`, `idAccessProfile`)
SELECT `idProfile`, 131, `idAccessProfile` FROM `${prefix}accessright` WHERE `idMenu`=97;
INSERT INTO `${prefix}accessright` (`idProfile`, `idMenu`, `idAccessProfile`)
SELECT `idProfile`, 132, `idAccessProfile` FROM `${prefix}accessright` WHERE `idMenu`=100;
INSERT INTO `${prefix}originable` (`id`,`name`, `idle`) VALUES (18,'Quotation', 0);
INSERT INTO `${prefix}mailable` (`id`,`name`, `idle`) VALUES (22,'Quotation', '0');
INSERT INTO `${prefix}linkable` (`id`,`name`, `idle`, `idDefaultLinkable`) VALUES (19,'Quotation', 0, 18);
INSERT INTO `${prefix}referencable` (`name`, `idle`) VALUES ('Quotation', 0);
INSERT INTO `${prefix}indicatorable` (`id`,`name`, `idle`) VALUES (11,'Quotation', '0');
INSERT INTO `${prefix}importable` (`id`,`name`, `idle`) VALUES (28,'Quotation', '0');
INSERT INTO `${prefix}copyable` (`id`,`name`, `idle`, `sortOrder`) VALUES (14,'Quotation', '0', '37');
INSERT INTO `${prefix}indicatorableindicator` (`idIndicatorable`, `nameIndicatorable`, `idIndicator`, `idle`) VALUES
('11', 'Quotation', '8', '0');
INSERT INTO `${prefix}indicatorableindicator` (`idIndicatorable`, `nameIndicatorable`, `idIndicator`, `idle`) VALUES
('11', 'Quotation', '5', '0');
INSERT INTO `${prefix}indicatorableindicator` (`idIndicatorable`, `nameIndicatorable`, `idIndicator`, `idle`) VALUES
('11', 'Quotation', '6', '0');
ALTER TABLE `${prefix}product` ADD COLUMN `designation` varchar(100) null DEFAULT NULL;
INSERT INTO `${prefix}parameter` (idUser,idProject, parameterCode, parameterValue)
VALUES (null, null, 'paramTopIconSize', '16');
ALTER TABLE `${prefix}filtercriteria` CHANGE `sqlValue` `sqlValue` VARCHAR(4000);
ALTER TABLE `${prefix}command` ADD COLUMN `idActivityType` int(12) unsigned DEFAULT NULL,
ADD COLUMN `idClient` int(12) unsigned DEFAULT NULL,
ADD COLUMN `idContact` int(12) unsigned DEFAULT NULL;
ALTER TABLE `${prefix}bill` ADD COLUMN `idActivityType` int(12) unsigned DEFAULT NULL;
INSERT INTO `${prefix}copyable` (`id`,`name`, `idle`, `sortOrder`) VALUES (15,'Bill', '0', '38');
DELETE FROM `${prefix}menu` where id=77;
ALTER TABLE `${prefix}report` ADD COLUMN `orientation` VARCHAR(1) DEFAULT 'L';
INSERT INTO `${prefix}habilitationother` (`idProfile`, `scope`, `rightAccess`) VALUES
(1, 'assignmentView', 1),
(2, 'assignmentView', 1),
(3, 'assignmentView', 1),
(4, 'assignmentView', 1),
(6, 'assignmentView', 2),
(7, 'assignmentView', 2),
(5, 'assignmentView', 2);
INSERT INTO `${prefix}habilitationother` (`idProfile`, `scope`, `rightAccess`) VALUES
(1, 'assignmentEdit', 1),
(2, 'assignmentEdit', 2),
(3, 'assignmentEdit', 1),
(4, 'assignmentEdit', 2),
(6, 'assignmentEdit', 2),
(7, 'assignmentEdit', 2),
(5, 'assignmentEdit', 2);
ALTER TABLE `${prefix}requirement` ADD COLUMN `initialDueDate` date DEFAULT NULL,
ADD COLUMN `actualDueDate` date DEFAULT NULL;
INSERT INTO `${prefix}indicatorable` (`id`,`name`, `idle`) VALUES (12,'Requirement', '0');
INSERT INTO `${prefix}indicatorableindicator` (`idIndicatorable`, `nameIndicatorable`, `idIndicator`, `idle`) VALUES
('12', 'Requirement', '3', '0');
INSERT INTO `${prefix}indicatorableindicator` (`idIndicatorable`, `nameIndicatorable`, `idIndicator`, `idle`) VALUES
('12', 'Requirement', '4', '0');
INSERT INTO `${prefix}parameter` (idUser,idProject, parameterCode, parameterValue) VALUES
(null, null, 'paramMailTitleApprover', '[${dbName}] message from ${sender} : You need to approve a document'),
(null, null, 'paramMailBodyApprover', '[${dbName}] You are approver of <a href="${url}" > Document #${id}</a> : "${name}".<br/>Please access <a href="${url}" >this document</a> and follow approval process.');
UPDATE `${prefix}menu` SET idMenu=0 where id in (16,102);
UPDATE `${prefix}menu` SET sortOrder=10 where id=1;
UPDATE `${prefix}menu` SET sortOrder=20 where id=16;
UPDATE `${prefix}menu` SET sortOrder=30 where id=102;
UPDATE `${prefix}menu` SET sortOrder=40 where id=2;
UPDATE `${prefix}menu` SET sortOrder=50 where id=22;
UPDATE `${prefix}menu` SET sortOrder=60 where id=118;
UPDATE `${prefix}menu` SET sortOrder=70 where id=25;
UPDATE `${prefix}menu` SET sortOrder=80 where id=26;
UPDATE `${prefix}menu` SET sortOrder=90 where id=4;
UPDATE `${prefix}menu` SET sortOrder=100 where id=7;
UPDATE `${prefix}menu` SET sortOrder=110 where id=8;
UPDATE `${prefix}menu` SET sortOrder=120 where id=9;
UPDATE `${prefix}menu` SET sortOrder=130 where id=123;
UPDATE `${prefix}menu` SET sortOrder=140 where id=106;
UPDATE `${prefix}menu` SET sortOrder=150 where id=61;
UPDATE `${prefix}menu` SET sortOrder=160 where id=110;
UPDATE `${prefix}menu` SET sortOrder=170 where id=111;
UPDATE `${prefix}menu` SET sortOrder=180 where id=112;
UPDATE `${prefix}menu` SET sortOrder=190 where id=113;
UPDATE `${prefix}menu` SET sortOrder=200 where id=74;
UPDATE `${prefix}menu` SET sortOrder=210 where id=75;
UPDATE `${prefix}menu` SET sortOrder=220 where id=76;
UPDATE `${prefix}menu` SET sortOrder=230 where id=131;
UPDATE `${prefix}menu` SET sortOrder=240 where id=125;
UPDATE `${prefix}menu` SET sortOrder=250 where id=96;
UPDATE `${prefix}menu` SET sortOrder=260 where id=97;
UPDATE `${prefix}menu` SET sortOrder=270 where id=78;
UPDATE `${prefix}menu` SET sortOrder=280 where id=94;
UPDATE `${prefix}menu` SET sortOrder=290 where id=43;
UPDATE `${prefix}menu` SET sortOrder=300 where id=3;
UPDATE `${prefix}menu` SET sortOrder=310 where id=119;
UPDATE `${prefix}menu` SET sortOrder=320 where id=5;
UPDATE `${prefix}menu` SET sortOrder=330 where id=6;
UPDATE `${prefix}menu` SET sortOrder=340 where id=62;
UPDATE `${prefix}menu` SET sortOrder=350 where id=124;
UPDATE `${prefix}menu` SET sortOrder=360 where id=63;
UPDATE `${prefix}menu` SET sortOrder=370 where id=64;
UPDATE `${prefix}menu` SET sortOrder=380 where id=11;
UPDATE `${prefix}menu` SET sortOrder=390 where id=12;
UPDATE `${prefix}menu` SET sortOrder=400 where id=69;
UPDATE `${prefix}menu` SET sortOrder=410 where id=91;
UPDATE `${prefix}menu` SET sortOrder=420 where id=51;
UPDATE `${prefix}menu` SET sortOrder=430 where id=58;
UPDATE `${prefix}menu` SET sortOrder=440 where id=14;
UPDATE `${prefix}menu` SET sortOrder=450 where id=86;
UPDATE `${prefix}menu` SET sortOrder=460 where id=87;
UPDATE `${prefix}menu` SET sortOrder=470 where id=50;
UPDATE `${prefix}menu` SET sortOrder=480 where id=104;
UPDATE `${prefix}menu` SET sortOrder=490 where id=17;
UPDATE `${prefix}menu` SET sortOrder=500 where id=44;
UPDATE `${prefix}menu` SET sortOrder=510 where id=72;
UPDATE `${prefix}menu` SET sortOrder=520 where id=15;
UPDATE `${prefix}menu` SET sortOrder=530 where id=95;
UPDATE `${prefix}menu` SET sortOrder=540 where id=57;
UPDATE `${prefix}menu` SET sortOrder=550 where id=103;
UPDATE `${prefix}menu` SET sortOrder=560 where id=85;
UPDATE `${prefix}menu` SET sortOrder=570 where id=88;
UPDATE `${prefix}menu` SET sortOrder=580 where id=59;
UPDATE `${prefix}menu` SET sortOrder=590 where id=68;
UPDATE `${prefix}menu` SET sortOrder=600 where id=89;
UPDATE `${prefix}menu` SET sortOrder=610 where id=90;
UPDATE `${prefix}menu` SET sortOrder=620 where id=116;
UPDATE `${prefix}menu` SET sortOrder=630 where id=130;
UPDATE `${prefix}menu` SET sortOrder=700 where id=13;
UPDATE `${prefix}menu` SET sortOrder=705 where id=36;
UPDATE `${prefix}menu` SET sortOrder=715 where id=73;
UPDATE `${prefix}menu` SET sortOrder=720 where id=34;
UPDATE `${prefix}menu` SET sortOrder=725 where id=128;
UPDATE `${prefix}menu` SET sortOrder=730 where id=121;
UPDATE `${prefix}menu` SET sortOrder=735 where id=127;
UPDATE `${prefix}menu` SET sortOrder=740 where id=129;
UPDATE `${prefix}menu` SET sortOrder=745 where id=39;
UPDATE `${prefix}menu` SET sortOrder=750 where id=40;
UPDATE `${prefix}menu` SET sortOrder=755 where id=38;
UPDATE `${prefix}menu` SET sortOrder=760 where id=42;
UPDATE `${prefix}menu` SET sortOrder=765 where id=41;
UPDATE `${prefix}menu` SET sortOrder=770 where id=114;
UPDATE `${prefix}menu` SET sortOrder=775 where id=115;
UPDATE `${prefix}menu` SET sortOrder=780 where id=117;
UPDATE `${prefix}menu` SET sortOrder=800 where id=79;
UPDATE `${prefix}menu` SET sortOrder=805 where id=93;
UPDATE `${prefix}menu` SET sortOrder=810 where id=53;
UPDATE `${prefix}menu` SET sortOrder=815 where id=55;
UPDATE `${prefix}menu` SET sortOrder=820 where id=56;
UPDATE `${prefix}menu` SET sortOrder=825 where id=132;
UPDATE `${prefix}menu` SET sortOrder=830 where id=126;
UPDATE `${prefix}menu` SET sortOrder=835 where id=80;
UPDATE `${prefix}menu` SET sortOrder=840 where id=81;
UPDATE `${prefix}menu` SET sortOrder=845 where id=84;
UPDATE `${prefix}menu` SET sortOrder=850 where id=100;
UPDATE `${prefix}menu` SET sortOrder=855 where id=83;
UPDATE `${prefix}menu` SET sortOrder=860 where id=45;
UPDATE `${prefix}menu` SET sortOrder=865 where id=120;
UPDATE `${prefix}menu` SET sortOrder=870 where id=60;
UPDATE `${prefix}menu` SET sortOrder=875 where id=46;
UPDATE `${prefix}menu` SET sortOrder=880 where id=65;
UPDATE `${prefix}menu` SET sortOrder=885 where id=66;
UPDATE `${prefix}menu` SET sortOrder=890 where id=67;
UPDATE `${prefix}menu` SET sortOrder=895 where id=52;
UPDATE `${prefix}menu` SET sortOrder=900 where id=101;
UPDATE `${prefix}menu` SET sortOrder=905 where id=105;
UPDATE `${prefix}menu` SET sortOrder=910 where id=107;
UPDATE `${prefix}menu` SET sortOrder=915 where id=108;
UPDATE `${prefix}menu` SET sortOrder=920 where id=109;
UPDATE `${prefix}menu` SET sortOrder=940 where id=37;
UPDATE `${prefix}menu` SET sortOrder=945 where id=49;
UPDATE `${prefix}menu` SET sortOrder=950 where id=47;
UPDATE `${prefix}menu` SET sortOrder=955 where id=21;
UPDATE `${prefix}menu` SET sortOrder=960 where id=70;
UPDATE `${prefix}menu` SET sortOrder=965 where id=48;
UPDATE `${prefix}menu` SET sortOrder=970 where id=71;
UPDATE `${prefix}menu` SET sortOrder=975 where id=92;
UPDATE `${prefix}menu` SET sortOrder=980 where id=122;
UPDATE `${prefix}menu` SET sortOrder=985 where id=18;
UPDATE `${prefix}menu` SET sortOrder=990 where id=19;
UPDATE `${prefix}menu` SET sortOrder=995 where id=20; | true |
7b04b3ce76b60f937aa7a789079fd1b3850635df | SQL | leoramos1292/The-Tech-Academy-SQL-Coding-Projects | /Final SQL Assignment/Values.sql | UTF-8 | 6,936 | 2.953125 | 3 | [] | no_license | use books_Library;
INSERT INTO Borrower
(CardNo, Name, Address, Phone)
values
('4308886204430311', 'Aiden Collins', 'Portland, OR', '(503) 258-9743'),
('4278126905777181', 'Chloe Williams', 'Portland, OR', '(503) 264-1649'),
('4997255895956099', 'Michael Thomas', 'Milwaukie, OR', '(503) 369-7412'),
('4251440833846237', 'Hunter Rodriguez', 'Tigard, OR', '(503) 125-1569'),
('4188481700436262', 'Anna Jackson', 'Happy Valley, OR', '(503) 679-8246'),
('4668014616230575', 'Jes Jones', 'Tualatin, OR', '(503) 649-7349'),
('4424842350934027', 'Addison Martin', 'Portland, OR', '(503) 678-5496'),
('4964814484351580', 'Ava Parker', 'Oak Grove, OR', '(503) 357-4623'),
('4181827203392187', 'Grace Jones', 'Beaverton, OR', '(503) 357-1598'),
('4842487112027431', 'Emily Thompson', 'Hood River, OR', '(541) 378-2587')
;
INSERT INTO Library_Branch
(BranchName, Address)
values
('Sharpstown', '7660 Clarewood Dr, Portland, OR 97206'),
('Central', '801 SW 10th Ave, Portland, OR 97205'),
('Paul L Boley', '10015 SW Terwilliger Blvd, Portland, OR 97219'),
('PCC Library', '12000 SW 49th Ave, Portland, OR 97219')
;
INSERT INTO Books
(Title, PublisherName)
values
('The Lost Tribe', 'Amazon'),
('It', 'Viking Press'),
('The Shining', 'Doubleday'),
('Harry Potter: and the Sorcerer''s Stone', 'Scholastic'),
('Danny Calloway', 'Story Road Publishing Inc.'),
('Enders Game', 'Starscape'),
('Now You See Her', 'Hachette Book Group, Inc.'),
('The Godfather', 'Fawcett Crest'),
('Atlas Shrugged', 'Signet'),
('Beautiful Creatures', 'Little Brown and Company'),
('Emily the Strange', 'Chronicle Book'),
('The Ultimate Hitchhikers Guide', 'Portland House'),
('The Davinci Code', 'Doubleday'),
('Best-Loved Folktales', 'Anchor Books'),
('Twilight Eyes', 'Berkely Books'),
('Charlie Bone and the Time Twister', 'Orchard Books'),
('The Princess Diaries', 'Harper Trophy'),
('Stardust', 'Perennial'),
('Why Do Men Have Nipples?', 'Three Rivers Press'),
('Molly Moons', 'Harper Trophy')
;
INSERT INTO Publisher
(PublisherName, Address, Phone)
values
('Amazon', 'Seattle, WA','1 (888) 280-4331'),
('Viking Press', 'New York, NY', '(212) 782-9000'),
('Doubleday', 'New York, NY', '(212) 940-7390'),
('Scholastic', 'New York, NY', '(212) 252-8486'),
('Story Road Publishing Inc.', 'Los Angeles, CA', '(323) 587-2678'),
('Starscape', 'Portland, OR', '(503) 645-8912'),
('Hachette Book Group, Inc.', 'New York City, NY', '(212) 687-649'),
('Fawcett Crest', 'New York City, NY', '(212) 738-0124'),
('Signet', 'New York City, NY', '(917) 534-3698'),
('Little Brown and Company', 'Boston, MA', '(617) 415-2356'),
('Chronicle Book', 'San Francisco, CA', '1 (800) 759-0190'),
('Portland House', 'Portland, OR', '(503) 345-4567'),
('Anchor Books', 'New York City, NY', '(917) 497-3729'),
('Berkely Books', 'New York City, NY', '(212) 819-3468'),
('Orchard Books', 'Chicago, IL', '(312) 456-7894'),
('Harper Trophy', 'New York City, NY', '(212) 456-1372'),
('Perennial', 'New York City, NY', '(917) 497-3148'),
('Three Rivers Press', 'New York City, NY', '(212) 159-7538')
;
INSERT INTO Book_Copies
(BookID, BranchID, Number_Of_Copies)
values
-- Branch 1
(1, 1, 5),
(2, 1, 5),
(3, 1, 5),
(4, 1, 5),
(5, 1, 5),
(6, 1, 5),
(7, 1, 5),
(8, 1, 5),
(9, 1, 5),
(10, 1, 5),
-- Branch 2
(2, 2, 5),
(3, 2, 5),
(8, 2, 5),
(9, 2, 5),
(10, 2, 5),
(6, 2, 5),
(15, 2, 5),
(18, 2, 5),
(9, 2, 5),
(12, 2, 5),
-- Branch 3
(11, 3, 5),
(12, 3, 5),
(13, 3, 5),
(14, 3, 5),
(15, 3, 5),
(16, 3, 5),
(17, 3, 5),
(18, 3, 5),
(19, 3, 5),
(20, 3, 5),
-- Branch 4
(5, 4, 5),
(8, 4, 5),
(7, 4, 5),
(3, 4, 5),
(2, 4, 5),
(16, 4, 5),
(17, 4, 5),
(18, 4, 5),
(19, 4, 5),
(20, 4, 5)
;
INSERT INTO Book_Authors
(BookID, AuthorName)
values
(1, 'Mark Lee'),
(2, 'Stephen King'),
(3, 'Stephen King'),
(4, 'J.K. Rowling'),
(5, 'Z.C. Bolger'),
(6, 'Orson Scott Card'),
(7, 'James Patterson'),
(8, 'Mario Puzo'),
(9, 'Ayn Rand'),
(10, 'Kami Garcia & Margaret Stohl'),
(11, 'Cosmic Debris'),
(12, 'Douglas Adams'),
(13, 'Dan Brown'),
(14, 'Joanna Cole'),
(15, 'Dean Koontz'),
(16, 'Jenny Nimmo'),
(17, 'Meg Cabot'),
(18, 'Neil Gaiman'),
(19, 'Mark Leyner & Billy Goldberg'),
(20, 'Georgia Byng')
;
INSERT INTO Book_Loans
(BookID, BranchID, CardNo, DateOut, DateDue)
values
(1, 1, '4188481700436262', '9/24/19', '10/24/19'),
(2, 1, '4188481700436262', '9/24/19', '10/24/19'),
(3, 1, '4308886204430311', '10/5/19', '11/5/19'),
(4, 1, '4668014616230575', '10/1/19', '11/1/19'),
(5, 1, '4997255895956099', '9/10/19', '10/10/19'),
(6, 1, '4188481700436262', '10/24/19', '11/24/19'),
(7, 1, '4964814484351580', '10/16/19', '11/16/19'),
(7, 1, '4278126905777181', '9/24/19', '10/24/19'),
(9, 1, '4251440833846237', '9/23/19', '10/23/19'),
(10, 1, '4424842350934027', '10/1/19', '11/1/19'),
(2, 2, '4308886204430311', '9/24/19', '10/24/19'),
(3, 2, '4668014616230575', '10/1/19', '11/1/19'),
(8, 2, '4251440833846237', '9/23/19', '10/23/19'),
(9, 2, '4997255895956099', '9/10/19', '10/10/19'),
(10, 2, '4964814484351580', '10/16/19', '11/16/19'),
(6, 2, '4251440833846237', '8/25/19', '9/25/19'),
(15, 2, '4278126905777181', '9/15/19', '10/15/19'),
(18, 2, '4668014616230575', '10/11/19', '11/11/19'),
(9, 2, '4251440833846237', '9/23/19', '10/23/19'),
(12, 2, '4308886204430311', '10/1/19', '11/1/19'),
(11, 3, '4278126905777181', '10/1/19', '11/1/19'),
(12, 3, '4668014616230575', '10/25/19', '11/25/19'),
(13, 3, '4278126905777181', '10/24/19', '11/24/19'),
(14, 3, '4997255895956099', '9/24/19', '10/24/19'),
(15, 3, '4668014616230575', '9/1/19', '10/1/19'),
(16, 3, '4188481700436262', '8/19/19', '9/19/19'),
(17, 3, '4278126905777181', '10/20/19', '11/20/19'),
(18, 3, '4188481700436262', '10/17/19', '11/17/19'),
(19, 3, '4251440833846237', '10/4/19', '11/4/19'),
(20, 3, '4964814484351580', '9/18/19', '10/18/19'),
(5, 4, '4997255895956099', '10/18/19', '11/18/19'),
(8, 4, '4668014616230575', '9/24/19', '10/24/19'),
(7, 4, '4278126905777181','9/18/19', '10/18/19'),
(3, 4, '4668014616230575', '10/17/19', '11/17/19'),
(2, 4, '4188481700436262', '10/11/19', '11/11/19'),
(16, 4, '4964814484351580', '10/1/19', '11/1/19'),
(17, 4, '4308886204430311', '8/19/19', '9/19/19'),
(18, 4, '4278126905777181', '10/25/19', '11/25/19'),
(19, 4, '4668014616230575', '10/16/19', '11/16/19'),
(20, 4, '4308886204430311', '9/24/19', '10/24/19'),
(5, 4, '4997255895956099', '10/18/19', '11/18/19'),
(8, 1, '4668014616230575', '9/24/19', '10/24/19'),
(7, 1, '4278126905777181','9/18/19', '10/18/19'),
(3, 4, '4668014616230575', '10/17/19', '11/17/19'),
(2, 1, '4188481700436262', '10/11/19', '11/11/19'),
(16, 3, '4964814484351580', '10/1/19', '11/1/19'),
(17, 4, '4308886204430311', '8/19/19', '9/19/19'),
(18, 2, '4278126905777181', '10/25/19', '11/25/19'),
(19, 4, '4668014616230575', '10/16/19', '11/16/19'),
(20, 3, '4308886204430311', '9/24/19', '10/24/19')
;
Select * From Borrower;
Select * From Library_Branch;
Select * From Publisher;
Select * From Books;
Select * From Book_Copies;
Select * From Book_Loans;
Select * From Book_Authors; | true |
28e3e650e9fbec278782ba5836638b6169619050 | SQL | cokyya/Web-Application-Design | /cine.sql | UTF-8 | 14,662 | 3.28125 | 3 | [] | no_license | use cine;
create table members (
username varchar(20),
password varchar(40),
email varchar(40),
name varchar(20),
primary key (username)
);
create table movieinfo
(
movieid int unsigned not null auto_increment primary key,
moviename varchar(256) not null,
PG char(50) not null,
cast varchar(1024) not null,
director varchar(256) not null,
runtime int unsigned not null,
synopsis text not null,
poster varchar(256)
);
create table sliderpic
(
sliderid int unsigned not null auto_increment primary key,
sliderpath varchar(256),
caption text not null
);
create table showtime
(
timeslotid int unsigned not null auto_increment primary key,
movieid int unsigned not null,
showdate varchar(50) not null,
timeslot varchar(50) not null
);
create table orders
(
totalid int unsigned not null auto_increment primary key,
orderid varchar(10) not null,
custname char(50) not null,
custemail varchar(50) not null,
movieorder varchar(256) not null,
dateorder varchar(256) not null,
timeorder varchar(256) not null,
seatno varchar(256) not null
);
create table seat
(
id int unsigned not null auto_increment primary key,
timeslotid int unsigned not null,
A1 char(50) null,
A2 char(50) null,
A3 char(50) null,
A4 char(50) null,
A5 char(50) null,
A6 char(50) null,
A7 char(50) null,
A8 char(50) null,
A9 char(50) null,
A10 char(50) null,
A11 char(50) null,
A12 char(50) null,
B1 char(50) null,
B2 char(50) null,
B3 char(50) null,
B4 char(50) null,
B5 char(50) null,
B6 char(50) null,
B7 char(50) null,
B8 char(50) null,
B9 char(50) null,
B10 char(50) null,
B11 char(50) null,
B12 char(50) null,
C1 char(50) null,
C2 char(50) null,
C3 char(50) null,
C4 char(50) null,
C5 char(50) null,
C6 char(50) null,
C7 char(50) null,
C8 char(50) null,
C9 char(50) null,
C10 char(50) null,
C11 char(50) null,
C12 char(50) null
);
create table price
(
id int unsigned not null auto_increment primary key,
customertype char(50) not null,
price int unsigned not null
);
insert into movieinfo values
(1,
"Hunter Killer",
"NC16",
"Gerard Butler, Gary Oldman, Common, Linda Cardellini, Toby Stephens", "Donovan Marsh",
121,
"Deep under the Arctic Ocean, American submarine Captain Joe Glass (Gerard Butler, Olympus Has Fallen, 300) is on the hunt for a U.S. sub in distress when he discovers a secret Russian coup is in the offing, threatening to dismantle the world order. With crew and country on the line, Captain Glass must now assemble an elite group of Navy SEALs to rescue the kidnapped Russian president and sneak through enemy waters to stop WWIII.",
"Movie Posters/HunterKiller.jpg"),
(2,
"Goosebumps 2: Haunted Halloween",
"PG",
"Madison Iseman, Jeremy Ray Taylor, Caleel Harris",
"Ari Sandel",
90,
"Halloween comes to life in a brand-new comedy adventure based on R.L. Stine’s 400-million-selling series of books.",
"Movie Posters/Goosebumps.jpg"),
(3, "Exes Baggage",
"NC16",
"Angelica Panganiban, Carlo Aquino, Dionne Monsanto",
"Ruben Fleischer",
104,
"After a chance encounter, PIA (Angelica Panganiban) and NIX (Carlo Aquino) instantly hit it off. Natural conversations eventually develop into deep attraction. Despite their wounds from previous relationships, both decide to take a chance on each other.", "Movie Posters/ExesBaggage.jpg"),
(4, "Venom", "PG13", "Tom Hardy, Michelle Williams, Riz Ahmed, Scott Haze, Reid Scott", "Ruben Fleischer", 112, "One of Marvel’s most enigmatic, complex and badass characters comes to the big screen, starring Academy Award nominated actor Tom Hardy as the lethal protector Venom.", "Movie Posters/Venom.jpg"),
(5, "First Man", "PG13", "Ryan Gosling, Claire Foy, Jason Clarke, Kyle Chandler, Patrick Fugit, Ciaran Hinds, Pablo Schreiber", "Damien Chazelle", 141, "On the heels of their six-time Academy Award®-winning smash, La La Land, Oscar®-winning director Damien Chazelle and star Ryan Gosling reteam for Universal Pictures’ First Man, the riveting story of NASA’s mission to land a man on the moon, focusing on Neil Armstrong and the years 1961-1969. A visceral, first-person account, based on the book by James R. Hansen, the movie will explore the sacrifices and the cost—on Armstrong and on the nation—of one of the most dangerous missions in history.", "Movie Posters/FirstMan.jpg");
insert into showtime values
(1, 1, "2017-11-15", "10:20"),
(2, 1, "2017-11-15", "20:10"),
(3, 1, "2017-11-16", "10:20"),
(4, 1, "2017-11-16", "20:10"),
(5, 1, "2017-11-17", "10:20"),
(6, 1, "2017-11-17", "20:10"),
(7, 1, "2017-11-18", "10:20"),
(8, 1, "2017-11-18", "20:10"),
(9, 2, "2017-11-15", "10:20"),
(10, 2, "2017-11-15", "20:10"),
(11, 2, "2017-11-16", "10:20"),
(12, 2, "2017-11-16", "20:10"),
(13, 2, "2017-11-17", "10:20"),
(14, 2, "2017-11-17", "20:10"),
(15, 2, "2017-11-18", "10:20"),
(16, 2, "2017-11-18", "20:10"),
(17, 3, "2017-11-15", "10:20"),
(18, 3, "2017-11-15", "20:10"),
(19, 3, "2017-11-16", "10:20"),
(20, 3, "2017-11-16", "20:10"),
(21, 3, "2017-11-17", "10:20"),
(22, 3, "2017-11-17", "20:10"),
(23, 3, "2017-11-18", "10:20"),
(24, 3, "2017-11-18", "20:10"),
(25, 4, "2017-11-15", "10:20"),
(26, 4, "2017-11-15", "20:10"),
(27, 4, "2017-11-16", "10:20"),
(28, 4, "2017-11-16", "20:10"),
(29, 4, "2017-11-17", "10:20"),
(30, 4, "2017-11-17", "20:10"),
(31, 4, "2017-11-18", "10:20"),
(32, 4, "2017-11-18", "20:10"),
(33, 5, "2017-11-15", "10:20"),
(34, 5, "2017-11-15", "20:10"),
(35, 5, "2017-11-16", "10:20"),
(36, 5, "2017-11-16", "20:10"),
(37, 5, "2017-11-17", "10:20"),
(38, 5, "2017-11-17", "20:10"),
(39, 5, "2017-11-18", "10:20"),
(40, 5, "2017-11-18", "20:10");
insert into seat values
(1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(3, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(4, 4, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(5, 5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(6, 6, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(7, 7, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(8, 8, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(9, 9, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(11, 11, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(12, 12, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(13, 13, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(14, 14, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(15, 15, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(16, 16, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(17, 17, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(18, 18, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(19, 19, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(20, 20, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(21, 21, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(22, 22, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(23, 23, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(24, 24, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(25, 25, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(26, 26, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(27, 27, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(28, 28, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(29, 29, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(30, 30, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(31, 31, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(32, 32, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(33, 33, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(34, 34, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(35, 35, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(36, 36, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(37, 37, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(38, 38, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(39, 39, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(40, 40, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
insert into price values
(1, "normal", "12"),
(2, "member", "10");
insert into sliderpic values
(1,
"Slider/img1.jpg",
"caption 1"),
(2,
"Slider/img2.jpg",
"caption 2"),
(3,
"Slider/img3.jpg",
"caption 3");
| true |
ea512f2401c8be3bb2f524d41fb548e53a8eb5ce | SQL | apache/spark | /sql/core/src/test/resources/sql-tests/inputs/cross-join.sql | UTF-8 | 1,218 | 4.5 | 4 | [
"BSD-3-Clause",
"CC0-1.0",
"CDDL-1.1",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"EPL-2.0",
"CDDL-1.0",
"MIT",
"LGPL-2.0-or-later",
"Python-2.0",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-free-unknown",... | permissive | -- Cross join detection and error checking is done in JoinSuite since explain output is
-- used in the error message and the ids are not stable. Only positive cases are checked here.
create temporary view nt1 as select * from values
("one", 1),
("two", 2),
("three", 3)
as nt1(k, v1);
create temporary view nt2 as select * from values
("one", 1),
("two", 22),
("one", 5)
as nt2(k, v2);
-- Cross joins with and without predicates
SELECT * FROM nt1 cross join nt2;
SELECT * FROM nt1 cross join nt2 where nt1.k = nt2.k;
SELECT * FROM nt1 cross join nt2 on (nt1.k = nt2.k);
SELECT * FROM nt1 cross join nt2 where nt1.v1 = 1 and nt2.v2 = 22;
SELECT a.key, b.key FROM
(SELECT k key FROM nt1 WHERE v1 < 2) a
CROSS JOIN
(SELECT k key FROM nt2 WHERE v2 = 22) b;
-- Join reordering
create temporary view A(a, va) as select * from nt1;
create temporary view B(b, vb) as select * from nt1;
create temporary view C(c, vc) as select * from nt1;
create temporary view D(d, vd) as select * from nt1;
-- Allowed since cross join with C is explicit
select * from ((A join B on (a = b)) cross join C) join D on (a = d);
-- Cross joins with non-equal predicates
SELECT * FROM nt1 CROSS JOIN nt2 ON (nt1.k > nt2.k);
| true |
305153c9423ee3e002469e74dcfdda1cb384141c | SQL | rarpal/BestPracticeETL | /ETL/DataWarehouse/Script.v1_PostDeployment.sql | UTF-8 | 1,229 | 3.578125 | 4 | [] | no_license | /*
Post-Deployment Script Template
--------------------------------------------------------------------------------------
This file contains SQL statements that will be appended to the build script.
Use SQLCMD syntax to include a file in the post-deployment script.
Example: :r .\myfile.sql
Use SQLCMD syntax to reference a variable in the post-deployment script.
Example: :setvar TableName MyTable
SELECT * FROM [$(TableName)]
--------------------------------------------------------------------------------------
*/
IF EXISTS (
SELECT 1 FROM sys.columns
WHERE [name] = 'KeyValue' AND OBJECT_NAME(object_id('audit.RejectsLog')) = 'RejectsLog'
)
BEGIN
UPDATE audit.RejectsLog SET
KeyField = SUBSTRING(KeyValue, 1, CHARINDEX(':',KeyValue) -1),
KeyFieldValue = SUBSTRING(KeyValue, CHARINDEX(':',KeyValue) +1, 50)
IF EXISTS (
SELECT 1 FROM sys.indexes
WHERE [name] = 'cix_RejectsLog' AND OBJECT_NAME(object_id('audit.RejectsLog')) = 'RejectsLog'
)
BEGIN
DROP INDEX cix_RejectsLog ON audit.RejectsLog
CREATE CLUSTERED INDEX cix_RejectsLog ON audit.RejectsLog (LogID, KeyFieldValue)
END
ALTER TABLE audit.RejectsLog DROP COLUMN KeyValue
END
| true |
05f1f993e044813b73c60eddaeeedd5dbd6d200a | SQL | RevatureGentry/1806-SNOW | /SQL/CHINOOK-SNOW.sql | WINDOWS-1252 | 2,939 | 4.25 | 4 | [] | no_license | -- Select all records from the Employee Table
select * from employee;
-- Select all records from the Employee Table where the lastname is 'King'
select * from employee where lastname = 'King';
-- Select all records from the Employee Table where the firstname is 'Andrew' and REPORTSTO is null
select * from employee where firstname = 'Andrew' and reportsto is null;
-- Select first name from Customer and sort result set in ascending order by city
select firstname, city from customer order by city;
-- Select all albums in Album table and sort result set in descending order by title
select * from album order by title desc;
-- Insert two new records into Genre table.
--select * from genre;
insert into genre values (26, 'Screamo');
insert into genre (name, genreid) values ('EDM', 27);
-- Update Aaron Mitchell in Customer table to Robert Walter
update customer set firstname = 'Robert', lastname = 'Walter' where firstname = 'Aaron' and
lastname = 'Mitchell';
commit;
-- Select all invoices with a billing address like T%.
select * from invoice where billingaddress like 'T%';
-- Select all employees hired between 1st of June 2003 and 1st of March 2004
select * from employee where hiredate between to_date('06-01-2003', 'mm-dd-yyyy')
and to_date('01.03.04', 'dd.mm.yy');
-- Delete a record in Customer table where the name is Robert Walter
select * from customer where lastname='Walter';
--select * from invoiceline il
-- inner join invoice i
-- on il.invoiceid = i.invoiceid
-- inner join customer c
-- on i.customerid = c.customerid
-- where c.customerid = 32;
-- Find out which invoices belong to Robert Walter
select * from invoice i
where i.customerid = 32;
-- From this query, we see that Robert Walter has invoices for id
-- 50, 61, 116, 245, 268, 290, 342
delete from invoiceline where
invoiceid = 50;
delete from invoiceline where
invoiceid = 61;
delete from invoiceline where
invoiceid in (116, 245, 268, 290, 342);
-- The previous query is equivalent to
-- delete from invoiceline where invoiceid = 116 or invoiceid = 245
-- or invoiceid = 268 or invoiceid = 290 or invoiceid = 342;
-- Now, all of the invoiceline records are taken care of
-- Now we can delete the individual invoices
delete from invoice where customerid = 32;
-- Now we can FINALLY delete Robert Walter
delete from customer where customerid = 32;
commit;
-- Create an inner join that joins customers and orders and specifies the name of the customer
-- and the invoiceId
select c.firstname || ' ' || c.lastname as CustomerName, i.invoiceid from customer c
inner join invoice i
on c.customerid = i.customerid;
-- Perform a self-join on the employee table, joining on the reportsto column
select e1.firstname || ' ' || e1.lastname as Employee,
e2.firstname || ' ' || e2.lastname as Manager
from employee e1
inner join employee e2
on e2.employeeid = e1.reportsto;
| true |
e6349ddd954b1dc5b6bcedd319a98350db9cceca | SQL | xxdoc/vb6-winpricing400 | /scripts/2_user_account.sql | UTF-8 | 642 | 2.6875 | 3 | [] | no_license |
CREATE TABLE USER_ACCOUNT
(
USER_ID ID_TYPE NOT NULL,
USER_NAME USERNAME_TYPE NOT NULL,
USER_PASSWORD PASSWORD_TYPE NOT NULL,
USER_DESC DESC_TYPE,
USER_STATUS FLAG_TYPE,
GROUP_ID ID_TYPE NOT NULL,
CHECK_EXPIRE FLAG_TYPE NOT NULL,
EXPIRE_DATE DATE_TYPE,
FROM_TIME TIME_TYPE,
TO_TIME TIME_TYPE,
EXCEPTION_FLAG FLAG_TYPE,
CREATE_DATE DATE_TYPE NOT NULL,
CREATE_BY ID_TYPE NOT NULL,
MODIFY_DATE DATE_TYPE NOT NULL,
MODIFY_BY ID_TYPE NOT NULL
);
| true |
c93ad0d72b5943bd3fa6576df7b2013c345a550d | SQL | MMeaney/General-Code | /SQL/EDEN/User Edit Membership.sql | UTF-8 | 2,446 | 3.609375 | 4 | [
"Apache-2.0"
] | permissive | -- *******************************************
-- *** Update user organisation memebership
USE [EdenSSO-PRD]
-- 7C310BE0-C20F-DE11-B526-0022642A33B2 EPA STG Org
-- 66298E85-AC36-4634-A8FF-5D7383204F7B Barry Houlihan
-- 566E449A-AC49-4365-BD52-943B73FB10D6 Maurice Meaney
BEGIN TRANSACTION
INSERT INTO dbo.OrganisationMembership
VALUES(
NEWID()
, '7C310BE0-C20F-DE11-B526-0022642A33B2'
, '66298E85-AC36-4634-A8FF-5D7383204F7B'
, '14-OCT-2015'
, '14-OCT-2015'
, '566E449A-AC49-4365-BD52-943B73FB10D6'
, 0
, 0
, 0
, 1
)
COMMIT TRANSACTION
--ROLLBACK TRANSACTION
SELECT * FROM dbo.UserProfile WHERE UserId = 'EB2BE35C-06F1-4E44-8901-02EF200D6F1B'
SELECT * FROM dbo.OrganisationMembership WHERE UserId = 'EB2BE35C-06F1-4E44-8901-02EF200D6F1B'
-- *******************************************
-- *** User details
SELECT DISTINCT
UPR.Email AS [EdenEmail]
, UPR.Username AS [EdenUsername]
, ORG.Name AS [Organisation]
, MDL.Name AS [Module]
, MAU.Active AS [ModActive]
, UMB.PasswordExpiration
, UPR.Email2 AS [CRMEmail]
, OTY.Name AS [OrganisationType]
, UPR.Active
, LTRIM(RTRIM(UPR.FirstName)) + ' ' + LTRIM(RTRIM(UPR.LastName)) AS [Name]
, LTRIM(RTRIM(APRV.FirstName)) + ' ' + LTRIM(RTRIM(APRV.LastName)) AS [ApprovedBy]
--, NOTF.Data AS [Notification]
--, NOTF.EmailSentOn
--, NTDF.Name AS [NotificationDefinition]
--, EVT.Name AS [EventType]
, UPR.*
, ORG.*
--, UMB.*
--, MDL.*
FROM dbo.UserProfile UPR
LEFT JOIN dbo.UserMembership UMB ON UMB.UserId = UPR.UserId
LEFT JOIN dbo.OrganisationMembership OMB ON OMB.UserId = UPR.UserId
LEFT JOIN dbo.Organisation ORG ON ORG.OrganisationId = OMB.OrganisationId
LEFT JOIN dbo.OrganisationType OTY ON OTY.OrganisationTypeId = ORG.OrganisationTypeId
LEFT JOIN dbo.ModuleAuthorisation MAU ON MAU.UserId = OMB.UserID
LEFT JOIN dbo.UserProfile APRV ON APRV.UserId = MAU.LastUpdatedBy
LEFT JOIN dbo.Module MDL ON MDL.ModuleId = MAU.ModuleId
LEFT JOIN dbo.Notification NOTF ON NOTF.AddresseeUserId = UPR.UserId
LEFT JOIN dbo.NotificationDefinition NTDF ON NTDF.NotificationDefinitionId = NOTF.NotificationDefinition
LEFT JOIN dbo.EventType EVT ON EVT.EventTypeId = NTDF.EventTypeId
WHERE UPR.Email LIKE '%b.houlihan@epa.ie%'
--WHERE UPR.Phone LIKE '%45%439464%'
ORDER BY UMB.PasswordExpiration, UPR.Email, MDL.Name, OTY.Name, ORG.Name
| true |
adccc2f71aee8086875f0fffc4cc16cf5cbd603c | SQL | gap6033/SQL-and-Python | /movies/1.sql | UTF-8 | 130 | 2.671875 | 3 | [] | no_license | -- In 1.sql, write a SQL query to list the titles of all
-- movies released in 2008.
SELECT title
FROM movies
WHERE year = 2008;
| true |
cb91c97981ea446b07b5d74521e4b8f86f973ecd | SQL | Nixus6/Licitaciones | /BasedeDatos/Licitaciones.sql | UTF-8 | 24,451 | 2.90625 | 3 | [] | no_license | drop database if exists LicitacionesFinal;
create DATABASE LicitacionesFinal;
USE LicitacionesFinal;
drop table if exists Oferta ;
CREATE TABLE `aboga` (
`id` INT(12) NOT NULL,
`nombre_aboga` VARCHAR(100) NOT NULL,
`valido_id` INT(12) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE `causal` (
`id` INT(12) NOT NULL,
`nombre_causal` VARCHAR(100) NOT NULL,
`valido_id` INT(12) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE `certificadosf` (
`id` INT(11) NOT NULL,
`nombre` VARCHAR(50) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
-- Tablas con Poco Proposito Investigar
CREATE TABLE `ecce` (
`id` INT(11) NOT NULL,
`vtIVA` VARCHAR(50) NOT NULL,
`acum` VARCHAR(80) NOT NULL,
`obligado` VARCHAR(10) NOT NULL,
`ebitda` VARCHAR(80) NOT NULL,
`tipoeventu` VARCHAR(80) NOT NULL,
`vpn` VARCHAR(80) NOT NULL,
`ordenc` VARCHAR(80) NOT NULL,
`fechaoc` DATE NOT NULL,
`fechafoc` DATE NOT NULL,
`ctari` VARCHAR(80) NOT NULL,
`targetari` VARCHAR(80) NOT NULL,
`tarim` VARCHAR(80) NOT NULL,
`ebitdatm` VARCHAR(80) NOT NULL,
`vpntari` VARCHAR(80) NOT NULL,
`myse` INT(11) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE `formanexos` (
`id` INT(11) NOT NULL,
`entregable` VARCHAR(100) NOT NULL,
`firmarl` VARCHAR(50) NOT NULL,
`requisitos` VARCHAR(500) NOT NULL,
`observaciones` VARCHAR(500) NOT NULL,
`myse` VARCHAR(50) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
-- CheklistLicitaciones
CREATE TABLE `requecaractecni` (
`id` INT(11) NOT NULL,
`entregable` VARCHAR(100) NOT NULL,
`firmarl` VARCHAR(50) NOT NULL,
`requisitos` VARCHAR(500) NOT NULL,
`observaciones` VARCHAR(500) NOT NULL,
`myse` VARCHAR(50) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE `requeexpe` (
`id` INT(11) NOT NULL,
`entregable` VARCHAR(100) NOT NULL,
`firmarl` VARCHAR(50) NOT NULL,
`requisitos` VARCHAR(500) NOT NULL,
`observaciones` VARCHAR(500) NOT NULL,
`myse` VARCHAR(50) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE `requejudiricos` (
`id` INT(11) NOT NULL,
`entregable` INT(11) NOT NULL,
`firmarl` VARCHAR(100) NOT NULL,
`requisitos` VARCHAR(500) NOT NULL,
`observaciones` VARCHAR(500) NOT NULL,
`myse` MEDIUMTEXT NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE `requerimientosj` (
`id` INT(11) NOT NULL,
`nombreRJ` VARCHAR(100) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE `requifinancieros` (
`id` INT(11) NOT NULL,
`entregable` VARCHAR(50) NOT NULL,
`firmarl` VARCHAR(50) NOT NULL,
`requisitos` VARCHAR(500) NOT NULL,
`observciones` VARCHAR(500) NOT NULL,
`myse` VARCHAR(50) NOT NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4;
-- Base de Datos Licitaciones
CREATE TABLE Usuario (
cedula_U BIGINT NOT NULL unique,
PRIMARY KEY (cedula_U),
imagen_perfil varchar(150) ,
nombre VARCHAR(100) NOT NULL,
apellido VARCHAR(100) NOT NULL,
correo VARCHAR(100) NOT NULL UNIQUE,
estado CHAR(1) DEFAULT 'A',
soporte_caso CHAR(2) DEFAULT 'No'
);
CREATE TABLE priv_certificaciones (
id_priv_certificaciones TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_priv_certificaciones),
privilegio VARCHAR(30) NOT NULL
);
INSERT INTO `priv_certificaciones` (`id_priv_certificaciones`, `privilegio`) VALUES
(1, 'Coordinador'),
(2, 'Usuario'),
(3, 'Consultor'),
(4, 'UsuarioPeticiones');
CREATE TABLE priv_licitaciones (
id_priv_licitaciones TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_priv_licitaciones),
privilegio VARCHAR(30) NOT NULL
);
INSERT INTO `priv_licitaciones` (`privilegio`) VALUES
('Administrador'),
('Usuario'),
('Asignar'),
('Usuario CCE'),
('ConsultorVP'),
('Corporativo'),
('Govermment'),
('Pymes'),
('Whosale');
CREATE TABLE TipoAcceso (
id_tipo_acceso TinyInt NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id_tipo_acceso),
Acceso varchar(50) NOT NULL
);
INSERT INTO `TipoAcceso` (`id_tipo_acceso`, `Acceso`) VALUES
(1, 'Multiple'),
(2, 'Licitaciones'),
(3, 'Certificaciones'),
(4, 'Facturaciones'),
(5, 'Contrataciones');
CREATE TABLE Acceso (
id_Acceso SMALLINT AUTO_INCREMENT,
PRIMARY KEY (id_Acceso),
usuario VARCHAR(100) not null,
clave VARCHAR(200) NOT NULL,
UsuarioNuevo char(1) default'0',
cedula_U BIGINT NOT NULL,
priv_licitaciones_id tinyint NOT NULL,
priv_certificaciones_id tinyint NOT NULL,
tipo_acceso_id tinyint NOT NULL,
FOREIGN KEY (cedula_U)
REFERENCES Usuario (cedula_U),
FOREIGN KEY (priv_licitaciones_id)
REFERENCES priv_licitaciones (id_priv_licitaciones),
FOREIGN KEY (priv_certificaciones_id)
REFERENCES priv_certificaciones (id_priv_certificaciones)
);
INSERT INTO `Acceso` (`usuario`, `clave`, `cedula_U`, `priv_licitaciones_id`,`priv_certificaciones_id`,`tipo_acceso_id`) VALUES
('nmorenoh', 'OGJtcWNpTDM0bDViRDYybm9ia2RXdz09', '1001084291', 1, 1, 1);
CREATE TABLE Acceso_TipoAcceso(
Acceso_id SMALLINT NOT NULL,
FOREIGN KEY (Acceso_id)
REFERENCES Acceso (id_Acceso),
tipo_acceso_id TINYINT NOT NULL,
FOREIGN KEY (tipo_acceso_id)
REFERENCES TipoAcceso (id_tipo_acceso)
);
INSERT INTO `Acceso_TipoAcceso` (`Acceso_id`, `tipo_acceso_id`) VALUES
(3, 1);
CREATE TABLE BitacoraAccesos(
id_bitacoraaccesos smallint NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id_bitacoraaccesos),
codigo varchar(50),
fecha date,
hora_inicio varchar(50),
hora_fin varchar(50) DEFAULT 'Indeterminado',
cedula BIGINT NOT NULL,
FOREIGN KEY (cedula)
REFERENCES Usuario (cedula_U)
);
-- SELECT id_bitacoraaccesos FROM BitacoraAccesos where codigo='CB17804963';
-- SELECT id_bitacoraaccesos FROM BitacoraAccesos where codigo='CB730246111';
Create table Sector(
id_sector TinyInt NOT NULL auto_increment unique,
PRIMARY KEY (id_sector),
nombre VARCHAR(100) NOT NULL
);
INSERT INTO `Sector` (`id_sector`, `nombre`) VALUES
(1, 'Prime'),
(2, 'Large'),
(3, 'Goverment'),
(4, 'Whosale'),
(5, 'Pymes');
create table Region(
id_region TinyInt NOT NULL auto_increment unique,
PRIMARY KEY (id_region),
nombre_reg VARCHAR(100) NOT NULL
);
INSERT INTO `Region` (`id_region`, `nombre_reg`) VALUES
(1, 'Centro'),
(2, 'Eje cafetero'),
(3, 'Nor occidente'),
(4, 'Norte'),
(5, 'Oriente'),
(6, 'Sur'),
(7, 'Pendiente');
CREATE TABLE Consultor (
id_consultor SMALLINT NOT NULL auto_increment unique,
PRIMARY KEY (id_consultor),
nombre_cons VARCHAR(150) NOT NULL
);
INSERT INTO `Consultor` (`nombre_cons`) VALUES
('Gloria Luz Muños Monsalve');
CREATE TABLE Director (
id_director SMALLINT NOT NULL auto_increment unique,
PRIMARY KEY (id_director),
nombre_dir VARCHAR(150) NOT NULL
);
INSERT INTO `Director` (`nombre_dir`) VALUES
('Sergio Andres Garcia Arango');
CREATE TABLE Ejecutivo (
id_ejecutivo SMALLINT NOT NULL auto_increment unique,
PRIMARY KEY (id_ejecutivo),
nombre VARCHAR(150) NOT NULL,
correo VARCHAR(120) NOT NULL,
sector_id TINYINT NOT NULL,
FOREIGN KEY (sector_id)
REFERENCES Sector (id_sector),
region_id TINYINT NOT NULL,
FOREIGN KEY (region_id)
REFERENCES Region (id_region),
consultor_id SMALLINT NOT NULL,
FOREIGN KEY (consultor_id)
REFERENCES Consultor (id_consultor),
director_id SMALLINT NOT NULL,
FOREIGN KEY (director_id)
REFERENCES Director (id_director)
);
INSERT INTO `Ejecutivo` (`nombre`,`correo`,`sector_id`,`region_id`,`consultor_id`,`director_id`) VALUES
('David Muños Saldarriaga','dmunozs@emtelco.com.co',5,1,1,1);
-- Tablas Caso
create table Proceso(
id_proceso TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_proceso),
nombre_proc varchar (100) NOT NULL
);
INSERT INTO Proceso (`id_proceso`, `nombre_proc`) VALUES
(1, 'Acuerdo de confidencialidad'),
(2, 'Contratacion Directa'),
(3, 'Convocatoria Publica'),
(4, 'Diligenciamiento de formatos'),
(5, 'Estudio de Mercado'),
(6, 'Evento CCE'),
(7, 'Invitacion a contratar'),
(8, 'Invitacion a presentar Oferta'),
(9, 'Invitacion Cerrada'),
(10, 'Invitacion Publica'),
(11, 'Licitacion Publica'),
(12, 'Manifestacion de interes'),
(13, 'Registro de proveedores'),
(14, 'Rfi'),
(15, 'Rfp'),
(16, 'Rfq'),
(17, 'Seleccion Abierta'),
(18, 'Seleccion Abreviada de menor cuantia'),
(19, 'Subasta Inversa'),
(20, 'Terminos de referencia'),
(21, 'Seleccion Abreviada'),
(22, 'Legalizacion Secoop II'),
(23, 'Evento CCE NP RFI'),
(24, 'Evento CCE NP RFQ'),
(25, 'Invitacion abierta'),
(26, 'Invitacion Privada'),
(27, 'Evento CCE Nube Privada III');
create table EstadoProceso(
id_estadoproceso TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_estadoproceso),
nombre_estadpro VARCHAR(100) NOT NULL
);
INSERT INTO EstadoProceso (`id_estadoproceso`, `nombre_estadpro`) VALUES
(1, 'Documentacion Enviada'),
(2, 'En Proceso'),
(3, 'No Participamos'),
(4, 'Oferta Presentada'),
(5, 'Suspendido'),
(6, 'Oferta Presentada - Estudio Mercado');
create table Proponente(
id_proponente TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_proponente),
nombre_prop VARCHAR(100) NOT NULL
);
INSERT INTO Proponente (`id_proponente`,`nombre_prop`) VALUES
(1, 'Colombia Movil S.A. E.S.P.'),
(2, 'Une EPM Telecomunicaciones S.A'),
(3, 'Edatel S.A.'),
(4, 'UT UNE - COLOMBIA MOVIL'),
(5, 'UT EDATEL - COLOMBIA MOVIL'),
(6, 'UT UNE - EDATEL'),
(7, 'UT TIGO - EDATEL');
create table CoberturaProyecto(
id_coberturaproyecto TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_coberturaproyecto),
zona VARCHAR(100) NOT NULL
);
INSERT INTO CoberturaProyecto (`id_coberturaproyecto`,`zona`) VALUES
(1, 'Nacional');
create table Poliza(
id_poliza TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_poliza),
nombre_pol VARCHAR(100) NOT NULL
);
INSERT INTO Poliza (`id_poliza`,`nombre_pol`) VALUES
(1, 'Si, Garantia de Seriedad de la Oferta'),
(2, 'No');
create table EstadoProyecto(
id_estadoproyecto TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_estadoproyecto),
nombre_estap VARCHAR(100) NOT NULL
);
INSERT INTO EstadoProyecto (`id_estadoproyecto`, `nombre_estap`) VALUES
(1, 'Pliegos'),
(2, 'Prepliegos'),
(3, 'Evento CCE');
create table Resultado(
id_resultado TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_resultado),
nombre_res VARCHAR(100) NOT NULL
);
INSERT INTO Resultado (`id_resultado`, `nombre_res`) VALUES
(1, 'Adjudicado'),
(2, 'Cerrado por la entidad'),
(3, 'Declarado Desierto'),
(4, 'Documentacion enviada'),
(5, 'No Participamos'),
(6, 'Perdido'),
(7, 'Por Definir'),
(8, 'Pendiente adjudicacion');
create table Poder(
id_poder TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_poder),
nombre_poder VARCHAR(100) NOT NULL
);
INSERT INTO Poder (`id_poder`,`nombre_poder`) VALUES
(1, 'Sin Poder'),
(2, 'Ok');
create table Causal(
id_causal TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_causal),
nombre_causal VARCHAR(100) NOT NULL
);
INSERT INTO Causal (`id_causal`,`nombre_causal`) VALUES
(1, 'Sin Causal'),
(2, 'Por Definir'),
(3, 'Adjudicado'),
(4, 'Alcance Tecnico'),
(5, 'Cerrado por la entidad'),
(6, 'Error en la plataforma SECOP II'),
(7, 'Error en la Plataforma del Cliente'),
(8, 'Limitado a miPymes'),
(9, 'Modelo financiero'),
(10, 'Precio'),
(11, 'Requisitos Habilitantes'),
(12, 'Requisitos Legales'),
(13, 'Precio+Calidad'),
(14, 'Precio Artifc. Bajo'),
(15, 'Pendiente'),
(16, 'Indicadores Financieros'),
(17, 'Se Presenta en Nicaragua');
create table Abogado(
id_abogado TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_abogado),
abogado VARCHAR(100) NOT NULL
);
INSERT INTO Abogado (`id_abogado`, `abogado`) VALUES
(1, 'Sin Abogado'),
(2, 'Diana Marcela Eslava'),
(3, 'Fabian Alejandro Vega'),
(4, 'Maira Alejandra Florez'),
(5, 'Manuela Sierra Escudero'),
(6, 'Mariana Villegas Giraldo'),
(7, 'Marcela Acevedo Arias'),
(8, 'Gloria Velasquez'),
(9, 'Julián Gregorio Neira');
create table IngenieroPreventa(
id_ingenieropreventa TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_ingenieropreventa),
Ingeniero VARCHAR(100) NOT NULL
);
INSERT INTO IngenieroPreventa (`id_ingenieropreventa`, `Ingeniero`) VALUES
(1, 'Prueba');
create table Producto(
id_producto TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_producto),
nombre_pro VARCHAR(100) NOT NULL
);
create table Certificado(
id_certificado TinyInt NOT NULL auto_increment,
PRIMARY KEY (id_certificado),
nombre_cer VARCHAR(100) NOT NULL
);
create table Caso(
id_caso smallint NOT NULL auto_increment,
PRIMARY KEY (id_caso),
myse MediumInt NOT NULL,
fecha_creacion date NOT NULL,
hora_creacion varchar(50),
nit int NOT NULL,
entidad varchar(150) NOT NULL,
fecha_cierre date NOT NULL,
hora_cierre varchar(50),
presupuesto decimal NOT NULL,
plazo_ejecucion TinyInt NOT NULL,
mensualidad bigint not null,
objeto_contrato TEXT NOT NULL,
R_C CHAR(2) Not Null DEFAULT 'No',
fecha_indicador date NOT NULL,
hora_indicador varchar(50),
porcentaje_poliza TINYINT Not null,
propuesta_dias SmallInt not null,
estampillas char(2) Not null,
-- Fecha con nu valor predeterminado de 1000-01-01 casi no se usa evaluar si este campo si es necesario
fecha_legalizacion date NOT NULL,
myse_experiencia MediumInt NOT NULL,
estadoproyecto_id TinyInt NOT NULL,
ejecutivo_id SMALLINT NOT NULL,
soporte BIGINT NOT NULL,
proponente_id TinyInt NOT NULL,
coberturaproyecto_id TinyInt NOT NULL,
poliza_id TinyInt NOT NULL,
abogado_id TinyInt NOT NULL,
resultado_id TinyInt NOT NULL,
poder_id TinyInt NOT NULL,
ingenieropreventa_id TinyInt NOT NULL,
FOREIGN KEY (estadoproyecto_id)
REFERENCES EstadoProyecto (id_estadoproyecto),
FOREIGN KEY (ejecutivo_id)
REFERENCES Ejecutivo (id_ejecutivo),
FOREIGN KEY (soporte)
REFERENCES Usuario (cedula_U),
FOREIGN KEY (proponente_id)
REFERENCES Proponente (id_proponente),
FOREIGN KEY (coberturaproyecto_id)
REFERENCES CoberturaProyecto (id_coberturaproyecto),
FOREIGN KEY (poliza_id)
REFERENCES Poliza (id_poliza),
FOREIGN KEY (abogado_id)
REFERENCES Abogado (id_abogado),
FOREIGN KEY (resultado_id)
REFERENCES Resultado (id_resultado),
FOREIGN KEY (poder_id)
REFERENCES Poder (id_poder),
FOREIGN KEY (ingenieropreventa_id)
REFERENCES IngenieroPreventa (id_ingenieropreventa)
);
-- `indi_Interes` VARCHAR(150)CHARACTER SET UTF8 NOT NULL,
-- `obCalidadProces` VARCHAR(1000)CHARACTER SET UTF8 NOT NULL,
-- `obFallaProces` VARCHAR(1000)CHARACTER SET UTF8 NOT NULL,
-- `accionPreCor` VARCHAR(1000)CHARACTER SET UTF8 NOT NULL,
-- `imputabilidad` VARCHAR(50)CHARACTER SET UTF8 NOT NULL,
-- `fecAreaTec` DATE NOT NULL,
-- `horAreaTec` VARCHAR(40)CHARACTER SET UTF8 NOT NULL,
-- `segmento` VARCHAR(50)CHARACTER SET UTF8 NOT NULL
INSERT INTO Caso (`myse`,`fecha_creacion`,`hora_creacion`,`nit`,`entidad`,`fecha_cierre`,`hora_cierre`,`presupuesto`,`plazo_ejecucion`,`mensualidad`,`objeto_contrato`,`fecha_indicador`,`hora_indicador`,`porcentaje_poliza`,`propuesta_dias`,`estampillas`,`fecha_legalizacion`,`myse_experiencia`,`estadoproyecto_id`,`ejecutivo_id`,`soporte`,`proponente_id`,`coberturaproyecto_id`,`poliza_id`,`abogado_id`,`resultado_id`,`poder_id`,`causal_id`,`ingenieropreventa_id`)
VALUES('00229574','2020-04-05','12:13:12 am',890907106,'Municipio De Envigado','2020-05-08','12:13:12 pm',20000000,8,1000000,'Legalizacion de documentos SECOP II','2020-06-05','12:13:12 pm',25,15,'No','2020-05-08',0, 2,1,1001084291,2,1,1,1,7,1,1,1);
create table Proceso_EstadoProceso_Caso(
caso_id smallint NOT NULL,
proceso_id TINYINT NOT NULL,
estadoproceso_id TINYINT NOT NULL,
causal_id TinyInt NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Caso (id_caso),
FOREIGN KEY (proceso_id)
REFERENCES Proceso (id_proceso),
FOREIGN KEY (estadoproceso_id)
REFERENCES EstadoProceso (id_estadoproceso),
FOREIGN KEY (causal_id)
REFERENCES Causal (id_causal),
numero_proceso varchar (40) NOT NULL
);
INSERT INTO Proceso_EstadoProceso_Caso (`caso_id`,`proceso_id`,`estadoproceso_id`,`numero_proceso`)
VALUES(1,23,3,'2020');
UPDATE Proceso_EstadoProceso_Caso
SET estadoproceso_id='2' WHERE caso_id='1';
SELECT PEC.*, C.id_caso, U.nombre, U.apellido, C.entidad, C.myse, Pr.nombre_proc, PY.nombre_estap, C.fecha_cierre, C.hora_cierre, Ob.fecha_observacion
FROM Caso C
LEFT OUTER JOIN Usuario U ON C.soporte = U.cedula_U
LEFT OUTER JOIN estadoproyecto PY ON C.estadoproyecto_id = PY.id_estadoproyecto
LEFT OUTER JOIN Proceso_EstadoProceso_Caso PEC ON C.id_caso = PEC.caso_id
LEFT OUTER JOIN proceso Pr ON PEC.proceso_id = Pr.id_proceso
LEFT OUTER JOIN Observacion Ob ON C.id_caso = Ob.caso_id
where PEC.estadoproceso_id ='2' || PEC.estadoproceso_id ='5'
ORDER BY C.id_caso;
create table Plataforma(
id_Plataforma smallint NOT NULL auto_increment,
nombre VARCHAR(100) NOT NULL,
usuario VARCHAR(100) not null,
clave VARCHAR(200) NOT NULL,
caso_id TINYINT NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Licitacion (id_caso)
);
create table Trazabilidad(
id_trazabilidad smallint NOT NULL auto_increment,
fecha_hora_trazabilidad TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
trazabilidad TEXT NOT NULL,
caso_id TINYINT NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Licitacion (id_caso)
);
create table Producto_Caso(
producto_id TINYINT NOT NULL,
FOREIGN KEY (producto_id)
REFERENCES Producto (id_producto),
caso_id TINYINT NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Licitacion (id_caso)
);
create table Certificado_Caso(
certificado_id TINYINT NOT NULL,
FOREIGN KEY (certificado_id )
REFERENCES Certificado (id_certificado),
caso_id TINYINT NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Licitacion (id_caso)
);
-- Tabla en duda
CREATE TABLE Detalles_Usuario_Licitacion (
licitacion_id SMALLINT NOT NULL,
cedula BIGINT NOT NULL,
FOREIGN KEY (licitacion_id)
REFERENCES Licitacion (id_licitacion),
FOREIGN KEY (cedula)
REFERENCES Usuario (cedula_U),
sector_id TINYINT NOT NULL,
FOREIGN KEY (sector_id)
REFERENCES Sector (id_sector),
proceso_id TINYINT NOT NULL,
FOREIGN KEY (proceso_id)
REFERENCES Proceso (id_proceso)
);
--
create table EmpresaGanadora(
id_empresaganadora TinyInt NOT NULL,
nombre VARCHAR(100) NOT NULL
);
create table OfertaGanadora(
id_ofertaganadora smallint NOT NULL,
valor_oferta_ganadora bigint Not Null,
empresaganadora_id TinyInt NOT NULL,
FOREIGN KEY (empresaganadora_id)
REFERENCES EmpresaGanadora (id_empresaganadora),
caso_id smallint NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Casos (id_caso)
);
create table Oferta(
id_oferta smallint NOT NULL auto_increment,
PRIMARY KEY (id_oferta),
fecha_presentacion_oferta date NOT NULL,
hora_presentacion_oferta varchar(50),
medio_presentacion_oferta VARCHAR(100),
valor_oferta bigint not null,
seguimiento CHAR(2),
caso_id smallint NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Caso (id_caso)
);
insert into oferta (fecha_presentacion_oferta,hora_presentacion_oferta,medio_presentacion_oferta,valor_oferta,seguimiento,caso_id)
values ('2020-05-08','12:13:12 pm','Secop II','0','No','1');
create table Observacion(
id_observacion smallint NOT NULL auto_increment,
PRIMARY KEY (id_observacion),
fecha_observacion date not null,
hora_observacion varchar(50) not null,
medio_presentacion_observacion VARCHAR(100) not null,
caso_id smallint NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Caso (id_caso)
);
INSERT INTO Observacion (`fecha_observacion`, `hora_observacion`, `medio_presentacion_observacion`, `caso_id`) VALUES
('2020-05-08', '12:13:12 pm', 'Ninguno', 1);
create table Interes(
id_interes smallint NOT NULL,
fecha_hora_manifestacion timestamp,
medio_manifestacion VARCHAR(100),
carta_manifestacion varchar (100),
caso_id smallint NOT NULL,
FOREIGN KEY (caso_id)
REFERENCES Casos (id_caso)
);
-- Tablas Oportunidad
create table EstadoOPortunidad(
id_oportunidad TinyInt NOT NULL,
opcion VARCHAR(100) NOT NULL
);
CREATE TABLE Oportunidad (
id_Oportunidad smallint NOT NULL,
PRIMARY KEY (id_Oportunidad),
nomEntidad VARCHAR(250) NOT NULL,
numContrato VARCHAR(200) NOT NULL,
Objeto VARCHAR(400) NOT NULL,
Cuantia int NOT NULL,
ubicacion Varchar(200) NOT NULL,
fPublicacion DATETIME NOT NULL,
fCreacion DATETIME NOT NULL,
fcierre DATETIME NOT NULL,
link VARCHAR(200) NOT NULL,
observacion VARCHAR(200) NOT NULL,
oportunidad_id TINYINT NOT NULL,
ejecutivo_id TINYINT NOT NULL,
FOREIGN KEY (oportunidad_id)
REFERENCES EstadoOPortunidad (id_oportunidad),
FOREIGN KEY (ejecutivo_id)
REFERENCES Ejecutivo (id_ejecutivo)
);
-- Histotial Licitaciones
create table HistorialTareasLicitaciones(
id_historial smallint NOT NULL,
fecha_hora_cambio TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
id_myse INT(11) NOT NULL,
Tarea char(1) DEFAULT 'R',
cedula BIGINT NOT NULL,
FOREIGN KEY (cedula)
REFERENCES Usuario (cedula_U)
);
create table CampoModifiacion(
id_campomodifiacion smallint NOT NULL,
campo varchar(500) NOT NULL,
historial_id smallint NOT NULL,
FOREIGN KEY (historial_id)
REFERENCES HistorialTareasLicitaciones (id_historial)
);
-- Hola soylicitaciones oficial
-- CRUD LOGIN
DELIMITER $$
drop procedure if exists Loguear;
create PROCEDURE Loguear /* nombre */
(/* parametros de Entrada INput */
IN P_usuario VARCHAR(100),
IN P_clave VARCHAR(200)
)
BEGIN /*inicio del la programación*/
SELECT A.*, U.estado FROM Acceso A inner join Usuario U WHERE A.usuario = P_usuario and A.clave = P_clave and U.estado = 'A' and A.cedula_U = U.cedula_U;
SELECT A.*, U.estado FROM Acceso A inner join Usuario U WHERE A.usuario = 'nmorenoh' and A.clave = 'OGJtcWNpTDM0bDViRDYybm9ia2RXdz09' and U.estado = 'A' and A.cedula_U = '1001084291';
END; $$
-- CRUD Bitacora
DELIMITER $$
drop procedure if exists Bitacora;
create PROCEDURE Bitacora /* nombre */
(/* parametros de Entrada INput */
IN P_codigo varchar(50),
IN P_fecha date,
IN P_hora_inicio varchar(50),
IN P_hora_fin varchar(50),
IN P_cedula BIGINT,
IN opcion CHAR(15)
)
BEGIN /*inicio del la programación*/
CASE opcion
WHEN 'Guardar' THEN
INSERT INTO BitacoraAccesos (codigo,fecha,hora_inicio,cedula) VALUES (P_codigo,P_fecha,P_hora_inicio,P_cedula);
WHEN 'ActualizarFin' THEN
UPDATE bitacoraaccesos SET hora_fin = P_hora_fin WHERE id_bitacoraaccesos = '6' and codigo = 'CB76685406';
END CASE;
END; $$
DELIMITER $$
drop procedure if exists Usuario;
create PROCEDURE Usuario /* nombre */
(/* parametros de Entrada INput */
IN P_cedula_U BIGINT,
IN P_nombre VARCHAR(100),
IN P_apellido VARCHAR(100),
IN P_correo VARCHAR(100),
IN P_estado char(1),
IN opcion CHAR(15)
)
BEGIN /*inicio del la programación*/
CASE opcion
WHEN 'DatosUsuario' THEN
Select * from usuario where cedula_U = P_cedula_U;
WHEN 'Registrar' THEN
INSERT INTO usuario (cedula_U,nombre,apellido,correo) VALUES (P_cedula_U,P_nombre,P_apellido,P_correo);
END CASE;
END; $$
DELIMITER $$
drop procedure if exists Acceso;
create PROCEDURE Acceso /* nombre */
(/* parametros de Entrada INput */
IN P_cedula_U BIGINT
)
BEGIN /*inicio del la programación*/
Select A.id_Acceso, PL.privilegio as 'privilegioL', PC.privilegio as 'privilegioC'from Acceso A
inner join priv_licitaciones PL on A.priv_licitaciones_id = PL.id_priv_licitaciones
inner join priv_certificaciones PC on A.priv_certificaciones_id = PC.id_priv_certificaciones
where A.cedula_U = P_cedula_U;
END; $$
call Usuario (1001084291,'Nicolas Andres','Moreno Higuavita','nicolas007andres@hotmail.com',null,'Registrar');
-- call Bitacora ('A1515151P','1001-01-01','3:27',null,'1001084291','Guardar');
CALL Usuario(1001084291,null,null,null,null,'DatosUsuario');
UPDATE bitacoraaccesos SET hora_fin='11:00:26 am' WHERE id_bitacora='CB730246111'
SELECT At.tipo_acceso_id NA.Acceso FROM Acceso_TipoAcceso At
INNER JOIN TipoAcceso NA ON AT.tipo_acceso_id = NA.id_tipo_acceso
WHERE At.Acceso_id ='3';
| true |
9fb7295e1dc14b2e30eb85baa53a940861a17276 | SQL | LE2002GHInc/comparables | /PLSQLCallBackFrmQueue.sql | UTF-8 | 6,177 | 2.96875 | 3 | [] | no_license | BEGIN
DBMS_AQADM.DROP_QUEUE_TABLE(queue_table => 'order_queue_table',force => true);
END;
/
DROP TABLE orders PURGE;
DROP TYPE orders_lisT_tt;
DROP TYPE order_ot;
--------------*****---------------------
CREATE TABLE orders(
order_id NUMBER
, order_total NUMBER
, ordered DATE
);
CREATE OR REPLACE TYPE order_ot AS OBJECT(
order_id NUMBER
, order_total NUMBER
, ordered DATE
);
/
CREATE OR REPLACE TYPE orders_lisT_tt AS TABLE OF order_ot;
/
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table => 'order_queue_table',queue_payload_type => 'order_ot',multiple_consumers => TRUE);
DBMS_AQADM.CREATE_QUEUE (queue_name => 'order_queue', queue_table => 'order_queue_table');
DBMS_AQADM.START_QUEUE('order_queue');
END;
/
CREATE OR REPLACE PROCEDURE process_order_from_queue(
context RAW,
reginfo SYS.AQ$_REG_INFO,
descr SYS.AQ$_DESCRIPTOR,
payload raw,
payloadl NUMBER
) AS
r_dequeue_options DBMS_AQ.DEQUEUE_OPTIONS_T;
r_message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
v_message_handle RAW(16);
o_payload order_ot;
v_case_id NUMBER;
BEGIN
r_dequeue_options.msgid := descr.msg_id;
r_dequeue_options.consumer_name := descr.consumer_name;
DBMS_OUTPUT.PUT_LINE('Starting.........');
/* Dequeue message from queue */
DBMS_AQ.DEQUEUE(
queue_name => descr.queue_name,
dequeue_options => r_dequeue_options,
message_properties => r_message_properties,
payload => o_payload,
msgid => v_message_handle
);
DBMS_OUTPUT.PUT_LINE('Dequeue => Successful');
/* Dequeue message from queue */
INSERT INTO orders( order_id, order_total, ordered )
VALUES ( o_payload.order_id,o_payload.order_total,o_payload.ordered);
ledev.case_mgt_pkg.create_business_case(141,110,v_case_id);
ledev.case_mgt_pkg.update_task(v_case_id,60,115,'COMPLETED',null);
ledev.case_mgt_pkg.update_task(v_case_id,61,116,'IN PROGRESS',null);
COMMIT;
DBMS_OUTPUT.PUT_LINE('Insertion => Successful');
END;
/
DECLARE
o_reg_info SYS.AQ$_REG_INFO;
BEGIN
DBMS_AQADM.ADD_SUBSCRIBER (
queue_name => 'order_queue',
subscriber => SYS.AQ$_AGENT('order_queue_subscriber',NULL,NULL)
);
o_reg_info := SYS.AQ$_REG_INFO(
'AQ_ADM.ORDER_QUEUE:ORDER_QUEUE_SUBSCRIBER',
DBMS_AQ.NAMESPACE_AQ,
'plsql://aq_adm.process_order_from_queue?pr=0',
HEXTORAW('FF')
);
DBMS_AQ.REGISTER (SYS.AQ$_REG_INFO_LIST(o_reg_info),1);
END;
/
CREATE OR REPLACE PROCEDURE enqueue_order(
order_id NUMBER
, order_total NUMBER
)AS
r_enqueue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
r_message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
v_message_handle RAW(16);
o_payload order_ot;
BEGIN
o_payload := order_ot(order_id,order_total,sysdate);
DBMS_AQ.ENQUEUE(
queue_name => 'order_queue',
enqueue_options => r_enqueue_options,
message_properties => r_message_properties,
payload => o_payload,
msgid => v_message_handle
);
END;
/
/**************************************************************************************************
CREATE type Message_typ as object(
subject VARCHAR2(30)
, text VARCHAR2(80)
);
/
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE(
queue_table => 'objmsgs80_qtab',
queue_payload_type => 'Message_typ',
multiple_consumers => TRUE
);
DBMS_AQADM.CREATE_QUEUE(
queue_name => 'MSG_QUEUE',
queue_table => 'objmsgs80_qtab'
);
DBMS_AQADM.START_QUEUE(queue_name => 'MSG_QUEUE');
END;
/
CREATE OR REPLACE PROCEDURE enqueue_msg(
p_msg in varchar2
)AS
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message message_typ;
BEGIN
message := message_typ('NORMAL MESSAGE', p_msg );
dbms_aq.enqueue(queue_name => 'msg_queue',
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
END;
/
create table message_table( subjct VARCHAR2(45),msg varchar2(80));
/
CREATE OR REPLACE PROCEDURE process_msg(
context raw,
reginfo sys.aq$_reg_info,
descr sys.aq$_descriptor,
payload raw,
payloadl number
)AS
dequeue_options dbms_aq.dequeue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message message_typ;
BEGIN
dequeue_options.msgid := descr.msg_id;
dequeue_options.consumer_name := descr.consumer_name;
DBMS_AQ.DEQUEUE(
queue_name => descr.queue_name,
dequeue_options => dequeue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
INSERT INTO message_table values(message.subject, 'Dequeued and processed "' || message.text || '"' );
END;
/
BEGIN
dbms_aqadm.add_subscriber(
queue_name => 'msg_queue',
subscriber => sys.aq$_agent( 'recipient', null, null )
);
END;
/
BEGIN
dbms_aq.register(
sys.aq$_reg_info_list(
sys.aq$_reg_info('AQ_ADM.MSG_QUEUE:RECIPIENT'
,DBMS_AQ.NAMESPACE_AQ
,'plsql://aq_adm.process_msg'
,HEXTORAW('FF')) ) ,
1 );
END;
*/
| true |
c856ed22575782735736d2404b74a6ebb00d26b9 | SQL | JonathanCHEMLA/ma-formation | /cours de MySQL/union.sql | UTF-8 | 1,264 | 3.3125 | 3 | [] | no_license |
--# UNION permet de fusionner plusieurs résulltats DANS UNE MEME COLONNE. Regrouper +eurs requetes en 1 seul resultat.
USE bibliotheque;
--# RASSEMBLER et afficher les auteurs et les abonnés DANS UNE SEULE ET MEME COLONNE
SELECT prenom AS 'liste des abonnés' FROM abonne UNION select auteur FROM livre;
--#
SELECT prenom AS 'liste des abonnés' FROM abonne
UNION
SELECT auteur FROM livre;
+-------------------+
| liste des abonnés |
+-------------------+
| Guillaume |
| Benoit |
| Chloe |
| Laura |
| jonathan |
| GUY DE MAUPASSANT |
| HONORE DE BALZAC |
| ALPHONSE DAUDET |
| ALEXANDRE DUMAS |
+-------------------+
--# UNION fait un DISTINCT par défaut
--# Pour avoir toutes les informations : UNION ALL
SELECT prenom AS 'liste des abonnés' FROM abonne
UNION ALL
SELECT auteur FROM livre;
+-------------------+
| liste des abonnés |
+-------------------+
| Guillaume |
| Benoit |
| Chloe |
| Laura |
| jonathan |
| GUY DE MAUPASSANT |
| GUY DE MAUPASSANT |
| HONORE DE BALZAC |
| ALPHONSE DAUDET |
| ALEXANDRE DUMAS |
| ALEXANDRE DUMAS |
+-------------------+
--# Permet de réunir par exemple tous les salaries de ETTER, tous les salaries de ALLIANCES EST et tous les salaries de Copy Mots Plus.
| true |
ea73fc4c334726d25acada27c2f77258996315d5 | SQL | fuchunhong/myStudy | /src/main/resources/db/migration/V3__create.table.sql | UTF-8 | 301 | 2.71875 | 3 | [] | no_license | DROP TABLE IF EXISTS `dada`;
CREATE TABLE `dada` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(20) NOT NULL COMMENT 'EVENT NAME',
`create_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'create_date',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | true |
62f999befad22f2bfba12ebcadb607d4e630fbd4 | SQL | florchus/Actividad-1.2 | /1-1/1-1.sql | UTF-8 | 707 | 3.8125 | 4 | [] | no_license | /*
Relacion 1 a 1. Actividad 1.2.
Se crean las tablas Alumnos y Usuarios. La relacion 1 a 1 se da porque un alumno puede tener un solo
usuario y un usuario puede pertenecer solo a un alumno.
*/
Create Database unoAuno
Use unoAuno
Create Table Alumnos(
DNI varchar(8) not null unique ,
Legajo bigint unique identity(1,1),
Apellido varchar(100) not null,
Nombres varchar(100) not null,
Sexo char(1),
Telefono varchar(20),
Mail nvarchar(100) primary key not null,
FechaDeNacimiento date check(FechaDeNacimiento < getdate()),
)
Use unoAuno
Create Table Usuarios(
Mail nvarchar(100) primary key foreign key references Alumnos(Mail) not null,
Contrasenia nvarchar(100) not null,
) | true |
394a485ab0d3f07bfa5b9e9cf07b0591e0b397e8 | SQL | feleHaile/Data-Warehousing-for-Business-Intelligence-Specialization | /Course 3 Relational Database Support for Data Warehouses/Course3Module3Assignment/query.sql | UTF-8 | 3,369 | 3.9375 | 4 | [] | no_license | --Query1
SELECT name, SUM(extcost) AS SUMextcost,
RANK() OVER (ORDER BY SUM(extcost) DESC) AS costRank
FROM inventory_fact, cust_vendor_dim
WHERE cust_vendor_dim.custvendorkey = inventory_fact.custvendorkey
AND transtypekey = 5
GROUP BY name;
--Query2
SELECT state, name, SUM(extcost) AS SUMextcost,
RANK() OVER (PARTITION BY state
ORDER BY SUM(extcost) DESC) AS costRank
FROM inventory_fact, cust_vendor_dim
WHERE cust_vendor_dim.custvendorkey = inventory_fact.custvendorkey
AND transtypekey = 5
GROUP BY state, name;
--Query3
SELECT name, COUNT(transtypekey) AS SUMtrans,
RANK() OVER (ORDER BY COUNT(transtypekey) DESC) AS transRank,
DENSE_RANK() OVER (ORDER BY COUNT(transtypekey) DESC) AS transDense
FROM inventory_fact, cust_vendor_dim
WHERE cust_vendor_dim.custvendorkey = inventory_fact.custvendorkey
AND transtypekey = 5
GROUP BY name;
--Query4
SELECT zip, calyear, calmonth, SUM(extcost) AS SUMextcost,
SUM(SUM(extcost)) OVER (ORDER BY zip, calyear, calmonth
ROWS UNBOUNDED PRECEDING) AS CumExtCost
FROM inventory_fact, cust_vendor_dim, date_dim
WHERE cust_vendor_dim.custvendorkey = inventory_fact.custvendorkey
AND date_dim.datekey = inventory_fact.datekey
AND transtypekey = 5
GROUP BY zip, calyear, calmonth;
--Query5
SELECT zip, calyear, calmonth, SUM(extcost) AS SUMextcost,
SUM(SUM(extcost)) OVER (PARTITION BY zip, calyear
ORDER BY zip, calyear, calmonth
ROWS UNBOUNDED PRECEDING) AS CumExtCost
FROM inventory_fact, cust_vendor_dim, date_dim
WHERE cust_vendor_dim.custvendorkey = inventory_fact.custvendorkey
AND date_dim.datekey = inventory_fact.datekey
AND transtypekey = 5
GROUP BY zip, calyear, calmonth;
--Using postgresql
--Query6
SELECT seconditemid, SUMitemextcost, SUMitemextcost/Sumextcost AS ratio
FROM
(SELECT seconditemid, SUM(extcost) AS SUMitemextcost
FROM inventory_fact, item_master_dim
WHERE item_master_dim.itemmasterkey = inventory_fact.itemmasterkey
AND transtypekey = 1
GROUP BY seconditemid) X1,
(SELECT SUM(extcost) AS SUMextcost
FROM inventory_fact
WHERE transtypekey = 1) X2
ORDER BY SUMitemextcost DESC;
--Using postgresql
--Query7
SELECT X1.calyear, seconditemid, SUMitemextcost, SUMitemextcost/Sumextcost AS ratio
FROM
(SELECT calyear, seconditemid, SUM(extcost) AS SUMitemextcost
FROM inventory_fact, item_master_dim, date_dim
WHERE item_master_dim.itemmasterkey = inventory_fact.itemmasterkey
AND date_dim.datekey = inventory_fact.datekey
AND transtypekey = 1
GROUP BY calyear, seconditemid) X1,
(SELECT calyear, SUM(extcost) AS SUMextcost
FROM inventory_fact, date_dim
WHERE transtypekey = 1
AND date_dim.datekey = inventory_fact.datekey
GROUP BY calyear
) X2
WHERE X1.calyear = X2.calyear
ORDER BY X1.calyear, SUMitemextcost DESC;
--QUERY8
SELECT BPName, companykey, carryingcost,
RANK() OVER (ORDER BY carryingcost),
Percent_Rank() OVER (ORDER BY carryingcost),
CUME_DIST() OVER (ORDER BY carryingcost)
FROM branch_plant_dim;
--QUERY9
SELECT BPName, companykey, carryingcost, CumCost
FROM
(SELECT BPName, companykey, carryingcost,
CUME_DIST() OVER (ORDER BY carryingcost) AS CumCost
FROM branch_plant_dim) X1
WHERE CumCost >= 0.85;
--Query10
-- SELECT extcost,
-- CUME_DIST() OVER (ORDER BY extcost)
-- FROM
-- (SELECT DISTINCT extcost
-- FROM inventory_fact, cust_vendor_dim
-- WHERE Inventory_fact.custvendorkey = cust_vendor_dim.custvendorkey
-- AND state = 'CO') X1;
| true |
4552f9f1acfda1ba4aec8475e7031c9e0b31c3f7 | SQL | vah-michael/Data_Bases | /Lesson_4/Lesson_4.sql | UTF-8 | 4,252 | 3.609375 | 4 | [] | no_license | -- DML (data manipulation language) - язык манипулирования данными
-- CRUD (create, read, update, delete, truncate)
use vk_test;
INSERT INTO `users` (`id`, `firstname`, `lastname`, `email`, `phone`)
VALUES ('58', 'Dean', 'Satterfield', 'orin69@example.net', '9160120629');
INSERT INTO users VALUES
('3', 'Reuben', 'Nienow', 'arlo51566@example.org', NULL)
;
INSERT INTO users
SET
firstname = 'Иван',
lastname = 'Диванов',
email = 'ivan@mail.ru',
phone = '987654321'
;
INSERT INTO `users`
(`id`, `firstname`, `lastname`, `email`, `phone`)
select
`id`, `firstname`, `lastname`, `email`, `phone`
from vk.users
where id = 85
;
-- select
SELECT 10+20;
SELECT distinct firstname, lastname
FROM users;
SELECT *
FROM users
LIMIT 1 offset 5;
SELECT *
FROM users
WHERE id = 5 OR firstname = 'Reuben';
SELECT *
FROM users
WHERE id IN (5,6,7,8);
-- UPDATE
-- отправка запроса в друзья
INSERT INTO friend_requests (`initiator_user_id`, `target_user_id`, `status`)
VALUES ('5', '6', 'requested');
INSERT INTO friend_requests (`initiator_user_id`, `target_user_id`, `status`)
VALUES ('5', '7', 'requested');
INSERT INTO friend_requests (`initiator_user_id`, `target_user_id`, `status`)
VALUES ('5', '8', 'requested');
INSERT INTO friend_requests (`initiator_user_id`, `target_user_id`, `status`)
VALUES ('1', '3', 'requested');
-- отклонить запрос в друзья
UPDATE friend_requests
SET
status = 'declined',
confirmed_at = now()
WHERE
initiator_user_id = 5 and target_user_id = 8
-- and status = 'requested'
;
-- DELETE
-- добавим несколько пользователей
insert into users (id, firstname, lastname, email, phone) values
('102', 'Reuben', 'Nienow', 'arlo50102@example.org', '9374071116'),
('200', 'Frederik', 'Upton', 'terrence.cartwright@example.org', '9127498182'),
('300', 'Unique', 'Windler', 'rupert55@example.org', '9921090703'),
('400', 'Norene', 'West', 'rebekah29@example.net', '9592139196'),
('500', 'Frederick', 'Effertz', 'von.bridget@example.net', '9909791725')
;
-- добавим несколько сообщений
INSERT INTO messages values
(default, '1','58','Voluptatem ut quaerat quia. Pariatur esse amet ratione qui quia. In necessitatibus reprehenderit et. Nam accusantium aut qui quae nesciunt non.','1995-08-28 22:44:29'),
(default, '5','58','Sint dolores et debitis est ducimus. Aut et quia beatae minus. Ipsa rerum totam modi sunt sed. Voluptas atque eum et odio ea molestias ipsam architecto.',now()),
(default, '5','58','Sed mollitia quo sequi nisi est tenetur at rerum. Sed quibusdam illo ea facilis nemo sequi. Et tempora repudiandae saepe quo.','1993-09-14 19:45:58'),
(default, '5','58','Quod dicta omnis placeat id et officiis et. Beatae enim aut aliquid neque occaecati odit. Facere eum distinctio assumenda omnis est delectus magnam.','1985-11-25 16:56:25'),
(default, '5','58','Voluptas omnis enim quia porro debitis facilis eaque ut. Id inventore non corrupti doloremque consequuntur. Molestiae molestiae deleniti exercitationem sunt qui ea accusamus deserunt.','1999-09-19 04:35:46')
;
delete from messages
where from_user_id = 1
;
delete from users
where id = 1;
-- TRUNCATE
truncate table messages;
-- delete from messages
INSERT INTO messages (id, from_user_id, to_user_id, body, created_at) values
(default,'1','200','Voluptatem ut quaerat quia. Pariatur esse amet ratione qui quia. In necessitatibus reprehenderit et. Nam accusantium aut qui quae nesciunt non.','1995-08-28 22:44:29'),
(default,'200','1','Sint dolores et debitis est ducimus. Aut et quia beatae minus. Ipsa rerum totam modi sunt sed. Voluptas atque eum et odio ea molestias ipsam architecto.',now()),
(default,'3','1','Sed mollitia quo sequi nisi est tenetur at rerum. Sed quibusdam illo ea facilis nemo sequi. Et tempora repudiandae saepe quo.','1993-09-14 19:45:58'),
(default,'1','3','Quod dicta omnis placeat id et officiis et. Beatae enim aut aliquid neque occaecati odit. Facere eum distinctio assumenda omnis est delectus magnam.','1985-11-25 16:56:25'),
(default,'1','500','Voluptas omnis enim quia porro debitis facilis eaque ut. Id inventore non corrupti doloremque consequuntur. Molestiae molestiae deleniti exercitationem sunt qui ea accusamus deserunt.','1999-09-19 04:35:46')
;
| true |
25cd82668ca0d1a8e7568ced1bb9f9a328540a98 | SQL | cloris-cc/SC-alibaba | /sharding-sphere/src/main/resources/sql/t_order.sql | UTF-8 | 1,025 | 3.0625 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : localhost_3306
Source Server Type : MySQL
Source Server Version : 80017
Source Host : localhost:3306
Source Schema : demo_ds_master_0_slave_1
Target Server Type : MySQL
Target Server Version : 80017
File Encoding : 65001
Date: 12/09/2020 19:47:00
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for t_order_0
-- ----------------------------
DROP TABLE IF EXISTS `t_order`;
CREATE TABLE `t_order`
(
`order_id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
PRIMARY KEY (`order_id`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci
ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
| true |
dfb8c150f3fbb03d4fe064b6b592769319d21d63 | SQL | pmirand6/soliris | /base_datos/diego_local/ST_CONTROL_MODIFICAR_VENTA.sql | UTF-8 | 3,026 | 3.671875 | 4 | [] | no_license | -- --------------------------------------------------------
-- Host: 127.0.0.1
-- Versión del servidor: 5.6.11-log - MySQL Community Server (GPL)
-- SO del servidor: Win64
-- HeidiSQL Versión: 11.0.0.5919
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!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' */;
-- Volcando estructura para procedimiento soliris.ST_CONTROL_MODIFICAR_VENTA
DELIMITER //
CREATE PROCEDURE `ST_CONTROL_MODIFICAR_VENTA`(IN `v_idVenta` int
,
IN `v_userName` varchar(50))
COMMENT 'DEVUELVE EL ESTADO DE LA VENTA, SI ESTA SIENDO MODIFICADA O TOMADA POR NP'
BEGIN
-- verificar si es el mismo usuario actualizar fecha y no lockear al usuario
-- CONTROLA:
-- SI LA VENTA TIENE UNA NP ASOCIADA
-- SI LA VENTA ESTA SIENDO MODIFICADA
-- - SI LA VENTA ESTA MODIFICADA DEVUELVE EL USUARIO QUE TIENE BLOQUEADO EL REGISTRO
SET @countLockeo := (SELECT
COUNT(*)
FROM maestro_ventas_lockeo mvl
WHERE mvl.venta_id = v_idVenta);
SET @userLockeo := (SELECT
mvl.usuario_id
FROM maestro_ventas_lockeo mvl
WHERE mvl.venta_id = v_idVenta);
SET @userId := (SELECT
FU_GET_ID_USUARIO(v_userName));
/** Verifico que el registro de venta no este en NP **/
SET @countNp := (SELECT
COUNT(*)
FROM maestro_ventas mv
WHERE mv.id = v_idVenta
AND mv.estado_id = 23);
IF (@countNp > 0) THEN
SELECT
(SELECT
'Venta con NP Asociada!') AS title,
(SELECT
CONCAT('La venta <b>', v_idVenta, '</b> esta asociado con la NP <b>', mv.nbr, '</b>. <br/> No se podrán realizar modificaciones al registro')) AS text
FROM maestro_ventas mv
WHERE mv.id = v_idVenta;
ELSE
IF (@userLockeo = @userId) THEN
DELETE
FROM maestro_ventas_lockeo
WHERE venta_id = v_idVenta
AND usuario_id = @userLockeo;
INSERT INTO maestro_ventas_lockeo
SET venta_id = v_idVenta,
usuario_id = (SELECT
FU_GET_ID_USUARIO(v_userName));
SELECT
TRUE AS mensaje;
ELSE
IF (@countLockeo > 0) THEN
SELECT
(SELECT
'Registro Bloqueado!') AS title,
(SELECT
CONCAT('El registro esta siendo modificado por el usuario: <b>', UPPER((SELECT
FU_GET_USERNAME_USUARIO(m.usuario_id))), '</b>.<br/> No se podrán realizar modificaciones al registro')) AS text
FROM maestro_ventas_lockeo m
WHERE venta_id = v_idVenta;
END IF;
END IF;
END IF;
END//
DELIMITER ;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
| true |
ac54b5b765f33cfd1353bf27182e89c58957b0be | SQL | albertomattos/SQL_gerais | /DBA/Memória.sql | UTF-8 | 769 | 3.640625 | 4 | [] | no_license | select
sid,
username,
round(total_user_mem/1024,2) mem_used_in_kb,
round(100 * total_user_mem/total_mem,2) mem_percent
from
(select
b.sid sid,
nvl(b.username,p.name) username,
sum(value) total_user_mem
from
sys.v_$statname c,
sys.v_$sesstat a,
sys.v_$session b,
sys.v_$bgprocess p
where
a.statistic#=c.statistic# and
p.paddr (+) = b.paddr and
b.sid=a.sid and
c.name in ('session pga memory','session uga memory')
group by
b.sid, nvl(b.username,p.name)),
(select
sum(value) total_mem
from
sys.v_$statname c,
sys.v_$sesstat a
where
a.statistic#=c.statistic# and
c.name in ('session pga memory','session uga memory'))
order by
3 desc; | true |
4c7e01ca7dcbfc29e598f5bd34339dcfaa4e51b4 | SQL | Fred-huu/Projects | /database/data.sql | UTF-8 | 4,551 | 3.453125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.0.10deb1
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2015-06-12 12:47:32
-- 服务器版本: 5.5.43-0ubuntu0.14.04.1
-- PHP 版本: 5.5.9-1ubuntu4.9
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 utf8 */;
--
-- 数据库: `汽车衡称重系统`
--
-- --------------------------------------------------------
--
-- 表的结构 `司机`
--
CREATE TABLE IF NOT EXISTS `司机` (
`驾驶证号` char(18) NOT NULL COMMENT '驾驶证号',
`姓名` text NOT NULL,
`出生日期` date NOT NULL COMMENT '出生日期',
`驾照类型` char(2) CHARACTER SET ascii NOT NULL COMMENT '驾照类型 c1 c2 a1什么滴',
`部门` text NOT NULL COMMENT '部门名字',
`联系电话` char(11) CHARACTER SET ascii NOT NULL COMMENT '11位手机号码',
`备注` text COMMENT '备注信息可为空',
UNIQUE KEY `驾驶证号` (`驾驶证号`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于存放司机信息!';
-- --------------------------------------------------------
--
-- 表的结构 `用户`
--
CREATE TABLE IF NOT EXISTS `用户` (
`姓名` text NOT NULL COMMENT '账户用户名',
`账号` char(20) NOT NULL COMMENT '账户名',
`密码` char(20) NOT NULL COMMENT '账户密码',
`权限` int(11) NOT NULL COMMENT '账户权限码',
`备注` text COMMENT '备注信息,可为空',
PRIMARY KEY (`账号`),
UNIQUE KEY `账号` (`账号`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统用户信息表';
-- --------------------------------------------------------
--
-- 表的结构 `称重管理`
--
CREATE TABLE IF NOT EXISTS `称重管理` (
`车牌号` char(20) NOT NULL COMMENT '车牌号',
`净重` float NOT NULL COMMENT '车辆所载货物重量',
`时间` datetime NOT NULL COMMENT '称量时间日期和时间(datetime)',
`管理账户` char(20) NOT NULL COMMENT '管理员账号',
`备注` text COMMENT '备注信息',
PRIMARY KEY (`车牌号`,`管理账户`),
KEY `管理账号` (`管理账户`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-车辆关系';
--
-- 表的关联 `称重管理`:
-- `管理账户`
-- `用户` -> `账号`
-- `车牌号`
-- `车辆` -> `车牌号`
--
-- --------------------------------------------------------
--
-- 表的结构 `车辆`
--
CREATE TABLE IF NOT EXISTS `车辆` (
`车牌号` char(20) NOT NULL COMMENT '车牌号',
`车型` text NOT NULL COMMENT '车辆类型(小型货车什么滴)',
`出厂日期` date NOT NULL COMMENT '出厂日期(date)',
`车重` float NOT NULL COMMENT '车辆重量',
`核定载重` float NOT NULL COMMENT '出厂核定载重',
`照片` longblob NOT NULL COMMENT '这里存放照片',
`备注` text COMMENT '备注信息',
PRIMARY KEY (`车牌号`),
UNIQUE KEY `车牌号` (`车牌号`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于存放搜集到的车辆的信息!';
-- --------------------------------------------------------
--
-- 表的结构 `驾驶`
--
CREATE TABLE IF NOT EXISTS `驾驶` (
`车牌号` char(20) NOT NULL COMMENT '车牌号,对应车辆表里的车牌号',
`驾驶证号` char(18) NOT NULL COMMENT '驾驶证号,对应司机表中的驾驶证号',
`备注` text COMMENT '备注信息',
PRIMARY KEY (`车牌号`,`驾驶证号`),
KEY `驾驶驾驶证号` (`驾驶证号`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='车辆司机关系表';
--
-- 表的关联 `驾驶`:
-- `驾驶证号`
-- `司机` -> `驾驶证号`
-- `车牌号`
-- `车辆` -> `车牌号`
--
--
-- 限制导出的表
--
--
-- 限制表 `称重管理`
--
ALTER TABLE `称重管理`
ADD CONSTRAINT `管理账号` FOREIGN KEY (`管理账户`) REFERENCES `用户` (`账号`),
ADD CONSTRAINT `管理车牌号` FOREIGN KEY (`车牌号`) REFERENCES `车辆` (`车牌号`);
--
-- 限制表 `驾驶`
--
ALTER TABLE `驾驶`
ADD CONSTRAINT `驾驶驾驶证号` FOREIGN KEY (`驾驶证号`) REFERENCES `司机` (`驾驶证号`),
ADD CONSTRAINT `驾驶车牌号` FOREIGN KEY (`车牌号`) REFERENCES `车辆` (`车牌号`);
/*!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 |
56111d9fc96ee2943350ca69530a2849feeaa8ce | SQL | Elvis-1/newproject | /cars.sql | UTF-8 | 7,211 | 3.09375 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 14, 2021 at 02:38 PM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.4.3
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: `cars`
--
-- --------------------------------------------------------
--
-- Table structure for table `cars`
--
CREATE TABLE `cars` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`founded` int(11) NOT NULL,
`description` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`image_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `cars`
--
INSERT INTO `cars` (`id`, `name`, `founded`, `description`, `created_at`, `updated_at`, `image_path`) VALUES
(1, 'Audi', 1890, 'This is Audi', NULL, NULL, ''),
(2, 'mercedes', 1770, 'Very new', '2021-05-14 08:49:18', '2021-05-14 08:49:18', '1620985758-mercedes.png');
-- --------------------------------------------------------
--
-- Table structure for table `cars_model`
--
CREATE TABLE `cars_model` (
`id` int(10) UNSIGNED NOT NULL,
`car_id` int(10) UNSIGNED NOT NULL,
`model_name` 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 `cars_model`
--
INSERT INTO `cars_model` (`id`, `car_id`, `model_name`, `created_at`, `updated_at`) VALUES
(1, 1, 'A1', NULL, NULL),
(2, 1, 'A3', NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `engines`
--
CREATE TABLE `engines` (
`id` bigint(20) UNSIGNED NOT NULL,
`model_id` int(10) UNSIGNED NOT NULL,
`engine_name` 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;
-- --------------------------------------------------------
--
-- Table structure for table `failed_jobs`
--
CREATE TABLE `failed_jobs` (
`id` bigint(20) UNSIGNED NOT NULL,
`uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
`queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
`payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- 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, '2019_08_19_000000_create_failed_jobs_table', 1),
(4, '2021_05_12_205438_create_cars_table', 1),
(5, '2021_05_13_131226_create_cars_model_table', 1),
(7, '2021_05_13_151012_create_engines_table', 2),
(8, '2021_05_14_083557_add_image_to_cars_table', 3);
-- --------------------------------------------------------
--
-- 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 `users`
--
CREATE TABLE `users` (
`id` bigint(20) 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,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `cars`
--
ALTER TABLE `cars`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `cars_model`
--
ALTER TABLE `cars_model`
ADD PRIMARY KEY (`id`),
ADD KEY `cars_model_car_id_foreign` (`car_id`);
--
-- Indexes for table `engines`
--
ALTER TABLE `engines`
ADD PRIMARY KEY (`id`),
ADD KEY `engines_model_id_foreign` (`model_id`);
--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);
--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`);
--
-- 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 `cars`
--
ALTER TABLE `cars`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `cars_model`
--
ALTER TABLE `cars_model`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `engines`
--
ALTER TABLE `engines`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `cars_model`
--
ALTER TABLE `cars_model`
ADD CONSTRAINT `cars_model_car_id_foreign` FOREIGN KEY (`car_id`) REFERENCES `cars` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `engines`
--
ALTER TABLE `engines`
ADD CONSTRAINT `engines_model_id_foreign` FOREIGN KEY (`model_id`) REFERENCES `cars_model` (`id`) ON DELETE 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 |
784dc00417e200e55ebe873d4d3f424b083601c5 | SQL | lp-apidae/conception | /tables/MLR1.SQL | ISO-8859-1 | 5,065 | 3.515625 | 4 | [] | no_license | -- -----------------------------------------------------------------------------
-- Gnration d'une base de donnes pour
-- Oracle Version 10g
-- (6/12/2018 11:59:21)
-- -----------------------------------------------------------------------------
-- Nom de la base : MLR1
-- Projet :
-- Auteur : Dpartement Informatique
-- Date de dernire modification : 6/12/2018 11:57:43
-- -----------------------------------------------------------------------------
DROP TABLE CATEGORIES CASCADE CONSTRAINTS;
DROP TABLE PRODUITS CASCADE CONSTRAINTS;
DROP TABLE COMMANDES CASCADE CONSTRAINTS;
DROP TABLE CLIENTS CASCADE CONSTRAINTS;
DROP TABLE COMMANDESPRODUITS CASCADE CONSTRAINTS;
-- -----------------------------------------------------------------------------
-- CREATION DE LA BASE
-- -----------------------------------------------------------------------------
CREATE DATABASE MLR1;
-- -----------------------------------------------------------------------------
-- TABLE : CATEGORIES
-- -----------------------------------------------------------------------------
CREATE TABLE CATEGORIES
(
IDCAT NUMBER(2) NOT NULL,
NOMCAT CHAR(32) NULL
, CONSTRAINT PK_CATEGORIES PRIMARY KEY (IDCAT)
) ;
-- -----------------------------------------------------------------------------
-- TABLE : PRODUITS
-- -----------------------------------------------------------------------------
CREATE TABLE PRODUITS
(
REFERENCEPRODUIT CHAR(32) NOT NULL,
NOM CHAR(32) NULL,
PRIXVENTE NUMBER(2) NULL
, CONSTRAINT PK_PRODUITS PRIMARY KEY (REFERENCEPRODUIT)
) ;
-- -----------------------------------------------------------------------------
-- TABLE : COMMANDES
-- -----------------------------------------------------------------------------
CREATE TABLE COMMANDES
(
IDCOMMANDE NUMBER(2) NOT NULL,
NUMCLIENT NUMBER(4) NOT NULL
, CONSTRAINT PK_COMMANDES PRIMARY KEY (IDCOMMANDE)
) ;
-- -----------------------------------------------------------------------------
-- INDEX DE LA TABLE COMMANDES
-- -----------------------------------------------------------------------------
CREATE INDEX I_FK_COMMANDES_CLIENTS
ON COMMANDES (NUMCLIENT ASC)
;
-- -----------------------------------------------------------------------------
-- TABLE : CLIENTS
-- -----------------------------------------------------------------------------
CREATE TABLE CLIENTS
(
NUMCLIENT NUMBER(4) NOT NULL,
IDCAT NUMBER(2) NOT NULL,
NOMCLIENT CHAR(32) NULL,
PRENOMCLIENT CHAR(32) NULL
, CONSTRAINT PK_CLIENTS PRIMARY KEY (NUMCLIENT)
) ;
-- -----------------------------------------------------------------------------
-- INDEX DE LA TABLE CLIENTS
-- -----------------------------------------------------------------------------
CREATE INDEX I_FK_CLIENTS_CATEGORIES
ON CLIENTS (IDCAT ASC)
;
-- -----------------------------------------------------------------------------
-- TABLE : COMMANDESPRODUITS
-- -----------------------------------------------------------------------------
CREATE TABLE COMMANDESPRODUITS
(
IDCOMMANDE NUMBER(2) NOT NULL,
REFERENCEPRODUIT CHAR(32) NOT NULL,
QUANTIT CHAR(32) NULL,
MONTANTPRODUIT NUMBER(2) NULL
, CONSTRAINT PK_COMMANDESPRODUITS PRIMARY KEY (IDCOMMANDE, REFERENCEPRODUIT)
) ;
-- -----------------------------------------------------------------------------
-- INDEX DE LA TABLE COMMANDESPRODUITS
-- -----------------------------------------------------------------------------
CREATE INDEX I_FK_COMMANDESPRODUITS_COMMAND
ON COMMANDESPRODUITS (IDCOMMANDE ASC)
;
CREATE INDEX I_FK_COMMANDESPRODUITS_PRODUIT
ON COMMANDESPRODUITS (REFERENCEPRODUIT ASC)
;
-- -----------------------------------------------------------------------------
-- CREATION DES REFERENCES DE TABLE
-- -----------------------------------------------------------------------------
ALTER TABLE COMMANDES ADD (
CONSTRAINT FK_COMMANDES_CLIENTS
FOREIGN KEY (NUMCLIENT)
REFERENCES CLIENTS (NUMCLIENT)) ;
ALTER TABLE CLIENTS ADD (
CONSTRAINT FK_CLIENTS_CATEGORIES
FOREIGN KEY (IDCAT)
REFERENCES CATEGORIES (IDCAT)) ;
ALTER TABLE COMMANDESPRODUITS ADD (
CONSTRAINT FK_COMMANDESPRODUITS_COMMANDES
FOREIGN KEY (IDCOMMANDE)
REFERENCES COMMANDES (IDCOMMANDE)) ;
ALTER TABLE COMMANDESPRODUITS ADD (
CONSTRAINT FK_COMMANDESPRODUITS_PRODUITS
FOREIGN KEY (REFERENCEPRODUIT)
REFERENCES PRODUITS (REFERENCEPRODUIT)) ;
-- -----------------------------------------------------------------------------
-- FIN DE GENERATION
-- ----------------------------------------------------------------------------- | true |
1c05d5bc8463dc9e902139009ac9513b346d625a | SQL | mundodron/arduino-bot-aurelio | /Querys/~ebAB85.sql | UTF-8 | 415 | 2.6875 | 3 | [] | no_license | select * from customer_id_acct_map where external_id = '999979750763'
select account_no,bill_ref_no from bill_invoice where bill_ref_no = 199330702
select p.*,
(select tira_acento(description_text) from descriptions dt where dt.description_code = P.ELEMENT_ID and dt.language_code = 2) "PRODUTO"
from product p
where p.billing_account_no = | true |
28cf64f86ebaa356df6d98e27f4b86e94af5d351 | SQL | cdesmarais/WebDB-Test | /WebDB/StoredProcedures/Common/dbo.SFBIncrementOpenEmailCount.prc | UTF-8 | 781 | 3.640625 | 4 | [] | no_license | if exists (select * from dbo.sysobjects where ID = object_id(N'[dbo].[SFBIncrementOpenEmailCount]') and OBJECTPROPERTY(ID, N'IsProcedure') = 1)
drop procedure [dbo].[SFBIncrementOpenEmailCount]
go
-- updates the count of the number of times a Share Feedback Email was opened
-- returns 0 on success, -1 for error
create procedure dbo.SFBIncrementOpenEmailCount
(
@ResID int
)
as
set nocount on
declare @error int
,@rc int
update ecbr
set OpenEmailCount = OpenEmailCount + 1
from SFBEmailCountByReso ecbr
where ResID = @ResID
select @error = @@error, @rc = @@rowcount
if @error != 0 or @rc != 1 goto ErrBlock
return 0 -- successfully incremented the count
ErrBlock:
return -1 -- error
go
grant execute on [SFBIncrementOpenEmailCount] to ExecuteOnlyRole
go
| true |
66e9fc26d437e4bd2449d1de2236e64e823e9412 | SQL | arowla/openFEC | /data/sql_updates/create_committee_detail_view.sql | UTF-8 | 6,400 | 3.296875 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | drop view if exists ofec_committee_detail_vw;
drop materialized view if exists ofec_committee_detail_mv_tmp;
create materialized view ofec_committee_detail_mv_tmp as
select distinct
row_number() over () as idx,
dimcmte.cmte_sk as committee_key,
dimcmte.cmte_id as committee_id,
dd.cmte_dsgn as designation,
case dd.cmte_dsgn
when 'A' then 'Authorized by a candidate'
when 'J' then 'Joint fundraising committee'
when 'P' then 'Principal campaign committee'
when 'U' then 'Unauthorized'
when 'B' then 'Lobbyist/Registrant PAC'
when 'D' then 'Leadership PAC'
else 'unknown' end as designation_full,
dd.cmte_tp as committee_type,
case dd.cmte_tp
when 'P' then 'Presidential'
when 'H' then 'House'
when 'S' then 'Senate'
when 'C' then 'Communication Cost'
when 'D' then 'Delegate Committee'
when 'E' then 'Electioneering Communication'
when 'I' then 'Independent Expenditor (Person or Group)'
when 'N' then 'PAC - Nonqualified'
when 'O' then 'Independent Expenditure-Only (Super PACs)'
when 'Q' then 'PAC - Qualified'
when 'U' then 'Single Candidate Independent Expenditure'
when 'V' then 'PAC with Non-Contribution Account - Nonqualified'
when 'W' then 'PAC with Non-Contribution Account - Qualified'
when 'X' then 'Party - Nonqualified'
when 'Y' then 'Party - Qualified'
when 'Z' then 'National Party Nonfederal Account'
else 'unknown' end as committee_type_full,
cp_most_recent.cmte_treasurer_nm as treasurer_name,
cp_most_recent.org_tp as organization_type,
cp_most_recent.org_tp_desc as organization_type_full,
cp_most_recent.cmte_st as state,
cp_most_recent.expire_date as expire_date,
cp_most_recent.cand_pty_affiliation as party,
p.party_affiliation_desc as party_full,
dates.load_date as original_registration_date,
cp_most_recent.cmte_nm as name,
-- (select all cand_id from dimlinkages dl where dl.cmte_sk = dimcmte.cmte_sk) as candidate_ids
-- Below here are committee variables for the detail view
-- Address
cp_most_recent.cmte_st1 as street_1,
cp_most_recent.cmte_st2 as street_2,
cp_most_recent.cmte_city as city,
cp_most_recent.cmte_st_desc as state_full,
cp_most_recent.cmte_zip as zip,
-- Treasurer
cp_most_recent.cmte_treasurer_city as treasurer_city,
cp_most_recent.cmte_treasurer_f_nm as treasurer_name_1,
cp_most_recent.cmte_treasurer_l_nm as treasurer_name_2,
cp_most_recent.cmte_treasurer_m_nm as treasurer_name_middle,
cp_most_recent.cmte_treasurer_ph_num as treasurer_phone,
cp_most_recent.cmte_treasurer_prefix as treasurer_name_prefix,
cp_most_recent.cmte_treasurer_st as treasurer_state,
cp_most_recent.cmte_treasurer_st1 as treasurer_street_1,
cp_most_recent.cmte_treasurer_st2 as treasurer_street_2,
cp_most_recent.cmte_treasurer_suffix as treasurer_name_suffix,
cp_most_recent.cmte_treasurer_title as treasurer_name_title,
cp_most_recent.cmte_treasurer_zip as treasurer_zip,
-- Custodian
cp_most_recent.cmte_custodian_city as custodian_city,
cp_most_recent.cmte_custodian_f_nm as custodian_name_1,
cp_most_recent.cmte_custodian_l_nm as custodian_name_2,
cp_most_recent.cmte_custodian_m_nm as custodian_name_middle,
cp_most_recent.cmte_custodian_nm as custodian_name_full,
cp_most_recent.cmte_custodian_ph_num as custodian_phone,
cp_most_recent.cmte_custodian_prefix as custodian_name_prefix,
cp_most_recent.cmte_custodian_st as custodian_state,
cp_most_recent.cmte_custodian_st1 as custodian_street_1,
cp_most_recent.cmte_custodian_st2 as custodian_street_2,
cp_most_recent.cmte_custodian_suffix as custodian_name_suffix,
cp_most_recent.cmte_custodian_title as custodian_name_title,
cp_most_recent.cmte_custodian_zip as custodian_zip,
-- Properties
cp_most_recent.cmte_email as email,
cp_most_recent.cmte_fax as fax,
cp_most_recent.cmte_web_url as website,
dd.filing_freq as filing_frequency,
cp_most_recent.form_tp as form_type,
cp_most_recent.leadership_pac as leadership_pac,
cp_most_recent.load_date as load_date,
cp_most_recent.lobbyist_registrant_pac_flg as lobbyist_registrant_pac,
cp_most_recent.party_cmte_type as party_type,
cp_most_recent.party_cmte_type_desc as party_type_full,
cp_most_recent.qual_dt as qualifying_date
from dimcmte
inner join dimcmtetpdsgn dd using (cmte_sk)
-- do a DISTINCT ON subselect to get the most recent properties for a committee
inner join (
select distinct on (cmte_sk) cmte_sk, cmte_nm, cmte_zip, cmte_treasurer_nm, org_tp, org_tp_desc, cmte_st, expire_date, cand_pty_affiliation, cmte_st1, cmte_st2, cmte_city, cmte_st_desc, cmte_zip cmte_treasurer_city, cmte_treasurer_f_nm, cmte_treasurer_l_nm, cmte_treasurer_m_nm, cmte_treasurer_ph_num, cmte_treasurer_prefix, cmte_treasurer_st, cmte_treasurer_st1, cmte_treasurer_st2, cmte_treasurer_suffix, cmte_treasurer_title, cmte_treasurer_zip, cmte_custodian_city, cmte_custodian_f_nm, cmte_custodian_l_nm, cmte_custodian_m_nm, cmte_custodian_nm, cmte_custodian_ph_num, cmte_custodian_prefix, cmte_custodian_st, cmte_custodian_st1, cmte_custodian_st2, cmte_custodian_suffix, cmte_custodian_title, cmte_custodian_zip, cmte_email, cmte_fax, cmte_web_url, form_tp, leadership_pac, load_date, lobbyist_registrant_pac_flg, party_cmte_type, party_cmte_type_desc, qual_dt from dimcmteproperties order by cmte_sk, cmteproperties_sk desc
) cp_most_recent using (cmte_sk)
left join dimparty p on cp_most_recent.cand_pty_affiliation = p.party_affiliation
left join (
select distinct on (cmte_sk) cmte_sk, load_date from dimcmteproperties
order by cmte_sk, cmteproperties_sk
) dates on dimcmte.cmte_sk = dates.cmte_sk
-- inner join dimlinkages dl using (cmte_sk)
;
create unique index on ofec_committee_detail_mv_tmp(idx);
create index on ofec_committee_detail_mv_tmp(designation);
create index on ofec_committee_detail_mv_tmp(expire_date);
create index on ofec_committee_detail_mv_tmp(committee_id);
create index on ofec_committee_detail_mv_tmp(committee_key);
create index on ofec_committee_detail_mv_tmp(committee_type);
create index on ofec_committee_detail_mv_tmp(organization_type);
| true |
7591527ce3fee0995494d1a53813782628beb46c | SQL | ZamboniL/m-zat | /prisma/migrations/20211016143229_permission/migration.sql | UTF-8 | 1,405 | 3.8125 | 4 | [
"MIT"
] | permissive | /*
Warnings:
- You are about to alter the column `title` on the `Bucket` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `VarChar(100)`.
- Added the required column `creatorId` to the `Bucket` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `Bucket` ADD COLUMN `creatorId` INTEGER NOT NULL,
ADD COLUMN `description` TINYTEXT,
MODIFY `title` VARCHAR(100) NOT NULL;
-- CreateTable
CREATE TABLE `Permission` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `_PermissionToRole` (
`A` INTEGER NOT NULL,
`B` INTEGER NOT NULL,
UNIQUE INDEX `_PermissionToRole_AB_unique`(`A`, `B`),
INDEX `_PermissionToRole_B_index`(`B`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `Bucket` ADD CONSTRAINT `Bucket_creatorId_fkey` FOREIGN KEY (`creatorId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `_PermissionToRole` ADD FOREIGN KEY (`A`) REFERENCES `Permission`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `_PermissionToRole` ADD FOREIGN KEY (`B`) REFERENCES `Role`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
| true |
2b51bd1c79600e2850c6acff918e6d00866ab457 | SQL | tacr-iotcloud/server-db | /pgsql/queries/roles_in_gateway/fetch_by_gateway_id.sql | UTF-8 | 291 | 3.453125 | 3 | [] | no_license | SELECT
r.id AS id,
r.gateway_id AS gateway_id,
r.identity_id AS identity_id,
r.level AS level,
extract(epoch FROM r.created)::bigint AS created,
i.email AS identity_email
FROM
beeeon.roles_in_gateway AS r
JOIN
beeeon.identities AS i
ON
r.identity_id = i.id
WHERE
r.gateway_id = $1
| true |
227d5791bddb63af6c246f5ea0a1a36873b112c3 | SQL | Djok216/Wegas | /BD/Script Creare/create_user_chess.sql | UTF-8 | 651 | 2.984375 | 3 | [] | no_license | DROP TABLESPACE chess INCLUDING CONTENTS and datafiles CASCADE CONSTRAINTS;
CREATE TABLESPACE chess
DATAFILE 'chess_perm_0001.dat'
SIZE 500M
REUSE
AUTOEXTEND ON NEXT 50M MAXSIZE 2000M;
/
CREATE TEMPORARY TABLESPACE aplicatie
TEMPFILE 'chess_temp_0001.dbf'
SIZE 5M
AUTOEXTEND ON;
/
CREATE UNDO TABLESPACE aplicatie
DATAFILE 'chess_undo_0001.dbf'
SIZE 5M
AUTOEXTEND ON
RETENTION GUARANTEE;
/
drop user chess cascade;
create user user_chess identified by user_chess;
alter user user_chess default tablespace chess quota 1990M on chess;
grant connect to user_chess;
grant all privileges to user_chess;
| true |
7da9130630d4722dc6715d7217eb0d0ecbc5672a | SQL | GlobalFishingWatch/paper-global-squid | /queries/carrier_positions_in_squidregions_v20220525.sql | UTF-8 | 7,165 | 3.953125 | 4 | [] | no_license | #standardsql
-----------------------------------------
-- Identify carrier positions in squid
-- regions for carriers that have at
-- least one loitering event in a squid
-- region. These may still be carriers
-- that primarily meet longlines given
-- the overlap in the Pacific.
--
-- results are saved in paper_global_squid.carrier_positions_in_squidregions_v20220525
-----------------------------------------
--
--SET your date minimum of interest
CREATE TEMP FUNCTION minimum() AS (timestamp("2017-01-01"));
--
--SET your date maximum of interest
CREATE TEMP FUNCTION maximum() AS (timestamp("2020-12-31"));
-----------------------------------------------
#standardsql
-----------------------------------------
-- Squid AOIs
-----------------------------------------
WITH aoi AS (
SELECT * FROM `paper_global_squid.final_squid_regions_v20220525`
),
-----------------------------------------
-- carrier list for vessels that have a
-- loitering event in the squid regions
-----------------------------------------
carrier_vessels AS (
SELECT
identity.ssvid AS ssvid,
identity.imo AS imo_ais,
identity.n_shipname AS shipname_ais,
identity.n_callsign AS callsign_ais,
identity.flag AS flag,
first_timestamp,
last_timestamp,
array_to_string(feature.geartype, "|") AS class
FROM `vessel_database.all_vessels_v20210901`
LEFT JOIN unnest(activity)
WHERE matched
AND is_carrier
AND identity.ssvid IN (
SELECT carrier_ssvid
FROM
`paper_global_squid.carriers_with_loitering_in_squid_regions_v20220525`
)
AND first_timestamp <= maximum()
AND last_timestamp >= minimum()
-- duplicate reefer/specialized reefer
AND NOT (identity.ssvid = '412440033'
AND identity.n_callsign = 'BMWA')
AND identity.ssvid != '441043000'),
-----------------------------------------
-- Get all carrier positions
-----------------------------------------
carrier_positions AS (
SELECT
ssvid,
timestamp,
lat,
lon,
hours,
cast(timestamp AS DATE) AS date
FROM (
SELECT
ssvid,
timestamp,
lat,
lon,
hours
FROM
`pipe_production_v20201001.research_messages`
WHERE
_partitiontime BETWEEN minimum() AND maximum())
INNER JOIN
(SELECT
ssvid,
first_timestamp,
last_timestamp
FROM
carrier_vessels)
USING (ssvid)
WHERE
timestamp BETWEEN first_timestamp AND last_timestamp
),
-----------------------------------------
-- Carrier Positions in Individual Regions
-----------------------------------------
--
-----------------------------------------
-- NW Pacific
-----------------------------------------
ssvid_in_nw_pacific AS (
SELECT
ssvid,
date,
'nw_pacific' AS aoi,
extract(year FROM date) AS year,
extract(month FROM date) AS month,
count(*) AS positions,
sum(hours) AS total_hours
--SUM(IF(nnet_score > 0.5, hours, 0)) AS fishing_hours
FROM
carrier_positions
WHERE
if(st_contains( (
SELECT
geometry
FROM
aoi
WHERE area = 'nw_pacific'),
st_geogpoint(lon,
lat)),
TRUE,
FALSE)
GROUP BY 1, 2, 3, 4 ,5),
-----------------------------------------
-- SE Pacific
-----------------------------------------
ssvid_in_se_pacific AS (
SELECT
ssvid,
date,
'se_pacific' AS aoi,
extract(year FROM date) AS year,
extract(month FROM date) AS month,
count(*) AS positions,
sum(hours) AS total_hours
--SUM(IF(nnet_score > 0.5, hours, 0)) AS fishing_hours
FROM
carrier_positions
WHERE
if(st_contains( (
SELECT
geometry
FROM
aoi
WHERE area = 'se_pacific'),
st_geogpoint(lon,
lat)),
TRUE,
FALSE)
GROUP BY 1, 2, 3, 4 ,5),
-----------------------------------------
-- SW Atlantic
-----------------------------------------
ssvid_in_sw_atlantic AS (
SELECT
ssvid,
date,
'sw_atlantic' AS aoi,
extract(year FROM date) AS year,
extract(month FROM date) AS month,
count(*) AS positions,
sum(hours) AS total_hours
--SUM(IF(nnet_score > 0.5, hours, 0)) AS fishing_hours
FROM
carrier_positions
WHERE
if(st_contains( (
SELECT
geometry
FROM
aoi
WHERE area = 'sw_atlantic'),
st_geogpoint(lon,
lat)),
TRUE,
FALSE)
GROUP BY 1, 2, 3, 4, 5),
-----------------------------------------
-- NW Indian
-----------------------------------------
ssvid_in_nw_indian AS (
SELECT
ssvid,
date,
'nw_indian' AS aoi,
extract(year FROM date) AS year,
extract(month FROM date) AS month,
count(*) AS positions,
sum(hours) AS total_hours
--SUM(IF(nnet_score > 0.5, hours, 0)) AS fishing_hours
FROM
carrier_positions
WHERE
if(st_contains( (
SELECT
geometry
FROM
aoi
WHERE area = 'nw_indian'),
st_geogpoint(lon,
lat)),
TRUE,
FALSE)
GROUP BY 1, 2, 3, 4, 5),
------------------------------------------
-- Combine carrier positions from all regions
------------------------------------------
ssvid_regions_combined AS (SELECT
*
FROM (
SELECT
*
FROM
ssvid_in_nw_pacific
UNION ALL
SELECT
*
FROM
ssvid_in_se_pacific
UNION ALL
SELECT
*
FROM
ssvid_in_sw_atlantic
UNION ALL
SELECT
*
FROM
ssvid_in_nw_indian
) AS a
LEFT JOIN
(SELECT
*
FROM
carrier_vessels) AS b
USING(ssvid)
WHERE
date BETWEEN cast(
first_timestamp AS DATE
) AND cast(last_timestamp AS DATE)
)
------------------------------------------
-- Final table
------------------------------------------
SELECT
ssvid,
date,
aoi,
year,
month,
positions,
total_hours,
imo_ais,
shipname_ais,
callsign_ais,
flag,
first_timestamp,
last_timestamp,
class
FROM
ssvid_regions_combined
| true |
03c1d1f6add3bc8e2e72b2d69d6d7df80877e38b | SQL | javiperales/BasesDeDatos | /pruebaDeExamentriggers.sql | UTF-8 | 3,151 | 3.875 | 4 | [] | no_license | alter table empleados2 add(foreign key(mgr) references empleados2(dni));
/*ejercicio1 crea un trigger sobre la tabla emp para que no se permita que un empleado sea jefe(mgr) de mas
de cinco empleados*/
create or replace trigger prueba11
before insert on empleados2
for each row
declare
supervisa integer;
begin
select count(*) into supervisa from empleados2 where mgr = :new.mgr;
if(supervisa > 4) then
raise_application_error(-20600, :new.mgr || 'no se puede superar mas de 5');
end if;
end;
/* ejercicio2 crea un trigger para impedir que se aumente el salario de un empleado en mas de un 20%*/
create or replace trigger prueba22
before insert or update on empleados2
for each row
begin
if(:new.salario> :old.salario*1.20) then
raise_application_error(-20611, :new.salario || 'no puede se puede aumentar mas de un 20%');
end if;
end;
/*ejercicio3 crea una tabla que inserte una fila en la tabla empleados cuando se borra una fila en la tabla empleados
#los datos ue se insertan son correspondientes al empleado que se da de baja en la tabla salgo en las columnas usuario
y fecha que se grabaran del sistema user y sysdate
#el comando que dispara el trigger es after delete
*/
create table empleados_baja
(
dni char(4) primary key,
nomemp varchar2(15),
mgr char(4),
salario integer,
usuario varchar2(15),
fecha date);
create or replace trigger bajas1
after delete on empleados2
for each row
begin
insert into empleados_baja
values(:old.dni, :old.nomemp,:old.mgr,:old.salario, user, sysdate);
end;
/*ejercicio7 creamos un trigger que se active cuando modificamos algun campo en la tabla empleados2
y almacene en otra tabla 'control cambios' el nombre del usuario, que realiza la actualizacion , la fecha,
el dato que se cambia y el nuevo valor*/
create or replace trigger ejer7
before insert or delete or update on empleados2
for each row
begin
if updating('dni') then
insert into control_cambios values (user,sysdate,:old.dni, :new.dni);
end if;
if updating('nomemp') then
insert into control_cambios values (user,sysdate,:old.nomemp, :new.nomemp);
end if;
if updating('mgr') then
insert into control_cambios values (user,sysdate,:old.mgr, :new.mgr);
end if;
if updating('salario') then
insert into control_cambios values (user,sysdate,:old.salario, :new.salario);
end if;
if inserting then
insert into control_cambios values (user,sysdate,null,:new.documento);
end if;
if deleting then
insert into control_cambios values (user,sysdate,:old.documento,null);
end if;
end;
/*ejercicio 8 el disparador tr_actualizar_pecio_libros* debe de cntrolar
el precio que se esta actualizando, si supera los 50 euros, se debe de redondear a tal valor entero hacia abajo
empleando("floor")*/
create or replace trigger tr_actualizar_precio_libros
before update of precio_libro on libros
for each row
if(:new.precio_libro>50) then
:new.precio_libro:=floor(:new.precio_libro);
end if;
insert into control values(user,sysdate,:new.codigo,:old.precio,:new.precio);
end tr_actualizar_precio_libros;
| true |
1fa2cf9a6e42c57cd4040be6cfdb012662f9395f | SQL | ezheidtmann/sfrs-activities | /modules/s4rs_activity_nav/breadcrumb_setup.sql | UTF-8 | 3,432 | 3.4375 | 3 | [] | no_license | /**
* @file Dump of "custom_breadcrumb" table, to document custom_breadcrumbs
* settings for S4RS Activity Pages and Extensions.
*
* The data included here is included for documentation purposes; unless you
* are on a fresh install you should probably not simply run this SQL.
*/
-- MySQL dump 10.13 Distrib 5.5.24, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: sfrs1
-- ------------------------------------------------------
-- Server version 5.5.24-0ubuntu0.12.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 */;
/*!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 `custom_breadcrumb`
--
DROP TABLE IF EXISTS `custom_breadcrumb`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `custom_breadcrumb` (
`bid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique identifier for the custom_breadcrumb.',
`name` varchar(128) DEFAULT NULL COMMENT 'An optional name for the custom breadcrumb.',
`titles` varchar(255) NOT NULL DEFAULT '' COMMENT 'A return-delimited list of titles for the breadcrumb links.',
`paths` varchar(255) DEFAULT NULL COMMENT 'A return-delimited list of url paths for the breadcrumb links.',
`visibility_php` mediumtext NOT NULL COMMENT 'An optional PHP snippet to control the custom_breadcrumb visibility.',
`node_type` varchar(64) DEFAULT 'AND' COMMENT 'Node types the custom_breadcrumb should apply to.',
`language` varchar(12) NOT NULL DEFAULT '' COMMENT 'The language this breadcrumb is for; if blank, the breadcrumb will be used for unknown languages.',
PRIMARY KEY (`bid`),
KEY `language` (`language`),
KEY `node_language` (`node_type`,`language`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='Stores custom breadcrumb trail overrides.';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `custom_breadcrumb`
--
LOCK TABLES `custom_breadcrumb` WRITE;
/*!40000 ALTER TABLE `custom_breadcrumb` DISABLE KEYS */;
set autocommit=0;
INSERT INTO `custom_breadcrumb` VALUES (1,'S4RS Activity Pages','Activities','activity-search','','s4rs_activity',''),(2,'S4RS Activity Extension Pages[node:field-parent-activity:title]','Activities\r\n[node:field-parent-activity:title]','activity-search\r\n[node:field-parent-activity:url]','','extension_activity','');
/*!40000 ALTER TABLE `custom_breadcrumb` ENABLE KEYS */;
UNLOCK TABLES;
commit;
/*!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 2012-11-15 17:23:25
| true |
d6b2505f6d15ec9a00f26c5d069010f3efd70325 | SQL | downfang888/coffcms | /data/backup/v1.3.5/sql/v1.3.2.sql | UTF-8 | 1,744 | 3.28125 | 3 | [] | no_license | UPDATE `ey_config` SET `value` = '0' WHERE `name` = 'web_exception' AND `inc_type` = 'web';
UPDATE `ey_guestbook` SET `channel` = '8' WHERE `aid` > 0;
DROP TABLE IF EXISTS `ey_users_menu`;
CREATE TABLE `ey_users_menu` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`title` varchar(30) DEFAULT '' COMMENT '导航名称',
`mca` varchar(50) DEFAULT '' COMMENT '分组/控制器/操作名',
`is_userpage` tinyint(1) DEFAULT '0' COMMENT '默认会员首页',
`sort_order` int(10) DEFAULT '0' COMMENT '排序号',
`status` tinyint(1) DEFAULT '1' COMMENT '状态,1=显示,0=隐藏',
`lang` varchar(20) DEFAULT 'cn' COMMENT '语言标识',
`add_time` int(11) DEFAULT '0' COMMENT '新增时间',
`update_time` int(11) DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='会员菜单表';
INSERT INTO `ey_users_menu` VALUES ('1', '个人信息', 'user/Users/index', '1', '100', '1', 'cn', '1555904190', '1555917737');
INSERT INTO `ey_users_menu` VALUES ('2', '账户充值', 'user/Pay/pay_consumer_details', '0', '100', '1', 'cn', '1555904190', '1555917761');
DROP TABLE IF EXISTS `ey_search_word`;
CREATE TABLE `ey_search_word` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`word` varchar(50) DEFAULT '' COMMENT '关键词',
`searchNum` int(10) DEFAULT '1' COMMENT '搜索次数',
`sort_order` int(10) DEFAULT '0' COMMENT '排序号',
`lang` varchar(30) DEFAULT 'cn' COMMENT '语言标识',
`add_time` int(11) DEFAULT '0' COMMENT '新增时间',
`update_time` int(11) DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `word` (`word`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='搜索词统计表'; | true |
424f11ea98468dc5793c4aac692299fab9f290ff | SQL | plifis/job4j_cars | /db/schema.sql | UTF-8 | 786 | 3.453125 | 3 | [] | no_license | create table users(
id serial primary key,
name varchar (100) NOT NULL,
email varchar (50) NOT NULL UNIQUE,
password varchar (20) NOT NULL
);
create table cars(
id serial primary key,
description varchar (1000),
mark varchar (50) NOT NULL,
body varchar (15) NOT NULL,
image varchar (255)
);
create table advts(
id serial primary key,
isSale boolean,
created timestamp,
price real,
car_id int not null references cars(id)
);
create table authors(
id serial primary key,
advt_id int references advts(id),
user_id int references users(id)
);
| true |
cad9d8fb6877e5ed838aff8614a4ae4504606329 | SQL | Yudhapradana/pkl | /db/sumber_dana (1).sql | UTF-8 | 3,119 | 3.0625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.8.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 01, 2019 at 05:47 AM
-- Server version: 10.1.33-MariaDB
-- PHP Version: 7.2.6
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: `pengelolaan-dana`
--
-- --------------------------------------------------------
--
-- Table structure for table `sumber_dana`
--
CREATE TABLE `sumber_dana` (
`id_sumber_dana` int(11) NOT NULL,
`id_sekolah` int(11) NOT NULL,
`id_jenis_sumber_dana` int(11) NOT NULL,
`nama_pemasukkan` varchar(100) NOT NULL,
`saldo_awal` int(11) NOT NULL DEFAULT '0',
`saldo_bank` int(11) NOT NULL DEFAULT '0',
`bunga_bank` float NOT NULL DEFAULT '0',
`saldo_kas_tunai` int(11) NOT NULL DEFAULT '0',
`jumlah` int(11) NOT NULL DEFAULT '0',
`tanggal` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `sumber_dana`
--
INSERT INTO `sumber_dana` (`id_sumber_dana`, `id_sekolah`, `id_jenis_sumber_dana`, `nama_pemasukkan`, `saldo_awal`, `saldo_bank`, `bunga_bank`, `saldo_kas_tunai`, `jumlah`, `tanggal`) VALUES
(4, 15, 1, 'Bosnas Januari 2017', 0, 0, 0, 0, 0, '2017-01-01'),
(5, 15, 1, 'Bosnas Februari 2017', 0, 0, 0, 0, 0, '2017-02-01'),
(6, 15, 1, 'Bosnas Maret 2017', 0, 185000000, 0, 0, 185000000, '2017-03-01'),
(7, 15, 1, 'Bosnas April 2017', 1, 0, 0, 0, 1, '2017-04-01'),
(8, 15, 1, 'Bosnas Mei 2017', 1, 1, 0, 0, 2, '2017-05-01'),
(9, 15, 1, 'Bosnas Juni 2017', 1, 1, 0, 1, 3, '2017-06-01'),
(15, 15, 1, 'Bosnas Agustus 2017', 20000, 0, 0, 0, 20000, '2017-08-15'),
(16, 15, 1, 'Saldo Akhir Periode Januari - Maret 2017', -185000000, 0, 0, 0, -185000000, '2017-04-01'),
(17, 15, 1, 'Saldo Akhir Periode Januari - Maret 2018', 0, 0, 0, 0, 0, '2018-04-01');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `sumber_dana`
--
ALTER TABLE `sumber_dana`
ADD PRIMARY KEY (`id_sumber_dana`),
ADD KEY `fk_id_sekolah_3` (`id_sekolah`),
ADD KEY `fk_id_jenis_sumber_dana` (`id_jenis_sumber_dana`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `sumber_dana`
--
ALTER TABLE `sumber_dana`
MODIFY `id_sumber_dana` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `sumber_dana`
--
ALTER TABLE `sumber_dana`
ADD CONSTRAINT `fk_id_jenis_sumber_dana` FOREIGN KEY (`id_jenis_sumber_dana`) REFERENCES `jenis_sumber_dana` (`id_jenis_sumber_dana`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `fk_id_sekolah_3` FOREIGN KEY (`id_sekolah`) REFERENCES `sekolah` (`id_sekolah`) 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 |
b6fcedfa3f0ae7ad8c8b0629300a21aaf88ba95a | SQL | 181221/dat104 | /lab4/oppgave2/bruker.sql | UTF-8 | 199 | 2.609375 | 3 | [] | no_license | DROP TABLE IF EXISTS bruker CASCADE;
CREATE TABLE bruker (
bruker_id SERIAL NOT NULL,
brukernavn VARCHAR(20),
PRIMARY KEY(bruker_id)
);
INSERT INTO bruker (brukernavn) VALUES('peder') | true |
da5495542e2416e2e57a448ccd328f5261904478 | SQL | finleysg/clubmanager-api | /registration_payment_view.sql | UTF-8 | 1,146 | 3.578125 | 4 | [] | no_license | ALTER VIEW club.online_payment_view AS
SELECT
e.id AS event_id
,e.name
,e.event_type
,e.start_date
,g.signed_up_by_id
,u.first_name
,u.last_name
,g.payment_amount
,g.payment_confirmation_code
,g.payment_confirmation_timestamp
,g.id AS record_id
,'group-payment' AS record_type
,concat(g.id, 'g') AS pkey
FROM club.events_event AS e
JOIN club.register_registrationgroup AS g ON e.id = g.event_id
JOIN club.core_member AS m ON g.signed_up_by_id = m.id
JOIN club.auth_user AS u ON m.user_id = u.id
WHERE g.payment_confirmation_code LIKE 'ch_%'
UNION ALL
SELECT
e.id AS event_id
,e.name
,e.event_type
,e.start_date
,p.recorded_by_id
,u.first_name
,u.last_name
,p.payment_amount
,p.payment_code
,p.payment_timestamp
,p.id AS record_id
,'slot-payment' AS record_type
,concat(p.id, 'p') AS pkey
FROM club.events_event AS e
JOIN club.register_registrationslot AS s ON e.id = s.event_id
JOIN club.register_registrationslotpayment AS p ON s.id = p.registration_slot_id
JOIN club.core_member AS m ON p.recorded_by_id = m.id
JOIN club.auth_user AS u ON m.user_id = u.id
WHERE p.payment_code LIKE 'ch_%'
| true |
859b29cf1a7336df3effec6dbfc26a3f447cf838 | SQL | littlepai/O2O-Coupon-Usage-Forecast | /code/pai/create_tab.sql | GB18030 | 3,885 | 3.828125 | 4 | [] | no_license | --drop ѵݱ
drop table train_online_stage2;
--create ѵݱ
create table train_online_stage2
(
user_id varchar2(100),
merchant_id varchar2(100),
action varchar2(100),
coupon_id varchar2(100),
discount_rate varchar2(100),
date_received varchar2(100),
date_pay varchar2(100)
);
comment on column train_online_stage2.user_id is 'ûID';
comment on column train_online_stage2.merchant_id is '̻ID';
comment on column train_online_stage2.action is '0 12ȡŻȯ ';
comment on column train_online_stage2.coupon_id is 'ŻȯIDnullʾŻȯѣʱDiscount_rateDate_receivedֶ塣fixedʾýʱͼۻ';
comment on column train_online_stage2.discount_rate is 'Żʣx \in [0,1]ۿʣx:yʾxyfixedʾͼʱŻݣ ';
comment on column train_online_stage2.date_received is 'ȡŻȯ ';
comment on column train_online_stage2.date_pay is 'ڣDate=null & Coupon_id != nullü¼ʾȡŻȯûʹãDate!=null & Coupon_id = nullʾͨڣDate!=null & Coupon_id != nullʾŻȯڣ';
--drop ѵݱ
drop table train_offline_stage2;
--create ѵݱ
create table train_offline_stage2
(
user_id varchar2(100),
merchant_id varchar2(100),
coupon_id varchar2(100),
discount_rate varchar2(100),
distance number,
date_received varchar2(100),
date_pay varchar2(100)
);
comment on column train_offline_stage2.user_id is 'ûID';
comment on column train_offline_stage2.merchant_id is '̻ID';
comment on column train_offline_stage2.coupon_id is 'ŻȯIDnullʾŻȯѣʱDiscount_rateDate_receivedֶ塣fixedʾýʱͼۻ';
comment on column train_offline_stage2.discount_rate is 'Żʣx \in [0,1]ۿʣx:yʾxyfixedʾͼʱŻݣ ';
comment on column train_offline_stage2.distance is 'userĵصmerchantŵx*500ף꣬ȡһŵ꣩x\in[0,10]nullʾϢ0ʾ500ף10ʾ5 ';
comment on column train_offline_stage2.date_received is 'ȡŻȯ ';
comment on column train_offline_stage2.date_pay is 'ڣDate=null & Coupon_id != nullü¼ʾȡŻȯûʹãDate!=null & Coupon_id = nullʾͨڣDate!=null & Coupon_id != nullʾŻȯڣ';
--drop Ԥݱ
drop table prediction_stage2;
--create Ԥݱ
create table prediction_stage2
(
user_id varchar2(100),
merchant_id varchar2(100),
coupon_id varchar2(100),
discount_rate varchar2(100),
distance varchar2(100),
date_received varchar2(100)
);
comment on column train_offline_stage2.user_id is 'ûID';
comment on column train_offline_stage2.merchant_id is '̻ID';
comment on column train_offline_stage2.coupon_id is 'ŻȯIDnullʾŻȯѣʱDiscount_rateDate_receivedֶ塣fixedʾýʱͼۻ';
comment on column train_offline_stage2.discount_rate is 'Żʣx \in [0,1]ۿʣx:yʾxyfixedʾͼʱŻݣ ';
comment on column train_offline_stage2.distance is 'userĵصmerchantŵx*500ף꣬ȡһŵ꣩x\in[0,10]nullʾϢ0ʾ500ף10ʾ5 ';
comment on column train_offline_stage2.date_received is 'ȡŻȯ ';
| true |
3dff41b02b9adee6c195678b632755ca2f430e92 | SQL | fwu96/SQL-JDBC | /Query9.sql | UTF-8 | 1,453 | 4.40625 | 4 | [] | no_license | WITH storedeptallsale AS(
SELECT store,dept,sum(weeklysales) AS all_sale
FROM sales
GROUP BY store,dept
), inf AS(
SELECT dept, SUM(all_sale/SIZE) AS normsales
FROM storedeptallsale
JOIN stores ON storedeptallsale.store = stores.store
GROUP BY dept
), deps AS (
SELECT dept AS d
FROM inf
ORDER BY normsales DESC
LIMIT 10
), info AS (
SELECT dept, yr, mo, monthlysales,
ROUND(CAST((monthlysales * 100 / total) AS DECIMAL), 2) AS contribution,
ROUND(CAST(cumulative_sales AS DECIMAL), 2) AS cumulative_sales
FROM (
SELECT dept, mo, yr, monthlysales,
SUM(monthlysales) OVER (PARTITION BY dept ORDER BY dept, yr, mo) AS cumulative_sales,
SUM(monthlysales) OVER (PARTITION BY dept) AS total
FROM (
SELECT SUM(weeklysales) AS monthlysales, dept,
EXTRACT(YEAR FROM weekdate) AS yr,
EXTRACT(MONTH FROM weekdate) AS mo
FROM sales
INNER JOIN deps ON sales.dept = deps.d
GROUP BY dept, yr, mo
ORDER BY yr, mo
) AS tmp
ORDER BY dept
) AS tmp2
ORDER BY dept, yr, mo
)
SELECT * FROM info
group by dept, mo, yr, monthlysales, contribution, cumulative_sales
ORDER BY dept, yr, mo;
| true |
4f16b35016360928edf85c9555080b1d05543f24 | SQL | alexxg98/The-Hive | /TheHive.sql | UTF-8 | 2,772 | 3.71875 | 4 | [] | no_license | DROP DATABASE IF EXISTS TheHive;
CREATE DATABASE TheHive;
use TheHive;
CREATE TABLE users(
username VARCHAR(25),
email VARCHAR(25),
PRIMARY KEY(username, email),
password VARCHAR(25),
reputation_score INT DEFAULT 0,
user_type ENUM('OU', 'VIP', 'SU'),
status VARCHAR(5) NULL,
votes INT DEFAULT 0,
taboo_count INT DEFAULT 0,
login_time VARCHAR(25)
);
CREATE TABLE pending_users(
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(25) NOT NULL,
email VARCHAR(25) NOT NULL,
reference VARCHAR(25) NOT NULL,
interest VARCHAR(25) NOT NULL,
credential VARCHAR(25) NOT NULL,
rejected INT DEFAULT 0,
appeal VARCHAR(225) NULL,
UNIQUE KEY (email)
);
CREATE TABLE projects(
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(25) NOT NULL,
description VARCHAR(50) NOT NULL,
creator VARCHAR(25),
projRank INT,
viewing VARCHAR(5) DEFAULT NULL,
CONSTRAINT fk_pojectcreator_id
FOREIGN KEY(creator)
REFERENCES users(username)
ON DELETE CASCADE
);
CREATE TABLE group_membership(
username VARCHAR(25),
group_id INT,
PRIMARY KEY(username, group_id),
CONSTRAINT fk_user_id
FOREIGN KEY (username)
REFERENCES users(username)
ON DELETE CASCADE,
CONSTRAINT fk_projects_id
FOREIGN KEY(group_id)
REFERENCES projects(id)
ON DELETE CASCADE
);
CREATE TABLE invitations(
inviter VARCHAR(25),
invited VARCHAR(25),
group_id INT,
CONSTRAINT fk_inviter
FOREIGN KEY(inviter)
REFERENCES users(username)
ON DELETE CASCADE,
CONSTRAINT fk_invited
FOREIGN KEY(invited)
REFERENCES users(username)
ON DELETE CASCADE,
CONSTRAINT fk_groupId
FOREIGN KEY(group_id)
REFERENCES projects(id)
ON DELETE CASCADE
);
CREATE TABLE black_list(
blacklister VARCHAR(25),
blacklisted VARCHAR(25),
PRIMARY KEY(blacklister, blacklisted)
);
CREATE TABLE white_list(
whitelister VARCHAR(25),
whitelisted VARCHAR(25),
PRIMARY KEY(whitelister, whitelisted),
CONSTRAINT fk_whitelister
FOREIGN KEY(whitelister)
REFERENCES users(username)
ON DELETE CASCADE,
CONSTRAINT fk_whitelisted
FOREIGN KEY(whitelisted)
REFERENCES users(username)
ON DELETE CASCADE
);
CREATE TABLE polls(
entry VARCHAR(25),
votes INT
);
CREATE TABLE posts(
postid INT,
group_id INT NOT NULL,
username VARCHAR(25),
content VARCHAR(225) NOT NULL,
CONSTRAINT fk_post_usr
FOREIGN KEY(username)
REFERENCES users(username)
ON DELETE CASCADE,
CONSTRAINT fk_post_id
FOREIGN KEY(group_id)
REFERENCES projects(id)
ON DELETE CASCADE
);
CREATE TABLE comments(
commentator VARCHAR(25),
userdirected VARCHAR(25),
comment VARCHAR(200),
comment_type INTEGER
);
| true |
2fde398c7e0b8ff7884e03c153b12716cf5df898 | SQL | TH1NKFASTER/sqlex | /exercises/063.sql | UTF-8 | 211 | 3.359375 | 3 | [] | no_license | SELECT name
FROM (SELECT DISTINCT ID_psg
FROM Pass_in_trip
GROUP BY ID_psg, place
HAVING COUNT(trip_no) > 1) AS x
INNER JOIN Passenger
ON Passenger.ID_psg = x.ID_psg
| true |
31deeb8f82f9184eb21ad41eff95e7d082e0cd65 | SQL | Melec-H/ec-code-2020-codflix-php | /codflix.sql | UTF-8 | 14,357 | 3.359375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Hôte : localhost:8889
-- Généré le : jeu. 25 juin 2020 à 18:28
-- Version du serveur : 5.7.23
-- Version de PHP : 7.2.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Base de données : `codflix`
--
-- --------------------------------------------------------
--
-- Structure de la table `genre`
--
CREATE TABLE `genre` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Déchargement des données de la table `genre`
--
INSERT INTO `genre` (`id`, `name`) VALUES
(1, 'Action'),
(2, 'Horreur'),
(3, 'Science-Fiction');
-- --------------------------------------------------------
--
-- Structure de la table `history`
--
CREATE TABLE `history` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`media_id` int(11) NOT NULL,
`start_date` datetime NOT NULL,
`finish_date` datetime DEFAULT NULL,
`watch_duration` int(11) NOT NULL DEFAULT '0' COMMENT 'in seconds'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Structure de la table `media`
--
CREATE TABLE `media` (
`id` int(11) NOT NULL,
`genre_id` int(20) NOT NULL,
`title` varchar(1024) NOT NULL,
`type` varchar(20) NOT NULL,
`status` varchar(20) NOT NULL,
`release_date` date NOT NULL,
`summary` longtext NOT NULL,
`trailer_url` varchar(100) NOT NULL,
`poster_url` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Déchargement des données de la table `media`
--
INSERT INTO `media` (`id`, `genre_id`, `title`, `type`, `status`, `release_date`, `summary`, `trailer_url`, `poster_url`) VALUES
(456, 3, 'The Simpsons', 'série', 'publié', '1989-12-17', 'Set in Springfield, the average American town, the show focuses on the antics and everyday adventures of the Simpson family; Homer, Marge, Bart, Lisa and Maggie, as well as a virtual cast of thousands. Since the beginning, the series has been a pop culture icon, attracting hundreds of celebrities to guest star. The show has also made name for itself in its fearless satirical take on politics, media and American life in general.', '', 'https://image.tmdb.org/t/p/w300//qcr9bBY6MVeLzriKCmJOv1562uY.jpg'),
(549, 3, 'Law & Order', 'série', 'publié', '1990-09-13', 'Law & Order is an American police procedural and legal drama television series, created by Dick Wolf and part of the Law & Order franchise. It originally aired on NBC and, in syndication, on various cable networks. Law & Order premiered on September 13, 1990, and completed its 20th and final season on May 24, 2010. At the time of its cancellation, Law & Order was the longest-running crime drama on American primetime television. After The Simpsons, both Law & Order and Gunsmoke tied for the second longest-running scripted American primetime series with ongoing characters.', '', 'https://image.tmdb.org/t/p/w300//jUKiOgSYVAP8ARYPotgnBwIK1x7.jpg'),
(1412, 3, 'Arrow', 'série', 'publié', '2012-10-10', 'Spoiled billionaire playboy Oliver Queen is missing and presumed dead when his yacht is lost at sea. He returns five years later a changed man, determined to clean up the city as a hooded vigilante armed with a bow.', '', 'https://image.tmdb.org/t/p/w300//gKG5QGz5Ngf8fgWpBsWtlg5L2SF.jpg'),
(1668, 3, 'Friends', 'série', 'publié', '1994-09-22', 'The misadventures of a group of friends as they navigate the pitfalls of work, life and love in Manhattan.', '', 'https://image.tmdb.org/t/p/w300//bRJOwllemPbE4JTQ0TtcVu9efff.jpg'),
(2734, 3, 'Law & Order: Special Victims Unit', 'série', 'publié', '1999-09-20', 'In the criminal justice system, sexually-based offenses are considered especially heinous. In New York City, the dedicated detectives who investigate these vicious felonies are members of an elite squad known as the Special Victims Unit. These are their stories.', '', 'https://image.tmdb.org/t/p/w300//6t6r1VGQTTQecN4V0sZeqsmdU9g.jpg'),
(30623, 3, 'Crayon Shin-chan', 'série', 'publié', '1992-04-13', 'Shin-chan, the boy next door, is a walking disaster, creating chaos wherever he goes. With the body of a child and the mind of an adult, Shinchan is wreaking more havoc than any child before. Shin-chan is carefree, optimistic and gets excited about everything. This 5 year-old likes to do things his way.', '', 'https://image.tmdb.org/t/p/w300//1YffzZDZmxonFz4MTy0gaBDC3S0.jpg'),
(60572, 3, 'Pokémon', 'série', 'publié', '1997-04-01', 'Join Ash Ketchum, accompanied by his partner Pikachu, as he travels through many regions, meets new friends and faces new challenges on his quest to become a Pokémon Master.', '', 'https://image.tmdb.org/t/p/w300//2AoqUTKKN4kjNe1K0kIPwiItHwv.jpg'),
(70523, 3, 'Dark', 'série', 'publié', '2017-12-01', 'A missing child causes four families to help each other for answers. What they could not imagine is that this mystery would be connected to innumerable other secrets of the small town.', '', 'https://image.tmdb.org/t/p/w300//ajmkAwuK1TRFWMjKoSMgoAXbnc7.jpg'),
(85853, 3, 'Perry Mason', 'série', 'publié', '2020-06-21', 'Set in 1932 Los Angeles, the series focuses on the origin story of famed defense lawyer Perry Mason. Living check-to-check as a low-rent private investigator, Mason is haunted by his wartime experiences in France and suffering the effects of a broken marriage. L.A. is booming while the rest of the country recovers from the Great Depression — but a kidnapping gone very wrong leads to Mason exposing a fractured city as he uncovers the truth of the crime.', '', 'https://image.tmdb.org/t/p/w300//gPBf35AqvXHvKEpDHaQ4D9xXxeX.jpg'),
(130267, 3, 'Seal Team Six: The Raid on Osama Bin Laden', 'film', 'publié', '2012-11-04', 'When the rumored whereabouts of Osama bin Laden are revealed, the CIA readies a team of seasoned U.S. Navy SEALs for the mission of a lifetime. Despite inconclusive evidence that bin Laden is inside the compound, and ignoring the possible ramifications of an unannounced attack on Pakistani soil, the Pentagon orders the attack. The SEAL Team bands together to complete their mission of justice in a riveting final showdown.', 'http://www.youtube.com/embed/M6vtiaNqtv4', 'https://image.tmdb.org/t/p/w300//hau6iHAIWJmlnaaZ0QRYZu9T6B1.jpg'),
(299536, 3, 'Avengers: Infinity War', 'film', 'publié', '2018-04-25', 'As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment - the fate of Earth and existence itself has never been more uncertain.', 'http://www.youtube.com/embed/sAOzrChqmd0', 'https://image.tmdb.org/t/p/w300//7WsyChQLEftFiDOVTGkv3hFpyyt.jpg'),
(419704, 3, 'Ad Astra', 'film', 'publié', '2019-09-17', 'The near future, a time when both hope and hardships drive humanity to look to the stars and beyond. While a mysterious phenomenon menaces to destroy life on planet Earth, astronaut Roy McBride undertakes a mission across the immensity of space and its many perils to uncover the truth about a lost expedition that decades before boldly faced emptiness and silence in search of the unknown.', 'http://www.youtube.com/embed/P6AaSMfXHbA', 'https://image.tmdb.org/t/p/w300//xBHvZcjRiWyobQ9kxBhO6B2dtRI.jpg'),
(420817, 3, 'Aladdin', 'film', 'publié', '2019-05-22', 'A kindhearted street urchin named Aladdin embarks on a magical adventure after finding a lamp that releases a wisecracking genie while a power-hungry Grand Vizier vies for the same lamp that has the power to make their deepest wishes come true.', 'http://www.youtube.com/embed/9g5knnlF7Zo', 'https://image.tmdb.org/t/p/w300//ykUEbfpkf8d0w49pHh0AD2KrT52.jpg'),
(454626, 3, 'Sonic the Hedgehog', 'film', 'publié', '2020-02-12', 'Based on the global blockbuster videogame franchise from Sega, Sonic the Hedgehog tells the story of the world’s speediest hedgehog as he embraces his new home on Earth. In this live-action adventure comedy, Sonic and his new best friend team up to defend the planet from the evil genius Dr. Robotnik and his plans for world domination.', 'http://www.youtube.com/embed/szby7ZHLnkA', 'https://image.tmdb.org/t/p/w300//aQvJ5WPzZgYVDrxLX4R6cLJCEaQ.jpg'),
(475557, 3, 'Joker', 'film', 'publié', '2019-10-02', 'During the 1980s, a failed stand-up comedian is driven insane and turns to a life of crime and chaos in Gotham City while becoming an infamous psychopathic crime figure.', 'http://www.youtube.com/embed/t433PEQGErc', 'https://image.tmdb.org/t/p/w300//udDclJoHjfjb8Ekgsd4FDteOkCU.jpg'),
(495764, 3, 'Birds of Prey (and the Fantabulous Emancipation of One Harley Quinn)', 'film', 'publié', '2020-02-05', 'Harley Quinn joins forces with a singer, an assassin and a police detective to help a young girl who had a hit placed on her after she stole a rare diamond from a crime lord.', 'http://www.youtube.com/embed/ptLZlrE8MrQ', 'https://image.tmdb.org/t/p/w300//h4VB6m0RwcicVEZvzftYZyKXs6K.jpg'),
(509585, 3, '7500', 'film', 'publié', '2019-12-26', 'When terrorists try to seize control of a Berlin-Paris flight, a soft-spoken young American co-pilot struggles to save the lives of the passengers and crew while forging a surprising connection with one of the hijackers.', 'http://www.youtube.com/embed/Z5Vz9nPw2lg', 'https://image.tmdb.org/t/p/w300//hL2uecLh2rTTbuVbOriXP0PhqIJ.jpg'),
(514593, 3, 'You Should Have Left', 'film', 'publié', '2020-06-19', 'In an effort to repair their relationship, a couple books a vacation in the countryside for themselves and their daughter. What starts as a perfect retreat begins to fall apart as one loses their grip on reality, and a sinister force tries to tear them apart.', 'http://www.youtube.com/embed/Bw0-cV_J9q4', 'https://image.tmdb.org/t/p/w300//2Gi9ZA4kRKKsWguUoTvIyj40dxF.jpg'),
(530915, 3, '1917', 'film', 'publié', '2019-12-25', 'At the height of the First World War, two young British soldiers must cross enemy territory and deliver a message that will stop a deadly attack on hundreds of soldiers.', 'http://www.youtube.com/embed/UcmZN0Mbl04', 'https://image.tmdb.org/t/p/w300//iZf0KyrE25z1sage4SYFLCCrMi9.jpg'),
(581859, 3, 'Da 5 Bloods', 'film', 'publié', '2020-06-12', 'Four African-American Vietnam veterans return to Vietnam. They are in search of the remains of their fallen squad leader and the promise of buried treasure. These heroes battle forces of humanity and nature while confronted by the lasting ravages of the immorality of the Vietnam War.', 'http://www.youtube.com/embed/D5RDTPfsLAI', 'https://image.tmdb.org/t/p/w300//yx4cp1ljJMDSFeEex0Zjv45b55E.jpg'),
(619592, 3, 'Force of Nature', 'film', 'publié', '2020-07-02', 'A gang of thieves plan a heist during a hurricane and encounter trouble when a disgraced cop tries to force everyone in the building to evacuate.', 'http://www.youtube.com/embed/iQKaY8G9VpQ', 'https://image.tmdb.org/t/p/w300//ucktgbaMSaETUDLUBp1ubGD6aNj.jpg'),
(706503, 3, 'Lost Bullet', 'film', 'publié', '2020-06-19', 'A small time delinquent, turned police mechanic for a go fast task force, is forced to defend his innocence when his mentor is killed by dirty cops.', 'http://www.youtube.com/embed/-qaYywvAyz8', 'https://image.tmdb.org/t/p/w300//qnlChF8U4diiykXQYs1miigGy7t.jpg'),
(707886, 3, 'Feel the Beat', 'film', 'publié', '2020-06-19', 'After failing to make it on Broadway, April returns to her hometown and reluctantly begins training a misfit group of young dancers for a competition.', 'http://www.youtube.com/embed/PhLSDnxLp-M', 'https://image.tmdb.org/t/p/w300//Af2jt7m9GLFpR4V11xOsFmT8OKD.jpg');
-- --------------------------------------------------------
--
-- Structure de la table `user`
--
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`email` varchar(254) NOT NULL,
`password` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Déchargement des données de la table `user`
--
INSERT INTO `user` (`id`, `email`, `password`) VALUES
(4, 'melecduhalgouet@yahoo.fr', 'a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3'),
(5, 'duhalgouetm@yahoo.com', 'a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3'),
(6, 'melec.duhalgouet@edu.itescia.fr', 'a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3'),
(7, 'slat@jaa.com', 'a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3'),
(8, 'panpan@panpan.com', 'a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3'),
(9, 'berenice.tritsch@gmail.fr', 'b18a694db12e4683ab1c9c49f31f926d8e43d17880f5b9f8b9175b69789e2802'),
(10, 'berenaice.triche@gmail.com', '6b51d431df5d7f141cbececcf79edf3dd861c3b4069f0b11661a3eefacbba918'),
(11, 'coding@gmail.com', '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92');
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `genre`
--
ALTER TABLE `genre`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `history`
--
ALTER TABLE `history`
ADD PRIMARY KEY (`id`),
ADD KEY `history_user_id_fk_media_id` (`user_id`),
ADD KEY `history_media_id_fk_media_id` (`media_id`);
--
-- Index pour la table `media`
--
ALTER TABLE `media`
ADD PRIMARY KEY (`id`),
ADD KEY `media_genre_id_fk_genre_id` (`genre_id`) USING BTREE;
--
-- Index pour la table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT pour les tables déchargées
--
--
-- AUTO_INCREMENT pour la table `genre`
--
ALTER TABLE `genre`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT pour la table `history`
--
ALTER TABLE `history`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `media`
--
ALTER TABLE `media`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=707887;
--
-- AUTO_INCREMENT pour la table `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `history`
--
ALTER TABLE `history`
ADD CONSTRAINT `history_media_id_fk_media_id` FOREIGN KEY (`media_id`) REFERENCES `media` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `history_user_id_fk_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Contraintes pour la table `media`
--
ALTER TABLE `media`
ADD CONSTRAINT `media_genre_id_b1257088_fk_genre_id` FOREIGN KEY (`genre_id`) REFERENCES `genre` (`id`);
| true |
26dc33eecad59390acaad31129cef5eb33d9dfab | SQL | oerpli/MONitERO | /sql/queries/monthly_stats.sql | UTF-8 | 3,188 | 4.0625 | 4 | [
"MIT"
] | permissive | \timing on
-- name of new table
\set name monthly_stats
-- aggregate over month/day/year/whatever?
\set granularity month
-- desired precision of various floats in the table. a precision of 2 should be enough for everybody (abraham hinteregger)
\set fprecision 2
-- creat quoted version of variable
\set q_granularity '''' :granularity ''''
DROP TABLE IF EXISTS :name;
CREATE TABLE :name AS (
WITH tx_stats as (select date_trunc(:q_granularity,time)::DATE as :granularity
, count(distinct txid) as num_tx -- #TXs
, count(distinct case when coinbase then txid end) as cb_tx -- #non coinbase TXs
, count(distinct case when not coinbase then txid end) as real_tx -- #non coinbase TXs
, count(distinct case when ringct then txid end) as ringct -- #ringct TXs
from tx
group by 1 order by 1 asc
) -- No CB TXs per default when joining with tx inputs
, input_stats as (select date_trunc(:q_granularity,time)::DATE as :granularity
, round(count(distinct inid)::numeric / count(distinct txid),:fprecision) as avg_in -- AVG #inputs per TX
, count(*) as num_in -- #Inputs
, count(case when effective_ringsize = 1 then 1 end) as linked_in -- #Inputs with known real
, count(case when ringsize > 1 then 1 end) as nt_in -- #Inputs(ringsize > 1)
, round(count(case when ringsize > 1 and effective_ringsize = 1 then 1 end)::numeric/ count(distinct case when ringsize > 1 then inid end),:fprecision) as linked_nt -- #Inputs(ringsize > 1) with known real (relative)
, count(case when ringsize > 1 and effective_ringsize = 1 then 1 end) as linked_nt_abs -- #Inputs(ringsize > 1) with known real (absolute)
, round(avg(ringsize)::numeric,:fprecision) as avg_rs -- Average Ringsize
, round(avg(effective_ringsize)::numeric,:fprecision) as avg_eff_rs -- Average Effective Ringsize
, round(count(case when ringsize <= minringsize(block) then 1 end)::numeric/ count(distinct inid),:fprecision) as rel_min_rs -- Amount of inputs that only uses minimum possible RS (or less, due to some old pre-RingCT outputs with denom)
-- , round(avg(case when ringsize > minringsize(block) then ringsize - minringsize(block) -1 end),:fprecision) as avgExtraMixins -- commented out - uninteresting table
from tx join txi using(txid)
group by 1 order by 1 asc
) -- Excluded CB TXs with where clause
, output_stats as (select date_trunc(:q_granularity,time)::DATE as :granularity
, count(*) as num_out -- #Outputs
, round(count(distinct outid)::numeric / count(distinct txid),:fprecision) as avg_out -- Average #Outputs per TX
, count(distinct amount) as dist_amount -- # distinct nonCB denominations
, round(sum(amount),:fprecision) as volume -- nonCB TX volume (not useful after ringct though)
from tx join txout using (txid)
where not coinbase
group by 1 order by 1 asc
)
select *
from tx_stats
join input_stats using (:granularity)
join output_stats using(:granularity)
order by :granularity asc
);
COMMENT ON TABLE :name IS 'Monthly TX stats, output and input stats exclude coinbase TXs. Details in .sql file';
\set file :outfolder:name'.csv'''
COPY :name TO :file CSV HEADER DELIMITER E'\t';
| true |
1dfc2be273cbefe291294f2bdf0fd055220ea4cd | SQL | jichuangsi/69Vedio_console | /data/20191217.sql | UTF-8 | 614 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | DROP TABLE IF EXISTS `ms_member_location`;
CREATE TABLE `ms_member_location` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`latitude` decimal(15,11) unsigned NOT NULL DEFAULT '0.00' COMMENT '经度',
`longitude` decimal(15,11) unsigned NOT NULL DEFAULT '0.00' COMMENT '维度',
`address` text default '' COMMENT '详细地址',
`uid` int(11) default 0 COMMENT '用户id',
`add_time` int(10) NOT NULL COMMENT '初始时间',
`update_time` int(10) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户地位信息'; | true |
fd3c01aa2c3acec92ad70dd80cf0d1deb98da0ba | SQL | dgupta-apttus/EDA | /Snowflake/SNAPSHOT/ViewDDL/LMA_LICENSE_C1_HISTORY.sql | UTF-8 | 5,483 | 2.71875 | 3 | [] | no_license | --DROP VIEW APTTUS_DW.SNAPSHOTS.FMA_VALUES_HISTORY ;
CREATE OR REPLACE VIEW APTTUS_DW.SNAPSHOTS.LMA_LICENSE_C1_HISTORY
COMMENT = 'Union LMA_LICENSE_C1 snapshots to make complete history'
AS
WITH the_union AS (
SELECT
ACCOUNT_SUSPENDED__C
, BA_EMAIL__C
, BA__C
, COMPANY_FROM_LEAD__C
, CONGA_EDITION__C
, CREATEDBYID
, CREATEDDATE
, CUSTOMER_ORG_ID__C
, EXPIRATION_DATE__C
, ID
, INSTALL_DATE_CHECK__C
, ISDELETED
, LASTMODIFIEDBYID
, LASTMODIFIEDDATE
, LEAD_COMPANY__C
, LEAD_EMAIL__C
, LICENSE_CHECK__C
, "NAME"
, OWNERID
, PACKAGE_NAMEFX__C
, PRODUCTION__C
, QUIK_CUSTOMER_ID__C
, RECORDTYPEID
, RECORD_URL__C
, SALESFORCE_ORGID__C
, SFLMA__ACCOUNT__C
, SFLMA__CONTACT__C
, SFLMA__EXPIRATION_DATE__C
, SFLMA__EXPIRATION__C
, SFLMA__HELP__C
, SFLMA__INSTALL_DATE__C
, SFLMA__INSTANCE__C
, SFLMA__IS_SANDBOX__C
, SFLMA__LAST_MODIFIED__C
, SFLMA__LEAD__C
, SFLMA__LICENSED_SEATS__C
, SFLMA__LICENSE_STATUS__C
, SFLMA__LICENSE_TYPE__C
, SFLMA__ORG_EDITION__C
, SFLMA__ORG_INSTANCE__C
, SFLMA__ORG_STATUS_FORMULA__C
, SFLMA__ORG_STATUS__C
, SFLMA__ORG_TRIAL_EXPIRATION__C
, SFLMA__ORG_TYPE__C
, SFLMA__PACKAGE_LICENSE_ID__C
, SFLMA__PACKAGE_VERSION_NUMBER__C
, SFLMA__PACKAGE_VERSION__C
, SFLMA__PACKAGE__C
, SFLMA__PROXY_USER__C
, SFLMA__SEATS__C
, SFLMA__STATUS__C
, SFLMA__SUBSCRIBER_ORG_ID__C
, SFLMA__SUBSCRIBER_ORG_IS_SANDBOX__C
, SFLMA__TRIAL_EXPIRATION_DATE__C
, SFLMA__USED_LICENSES__C
, SFLMA__VERSION_NUMBER__C
, SUSPEND_ACCOUNT__C
, SYSTEMMODSTAMP
, UNINSTALL_DATE__C
, "_SDC_BATCHED_AT"
, "_SDC_EXTRACTED_AT"
, "_SDC_RECEIVED_AT"
, "_SDC_SEQUENCE"
, "_SDC_TABLE_VERSION"
, SNAP_LOAD_AT
FROM
APTTUS_DW.SNAPSHOTS.LMA_LICENSE_C1_SNAP_1595011981947_1600187624271
UNION
SELECT
ACCOUNT_SUSPENDED__C
, BA_EMAIL__C
, BA__C
, COMPANY_FROM_LEAD__C
, CONGA_EDITION__C
, CREATEDBYID
, CREATEDDATE
, CUSTOMER_ORG_ID__C
, EXPIRATION_DATE__C
, ID
, INSTALL_DATE_CHECK__C
, ISDELETED
, LASTMODIFIEDBYID
, LASTMODIFIEDDATE
, LEAD_COMPANY__C
, LEAD_EMAIL__C
, LICENSE_CHECK__C
, "NAME"
, OWNERID
, PACKAGE_NAMEFX__C
, PRODUCTION__C
, QUIK_CUSTOMER_ID__C
, RECORDTYPEID
, RECORD_URL__C
, SALESFORCE_ORGID__C
, SFLMA__ACCOUNT__C
, SFLMA__CONTACT__C
, SFLMA__EXPIRATION_DATE__C
, SFLMA__EXPIRATION__C
, SFLMA__HELP__C
, SFLMA__INSTALL_DATE__C
, SFLMA__INSTANCE__C
, SFLMA__IS_SANDBOX__C
, SFLMA__LAST_MODIFIED__C
, SFLMA__LEAD__C
, SFLMA__LICENSED_SEATS__C
, SFLMA__LICENSE_STATUS__C
, SFLMA__LICENSE_TYPE__C
, SFLMA__ORG_EDITION__C
, SFLMA__ORG_INSTANCE__C
, SFLMA__ORG_STATUS_FORMULA__C
, SFLMA__ORG_STATUS__C
, SFLMA__ORG_TRIAL_EXPIRATION__C
, SFLMA__ORG_TYPE__C
, SFLMA__PACKAGE_LICENSE_ID__C
, SFLMA__PACKAGE_VERSION_NUMBER__C
, SFLMA__PACKAGE_VERSION__C
, SFLMA__PACKAGE__C
, SFLMA__PROXY_USER__C
, SFLMA__SEATS__C
, SFLMA__STATUS__C
, SFLMA__SUBSCRIBER_ORG_ID__C
, SFLMA__SUBSCRIBER_ORG_IS_SANDBOX__C
, SFLMA__TRIAL_EXPIRATION_DATE__C
, SFLMA__USED_LICENSES__C
, SFLMA__VERSION_NUMBER__C
, SUSPEND_ACCOUNT__C
, SYSTEMMODSTAMP
, UNINSTALL_DATE__C
, "_SDC_BATCHED_AT"
, "_SDC_EXTRACTED_AT"
, "_SDC_RECEIVED_AT"
, "_SDC_SEQUENCE"
, "_SDC_TABLE_VERSION"
, SNAP_LOAD_AT
FROM
APTTUS_DW.SNAPSHOTS.LMA_LICENSE_C1_SNAP_1
UNION
SELECT
ACCOUNT_SUSPENDED__C
, BA_EMAIL__C
, BA__C
, COMPANY_FROM_LEAD__C
, CONGA_EDITION__C
, CREATEDBYID
, CREATEDDATE
, CUSTOMER_ORG_ID__C
, EXPIRATION_DATE__C
, ID
, INSTALL_DATE_CHECK__C
, ISDELETED
, LASTMODIFIEDBYID
, LASTMODIFIEDDATE
, LEAD_COMPANY__C
, LEAD_EMAIL__C
, LICENSE_CHECK__C
, "NAME"
, OWNERID
, PACKAGE_NAMEFX__C
, PRODUCTION__C
, QUIK_CUSTOMER_ID__C
, RECORDTYPEID
, RECORD_URL__C
, SALESFORCE_ORGID__C
, SFLMA__ACCOUNT__C
, SFLMA__CONTACT__C
, SFLMA__EXPIRATION_DATE__C
, SFLMA__EXPIRATION__C
, SFLMA__HELP__C
, SFLMA__INSTALL_DATE__C
, SFLMA__INSTANCE__C
, SFLMA__IS_SANDBOX__C
, SFLMA__LAST_MODIFIED__C
, SFLMA__LEAD__C
, SFLMA__LICENSED_SEATS__C
, SFLMA__LICENSE_STATUS__C
, SFLMA__LICENSE_TYPE__C
, SFLMA__ORG_EDITION__C
, SFLMA__ORG_INSTANCE__C
, SFLMA__ORG_STATUS_FORMULA__C
, SFLMA__ORG_STATUS__C
, SFLMA__ORG_TRIAL_EXPIRATION__C
, SFLMA__ORG_TYPE__C
, SFLMA__PACKAGE_LICENSE_ID__C
, SFLMA__PACKAGE_VERSION_NUMBER__C
, SFLMA__PACKAGE_VERSION__C
, SFLMA__PACKAGE__C
, SFLMA__PROXY_USER__C
, SFLMA__SEATS__C
, SFLMA__STATUS__C
, SFLMA__SUBSCRIBER_ORG_ID__C
, SFLMA__SUBSCRIBER_ORG_IS_SANDBOX__C
, SFLMA__TRIAL_EXPIRATION_DATE__C
, SFLMA__USED_LICENSES__C
, SFLMA__VERSION_NUMBER__C
, SUSPEND_ACCOUNT__C
, SYSTEMMODSTAMP
, UNINSTALL_DATE__C
, "_SDC_BATCHED_AT"
, "_SDC_EXTRACTED_AT"
, "_SDC_RECEIVED_AT"
, "_SDC_SEQUENCE"
, "_SDC_TABLE_VERSION"
, SNAP_LOAD_AT
FROM APTTUS_DW.SNAPSHOTS.LMA_LICENSE_C1_FROMREDSHIFT
)
, the_unique AS (
SELECT ID
, _SDC_EXTRACTED_AT
, MAX(SNAP_LOAD_AT) AS SNAP_LOAD_AT
FROM the_union
GROUP BY ID
, _SDC_EXTRACTED_AT
)
SELECT A.*
, to_date(SYSTEMMODSTAMP) AS ACTIVITY_DATE
, dateadd(day, -1, to_date(A."_SDC_EXTRACTED_AT")) AS EXTRACT_DATE
, dateadd(day, -1, to_date(A."SNAP_LOAD_AT")) AS REPORTING_DATE
FROM the_union A
INNER JOIN the_unique B
ON A.ID = B.ID
AND A._SDC_EXTRACTED_AT = B._SDC_EXTRACTED_AT
AND A.SNAP_LOAD_AT = B.SNAP_LOAD_AT
;
| true |
579daa025858ddd7aba336e33c5047f2f413157f | SQL | sevdalin/Software-University-SoftUni | /CSharp-DB-Fundamentals/Databases Basics - MS SQL Server/08. Functions, Triggers and Transactions/Problem 3 - Town Names Starting With.sql | UTF-8 | 130 | 2.921875 | 3 | [
"MIT"
] | permissive | CREATE PROC usp_GetTownsStartingWith (@TownName nvarchar(20))
AS
SELECT t.Name FROM Towns AS [t]
WHERE t.Name LIKE @TownName + '%' | true |
db8162db94454a348c254096697708327be6f15c | SQL | Rufaidamugalli/springacademy- | /Spring-data-jdbc-relationships-sample/src/main/resources/schema.sql | UTF-8 | 281 | 2.765625 | 3 | [] | no_license | drop table if exists rental;
drop table if exists movie;
create table movie(
id serial primary key,
title text,
description text
);
create table rental(
id serial primary key,
movie integer references movie(id),
movie_key text,
duration text,
price integer
); | true |
fbea51ca0a79bb02b389a9c626a67f3651033a5b | SQL | IF65/script | /SQL/accoda_giornata.sql | UTF-8 | 996 | 2.828125 | 3 | [] | no_license | delete archivi.`riepvegi` from archivi.`riepvegi` join
(select distinct substr(`NEGOZIO`,1,2) as `societa`,substr(`NEGOZIO`,3,2) as `negozio`,str_to_date(`DATA`,'%Y%m%d') as `data` from rvg.`RIEPVEGI_RIE`) as rr
on archivi.`riepvegi`.`RVG-CODSOC`=rr.`societa` and archivi.`riepvegi`.`RVG-CODNEG`=rr.`negozio` and archivi.`riepvegi`.`RVG-DATA`=rr.`data`;
insert into archivi.`riepvegi`
(`RVG-CODSOC`,`RVG-CODNEG`,`RVG-CODICE`,`RVG-CODBARRE`,`RVG-DATA`,`RVG-QTA-USC`,`RVG-QTA-USC-OS`,`RVG-QTA-USC-SCO`,`RVG-VAL-VEN-CASSE-E`
,`RVG-VAL-VEN-CED-E`,`RVG-VAL-VEN-LOC-E`,`RVG-VAL-VEN-OS-E`,`RVG-VAL-VEN-SCO-E`,`RVG-SEGNO-TIPO-PREZZO`,`RVG-FORZAPRE`,`RVG-REPARTO`,`RVG-CODFOR`)
SELECT SUBSTR(`NEGOZIO`,1,2) AS `SOCIETA`,SUBSTR(`NEGOZIO`,3,2) AS `NEGOZIO`,ARTICOLO,BARCODE,STR_TO_DATE(`DATA`,'%Y%m%d') AS `DATA`,QTA_USC,QTA_USC_OS,QTA_USC_SCO,
VAL_VEN_CASSE_E/100,VAL_VEN_CED_E/100,VAL_VEN_LOC_E/100,VAL_VEN_OS_E/100,VAL_VEN_SCO_E/100,SEGNO_TIPO_PREZZO,FORZAPRE,REPARTO,CODFOR
FROM rvg.RIEPVEGI_RIE;
| true |
83a795c6717b623dff47712c5c636e3170d03d25 | SQL | KHNRV/FlashQuiz | /db/00_schema/03_questions.sql | UTF-8 | 263 | 3.078125 | 3 | [] | no_license | DROP TABLE IF EXISTS questions CASCADE;
CREATE TABLE questions (
id SERIAL PRIMARY KEY,
quiz_id INTEGER REFERENCES quizzes(id) ON DELETE CASCADE,
prompt TEXT NOT NULL,
time_limit INTEGER NOT NULL DEFAULT 8000 --default time_limit is 8000 milliseconds
);
| true |
9202510b0c8f9d452dc9eeb99ae52bfc5e3dcd44 | SQL | SkillHard/Diplom | /modules/core/db/update/postgres/19/190624-2-updateConnection04.sql | UTF-8 | 664 | 2.671875 | 3 | [] | no_license | alter table ABITCARD_CONNECTION rename column direction_id to direction_id__u40288 ;
drop index IDX_ABITCARD_CONNECTION_ON_DIRECTION ;
alter table ABITCARD_CONNECTION drop constraint FK_ABITCARD_CONNECTION_ON_DIRECTION ;
alter table ABITCARD_CONNECTION rename column disciplin_three to disciplin_three__u27775 ;
alter table ABITCARD_CONNECTION rename column disciplin_two to disciplin_two__u02504 ;
alter table ABITCARD_CONNECTION rename column disciplin_one to disciplin_one__u53276 ;
alter table ABITCARD_CONNECTION add column SECOND_ID uuid ;
alter table ABITCARD_CONNECTION add column THIRD_ID uuid ;
alter table ABITCARD_CONNECTION add column FIRST_ID uuid ;
| true |
ac6eb542b64687e208d4763f5c9ee3a0e44df56c | SQL | PhanVanNam1998/DoAn_K57 | /test1.sql | UTF-8 | 2,686 | 3.234375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.1
-- https://www.phpmyadmin.net/
--
-- Máy chủ: 127.0.0.1
-- Thời gian đã tạo: Th8 27, 2020 lúc 04:46 AM
-- Phiên bản máy phục vụ: 10.4.11-MariaDB
-- Phiên bản PHP: 7.4.3
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 */;
--
-- Cơ sở dữ liệu: `test1`
--
-- --------------------------------------------------------
--
-- Cấu trúc bảng cho bảng `diemdanh`
--
CREATE TABLE `diemdanh` (
`STT` int(11) NOT NULL,
`Ten` varchar(255) NOT NULL,
`Ma_SV` varchar(10) NOT NULL,
`hinhanh` varchar(255) NOT NULL,
`Date` date NOT NULL,
`thioigian_den` time NOT NULL,
`den_muon` varchar(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Đang đổ dữ liệu cho bảng `diemdanh`
--
INSERT INTO `diemdanh` (`STT`, `Ten`, `Ma_SV`, `hinhanh`, `Date`, `thioigian_den`, `den_muon`) VALUES
(110, 'Hiep', '67290', 'static/known_face/67290_Hiep/Hiep_1.jpg', '2020-08-27', '09:26:05', 'No'),
(112, 'Hai', '68583', 'static/known_face/68583_Hai/Hai_1.jpg', '2020-08-27', '09:38:43', 'No');
-- --------------------------------------------------------
--
-- Cấu trúc bảng cho bảng `user`
--
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`status` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Đang đổ dữ liệu cho bảng `user`
--
INSERT INTO `user` (`id`, `username`, `password`, `status`) VALUES
(1, 'admin27', 'admin77', 0),
(2, 'admin', 'admin', 1),
(3, 'admin2', 'admin2', 0),
(4, 'admin3', 'admin3', 0),
(5, 'admin4', 'admin4', 1),
(13, 't', 't', 0);
--
-- Chỉ mục cho các bảng đã đổ
--
--
-- Chỉ mục cho bảng `diemdanh`
--
ALTER TABLE `diemdanh`
ADD PRIMARY KEY (`STT`);
--
-- Chỉ mục cho bảng `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT cho các bảng đã đổ
--
--
-- AUTO_INCREMENT cho bảng `diemdanh`
--
ALTER TABLE `diemdanh`
MODIFY `STT` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=113;
--
-- AUTO_INCREMENT cho bảng `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
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 |
72203043b4e0dd8b875accf0dcaa31c452b4ca5d | SQL | nabla-containers/rumprun-packages | /mysql/mysql_rump_bootstrap.sql | UTF-8 | 318 | 2.5625 | 3 | [
"CC0-1.0"
] | permissive | -- Rump-specific bootstrap for MySQL.
-- For demonstration purposes, drop all users except 'rump' which is made
-- equivalent to the 'root' user and allowed to login from any host.
USE mysql;
UPDATE user SET User = 'rump', Host = '%' WHERE User = 'root' AND Host = 'localhost';
DELETE from user WHERE User != 'rump';
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.