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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
913359b982fbe9dd009235edb1adabbe8232f3bf | SQL | Marcinar1010/CS50 | /pset7/movies/7.sql | UTF-8 | 112 | 3.09375 | 3 | [] | no_license | SELECT title, rating FROM movies
JOIN ratings ON (id = movie_id)
WHERE year = 2010 ORDER BY rating DESC, title;
| true |
1ff0f79d444d1aec730d69451e526ca7b113fb7c | SQL | ngthanhtien1104/Railway-08 | /SQL/Testing_System/Testing_System_7.sql | UTF-8 | 361 | 3.453125 | 3 | [] | no_license | USE testing_system;
-- Question 1: Tạo trigger không cho phép người dùng nhập vào Group có ngày tạo trước 1 năm trước
DELIMITER $$
CREATE TRIGGER log_in
BEFORE INSERT
ON `group`
FOR EACH ROW
BEGIN
SELECT Creatdate
FROM `group`
WHERE Creatdate (yeah(Now) - yeah(creatdate) >= 1);
END $$
DELIMITER ;
| true |
fef4b4622e76f533c47973710921851c0c80be50 | SQL | unison/unison | /misc/sql-scraps/assign_tax_id.sql | UTF-8 | 3,269 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"CC-BY-4.0"
] | permissive | -- -----------------------------------------------------------------------------
-- NAME: assign_tax_id.sql
-- PURPOSE: assign tax_id in the paliasorigin table
--
-- $Id: assign_tax_id.sql,v 1.7 2004/04/02 19:52:15 rkh Exp $
-- -----------------------------------------------------------------------------
-- swissprot - key off the gs info in the accession
UPDATE paliasorigin SET tax_id=gs2tax_id('HUMAN')
WHERE origin_id=origin_id_lookup('Swiss-Prot'::text) AND alias ~ '_HUMAN$'::text AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('MOUSE')
WHERE origin_id=origin_id_lookup('Swiss-Prot'::text) AND alias ~ '_MOUSE$'::text AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('RAT')
WHERE origin_id=origin_id_lookup('Swiss-Prot'::text) AND alias ~ '_RAT$'::text AND tax_id IS NULL;
-- refseq - key off the gs in the descr
UPDATE paliasorigin SET tax_id=gs2tax_id('HUMAN')
WHERE origin_id=origin_id_lookup('Refseq'::text) AND descr ~ '[[]Homo sapiens[]]$'::text AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('MOUSE')
WHERE origin_id=origin_id_lookup('Refseq'::text) AND descr ~ '[[]Mus musculus[]]$'::text AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('RAT')
WHERE origin_id=origin_id_lookup('Refseq'::text) AND descr ~ '[[]Rattus norvegicus[]]$'::text AND tax_id IS NULL;
-- proteome - key off species identifier in descr
UPDATE paliasorigin SET tax_id=gs2tax_id('HUMAN')
WHERE origin_id=origin_id_lookup('Proteome'::text) AND descr ~ '^[[]Human[]]' AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('MOUSE')
WHERE origin_id=origin_id_lookup('Proteome'::text) AND descr ~ '^[[]Mouse[]]' AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('RAT')
WHERE origin_id=origin_id_lookup('Proteome'::text) AND descr ~ '^[[]Rat[]]' AND tax_id IS NULL;
-- dblast - key off the gs in the descr
UPDATE paliasorigin SET tax_id=gs2tax_id('HUMAN')
WHERE origin_id=origin_id_lookup('dblast'::text) AND descr ~ '- Homo sapiens$' AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('MOUSE')
WHERE origin_id=origin_id_lookup('dblast'::text) AND descr ~ '- Mus musculus$' AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('HUMAN')
WHERE origin_id=origin_id_lookup('dblast'::text) AND descr ~ '- Rattus norvegicus$' AND tax_id IS NULL;
-- SPDI - key off the initial species word in the descr
UPDATE paliasorigin SET tax_id=gs2tax_id('HUMAN')
WHERE origin_id=origin_id_lookup('SPDI'::text) AND descr ~ '^Human'::text AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('MOUSE')
WHERE origin_id=origin_id_lookup('SPDI'::text) AND descr ~ '^Mouse'::text AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('RAT')
WHERE origin_id=origin_id_lookup('SPDI'::text) AND descr ~ '^Rat'::text AND tax_id IS NULL;
-- species specific database stuff
UPDATE paliasorigin SET tax_id=gs2tax_id('MOUSE')
WHERE origin_id=origin_id_lookup('mus'::text) AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('HUMAN')
WHERE origin_id=origin_id_lookup('MGC/Human'::text) AND tax_id IS NULL;
UPDATE paliasorigin SET tax_id=gs2tax_id('MOUSE')
WHERE origin_id=origin_id_lookup('MGC/Mouse'::text) AND tax_id IS NULL;
| true |
7085c2101af554be450668c7f1a49058bc8b3d4c | SQL | guidecayeux/temporis-v-back | /sql_scripts/logs.sql | UTF-8 | 303 | 2.796875 | 3 | [] | no_license | CREATE TABLE public.logs
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
log text COLLATE pg_catalog."default",
CONSTRAINT logs_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE public.logs
OWNER to root;
| true |
5dd2fa7279949debd79d0fddd4484d6ba945aad7 | SQL | MarvinEdorh/Data-Mining | /survival_table.sql | UTF-8 | 2,003 | 4.4375 | 4 | [] | no_license | WITH
visit AS (
SELECT fullvisitorid, MIN(date) AS date_first_visit, MAX(date) AS date_last_visit
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*` GROUP BY fullvisitorid),
device_visit AS (
SELECT DISTINCT fullvisitorid, date, device.deviceCategory
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`),
transactions AS (
SELECT fullvisitorid, MIN(date) AS date_transactions, 1 AS transaction
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*` AS ga, UNNEST(ga.hits) AS hits
WHERE hits.transaction.transactionId IS NOT NULL GROUP BY fullvisitorid),
device_transactions AS (
SELECT DISTINCT fullvisitorid, date, device.deviceCategory
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*` AS ga, UNNEST(ga.hits) AS hits
WHERE hits.transaction.transactionId IS NOT NULL),
visits_transactions AS (
SELECT visit.fullvisitorid, date_first_visit, date_transactions, date_last_visit ,
device_visit.deviceCategory AS device_last_visit, device_transactions.deviceCategory AS device_transaction,
IFNULL(transactions.transaction,0) AS transaction
FROM visit LEFT JOIN transactions ON visit.fullvisitorid = transactions.fullvisitorid
LEFT JOIN device_visit ON visit.fullvisitorid = device_visit.fullvisitorid
AND visit.date_last_visit = device_visit.date
LEFT JOIN device_transactions ON visit.fullvisitorid = device_transactions.fullvisitorid
AND transactions.date_transactions = device_transactions.date ),
mortality_table AS (
SELECT fullvisitorid, date_first_visit,
CASE WHEN date_transactions IS NULL THEN date_last_visit ELSE date_transactions END AS date_event,
CASE WHEN device_transaction IS NULL THEN device_last_visit ELSE device_transaction END AS device, transaction
FROM visits_transactions )
SELECT fullvisitorid, DATE_DIFF(PARSE_DATE('%Y%m%d',date_event), PARSE_DATE('%Y%m%d', date_first_visit),DAY) AS time,
transaction, device FROM mortality_table
| true |
0e8b6cb45ff6ad52e5a014f6fa70934caa4f1628 | SQL | hernan-alperin/urbix | /test.sql | UTF-8 | 3,343 | 4.15625 | 4 | [] | no_license | select day, round(avg(data)*workday_duration) as totdias, day_colour
from bkn_variable o, bkn_result m, ftn_time_period n
where date( m.time) = n.date
and m.variable_id = o.variable_id
and m.variable_id = 10
and date(m.time) between date('2015/04/19') and date('2015/05/04')
and extract(hour from time) between extract(hour from workday_start) and extract(hour from workday_start) + workday_duration
group by day, workday_duration, day_of_week, day_colour
order by day_of_week
;
select day, round(avg(data)*workday_duration) as totdias, day_colour from bkn_variable o, bkn_result m, ftn_time_period n where date( m.time) = n.date and m.variable_id = o.variable_id and m.variable_id = 10 and date(m.time) between date('2015/04/19') and date('2015/05/04') and extract(hour from time) between extract(hour from workday_start) and extract(hour from workday_start) + workday_duration group by day, workday_duration, day_of_week, day_colour order by day_of_week
;
select distribucion_dias.day, round(totales_por_dia_de_semana/cantidad_dias_por_dia_de_semana) as totdias, day_colour
from (
select day, count(distinct date(time)) as cantidad_dias_por_dia_de_semana
from
bkn_variable join bkn_result using (variable_id) join ftn_time_period on date(bkn_result.time) = ftn_time_period.date
where
bkn_variable.variable_id = 51 and
time between (date('2015/06/29') + workday_start::time)
and (date('2015/06/29') + workday_start::time + (workday_duration || ' hours')::interval)
and time between (date(time) + workday_start::time) and (date(time) + workday_start::time + (workday_duration || ' hours')::interval)
-- group by day, workday_duration, day_of_week, day_colour
order by day_of_week
) as totales_por_dia_de_la_semana
natural right join (
select day, round(sum(data)) as totales_por_dia_de_semana, day_colour
from bkn_variable join bkn_result using (variable_id) join ftn_time_period on date(bkn_result.time) = ftn_time_period.date
where
bkn_variable.variable_id = 51 and
time between (date('2015/06/29') + workday_start::time)
and (date('2015/06/29') + workday_start::time + (workday_duration || ' hours')::interval)
and time between (date(time) + workday_start::time) and (date(time) + workday_start::time + (workday_duration || ' hours')::interval)
-- group by day, workday_duration, day_of_week, day_colour
order by day_of_week
) as distribucion_dias
;
-----------
select 'promedio' as serie,
extract(hour from time) as hora,
extract(hour from time)||'-'||extract(hour from (time + interval '1 hour')) as hs,
round(avg(data)) as valor
from
bkn_variable
join bkn_result using (variable_id)
join ftn_time_period on date(time)=date
where bkn_variable.variable_id = 51
and time between ('2015-06-29'::date + '10:00'::time) and ('2015-06-29'::date + '10:00'::time + '16 hours'::interval)
and time between (date + '10:00'::time) and (date + '10:00'::time + '16 hours'::interval)
group by hora, bkn_variable.variable_id, hs
order by hora
;
select hour
--, (time::date + '10:00'::time) as start, (time::date + '10:00'::time + '16 hours'::interval) as end
from (select (h||':00')::time as hour from generate_series(0,23,1) as h) as time
where hour between (hour + '10:00'::time) and (hour + '10:00'::time + '16 hours'::interval)
group by hora
order by hora
;
| true |
f33a87ef6171227cf0e9fa70b77538a31d0082d3 | SQL | Yorymotoru/learning-sql | /Practice 3/Task 11.sql | UTF-8 | 124 | 3.15625 | 3 | [] | no_license | SELECT d.DEPTNO
FROM DEPT d
WHERE 3 >= (SELECT COUNT(e.EMPNO)
FROM EMP e
WHERE e.DEPTNO = d.DEPTNO); | true |
57de1d7405e16703eecf8a4a0cf5d4d7f669d6aa | SQL | romanV7/rest | /src/database.sql | UTF-8 | 785 | 3.609375 | 4 | [
"MIT"
] | permissive | SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS users; SET FOREIGN_KEY_CHECKS=1;
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name varchar(255) NOT NULL,
email varchar(255) NOT NULL UNIQUE,
password varchar(255) NOT NULL
) ENGINE InnoDB;
DROP TABLE IF EXISTS files;
CREATE TABLE files (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name varchar(255) NOT NULL,
extention varchar(255) NOT NULL,
mimetype varchar(255) NOT NULL,
size INT NOT NULL,
filePath varchar(255) NOT NULL,
data date
);
DROP TABLE IF EXISTS tokens;
CREATE TABLE tokens (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
refresh INTEGER,
payload varchar(255) NOT NULL
);
ALTER TABLE tokens ADD CONSTRAINT pkTokensRefresh FOREIGN KEY (refresh) REFERENCES users (id) ON DELETE RESTRICT;
| true |
0a58964edd423bff3a3d170be2c25b77d57b5eb6 | SQL | Brandonluke/PusheenUnicorns | /Downloads/Tables - Copy.sql | UTF-8 | 831 | 3.25 | 3 | [] | no_license | CREATE TABLE Job(
jobCode char(4),
jobdesc varchar(50)
PRIMARY KEY (jobCode),
CONSTRAINT JOB_JOBCODE CHECK(jobCode IN('CAST', 'ENGI', 'INSP', 'PMGR'))
)
CREATE TABLE Employee(
empNumber char(8),
firstName varchar(25),
lastName varchar(25),
ssn char(9),
address varchar(50),
state char(2),
zip char(5),
jobCode char(4),
dateOfBirth date,
certification bit,
salary money,
PRIMARY KEY (empNumber),
CONSTRAINT FK_JOB FOREIGN KEY (jobCode)
REFERENCES Job(jobCode),
CONSTRAINT EMP_STATECHECK CHECK(state IN('CA', 'FL'))
)
CREATE TABLE Paycheck(
payID char(8),
empNumber char(8),
periodBegin date,
periodEnd date,
payDate date,
GrossPay money,
NetPay money,
containsBounus bit,
CONSTRAINT FK_Emp FOREIGN KEY (empNumber)
REFERENCES Employee(empNumber)
) | true |
dbb7edb1da168633ac18f4f91580420406d02254 | SQL | ithillel-nikitamuzichenko/eJournal | /eJournal/db/Journal.sql | UTF-8 | 1,195 | 3.703125 | 4 | [] | no_license | CREATE SCHEMA IF NOT EXISTS EJOURNAL;
CREATE TABLE IF NOT EXISTS EJOURNAL.USERS (
ID INT NOT NULL AUTO_INCREMENT ,
ROLE INT NOT NULL ,
NAME VARCHAR(45) NULL ,
SURNAME VARCHAR(45) NULL ,
BIRTHDATE DATETIME NULL ,
SEX INT NULL,
LOGIN VARCHAR(45) NOT NULL ,
PASSWORD VARCHAR(45) NOT NULL ,
PRIMARY KEY (ID) ,
INSERT INTO EJOURNAL.USERS VALUES (NULL, 2, 'ADMIN', 'ADMIN', NULL, 1, 'admin', '827ccb0eea8a706c4c34a16891f84e7b');
CREATE TABLE IF NOT EXISTS EJOURNAL.ENTITIESLOG (
ID INT NOT NULL AUTO_INCREMENT ,
ENTITYID INT NOT NULL ,
ENTITYTYPE INT NOT NULL ,
DATE DATETIME NULL ,
ACTION INT NOT NULL,
COMMENT VARCHAR(255) NULL ,
USERID INT NOT NULL,
PRIMARY KEY (ID));
ALTER TABLE EJOURNAL.ENTITIESLOG ADD FOREIGN KEY (USERID) REFERENCES EJOURNAL.USERS(ID);
CREATE TABLE IF NOT EXISTS EJOURNAL.SUBJECTS (
ID INT NOT NULL AUTO_INCREMENT ,
NAME VARCHAR(255) NOT NULL,
SHORTNAME VARCHAR(12) NULL,
PRIMARY KEY (ID));
CREATE TABLE IF NOT EXISTS EJOURNAL.TEACHERS (
ID INT NOT NULL AUTO_INCREMENT ,
USERID INT NOT NULL,
START_WORK DATE NULL,
EXPERIENCE INT NULL,
PRIMARY KEY (ID));
ALTER TABLE EJOURNAL.TEACHERS ADD FOREIGN KEY (USERID) REFERENCES EJOURNAL.USERS(ID); | true |
e340028f4e6d91f65a8ee5c52312caf40051a2cb | SQL | greenplum-db/gpdb | /src/test/regress/sql/index_constraint_naming_upgrade.sql | UTF-8 | 5,330 | 4.40625 | 4 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"PostgreSQL",
"OpenSSL",
"LicenseRef-scancode-stream-benchmark",
"ISC",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-ssleay-windows",
"BSD-2-Clause",
"Python-2.0"
] | permissive | --
-- test that index-backed constraints have matching index and constraint names
-- that work with pg_upgrade. We are either testing results here or simply
-- creating tables that will be placed in ICW so that pg_upgrade will see them
-- in testing.
DROP FUNCTION IF EXISTS constraints_and_indices();
CREATE FUNCTION constraints_and_indices() RETURNS TABLE(table_name regclass, constraint_name name, index_name regclass, constraint_type char)
LANGUAGE SQL STABLE STRICT AS $fn$
SELECT
con.conrelid::regclass,
con.conname,
con.conindid::regclass,
con.contype::char
FROM
pg_constraint con
WHERE
con.contype != 'c'
ORDER BY conrelid
;
$fn$;
-- *************************************************************
-- Renamed Table With Constraint Scenario...create it in ICW so it exists for
-- pg_upgrade
CREATE TABLE rename_table_o (a INT, b INT, UNIQUE (a,b));
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='rename_table_o';
ALTER TABLE rename_table_o RENAME TO rename_table_r;
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='rename_table_r';
-- *************************************************************
-- Name Collision Scenario...create it in ICW
-- hoard index name in pg_class
CREATE TYPE table_collision_a_b_key AS (my_constraint int);
-- create table with constraint called same as the type above, such that an index name collision occurs
-- Due to the name collision from the type, the table constraint name gets named to 'mytype_for_upgrade1' instead of the expected 'mytype_for_upgrade'.
-- The index name gets named to 'test_a_b_pkey1' instead of the expected 'test_a_b_pkey'
-- Note: until we implement ALTER TABLE i1 ATTACH INDEX i2, this needs to
-- throw an error relatior "table_collision_a_b_key1" exists for upgrade
-- to work correctly
CREATE TABLE table_collision (a INT, b INT, UNIQUE (a,b)) DISTRIBUTED BY (a);
-- show constraint and index names
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='table_collision';
-- drop the type since it is no longer needed
DROP TYPE table_collision_a_b_key;
-- *************************************************************
-- Exchange Partition Scenario
-- Create two partition tables with primary key constraints.
-- One to drop in this test, and one to be testd druing upgrade.
CREATE TABLE part_table_for_upgrade (a INT, b INT) DISTRIBUTED BY (a) PARTITION BY RANGE(b) (PARTITION alpha END (3), PARTITION beta START (3));
CREATE TABLE part_table_for_upgrade2 (a INT, b INT) DISTRIBUTED BY (a) PARTITION BY RANGE(b) (PARTITION alpha END (3), PARTITION beta START (3));
ALTER TABLE part_table_for_upgrade ADD PRIMARY KEY(a, b);
ALTER TABLE part_table_for_upgrade2 ADD PRIMARY KEY(a, b);
-- Create a table to be used as a partition exchange.
CREATE TABLE like_table (like part_table_for_upgrade INCLUDING CONSTRAINTS INCLUDING INDEXES) DISTRIBUTED BY (a) ;
CREATE TABLE like_table2 (like part_table_for_upgrade INCLUDING CONSTRAINTS INCLUDING INDEXES) DISTRIBUTED BY (a) ;
-- show constraint and index names
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('part_table_for_upgrade', 'part_table_for_upgrade2');
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('like_table', 'like_table2');
-- Exchange the beta partition with like_table.
-- Everything gets swapped, but the constraint index name of like_table does not match with part_table_for_upgrade_1_prt_beta.
ALTER TABLE part_table_for_upgrade EXCHANGE PARTITION beta WITH TABLE like_table;
ALTER TABLE part_table_for_upgrade2 EXCHANGE PARTITION beta WITH TABLE like_table2;
-- show constraint and index names for each table
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('part_table_for_upgrade', 'part_table_for_upgrade2');
-- only tables are renamed in exchange partition
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('like_table', 'like_table2');
-- Drop the first partition table, the constraint in like_table should NOT be dropped
DROP TABLE part_table_for_upgrade CASCADE;
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='like_table';
-- *************************************************************
--Name Collision Scenario when Unifying Constraint & Index Names
-- NOTE: I think this is moot in our current fix but I include it here for
-- completeness.
-- create a table with constraint names that will collide with their index names
-- the check constraint name 'test_a_key' will potentially collide with the my_constraint2 index name in GPDB5
-- the check constraint name 'test_a_b_key' will potentially collide with the my_constraint2 index name in GPDB6
CREATE TABLE test_cc (a INT, b INT, CONSTRAINT test_cc_a_key CHECK (b > -42), CONSTRAINT test_cc_a_b_key CHECK (a+b > -1), CONSTRAINT my_constraint2 UNIQUE (a,b));
-- show unique constraint and index names (see prerequisites above to install the following function)
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='test_cc';
-- show check constraint names
select conname as check_constraint_name from pg_constraint where conrelid = (select oid from pg_class where relname = 'test_cc') and contype = 'c';
| true |
cd32993e1c8fe7caf5d0a4dc572c95b1810f030a | SQL | bruno-victor32/Aula-de-banco-de-dados-faculdade-esamc | /Softblue/Primeiro banco de dados/Exercicio 1.sql | UTF-8 | 3,165 | 4.3125 | 4 | [
"MIT"
] | permissive | -- Cria o banco de dados e acessa o mesmo
--
CREATE DATABASE SOFTBLUE DEFAULT CHARSET=latin1;
USE SOFTBLUE;
--
-- Cria a tabela TIPO
--
CREATE TABLE TIPO (
CODIGO INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, -- Código interno (PK)
TIPO VARCHAR(32) NOT NULL, -- Descrição
PRIMARY KEY(CODIGO) -- Define o campo CODIGO como PK (Primary Key)
);
--
-- Cria a tabela INSTRUTOR
--
CREATE TABLE INSTRUTOR (
CODIGO INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, -- Código interno (PK)
INSTRUTOR VARCHAR(64) NOT NULL, -- Nome com até 64 caracteres
TELEFONE VARCHAR(9) NULL, -- Telefone, podendo ser nulo caso não tenha
PRIMARY KEY(CODIGO) -- Define o campo CODIGO como PK (Primary Key)
);
--
-- Cria a tabela CURSO
--
CREATE TABLE CURSO (
CODIGO INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, -- Código interno (PK)
CURSO VARCHAR(64) NOT NULL, -- Título com até 64 caracteres
TIPO INTEGER UNSIGNED NOT NULL, -- Código do tipo de curso (idêntico a PK em CURSO)
INSTRUTOR INTEGER UNSIGNED NOT NULL, -- Código do instrutor (idêntico a PK em INSTRUTOR)
VALOR DOUBLE NOT NULL, -- Valor do curso
PRIMARY KEY(CODIGO), -- Define o campo CODIGO como PK (Primary Key)
INDEX FK_TIPO(TIPO), -- Define o campo TIPO como um índice
INDEX FK_INSTRUTOR(INSTRUTOR), -- Define o campo INSTRUTOR como um índice
FOREIGN KEY(TIPO) REFERENCES TIPO(CODIGO), -- Cria o relacionamento (FK) com a tabela TIPO
FOREIGN KEY(INSTRUTOR) REFERENCES INSTRUTOR(CODIGO) -- Cria o relacionamento (FK) com a tabela INSTRUTOR
);
--
-- Cria a tabela ALUNO
--
CREATE TABLE ALUNO (
CODIGO INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, -- Código interno (PK)
ALUNO VARCHAR(64) NOT NULL, -- Nome com até 64 caracteres
ENDERECO VARCHAR(230) NOT NULL, -- Endereço com até 230 caracteres
EMAIL VARCHAR(128) NOT NULL, -- E-mail com até 128 caracteres
PRIMARY KEY(CODIGO) -- Define o campo CODIGO como PK (Primary Key)
);
--
-- Cria a tabela PEDIDO
--
CREATE TABLE PEDIDO (
CODIGO INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, -- Código interno (PK)
ALUNO INTEGER UNSIGNED NOT NULL, -- Código do aluno (idêntico a PK em ALUNO)
DATAHORA DATETIME NOT NULL, -- Armazena data e hora em uma única coluna
PRIMARY KEY(CODIGO), -- Define o campo CODIGO como PK (Primary Key)
INDEX FK_ALUNO(ALUNO), -- Define o campo ALUNO como um índice
FOREIGN KEY(ALUNO) REFERENCES ALUNO(CODIGO) -- Cria o relacionamento (FK) com a tabela ALUNO
);
--
-- Cria a tabela PEDIDO_DETALHE
--
CREATE TABLE PEDIDO_DETALHE (
PEDIDO INTEGER UNSIGNED NOT NULL, -- Código do pedido (idêntico a PK em PEDIDO)
CURSO INTEGER UNSIGNED NOT NULL, -- Código do curso (idêntico a PK em CURSO)
VALOR DOUBLE NOT NULL, -- Valor do curso
INDEX FK_PEDIDO(PEDIDO), -- Define o campo ALUNO como um índice
INDEX FK_CURSO(CURSO), -- Define o campo ALUNO como um índice
PRIMARY KEY(PEDIDO, CURSO), -- Define a chave primária composta
FOREIGN KEY(PEDIDO) REFERENCES PEDIDO(CODIGO), -- Cria o relacionamento (FK) com a tabela PEDIDO
FOREIGN KEY(CURSO) REFERENCES CURSO(CODIGO) -- Cria o relacionamento (FK) com a tabela CURSO
);
| true |
772ad488869702962412e4e22cc8a0e279c553e2 | SQL | mbikas/Undergraduate-Projects | /PL-SQL/even_odd/program.sql | UTF-8 | 513 | 2.875 | 3 | [] | no_license | DECLARE
p number;
cursor my_cursor is select * from even_odd;
temp my_cursor % rowtype;
BEGIN
open my_cursor;
LOOP
fetch my_cursor into temp;
exit when my_cursor % notfound;
select num into p from even_odd where num = temp.num;
dbms_output.put_line(p);
if p mod 2 = 0 then
insert into even_odd_output values(p ,'even');
else
insert into even_odd_output values(p ,'odd');
end if;
END LOOP;
close my_cursor;
END; | true |
d274610212f2f0ef37382533e2a4de191ec86a1a | SQL | babtsoualiaksandr/shop-telethones-be | /create_and_mock_DB.sql | UTF-8 | 927 | 3.90625 | 4 | [
"MIT"
] | permissive | create table products (
id uuid primary key default uuid_generate_v4(),
title text not null,
description text,
price numeric
);
-- CREATE extension if not exists "uuid-ossp";
create table stocks (
id uuid primary key default uuid_generate_v4(),
product_id uuid UNIQUE,
count numeric,
foreign key ("product_id") references "products" ("id")
);
INSERT INTO products (title, description, price)
VALUES ('APPLE', 'description PRODUCTS ONE', 100);
do $$
DECLARE title text := 'title product';
DECLARE description text := 'description product';
begin
for r in 1..33 loop
title := 'title phone - ' || r;
description := 'description phone - ' || r;
insert into public.products(price, title, description) values(r, title, description);
end loop;
end;
$$;
TRUNCATE products CASCADE
DROP TABLE products;
DROP TABLE stocks;
INSERT INTO stocks (product_id, count) SELECT id, price FROM products;
| true |
549939249cd39564152f044b33d2a057b542ee38 | SQL | konradczarnecki/Lunchmaster | /src/main/resources/database/v_0_0_2/data/lunchmaster_user.sql | UTF-8 | 1,647 | 2.5625 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: localhost Database: lunchmaster
-- ------------------------------------------------------
-- Server version 5.6.36-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Dumping data for table `user`
--
LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (1,'Mikolaj','Slefarski','mikolaj.slefarski@gmail.com','737767882','Service Development','VD SA','VD',13,'<bank acc>'),(2,'Jan','Kowalski','jankowalski@nowhere.com','3423453','Service Development','VD SA','VD',13,'<bank acc 2>');
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-10-13 15:24:53
| true |
b6bfeaf0bed151126a621e29b27a59f864e14a47 | SQL | phuongtn2/manager-building | /db/building_t_user.sql | UTF-8 | 2,826 | 3.046875 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 5.7.12, for Win64 (x86_64)
--
-- Host: localhost Database: building
-- ------------------------------------------------------
-- Server version 5.5.5-10.1.13-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `t_user`
--
DROP TABLE IF EXISTS `t_user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_user` (
`userId` int(11) NOT NULL AUTO_INCREMENT,
`empCode` varchar(255) DEFAULT NULL,
`adId` varchar(30) DEFAULT NULL,
`password` varchar(45) NOT NULL,
`userStatus` tinyint(4) DEFAULT NULL,
`fullName` varchar(255) NOT NULL,
`lastName` varchar(255) NOT NULL,
`firstName` varchar(255) NOT NULL,
`mail` varchar(255) NOT NULL,
`tel` varchar(255) DEFAULT NULL,
`mobilePhone` varchar(255) DEFAULT NULL,
`startDay` datetime DEFAULT NULL,
`endDay` datetime DEFAULT NULL,
`hideFlg` tinyint(4) DEFAULT '0',
`male` int(11) DEFAULT NULL,
`memo` text,
`logo` varchar(255) DEFAULT NULL,
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`lastUpdate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`createId` int(11) NOT NULL DEFAULT '0',
`updateId` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`userId`),
UNIQUE KEY `userId` (`userId`)
) ENGINE=InnoDB AUTO_INCREMENT=913 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `t_user`
--
LOCK TABLES `t_user` WRITE;
/*!40000 ALTER TABLE `t_user` DISABLE KEYS */;
INSERT INTO `t_user` VALUES (1,'10000','phuongtn2','123456',1,'Tran Ngoc Phuong','Tran','Phuong','chuchuot12a15tnp@gmail.com','0976408409','0976408409',NULL,NULL,0,0,'N/A',NULL,'2016-11-03 19:37:40','2016-11-03 19:37:40',0,0);
/*!40000 ALTER TABLE `t_user` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2016-11-03 22:23:01
| true |
a3a2d96c1768b573b05e3d8caaa8a267f38afe3d | SQL | raulprogramacionfuenla/Formas_De_AprendizajeUAQ.net | /palabrasclave.sql | UTF-8 | 4,887 | 2.8125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 06-09-2017 a las 00:34:10
-- Versión del servidor: 10.1.10-MariaDB
-- Versión de PHP: 5.5.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: `palabrasclave`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `auditivo`
--
CREATE TABLE `auditivo` (
`idPalabra` int(11) NOT NULL,
`Palabras` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `auditivo`
--
INSERT INTO `auditivo` (`idPalabra`, `Palabras`) VALUES
(1, 'alto'),
(2, 'claro'),
(3, 'suena'),
(4, 'escuchar'),
(5, 'gritar'),
(6, 'decir'),
(7, 'proclamar'),
(8, 'escuchar'),
(9, 'escuche'),
(10, 'grite'),
(11, 'dije'),
(12, 'sonaba'),
(13, 'musica\r\n'),
(14, 'oir'),
(15, 'relatar'),
(16, 'arritmico'),
(17, 'relatar'),
(18, 'susurrar'),
(19, 'pronunciar'),
(20, 'cancion'),
(22, 'preguntar'),
(23, 'pregunto'),
(24, 'mencionar'),
(25, 'discutir'),
(26, 'mencione'),
(27, 'menciono'),
(28, 'discutir'),
(29, 'discuti'),
(30, 'hablar'),
(31, 'hable'),
(32, 'hablamos'),
(33, 'armonia'),
(34, 'tono'),
(35, 'tempo'),
(36, 'desafinado'),
(37, 'estrepitoso'),
(38, 'eco'),
(39, 'gruñido'),
(40, 'timbre'),
(41, 'intenso'),
(42, 'afinado'),
(43, 'musica'),
(44, 'sonido'),
(45, 'lejano'),
(46, 'cercanop'),
(47, 'fuerte'),
(48, 'melodioso'),
(49, 'melodia'),
(50, 'sonara');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `kinestesico`
--
CREATE TABLE `kinestesico` (
`idPalabra` int(11) NOT NULL,
`Palabras` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `kinestesico`
--
INSERT INTO `kinestesico` (`idPalabra`, `Palabras`) VALUES
(1, 'movimiento'),
(2, 'textura'),
(3, 'arrullo'),
(4, 'vertigo'),
(5, 'sentir'),
(6, 'tocar'),
(7, 'acariciar'),
(8, 'rigido'),
(9, 'gravedad'),
(10, 'rosar'),
(11, 'sostener'),
(12, 'ambiente'),
(13, 'agarrar'),
(14, 'percibir'),
(15, 'abrazar'),
(16, 'relajante'),
(17, 'estimulante'),
(18, 'pesar'),
(19, 'calido'),
(20, 'acojedor'),
(21, 'aburrido'),
(22, 'frieldad'),
(23, 'suave'),
(24, 'solido'),
(25, 'firme'),
(26, 'aguado'),
(27, 'frajil'),
(28, 'resistente'),
(29, 'compacto'),
(30, 'dulce'),
(31, 'salado'),
(32, 'amargo'),
(33, 'picante'),
(34, 'caliente'),
(35, 'frio'),
(36, 'esponjoso'),
(37, 'blando'),
(38, 'rugoso'),
(39, 'pulido'),
(40, 'terso'),
(41, 'sabroso'),
(42, 'agrio'),
(43, 'fresco'),
(44, 'aspero'),
(45, 'tentar'),
(46, 'sobar'),
(47, 'corrioso'),
(48, 'delicado'),
(49, 'peludo'),
(50, 'tibio'),
(51, 'templado'),
(52, 'liso'),
(53, 'bordeado'),
(54, 'poroso');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `visual`
--
CREATE TABLE `visual` (
`idPalabra` int(11) NOT NULL,
`Palabras` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `visual`
--
INSERT INTO `visual` (`idPalabra`, `Palabras`) VALUES
(1, 'opaco'),
(2, 'brillante'),
(3, 'admirar'),
(4, 'fotografia'),
(5, 'video'),
(6, 'profundidad'),
(7, 'peliculas'),
(8, 'lejos'),
(9, 'cerca'),
(10, 'señas'),
(11, 'vizualisar'),
(12, 'perspectiva'),
(13, 'observar'),
(14, 'imagen'),
(15, 'ilustrar'),
(16, 'notar'),
(17, 'vision'),
(18, 'visualizar'),
(19, 'negrura'),
(20, 'graficar'),
(21, 'colorido'),
(22, 'empalidecer'),
(23, 'reflejar'),
(24, 'resplandeciente'),
(25, 'soleado'),
(26, 'mirar'),
(27, 'claro'),
(28, 'oscuro'),
(29, 'panorama'),
(30, 'minimalista');
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `auditivo`
--
ALTER TABLE `auditivo`
ADD PRIMARY KEY (`idPalabra`);
--
-- Indices de la tabla `kinestesico`
--
ALTER TABLE `kinestesico`
ADD PRIMARY KEY (`idPalabra`);
--
-- Indices de la tabla `visual`
--
ALTER TABLE `visual`
ADD PRIMARY KEY (`idPalabra`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `auditivo`
--
ALTER TABLE `auditivo`
MODIFY `idPalabra` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=51;
--
-- AUTO_INCREMENT de la tabla `kinestesico`
--
ALTER TABLE `kinestesico`
MODIFY `idPalabra` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=55;
--
-- AUTO_INCREMENT de la tabla `visual`
--
ALTER TABLE `visual`
MODIFY `idPalabra` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31;
/*!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 |
5b5a1797aa5cf67ba601e1688f47fafbbdcdaee8 | SQL | mkovar52/database-exercises | /subqueries_exercises.sql | UTF-8 | 1,337 | 4.1875 | 4 | [] | no_license | -- # Find ALL the employees with the SAME "HIRE_DATE" as employee 101010 using a sub-query.
-- # output: 69 Rows
-- # desired hire_date for these employees is 1990-10-22 / Oct. 22nd / 1990
select e.hire_date
from employees as e
where e.emp_no = '101010';
-- # exercise 1 ======================
select first_name, last_name, hire_date
from employees
where emp_no in (
select emp_no
from dept_emp
where hire_date = '1990-10-22'
);
-- # exercise 2 ======================
-- # Find all the TITLES held by all employees with the "first_name" = Aamod.
-- # desired output: 314 total titles, 6 unique titles
select t.title as 'Title'
from titles as t
where emp_no in (
select emp_no
from employees
where first_name = 'Aamod'
);
-- # how to combine count and this within the same query?
-- # group by title;
-- # exercise 3 ======================
-- # Find all the current department managers that are female.
-- # +------------+------------+
-- # | first_name | last_name |
-- # +------------+------------+
-- # | Isamu | Legleitner |
-- # | Karsten | Sigstam |
-- # | Leon | DasSarma |
-- # | Hilary | Kambil |
-- # +------------+------------+
select first_name, last_name
from employees
where emp_no in (
select emp_no
from dept_manager as dm
where dm.to_date > now()
and gender = 'F'
); | true |
890a521e6956a80a95a15a47397fb64052d17fdc | SQL | 1admiral4/unfinished | /database.sql | UTF-8 | 262 | 2.671875 | 3 | [] | no_license | create database kevin_db;
use kevin_db;
CREATE TABLE `products` (
`pId` int(11) NOT NULL auto_increment,
`pName` varchar(100) NOT NULL,
`pDesc` float NOT NULL,
`pPrice` int NOT NULL,
`pStock` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
); | true |
9713fd2e2ae36a523fb238b289b9396a1f0d2e14 | SQL | antlr/grammars-v4 | /sql/plsql/examples-sql-script/trigger_examples.sql | UTF-8 | 391 | 2.546875 | 3 | [] | permissive | create or replace trigger trg_status_tick
after insert or update or delete on status for each row
declare
begin
if inserting then
tp_ticket_util.fire('status', tp_ticket_const.cinsert, :new.id);
elsif updating then
tp_ticket_util.fire('status', tp_ticket_const.cupdate, :new.id);
elsif deleting then
tp_ticket_util.fire('status', tp_ticket_const.cdelete, :old.id);
end if;
end; | true |
6cfce9562f6a267b5e896c5eac62218c01cde965 | SQL | bgulbis/stroke_ich | /cva_acei_kyndol/qry/allergies_supp.sql | UTF-8 | 1,220 | 3.71875 | 4 | [] | no_license | WITH PATIENTS AS (
SELECT DISTINCT
ENCOUNTER.ENCNTR_ID,
ENCOUNTER.PERSON_ID,
ENCNTR_ALIAS.ALIAS AS FIN,
ENCOUNTER.REG_DT_TM,
ENCOUNTER.DISCH_DT_TM
FROM
ENCNTR_ALIAS,
ENCOUNTER
WHERE
ENCNTR_ALIAS.ALIAS IN @prompt('Enter value(s) for Alias','A',,Multi,Free,Persistent,,User:0)
AND ENCNTR_ALIAS.ENCNTR_ALIAS_TYPE_CD = 619 -- FIN NBR
AND ENCNTR_ALIAS.ACTIVE_IND = 1
AND ENCNTR_ALIAS.ENCNTR_ID = ENCOUNTER.ENCNTR_ID
), ACEI_ALLERGY AS (
SELECT DISTINCT
-- PATIENTS.PERSON_ID,
PATIENTS.ENCNTR_ID,
ALLERGY.ALLERGY_ID,
NOMENCLATURE.SOURCE_STRING AS ALLERGY
FROM
ALLERGY,
NOMENCLATURE,
PATIENTS
WHERE
PATIENTS.PERSON_ID = ALLERGY.PERSON_ID
AND ALLERGY.CREATED_DT_TM < PATIENTS.DISCH_DT_TM
AND ALLERGY.END_EFFECTIVE_DT_TM >= PATIENTS.REG_DT_TM
AND ALLERGY.SUBSTANCE_NOM_ID = NOMENCLATURE.NOMENCLATURE_ID
-- AND REGEXP_INSTR(LOWER(NOMENCLATURE.SOURCE_STRING), 'benazepril|captopril|enalapril|fosinopril|lisinopril|moexipril|perindopril|quinapril|ramipril|trandolapril|ace inhibitor|angiotensin converting enzyme') > 0
)
SELECT DISTINCT
PATIENTS.ENCNTR_ID,
PATIENTS.FIN,
ACEI_ALLERGY.ALLERGY
FROM
ACEI_ALLERGY,
PATIENTS
WHERE
PATIENTS.ENCNTR_ID = ACEI_ALLERGY.ENCNTR_ID
| true |
445597ef4a170239c8db53a81f42ce3b98c75087 | SQL | pucinsk/scripts | /select_defect_outter_join.sql | UTF-8 | 283 | 3.15625 | 3 | [] | no_license | SELECT defects.name AS Defektas,
defect_types.name AS Defekto_tipas,
defect_positions.name AS Defekto_pozicija
FROM defects, defect_types, defect_positions
WHERE defects.id = defect_types.defects_id(+)
AND defects.id = defect_positions.defects_id(+);
| true |
bac1ee71972dae96ad7cfb53db96c6dc89069b96 | SQL | jworkman119/HTC | /Pinnacle/Database/SQL/qryMonthly_QuarterlyReport.sql | UTF-8 | 566 | 3.953125 | 4 | [] | no_license | Select ReportColumns.Name
, ReportColumns.ID as Column
, Staff.FirstName || ' ' || Staff.LastName as Staff
, Avg(ReviewCost.PayRate) as Avg_PayRate
, sum(ReviewCost.Hours) as Hours
, sum(ReviewCost.Cost) as Cost
From ReportColumns, Staff
Left Join ReviewCost on ReviewCost.Funding_ID = ReportColumns.Name
and strftime('%m',ReviewCost.Date) ='12' AND strftime('%Y',Date) ='2012'
and ReviewCost.Staff_ID = Staff.ID
Where Staff.Active = 'true'
and Staff.Role_ID = 'Stf'
Group By
ReportColumns.Name
, ReportColumns.ID
, Staff.ID
Order by Staff
| true |
3f7329e4d7e087ca0c0979bfea6281f7e64e484a | SQL | wangjiexin123456/rrepository | /t88_zt_gzsb_modresource.sql | UTF-8 | 1,169 | 3.109375 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : xx
Source Server Version : 50626
Source Host : 39.105.229.154:3306
Source Database : gzsb
Target Server Type : MYSQL
Target Server Version : 50626
File Encoding : 65001
Date: 2019-11-23 22:06:31
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for t88_zt_gzsb_modresource
-- ----------------------------
DROP TABLE IF EXISTS `t88_zt_gzsb_modresource`;
CREATE TABLE `t88_zt_gzsb_modresource` (
`id` varchar(50) NOT NULL COMMENT '主键',
`name` varchar(255) DEFAULT NULL COMMENT '模块名称',
`delFlag` varchar(10) DEFAULT '0' COMMENT '删除标志 0 有效1 无效',
`creatTime` varchar(200) DEFAULT NULL COMMENT '创建时间',
`updateTime` varchar(200) DEFAULT NULL COMMENT '更新时间',
`createUserId` varchar(50) DEFAULT NULL COMMENT '创建人id',
`modType` varchar(10) DEFAULT NULL COMMENT '模板类型 1 基本元素(文本框、下拉框等) 2.电子资料',
`createUserName` varchar(255) DEFAULT NULL COMMENT '创建人姓名',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
| true |
1f772206baa44ac6b38865daeabaf5912db7ece5 | SQL | Balamuralit/sqlqueries | /GGACDR19_Source~1.sql | UTF-8 | 2,532 | 3.390625 | 3 | [] | no_license | select
create bigfile tablespace BTEST;
CREATE USER BTEST IDENTIFIED BY BTEST DEFAULT TABLESPACE BTEST;
grant dba to BTEST;
create bigfile tablespace BTEST1;
CREATE USER BTEST1 IDENTIFIED BY BTEST1 DEFAULT TABLESPACE BTEST1;
grant dba to BTEST1
select username from dba_users;
select * from dba_tablespaces;
desc dba_objects;
select * from dba_objects where OWNER='BTEST';
select * from dba_objects where OWNER='BTEST1';
select 'alter system kill session ''' ||sid|| ',' || serial#|| ''' immediate;' from gv$session where username='BTEST';
exec rdsadmin.rdsadmin_util.kill(2826,34273,'IMMEDIATE');
desc dba_segments;
select sum (BYTES/1024/1024/1024) from dba_segments where OWNER='BTEST';
SELECT o.name FROM sys.obj$ o, sys.user$ u, sys.sum$ s WHERE o.type# = 42 AND bitand(s.mflags, 8) =8;
desc DBA_APPLY_ERROR_MESSAGES
select * from DBA_APPLY_ERROR_MESSAGES;
alter user gger identified by gger
show parameter gold
select * from global_name;
declare
v_cnt number;
begin
for i in (select table_name from dba_tables where owner='BTEST') loop
execute immediate 'select count(*) from BTEST.' || i.table_name into v_cnt;
dbms_output.put_line(i.table_name || ' - ' || to_char(v_cnt, '999,999,999'));
end loop;
end;
/
SELECT * FROM ALL_GG_AUTO_CDR_TABLES ORDER BY TABLE_OWNER, TABLE_NAME;
desc DBMS_GOLDENGATE_ADM.ADD_AUTO_CDR;
select * from BTEST.DT$_ACDRTEST order by 2;
select count(*) from BTEST.DT$_ACDRTEST;
SELECT TABLE_OWNER,
TABLE_NAME,
TOMBSTONE_TABLE,
ROW_RESOLUTION_COLUMN
FROM ALL_GG_AUTO_CDR_TABLES
ORDER BY TABLE_OWNER, TABLE_NAME;
select * from ALL_GG_AUTO_CDR_TABLES;
select * from BTEST.DT$_ACDR_ARD_DETAILS;
SELECT TABLE_OWNER,
TABLE_NAME,
COLUMN_GROUP_NAME,
COLUMN_NAME,
RESOLUTION_COLUMN
FROM ALL_GG_AUTO_CDR_COLUMNS
ORDER BY TABLE_OWNER, TABLE_NAME;
BEGIN
DBMS_GOLDENGATE_ADM.ALTER_AUTO_CDR(
schema_name => 'BTEST',
table_name => 'acdrtest',
tombstone_deletes => TRUE );
END;
/
BEGIN
DBMS_GOLDENGATE_ADM.ADD_AUTO_CDR(
schema_name => 'BTEST',
table_name => 'CARD_DETAILS');
END;
/
BEGIN
DBMS_GOLDENGATE_ADM.ADD_AUTO_CDR(
schema_name => 'BTEST',
table_name => 'GGACDR_CARD_DETAILS');
END;
/
BEGIN
DBMS_GOLDENGATE_ADM.ALTER_AUTO_CDR(
schema_name => 'BTEST',
table_name => 'GGACDR_CARD_DETAILS',
RECORD_CONFLICTS => 'TRUE');
END;
/
BEGIN
DBMS_GOLDENGATE_ADM.REMOVE_AUTO_CDR(
schema_name => 'BTEST',
table_name => 'GGACDR_CARD_DETAILS');
END;
/
| true |
0fcaf4cf96256af9092328862b7dd22ceba9998e | SQL | Kyouru/SUNAT-ECR-2018-2019 | /May2021/ECR 2020.sql | UTF-8 | 29,969 | 3.046875 | 3 | [] | no_license | --Reporte del periodo 2020
CREATE TABLE SISGODBA.ECR_ACCOUNTREPORT
AS
SELECT DISTINCT 'OECD1' cDocTypeIndic,
--Cambiar el periodo
'PE20202011106501300001' || LPAD(ROW_NUMBER() OVER(ORDER BY numerocuenta ASC),5,'0') AS cDocRefId,
numerocuenta cAccountNumber,
'OECD605' cTypeAccountNumber,
'false' cUndocumentedAccount,
CASE estado WHEN 3 THEN 'true' WHEN 2 THEN 'true' ELSE 'false' END cClosedAccount,
CASE estado WHEN 4 THEN 'true' ELSE 'false' END cDormantAccount,
CASE tipopersona WHEN 1 THEN 'Individual' ELSE 'Organisation' END cTypeHolder,
UPPER(pkg_syst900.f_obt_tbldesabr(3, codigopais)) cResCountryCode,
CASE tipopersona WHEN 1 THEN pkg_personanatural.f_obt_numerodocumentoid(codigopersona) ELSE (CASE pkg_persona.f_obt_numeroruc(codigopersona) WHEN NULL THEN CAST(NULL AS VARCHAR2(100)) ELSE TO_CHAR(pkg_persona.f_obt_numeroruc(codigopersona)) END) END cIN,
CASE tipopersona WHEN 1 THEN (CASE pkg_personanatural.f_obt_tipodocumentoid(codigopersona) WHEN 1 THEN 'PE' ELSE UPPER(pkg_syst900.f_obt_tbldesabr(3, pkg_personanatural.f_obt_lugarnacimiento(codigopersona))) END) ELSE (CASE pkg_persona.f_obt_numeroruc(codigopersona) WHEN NULL THEN CAST(NULL AS VARCHAR2(100)) ELSE 'PE' END) END cIN_IssuedBy,
TRANSLATE(bd_nombrecompleto(codigopersona), '&', 'Y') cName,
CASE tipopersona WHEN 2 THEN 'OECD207' ELSE 'OECD202' END cName_nameType,
TRIM(pkg_personanatural.f_obt_nombres(codigopersona)) cFirstName,
TRIM(TRIM(pkg_personanatural.f_obt_apellidopaterno(codigopersona)) || ' ' || TRIM(pkg_personanatural.f_obt_apellidomaterno(codigopersona))) cLastName,
'OECD304' cAddress_legalAddressType,
UPPER(pkg_syst900.f_obt_tbldesabr(3, codigopais)) cCountryCode,
CAST(NULL AS VARCHAR2(100)) cStreet,
CAST(NULL AS VARCHAR2(100)) cBuildingIdentifier,
CAST(NULL AS VARCHAR2(100)) cSuiteIdentifier,
CAST(NULL AS VARCHAR2(100)) cFloorIdentifier,
CAST(NULL AS VARCHAR2(100)) cDistrictName,
CAST(NULL AS VARCHAR2(100)) cPOB,
CAST(NULL AS VARCHAR2(100)) cPostCode,
CAST(NULL AS VARCHAR2(100)) cCity,
TRIM(direccion) cAddressFree,
pkg_personanatural.f_obt_fechacumpleanos(codigopersona) cBirthDate,
CAST(NULL AS VARCHAR2(100)) cBirthCity,
UPPER(pkg_syst900.f_obt_tbldesabr(3, pkg_personanatural.f_obt_lugarnacimiento(codigopersona))) cBirthCountryCode,
CAST(NULL AS VARCHAR2(100)) cBirthFormerCountryName,
CASE tipopersona WHEN 2 THEN 'CRS101' ELSE CAST(NULL AS VARCHAR2(100)) END cAcctHolderTypeCRS,
CASE tipovinculo WHEN 1 THEN 'CRS803' WHEN 79 THEN 'CRS801' ELSE CAST(NULL AS VARCHAR2(100)) END cCtrlgPersonType, --Accionestas y Gerente General
CASE WHEN moneda = 1 THEN salcon_soles + intcon_soles ELSE salcon_dolares + intcon_dolares END cAccountBalance,
CASE WHEN moneda = 1 THEN 'PEN' ELSE 'USD' END cAccountBalance_CurrCode,
'CRS502' cType, --Intereses
CASE WHEN moneda = 1 THEN intcon_soles ELSE intcon_dolares END cPaymentAmnt,
CASE WHEN moneda = 1 THEN 'PEN' ELSE 'USD' END cPaymentAmnt_currCode,
CASE pkg_persona.f_obt_tipopersona(personavinculada) WHEN 1 THEN 'Individual' WHEN 2 THEN 'Organisation' ELSE CAST(NULL AS VARCHAR2(100)) END ccTypeHolder,
UPPER(pkg_syst900.f_obt_tbldesabr(3, codigopaisvinculo)) ccResCountryCode,
CASE pkg_persona.f_obt_tipopersona(personavinculada) WHEN 1 THEN pkg_personanatural.f_obt_numerodocumentoid(personavinculada) ELSE TO_CHAR(pkg_persona.f_obt_numeroruc(personavinculada)) END ccIN,
CASE personavinculada
WHEN 1 THEN
(CASE pkg_persona.f_obt_tipopersona(personavinculada) WHEN 1 THEN (CASE pkg_personanatural.f_obt_tipodocumentoid(personavinculada) WHEN 1 THEN 'PE' ELSE CAST(NULL AS VARCHAR2(100)) END) ELSE (CASE pkg_persona.f_obt_numeroruc(personavinculada) WHEN NULL THEN CAST(NULL AS VARCHAR2(100)) ELSE 'PE' END) END)
WHEN 79 THEN
(CASE pkg_persona.f_obt_tipopersona(personavinculada) WHEN 1 THEN (CASE pkg_personanatural.f_obt_tipodocumentoid(personavinculada) WHEN 1 THEN 'PE' ELSE CAST(NULL AS VARCHAR2(100)) END) ELSE (CASE pkg_persona.f_obt_numeroruc(personavinculada) WHEN NULL THEN CAST(NULL AS VARCHAR2(100)) ELSE 'PE' END) END)
ELSE CAST(NULL AS VARCHAR2(100))
END ccIN_IssuedBy,
TRANSLATE(bd_nombrecompleto(personavinculada), '&', 'Y') ccName,
CASE pkg_persona.f_obt_tipopersona(personavinculada) WHEN 2 THEN 'OECD207' WHEN 1 THEN 'OECD202' ELSE CAST(NULL AS VARCHAR2(100)) END ccName_nameType,
TRIM(pkg_personanatural.f_obt_nombres(personavinculada)) ccFirstName,
TRIM(TRIM(pkg_personanatural.f_obt_apellidopaterno(personavinculada)) || ' ' || TRIM(pkg_personanatural.f_obt_apellidomaterno(personavinculada))) ccLastName,
CAST(NULL AS VARCHAR2(100)) ccAddress_legalAddressType,
UPPER(pkg_syst900.f_obt_tbldesabr(3, codigopaisvinculo)) ccCountryCode,
CAST(direccionvinculo AS VARCHAR2(1000)) ccAddressFree,
CAST(NULL AS VARCHAR2(100)) ccStreet,
CAST(NULL AS VARCHAR2(100)) ccBuildingIdentifier,
CAST(NULL AS VARCHAR2(100)) ccSuiteIdentifier,
CAST(NULL AS VARCHAR2(100)) ccFloorIdentifier,
CAST(NULL AS VARCHAR2(100)) ccDistrictName,
CAST(NULL AS VARCHAR2(100)) ccPOB,
CAST(NULL AS VARCHAR2(100)) ccPostCode,
CAST(NULL AS VARCHAR2(100)) ccCity,
pkg_personanatural.f_obt_fechacumpleanos(personavinculada) ccBirthDate,
CAST(NULL AS VARCHAR2(100)) ccBirthCity,
UPPER(pkg_syst900.f_obt_tbldesabr(3, pkg_personanatural.f_obt_lugarnacimiento(personavinculada))) ccBirthCountryCode,
CAST(NULL AS VARCHAR2(100)) ccBirthFormerCountryName
FROM (
-- Ctas. Nuevas al 2020 PN-PJ
SELECT cta_max_reporte.numerocuenta,
cta_max_reporte.codigopersona,
cta_max_reporte.tablaservicio,
cta_max_reporte.tipopersona,
--reporte.codigodireccion,
(SELECT tipovia||' '||TRIM(callenumero)||' '||
DECODE(TRIM(numeropuerta),NULL,NULL,'Nro.:'||TRIM(numeropuerta))||' '||
DECODE(TRIM(manzana),NULL,NULL,'Mz.:'||' '||TRIM(manzana))||' '||
DECODE(TRIM(lote),NULL,NULL,'Lt.:'||' '||TRIM(lote))||' '||
DECODE(TRIM(referencia),NULL,NULL,'Referencia :'||TRIM(referencia))||' *** '||
UPPER(pkg_syst090.f_obt_descdepartamento(codigoregion, codigodepartamento))||' - '||
UPPER(pkg_syst090.f_obt_descprovincia(codigoregion, codigodepartamento, codigoprovincia ))||' - '||
UPPER(pkg_syst090.f_obt_descdistrito(codigoregion, codigodepartamento, codigoprovincia, codigodistrito ))
FROM direccion_20201231 where codigodireccion = cta_max_reporte.codigodireccion) AS direccion,
cta_max_reporte.codigopais,
cta_max_reporte.estado,
cta_max_reporte.moneda,
CASE WHEN cta_max_reporte.moneda=1 THEN cta_max_reporte.saldoimporte1 ELSE cta_max_reporte.saldoimporte1*GEN05200('31/12/2020', 3, 3) END AS salcon_soles,
CASE WHEN cta_max_reporte.moneda=2 THEN cta_max_reporte.saldoimporte1 ELSE cta_max_reporte.saldoimporte1/GEN05200('31/12/2020', 3, 3) END AS salcon_dolares,
CASE WHEN cta_max_reporte.moneda=1 THEN cta_max_reporte.interestotal ELSE cta_max_reporte.interestotal*GEN05200('31/12/2020', 3, 3) END AS intcon_soles,
CASE WHEN cta_max_reporte.moneda=2 THEN cta_max_reporte.interestotal ELSE cta_max_reporte.interestotal/GEN05200('31/12/2020', 3, 3) END AS intcon_dolares,
pjv.personavinculada,
pjv.tipovinculo,
--pjv.codigodireccion,
CASE WHEN pjv.codigodireccion IS NOT NULL THEN
(SELECT tipovia||' '||TRIM(callenumero)||' '||
DECODE(TRIM(numeropuerta),NULL,NULL,'Nro.:'||TRIM(numeropuerta))||' '||
DECODE(TRIM(manzana),NULL,NULL,'Mz.:'||' '||TRIM(manzana))||' '||
DECODE(TRIM(lote),NULL,NULL,'Lt.:'||' '||TRIM(lote))||' '||
DECODE(TRIM(referencia),NULL,NULL,'Referencia :'||TRIM(referencia))||' *** '||
UPPER(pkg_syst090.f_obt_descdepartamento(codigoregion, codigodepartamento))||' - '||
UPPER(pkg_syst090.f_obt_descprovincia(codigoregion, codigodepartamento, codigoprovincia ))||' - '||
UPPER(pkg_syst090.f_obt_descdistrito(codigoregion, codigodepartamento, codigoprovincia, codigodistrito ))
FROM direccion_20201231 where codigodireccion = cta_max_reporte.codigodireccion)
ELSE CAST(NULL AS VARCHAR2(100)) END AS direccionvinculo,
pkg_direccion.f_obt_codigopais(pjv.codigodireccion) AS codigopaisvinculo
FROM
--Ctas. Nuevas al 31/12/2020
(SELECT maxfecha_reporte.numerocuenta,
maxfecha_reporte.codigopersona,
maxfecha_reporte.tablaservicio,
maxfecha_reporte.tipopersona,
maxfecha_reporte.codigodireccion,
maxfecha_reporte.codigopais,
maxfecha_reporte.maxfecha,
maxfecha_reporte.estado,
ca.moneda,
ca.saldoimporte1,
ca.interestotal
FROM captacionanexo ca
INNER JOIN (SELECT ca.numerocuenta,
codigopersona,
ca.tablaservicio,
cuenta_reporte.estado,
tipopersona,
codigodireccion,
codigopais,
MAX(fecha) AS maxfecha
FROM captacionanexo ca
INNER JOIN (SELECT numerocuenta,
cc.codigopersona,
cc.tablaservicio,
cc.estado,
tipopersona,
codigodireccion,
codigopais
FROM cuentacorriente cc
INNER JOIN (SELECT per.codigopersona,
per.tipopersona,
codigodireccion,
codigopais
FROM persona per
INNER JOIN (SELECT perdir2020.codigopersona,
perdir2020.codigodireccion,
codigopais
FROM personadireccion_20201231 perdir2020
INNER JOIN (SELECT codigopersona,
MAX(pd.codigodireccion) codigodireccion
FROM personadireccion_20201231 pd
WHERE pd.tipodireccion = 1
AND pd.enviocorreo ='S'
GROUP BY codigopersona
) maxperdir2020
ON perdir2020.codigopersona = maxperdir2020.codigopersona
AND perdir2020.codigodireccion = maxperdir2020.codigodireccion
INNER JOIN (SELECT codigodireccion,
codigopais
FROM direccion_20201231 dir2020
INNER JOIN (SELECT tbl_pais.TBLCODARG
FROM t_wdd_paises auxpais
INNER JOIN (SELECT TBLCODARG,
UPPER(TBLDESCRI) AS nom_pais
FROM syst900
WHERE tblcodtab = 3
) tbl_pais
ON auxpais.pais_dp = tbl_pais.nom_pais
WHERE marca='X'
) pais_reporte
ON dir2020.codigopais = pais_reporte.TBLCODARG
) dir_reporte
ON perdir2020.codigodireccion = dir_reporte.codigodireccion
) perdir_reporte
ON per.codigopersona = perdir_reporte.codigopersona
) persona_reporte
ON cc.codigopersona = persona_reporte.codigopersona
) cuenta_reporte
ON ca.numerocuenta = cuenta_reporte.numerocuenta
WHERE TRUNC(fecha) <= TO_DATE('31/12/2020','DD/MM/YYYY') --Hasta el 31/12/2020
AND TRUNC(fechaapertura) >= TO_DATE('01/01/2020','DD/MM/YYYY') --Aperturadas en el periodo 2020
AND (cuenta_reporte.tablaservicio = 101 --AHV
OR cuenta_reporte.tablaservicio = 102) --CDE
GROUP BY ca.numerocuenta,
codigopersona,
ca.tablaservicio,
cuenta_reporte.estado,
tipopersona,
codigodireccion,
codigopais
) maxfecha_reporte
ON ca.numerocuenta = maxfecha_reporte.numerocuenta
AND maxfecha_reporte.maxfecha = ca.fecha
) cta_max_reporte
LEFT JOIN (SELECT pjv.codigopersona,
pjv.personavinculada,
pjv.tipovinculo,
maxdir2020.codigodireccion
FROM personajurvinculada pjv
INNER JOIN (SELECT codigopersona,
MAX(pd.codigodireccion) codigodireccion
FROM personadireccion_20201231 pd
WHERE pd.tipodireccion = 1
AND pd.enviocorreo ='S'
GROUP BY codigopersona
) maxdir2020
ON pjv.codigopersona = maxdir2020.codigopersona
) pjv
ON pjv.codigopersona = cta_max_reporte.codigopersona
WHERE (pjv.tipovinculo = 1
OR pjv.tipovinculo = 79
OR pjv.tipovinculo IS NULL
)
UNION ALL
--Cuentas Preexistentes hasta el 31/12/2020 PN
SELECT maxfecha_reporte.numerocuenta,
maxfecha_reporte.codigopersona,
maxfecha_reporte.tablaservicio,
maxfecha_reporte.tipopersona,
--maxfecha_reporte.codigodireccion
(SELECT tipovia||' '||TRIM(callenumero)||' '||
DECODE(TRIM(numeropuerta),NULL,NULL,'Nro.:'||TRIM(numeropuerta))||' '||
DECODE(TRIM(manzana),NULL,NULL,'Mz.:'||' '||TRIM(manzana))||' '||
DECODE(TRIM(lote),NULL,NULL,'Lt.:'||' '||TRIM(lote))||' '||
DECODE(TRIM(referencia),NULL,NULL,'Referencia :'||TRIM(referencia))||' *** '||
UPPER(pkg_syst090.f_obt_descdepartamento(codigoregion, codigodepartamento))||' - '||
UPPER(pkg_syst090.f_obt_descprovincia(codigoregion, codigodepartamento, codigoprovincia ))||' - '||
UPPER(pkg_syst090.f_obt_descdistrito(codigoregion, codigodepartamento, codigoprovincia, codigodistrito ))
FROM direccion_20201231 where codigodireccion = maxfecha_reporte.codigodireccion) AS direccion,
maxfecha_reporte.codigopais,
maxfecha_reporte.estado,
maxfecha_reporte.moneda,
CASE WHEN maxfecha_reporte.moneda = 1 THEN ca.saldoimporte1 ELSE ca.saldoimporte1 * GEN05200('31/12/2020', 3, 3) END AS salcon_soles,
CASE WHEN maxfecha_reporte.moneda = 2 THEN ca.saldoimporte1 ELSE ca.saldoimporte1 / GEN05200('31/12/2020', 3, 3) END AS salcon_dolares,
CASE WHEN maxfecha_reporte.moneda = 1 THEN ca.interestotal ELSE ca.interestotal * GEN05200('31/12/2020', 3, 3) END AS intcon_soles,
CASE WHEN maxfecha_reporte.moneda = 2 THEN ca.interestotal ELSE ca.interestotal / GEN05200('31/12/2020', 3, 3) END AS intcon_dolares,
NULL AS personavinculada,
NULL AS tipovinculo,
NULL AS direccionvinculo,
NULL AS codigopaisvinculo
FROM captacionanexo ca
INNER JOIN (SELECT ca.numerocuenta,
cuenta_reporte.moneda,
codigopersona,
ca.tablaservicio,
cuenta_reporte.estado,
tipopersona,
codigodireccion,
codigopais,
MAX(fecha) AS maxfecha
FROM captacionanexo ca
INNER JOIN (SELECT numerocuenta,
cc.moneda,
cc.codigopersona,
cc.tablaservicio,
cc.estado,
tipopersona,
codigodireccion,
codigopais
FROM cuentacorriente cc
INNER JOIN (SELECT per.codigopersona,
per.tipopersona,
codigodireccion,
codigopais
FROM persona per
INNER JOIN (SELECT perdir2020.codigopersona,
perdir2020.codigodireccion,
codigopais
FROM personadireccion_20201231 perdir2020
INNER JOIN (SELECT codigopersona,
MAX(pd.codigodireccion) codigodireccion
FROM personadireccion_20201231 pd
WHERE pd.tipodireccion = 1
AND pd.enviocorreo ='S'
GROUP BY codigopersona
) maxperdir2020
ON perdir2020.codigopersona = maxperdir2020.codigopersona
AND perdir2020.codigodireccion = maxperdir2020.codigodireccion
INNER JOIN (SELECT codigodireccion,
codigopais
FROM direccion_20201231 dir2020
INNER JOIN (SELECT tbl_pais.TBLCODARG
FROM t_wdd_paises auxpais
INNER JOIN (SELECT TBLCODARG,
UPPER(TBLDESCRI) AS nom_pais
FROM syst900
WHERE tblcodtab = 3
) tbl_pais
ON auxpais.pais_dp = tbl_pais.nom_pais WHERE marca = 'X'
) pais_reporte
ON dir2020.codigopais = pais_reporte.TBLCODARG
) dir_reporte
ON perdir2020.codigodireccion = dir_reporte.codigodireccion
) perdir_reporte
ON per.codigopersona = perdir_reporte.codigopersona
WHERE tipopersona = 1 --Solo Personas Naturales
) persona_reporte
ON cc.codigopersona = persona_reporte.codigopersona
) cuenta_reporte
ON ca.numerocuenta = cuenta_reporte.numerocuenta
WHERE TRUNC(fechaapertura) <= TO_DATE('31/12/2019','DD/MM/YYYY') --Ctas. aperturadas hasta el 31/12/2019
AND (cuenta_reporte.tablaservicio = 101
OR cuenta_reporte.tablaservicio = 102
)
GROUP BY ca.numerocuenta,
cuenta_reporte.moneda,
codigopersona,
ca.tablaservicio,
cuenta_reporte.estado,
tipopersona,
codigodireccion,
codigopais
) maxfecha_reporte
ON ca.numerocuenta = maxfecha_reporte.numerocuenta
AND maxfecha_reporte.maxfecha = ca.fecha
UNION ALL
--Ctas. Pre-Existentes EJ Al 31/12/2020
SELECT maxfecha_reporte.numerocuenta,
maxfecha_reporte.codigopersona,
maxfecha_reporte.tablaservicio,
maxfecha_reporte.tipopersona,
--maxfecha_reporte.codigodireccion
(SELECT tipovia||' '||TRIM(callenumero)||' '||
DECODE(TRIM(numeropuerta),NULL,NULL,'Nro.:'||TRIM(numeropuerta))||' '||
DECODE(TRIM(manzana),NULL,NULL,'Mz.:'||' '||TRIM(manzana))||' '||
DECODE(TRIM(lote),NULL,NULL,'Lt.:'||' '||TRIM(lote))||' '||
DECODE(TRIM(referencia),NULL,NULL,'Referencia :'||TRIM(referencia))||' *** '||
UPPER(pkg_syst090.f_obt_descdepartamento(codigoregion, codigodepartamento))||' - '||
UPPER(pkg_syst090.f_obt_descprovincia(codigoregion, codigodepartamento, codigoprovincia ))||' - '||
UPPER(pkg_syst090.f_obt_descdistrito(codigoregion, codigodepartamento, codigoprovincia, codigodistrito ))
FROM direccion_20201231 where codigodireccion = maxfecha_reporte.codigodireccion) AS direccion,
maxfecha_reporte.codigopais,
maxfecha_reporte.estado,
maxfecha_reporte.moneda,
CASE WHEN maxfecha_reporte.moneda = 1 THEN ca.saldoimporte1 ELSE ca.saldoimporte1 * GEN05200('31/12/2020', 3, 3) END AS salcon_soles,
CASE WHEN maxfecha_reporte.moneda = 2 THEN ca.saldoimporte1 ELSE ca.saldoimporte1 / GEN05200('31/12/2020', 3, 3) END AS salcon_dolares,
CASE WHEN maxfecha_reporte.moneda = 1 THEN ca.interestotal ELSE ca.interestotal * GEN05200('31/12/2020', 3, 3) END AS intcon_soles,
CASE WHEN maxfecha_reporte.moneda = 2 THEN ca.interestotal ELSE ca.interestotal / GEN05200('31/12/2020', 3, 3) END AS intcon_dolares,
NULL AS personavinculada,
NULL AS tipovinculo,
NULL AS direccionvinculo,
NULL AS codigopaisvinculo
FROM captacionanexo ca
INNER JOIN (SELECT ca.numerocuenta,
cuenta_reporte.moneda,
codigopersona,
ca.tablaservicio,
cuenta_reporte.estado,
tipopersona,
codigodireccion,
codigopais,
MAX(fecha) AS maxfecha
FROM captacionanexo ca
INNER JOIN (SELECT numerocuenta,
cc.moneda,
cc.codigopersona,
cc.tablaservicio,
cc.estado,
tipopersona,
codigodireccion,
codigopais
FROM cuentacorriente cc
INNER JOIN (SELECT per.codigopersona,
per.tipopersona,
codigodireccion,
codigopais
FROM persona per
INNER JOIN (SELECT perdir2020.codigopersona,
perdir2020.codigodireccion,
codigopais
FROM personadireccion_20201231 perdir2020
INNER JOIN (SELECT codigopersona,
MAX(pd.codigodireccion) codigodireccion
FROM personadireccion_20201231 pd
WHERE pd.tipodireccion = 1
AND pd.enviocorreo ='S'
GROUP BY codigopersona
) maxperdir2020
ON perdir2020.codigopersona = maxperdir2020.codigopersona
AND perdir2020.codigodireccion = maxperdir2020.codigodireccion
INNER JOIN (SELECT codigodireccion,
codigopais
FROM direccion_20201231 dir2020
INNER JOIN (SELECT tbl_pais.TBLCODARG
FROM t_wdd_paises auxpais
INNER JOIN (SELECT TBLCODARG,
UPPER(TBLDESCRI) AS nom_pais
FROM syst900
WHERE tblcodtab = 3
) tbl_pais
ON auxpais.pais_dp = tbl_pais.nom_pais WHERE marca = 'X'
) pais_reporte
ON dir2020.codigopais = pais_reporte.TBLCODARG
) dir_reporte
ON perdir2020.codigodireccion = dir_reporte.codigodireccion
) perdir_reporte
ON per.codigopersona = perdir_reporte.codigopersona
WHERE tipopersona = 2 --Solo Personas Juridicas
) persona_reporte
ON cc.codigopersona = persona_reporte.codigopersona
) cuenta_reporte
ON ca.numerocuenta = cuenta_reporte.numerocuenta
WHERE TRUNC(fechaapertura) <= TO_DATE('31/12/2019','DD/MM/YYYY') --Ctas. aperturadas hasta el 31/12/2019
AND (cuenta_reporte.tablaservicio = 101
OR cuenta_reporte.tablaservicio = 102
)
GROUP BY ca.numerocuenta,
cuenta_reporte.moneda,
codigopersona,
ca.tablaservicio,
cuenta_reporte.estado,
tipopersona,
codigodireccion,
codigopais
) maxfecha_reporte
ON ca.numerocuenta = maxfecha_reporte.numerocuenta
AND maxfecha_reporte.maxfecha = ca.fecha
--Lista de Socios que cumplen la condicion
INNER JOIN ( SELECT canexo_reporte.codigopersona,
--apo.numerocuenta,
--canexo_reporte.moneda,
--canexo_reporte.estado,
SUM(canexo_reporte.saldopromedio),
SUM(apo.saldoacumulado),
SUM(apo.saldomaximo),
SUM(canexo_reporte.saldofinal),
SUM(canexo_reporte.interestotal)
FROM
-- SALDOACUMULADO SALDOMAXIMO de la tabla APORTES
(SELECT apo.numerocuenta,
ABS(SUM(CASE WHEN maxfecha_reporte.moneda = 2 THEN
CASE WHEN MOD(tipomovimiento, 2) = 0 THEN
IMPORTE1*(-1)
ELSE
IMPORTE1
END
ELSE
CASE WHEN MOD(tipomovimiento, 2) = 0 THEN
(IMPORTE1 * (-1)) / GEN05200('31/12/2020', 3, 3)
ELSE
IMPORTE1 / GEN05200('31/12/2020', 3, 3)
END
END
) ) AS SALDOACUMULADO,
MAX(CASE WHEN maxfecha_reporte.moneda = 2 THEN apo.saldoimporte1 ELSE apo.saldoimporte1 / GEN05200('31/12/2020', 3, 3) END
) AS SALDOMAXIMO
FROM aportes apo
INNER JOIN
(SELECT cuenta_reporte.codigopersona,
ca.numerocuenta,
cuenta_reporte.moneda,
cuenta_reporte.estado,
MAX(fecha) AS maxfecha
FROM captacionanexo ca
INNER JOIN (SELECT numerocuenta,
cc.moneda,
cc.estado,
cc.codigopersona,
cc.tablaservicio,
tipopersona,
codigodireccion,
codigopais
FROM cuentacorriente cc
INNER JOIN (SELECT per.codigopersona,
per.tipopersona,
codigodireccion,
codigopais
FROM persona per
INNER JOIN (SELECT perdir2020.codigopersona,
perdir2020.codigodireccion,
codigopais
FROM personadireccion_20201231 perdir2020
INNER JOIN (SELECT codigopersona,
MAX(pd.codigodireccion) codigodireccion
FROM personadireccion_20201231 pd
WHERE pd.tipodireccion = 1
AND pd.enviocorreo ='S'
GROUP BY codigopersona
) maxperdir2020
ON perdir2020.codigopersona = maxperdir2020.codigopersona
AND perdir2020.codigodireccion = maxperdir2020.codigodireccion
INNER JOIN (SELECT codigodireccion, codigopais
FROM direccion_20201231 dir2020
INNER JOIN (SELECT tbl_pais.TBLCODARG
FROM t_wdd_paises auxpais
INNER JOIN (SELECT TBLCODARG,
UPPER(TBLDESCRI) AS nom_pais
FROM syst900
WHERE tblcodtab = 3
) tbl_pais
ON auxpais.pais_dp = tbl_pais.nom_pais WHERE marca = 'X'
) pais_reporte
ON dir2020.codigopais = pais_reporte.TBLCODARG
) dir_reporte
ON perdir2020.codigodireccion = dir_reporte.codigodireccion
) perdir_reporte
ON per.codigopersona = perdir_reporte.codigopersona
) persona_reporte
ON cc.codigopersona = persona_reporte.codigopersona
) cuenta_reporte
ON ca.numerocuenta = cuenta_reporte.numerocuenta
WHERE TRUNC(fechaapertura) <= TO_DATE('31/12/2019','DD/MM/YYYY') --Ctas. aperturadas hasta el 31/12/2019
AND (cuenta_reporte.tablaservicio = 101
OR cuenta_reporte.tablaservicio = 102
) --Cuentas de Ahorro y CDE
AND tipopersona = 2 --Solo Personas Juridicas
GROUP BY cuenta_reporte.codigopersona,
ca.numerocuenta,
cuenta_reporte.moneda,
cuenta_reporte.estado,
fechaapertura
) maxfecha_reporte
ON maxfecha_reporte.numerocuenta = apo.numerocuenta
WHERE TRUNC(apo.fechamovimiento) <= TO_DATE('31/12/2020','DD/MM/YYYY') --Los movimientos al 31/12/2020
GROUP BY apo.numerocuenta) apo
INNER JOIN
(SELECT maxfecha_reporte.codigopersona,
maxfecha_reporte.numerocuenta,
maxfecha_reporte.moneda,
maxfecha_reporte.estado,
maxfecha_reporte.saldopromedio,
ca.saldoimporte1 AS saldofinal,
ca.interestotal AS interestotal
FROM captacionanexo ca
INNER JOIN (SELECT cuenta_reporte.codigopersona,
ca.numerocuenta,
cuenta_reporte.moneda,
cuenta_reporte.estado,
MAX(fecha) AS maxfecha,
SUM(saldoimporte1) / (MAX(fecha) - MIN(fecha) + 1) AS saldopromedio
FROM captacionanexo ca
INNER JOIN (SELECT numerocuenta,
cc.moneda,
cc.estado,
cc.codigopersona,
cc.tablaservicio,
tipopersona,
codigodireccion,
codigopais
FROM cuentacorriente cc
INNER JOIN (SELECT per.codigopersona,
per.tipopersona,
codigodireccion,
codigopais
FROM persona per
INNER JOIN (SELECT perdir2020.codigopersona,
perdir2020.codigodireccion,
codigopais
FROM personadireccion_20201231 perdir2020
INNER JOIN (SELECT codigopersona,
max(pd.codigodireccion) codigodireccion
FROM personadireccion_20201231 pd
WHERE pd.tipodireccion = 1
AND pd.enviocorreo = 'S'
GROUP BY codigopersona
) maxperdir2020
ON perdir2020.codigopersona = maxperdir2020.codigopersona
AND perdir2020.codigodireccion = maxperdir2020.codigodireccion
INNER JOIN (SELECT codigodireccion,
codigopais
FROM direccion_20201231 dir2020
INNER JOIN (SELECT tbl_pais.TBLCODARG
FROM t_wdd_paises auxpais
INNER JOIN (SELECT TBLCODARG,
UPPER(TBLDESCRI) AS nom_pais
FROM syst900
WHERE tblcodtab = 3
) tbl_pais
ON auxpais.pais_dp = tbl_pais.nom_pais
WHERE marca= 'X'
) pais_reporte
ON dir2020.codigopais = pais_reporte.TBLCODARG
) dir_reporte
ON perdir2020.codigodireccion = dir_reporte.codigodireccion
) perdir_reporte
ON per.codigopersona = perdir_reporte.codigopersona
) persona_reporte
ON cc.codigopersona = persona_reporte.codigopersona
) cuenta_reporte
ON ca.numerocuenta = cuenta_reporte.numerocuenta
WHERE TRUNC(fecha) <= TO_DATE('31/12/2020','DD/MM/YYYY') --Los movimientos Hasta el 31/12/2020
AND (cuenta_reporte.tablaservicio = 101
OR cuenta_reporte.tablaservicio = 102
) --Cuentas de Ahorro y CDE
AND tipopersona = 2 --Solo Personas Juridicas
GROUP BY cuenta_reporte.codigopersona,
ca.numerocuenta,
cuenta_reporte.moneda,
cuenta_reporte.estado,
fechaapertura
) maxfecha_reporte
ON ca.numerocuenta = maxfecha_reporte.numerocuenta
AND maxfecha_reporte.maxfecha = ca.fecha
) canexo_reporte
ON canexo_reporte.numerocuenta = apo.numerocuenta
GROUP BY canexo_reporte.codigopersona
HAVING (SUM(saldofinal) >= 250000
OR SUM(interestotal) >= 250000
OR SUM(saldopromedio) >= 250000
OR SUM(saldoacumulado) >= 250000
OR SUM(saldomaximo) >= 250000
)
) personas_reporte
ON maxfecha_reporte.codigopersona = personas_reporte.codigopersona
) ORDER BY cDocRefId; | true |
31529b10ce596a1426441ffbbb2ccdef396e080b | SQL | zhiyinn/ETL_Project | /Farzad/Resources/LADATA.sql | UTF-8 | 1,999 | 2.875 | 3 | [] | no_license | DROP DATABASE IF EXISTS LADATA_DB;
CREATE DATABASE LADATA_DB;
USE LADATA_DB;
CREATE TABLE `LADATA_DB`.`la_crimes_rate` (
`DR Number` int(11) NOT NULL,
`Date_Reported` varchar(45) DEFAULT NULL,
`Date_Occurred` varchar(45) DEFAULT NULL,
`Time_Occurred` varchar(45) DEFAULT NULL,
`Area_ID` varchar(45) DEFAULT NULL,
`Area_Name` varchar(45) DEFAULT NULL,
`Reporting_District` varchar(45) DEFAULT NULL,
`Crime_Code` varchar(45) DEFAULT NULL,
`Crime_Code_Description` varchar(45) DEFAULT NULL,
`MO_Codes` varchar(45) DEFAULT NULL,
`Victim_Age` varchar(45) DEFAULT NULL,
`Victim_Sex` varchar(45) DEFAULT NULL,
`Victim_Descent` varchar(45) DEFAULT NULL,
`Premise_Code` varchar(45) DEFAULT NULL,
`Premise_Description` varchar(45) DEFAULT NULL,
`Weapon_Used_Code` varchar(45) DEFAULT NULL,
`Weapon_Description` varchar(45) DEFAULT NULL,
`Status_Code` varchar(45) DEFAULT NULL,
`Status_Description` varchar(45) DEFAULT NULL,
`Crime Code_1` varchar(45) DEFAULT NULL,
`Crime Code_2` varchar(45) DEFAULT NULL,
`Crime Code_3` varchar(45) DEFAULT NULL,
`Crime Code_4` varchar(45) DEFAULT NULL,
`Address` varchar(45) DEFAULT NULL,
`Cross_Street` varchar(45) DEFAULT NULL,
`Location` varchar(45) DEFAULT NULL
);
CREATE TABLE `LADATA_DB`.`parking_citations` (
`Ticket_number` INT NOT NULL,
`Issue_Date` VARCHAR(45) NULL,
`Issue_time` VARCHAR(45) NULL,
`Meter Id` VARCHAR(45) NULL,
`Marked_Time` VARCHAR(45) NULL,
`RP State_Plate` VARCHAR(45) NULL,
`Plate Expiry_Date` VARCHAR(45) NULL,
`VIN` VARCHAR(45) NULL,
`Make` VARCHAR(45) NULL,
`Body_Style` VARCHAR(45) NULL,
`Color` VARCHAR(45) NULL,
`Location` VARCHAR(45) NULL,
`Route` VARCHAR(45) NULL,
`Agency` VARCHAR(45) NULL,
`Violation_code` VARCHAR(45) NULL,
`Violation_Description` VARCHAR(45) NULL,
`Fine amount` VARCHAR(45) NULL,
`Latitude` VARCHAR(45) NULL,
`Longitude` VARCHAR(45) NULL,
PRIMARY KEY (`Ticket_number`));
| true |
8ab0682f87149f9677c1c7543c7902e2423fbb04 | SQL | tamminh2003/BookAdminConsole | /src/BookStoreSchema.sql | UTF-8 | 2,184 | 3.859375 | 4 | [] | no_license | Create database IF NOT EXISTS BOOKSTORE;
Use BOOKSTORE;
CREATE TABLE IF NOT EXISTS users (
uid int NOT NULL AUTO_INCREMENT,
lastname VARCHAR(30),
firstname VARCHAR(30),
username VARCHAR(30),
pass VARCHAR(30),
isadmin boolean,
PRIMARY KEY (uid)
);
INSERT INTO users (uid, lastname,firstname,username,pass, isadmin) VALUES
(1, 'AdminFirst','AdminLast','Admin','pass1', true),
(2, 'UserFname', 'UserLname', 'user1', 'pass2', false);
CREATE TABLE IF NOT EXISTS session (
sessionid VARCHAR(32) PRIMARY KEY,
username VARCHAR(30));
CREATE TABLE IF NOT EXISTS book_category (
cid int,
categorytitle varchar(100) NOT NULL,
PRIMARY KEY (cid)
);
INSERT INTO book_category (cid, categorytitle) VALUES
(1, 'Fantasy'),
(2, 'Adventure'),
(3, 'Romance'),
(4, 'Academic');
CREATE TABLE IF NOT EXISTS books (
bid int,
cid int NOT NULL,
booktitle varchar(100) NOT NULL,
description varchar(250) NOT NULL,
author varchar(100) NOT NULL,
publisheddate timestamp NOT NULL,
isbn char(12) unique,
price decimal,
noofpages int,
FOREIGN KEY (cid) REFERENCES book_category(cid),
PRIMARY KEY (bid));
INSERT INTO books (bid, booktitle,description, author, publisheddate, isbn,price,noofpages,cid) VALUES
(1, 'Star Wars','My First Book Description', 'Alexander Freed', '2020-07-02 12:08:17.320053-03', '987152912461',26.25,368,1),
(2, 'My SQL Book','My SQL Book Description' ,'John Mayer', '2016-07-03 09:22:45.050088-07', '85730092371',4.99,600,4),
(3, 'My Second SQL Book','My SecondSQL Book', 'Cary Flint', '2015-10-18 14:05:44.547516-07', '52312096781',10.95,780,4);
CREATE TABLE IF NOT EXISTS comments (
id int,
bid integer NOT NULL,
reviewername varchar(255),
commentcontent varchar(255),
commentdate timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (bid) REFERENCES books(bid) ON DELETE CASCADE
);
INSERT INTO comments (id, bid, reviewername, commentcontent, commentdate) VALUES
(1, 1, 'John Smith', 'First review', '2020-08-10 05:50:11.127281-02'),
(2, 1, 'Anonymous', 'Second review', '2020-08-13 15:05:12.673382-05'),
(3, 2, 'Alice', 'Another review', '2017-10-22 23:47:10.407569-07'); | true |
5d8671455fd9ad63fc5dfdc0873ee3af83b07cd0 | SQL | kiosowski/Database | /Projects/DatabaseBasics/Exam/Exam/01.DDL.sql | UTF-8 | 1,948 | 4.1875 | 4 | [] | no_license | CREATE DATABASE TripService
USE TripService
CREATE TABLE Cities (
Id INT NOT NULL IDENTITY,
[Name] NVARCHAR(20) NOT NULL,
CountryCode CHAR(2) NOT NULL
CONSTRAINT PK_Cities PRIMARY KEY(Id)
)
CREATE TABLE Hotels (
Id INT NOT NULL IDENTITY,
Name NVARCHAR(30) NOT NULL,
CityId INT NOT NULL,
EmployeeCount INT NOT NULL,
BaseRate DECIMAL(10,2)
CONSTRAINT PK_Hotels PRIMARY KEY(Id),
CONSTRAINT FK_Hotels_Cities FOREIGN KEY(CityId) REFERENCES Cities(Id)
)
CREATE TABLE Rooms (
Id INT NOT NULL IDENTITY,
Price DECIMAL(10,2) NOT NULL,
Type NVARCHAR(20) NOT NULL,
Beds INT NOT NULL,
HotelId INT NOT NULL
CONSTRAINT PK_Rooms PRIMARY KEY(Id),
CONSTRAINT FK_Rooms_Hotels FOREIGN KEY(HotelId) REFERENCES Hotels(Id)
)
CREATE TABLE Trips (
Id INT NOT NULL IDENTITY,
RoomId INT NOT NULL,
BookDate DATETIME NOT NULL,
ArrivalDate DATETIME NOT NULL,
ReturnDate DATETIME NOT NULL,
CancelDate DATETIME
CONSTRAINT PK_Trips PRIMARY KEY(Id),
CONSTRAINT FK_Trips_Rooms FOREIGN KEY(RoomId) REFERENCES Rooms(Id),
CONSTRAINT CHK_Trips_BookDate CHECK (BookDate <= ArrivalDate),
CONSTRAINT CHK_Trips_ArrivalDate CHECK (ArrivalDate <= ReturnDate)
)
CREATE TABLE Accounts (
Id INT NOT NULL IDENTITY,
FirstName NVARCHAR(50) NOT NULL,
MiddleName NVARCHAR(20),
LastName NVARCHAR(50) NOT NULL,
CityId INT NOT NULL,
BirthDate DATETIME NOT NULL,
Email VARCHAR(100) NOT NULL
CONSTRAINT PK_Accounts PRIMARY KEY(Id),
CONSTRAINT FK_Accounts_Cities FOREIGN KEY(CityId) REFERENCES Cities(Id),
CONSTRAINT UQ_Accounts_Email UNIQUE (Email)
)
CREATE TABLE AccountsTrips (
AccountId INT NOT NULL,
TripId INT NOT NULL,
Luggage INT NOT NULL
CONSTRAINT PK_AccountsTrips_Accounts_Trips PRIMARY KEY(AccountId,TripId),
CONSTRAINT FK_AccountsTrips_Accounts FOREIGN KEY(AccountId) REFERENCES Accounts(Id),
CONSTRAINT FK_AccountsTrips_Trips FOREIGN KEY(TripId) REFERENCES Trips(Id),
CONSTRAINT CHK_AccountsTrips_Luggage CHECK (Luggage >= 0)
)
| true |
4d6940e40787fc19458e0be753c14168280f78c8 | SQL | halaszd/email-system | /backend/prisma/migrations/20211015144643_init/migration.sql | UTF-8 | 695 | 3.71875 | 4 | [] | no_license | -- CreateTable
CREATE TABLE "Email" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"fromId" INTEGER NOT NULL,
"toId" INTEGER NOT NULL,
"message" TEXT,
CONSTRAINT "Email_fromId_fkey" FOREIGN KEY ("fromId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "Email_toId_fkey" FOREIGN KEY ("toId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
| true |
782f708fd76965eac560b06aae0fcf9b8a6c622e | SQL | alazar-des/alx-higher_level_programming | /0x0D-SQL_introduction/11-best_score.sql | UTF-8 | 143 | 2.8125 | 3 | [] | no_license | -- Show name and score of a table in ascending order
SELECT score, name FROM second_table
WHERE score >= 10
ORDER BY score DESC;
| true |
9d62962c0191accf9707cdd65bbc4e14b82a9ec3 | SQL | giovanne-rf/professor-allocation | /src/main/resources/db/migration/V0_0_1_1__create_tables.sql | UTF-8 | 1,598 | 3.484375 | 3 | [] | no_license | CREATE TABLE `course` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_4xqvdpkafb91tt3hsb67ga3fj` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `department` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_1t68827l97cwyxo9r1u6t4p7d` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `professor` (
`id` bigint NOT NULL AUTO_INCREMENT,
`cpf` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`department_id` bigint NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_pk1omryj5cud6uslkepgyfrca` (`cpf`),
KEY `FKbxh9gr7acx9qalq9jjcj4j9tr` (`department_id`),
CONSTRAINT `FKbxh9gr7acx9qalq9jjcj4j9tr` FOREIGN KEY (`department_id`) REFERENCES `department` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `allocation` (
`id` bigint NOT NULL AUTO_INCREMENT,
`day` varchar(255) NOT NULL,
`start` time NOT NULL,
`end` time NOT NULL,
`course_id` bigint NOT NULL,
`professor_id` bigint NOT NULL,
PRIMARY KEY (`id`),
KEY `FK9v3xv73yong82i54eabplyabv` (`course_id`),
KEY `FKnqw55qf7cu1g34wxv5rfjf53t` (`professor_id`),
CONSTRAINT `FK9v3xv73yong82i54eabplyabv` FOREIGN KEY (`course_id`) REFERENCES `course` (`id`),
CONSTRAINT `FKnqw55qf7cu1g34wxv5rfjf53t` FOREIGN KEY (`professor_id`) REFERENCES `professor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
| true |
4ee6903a945fc9fb89e726c4af48c69b55115087 | SQL | AitorAlday/PROYECTO-SOLO | /BASES/Tablas.sql | ISO-8859-10 | 2,033 | 3.203125 | 3 | [] | no_license | --LAS TABLAS DEL PROYECTO
DROP TABLE Equipo CASCADE CONSTRAINTS;
CREATE TABLE Equipo (
id_equipo INTEGER NOT NULL,
nombre VARCHAR(15) NOT NULL,
CONSTRAINT id_eq_pk PRIMARY KEY(id_equipo));
DROP TABLE Jugador CASCADE CONSTRAINTS;
CREATE TABLE Jugador (
id_jugador INTEGER NOT NULL,
nickname VARCHAR(15) UNIQUE NOT NULL,
nombre VARCHAR(15) NOT NULL,
sueldo NUMBER(6,2) NOT NULL,
id_equipo INTEGER NOT NULL,
CONSTRAINT id_ju_pk PRIMARY KEY(id_jugador),
CONSTRAINT id_eqj_fk FOREIGN KEY(id_equipo) REFERENCES Equipo (id_equipo));
DROP TABLE Persona CASCADE CONSTRAINTS;
CREATE TABLE Persona (
id_persona INTEGER NOT NULL,
nombre VARCHAR(15) NOT NULL,
usuario VARCHAR(15) NOT NULL,
contrasea VARCHAR(15) NOT NULL,
tipo INTEGER NOT NULL,
id_equipo INTEGER NOT NULL,
CONSTRAINT id_pe_pk PRIMARY KEY (id_persona),
CONSTRAINT id_eqp_fk FOREIGN KEY (id_equipo) REFERENCES Equipo (id_equipo));
DROP TABLE Jornada CASCADE CONSTRAINTS;
CREATE TABLE Jornada (
id_jornada INTEGER NOT NULL,
fec_ini DATE NOT NULL,
fec_fin DATE NOT NULL,
CONSTRAINT id_jo_pk PRIMARY KEY (id_jornada));
DROP TABLE Partido CASCADE CONSTRAINTS;
CREATE TABLE Partido (
id_partido INTEGER NOT NULL,
fecha DATE NOT NULL,
puntos_loc INTEGER NOT NULL,
puntos_vis INTEGER NOT NULL,
id_jornada INTEGER NOT NULL,
CONSTRAINT id_pa_pk PRIMARY KEY (id_partido),
CONSTRAINT id_jo_fk FOREIGN KEY (id_jornada) REFERENCES Jornada (id_jornada));
DROP TABLE Juegan CASCADE CONSTRAINTS;
CREATE TABLE Juegan (
id_partido INTEGER NOT NULL,
id_equipo INTEGER NOT NULL,
CONSTRAINT id_pa_fk FOREIGN KEY (id_partido) REFERENCES Partido (id_partido),
CONSTRAINT id_eqju_fk FOREIGN KEY(id_equipo) REFERENCES Equipo (id_equipo));
| true |
460c266c85e9e64fb7ee98c508199159db65a406 | SQL | LordOfDarknessAlexander/Auto_ObsessionsX | /Users/achievements.sql | UTF-8 | 249 | 2.828125 | 3 | [] | no_license |
-- --------------------------------------------------------
-- Table structure for table `achievements`
create table achievements(
achievement_id int not null auto_increment,
description varchar(100) not null,
primary key (achievement_id)
)
| true |
fd9124c82bc21f1bf7dc87f1d3a2cbf294a28426 | SQL | qxev/cv2 | /db/splitReportTrackMatch/proc_move_report_trackmatch_one_by_one.sql | UTF-8 | 977 | 3.59375 | 4 | [] | no_license | drop procedure IF EXISTS `cv2`.`proc_move_report_trackmatch_one_by_one`;
DELIMITER $$
CREATE PROCEDURE `cv2`.`proc_move_report_trackmatch_one_by_one`(IN p_name varchar(25), IN p_cur_date varchar(20))
BEGIN
DECLARE d_step int(4) default 0;
DECLARE done int(1) default 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET done=1;
SET @sql = concat('SELECT @dataTotal:=count(1) FROM ',p_name,' WHERE trackTime >= "',DATE(p_cur_date),'" AND trackTime < "',DATE(DATE_ADD(p_cur_date, INTERVAL 1 DAY)),'"');
prepare fmd from @sql;
execute fmd;
deallocate prepare fmd;
select CONCAT('total: ',@dataTotal);
WHILE d_step <= @dataTotal DO
SET @sql = concat('INSERT INTO `report_trackmatch` (SELECT * FROM ',p_name,' WHERE trackTime >= "',DATE(p_cur_date),'" AND trackTime < "',DATE(DATE_ADD(p_cur_date, INTERVAL 1 DAY)),'" limit ',d_step,',1)');
prepare fmd from @sql;
execute fmd;
deallocate prepare fmd;
set d_step = d_step + 1;
END WHILE;
END $$
DELIMITER ; | true |
90183251ceaaa32908827283912e6c6c21d127e5 | SQL | nathanmoon/sql-tutorial | /queries/tut-aggregate-mistake-raw.sql | UTF-8 | 1,642 | 4.65625 | 5 | [
"MIT"
] | permissive | /*
Take a look at the raw table to see why the previous query was wrong:
*/
SELECT *
FROM inventory inv
JOIN item it ON inv.item_id = it.id
JOIN review r ON r.item_id = it.id
;
/*
We have more rows in our table because there are multiple reviews per item, so we get
multiple rows with the same inventory info. Those duplicates are getting aggregated
into the count, making it incorrect (too big).
Also note that the average rating value is going to be incorrect too, because of the
duplicate values from the review table. We can make it better by fixing the joins so
that the reviews and inventory both join with the location table as well
*/
SELECT *
FROM inventory inv
JOIN location l ON inv.location_id = l.id
JOIN item it ON inv.item_id = it.id
JOIN review r ON r.item_id = it.id
WHERE r.location_id = l.id
;
/*
But even this is incorrect, because this way of joining will cause us to miss reviews for
items that aren't currently stocked at a location. But if we are willing to ignore this, we
can use DISTINCT on our COUNT to at least get the correct value for stores_carrying_item:
*/
SELECT it.name, COUNT(DISTINCT inv) AS stores_carrying_item, AVG(inv.price) AS avg_price, AVG(r.rating) AS average_rating
FROM inventory inv
JOIN location l ON l.id = inv.location_id
JOIN item it ON inv.item_id = it.id
JOIN review r ON r.item_id = it.id
WHERE r.location_id = l.id
GROUP BY it.name
;
/*
I am not aware of a way to get exactly what we were originally looking for in one query
using just joins and aggregates. Two queries would be better, or you could probably use
subqueries if you needed them to come back in a single query.
*/
| true |
18ab4b71288ff93111a55cea7f1190107d6b2bfd | SQL | facka/phcsa | /sql/CR_Table_Unidad.sql | UTF-8 | 706 | 3.921875 | 4 | [] | no_license | -- Table: unidad
-- DROP TABLE unidad;
CREATE SEQUENCE unidad_idunidad_seq;
CREATE TABLE unidad
(
id integer NOT NULL DEFAULT nextval('unidad_idunidad_seq'::regclass),
numero integer,
direccion_extendida character varying(120),
idedificio integer NOT NULL,
CONSTRAINT unidad_pkey PRIMARY KEY (id),
CONSTRAINT eidificio_fk FOREIGN KEY (idedificio)
REFERENCES edificio (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE unidad
OWNER TO postgres;
-- Index: fki_eidificio_fk
-- DROP INDEX fki_eidificio_fk;
CREATE INDEX fki_eidificio_fk
ON unidad
USING btree
(idedificio);
ALTER SEQUENCE unidad_idunidad_seq OWNED BY unidad.id; | true |
75adaee5cd0c86a7208c17e04bc7ca69f4330057 | SQL | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w03/d02/Adam/domains_hw/travel_log.sql | UTF-8 | 294 | 2.90625 | 3 | [] | no_license | CREATE TABLE entries (
id serial PRIMARY KEY,
city varchar(30) NOT NULL,
content varchar(500) NOT NULL,
);
CREATE TABLE tags (
id serial PRIMARY KEY,
parent_id integer REFERENCES tags (id),
);
CREATE TABLE location_keys (
id serial PRIMARY KEY
location varchar(100) NOT NULL
);
| true |
cb07367813d8ba798e7c9dcf8ea1fbe7d22f0095 | SQL | rumman189/generic-dashboard | /controller/water-tank/datasoft_water_tank.sql | UTF-8 | 1,814 | 3.125 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 19, 2018 at 08:33 AM
-- Server version: 10.1.16-MariaDB
-- PHP Version: 7.0.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 utf8mb4 */;
--
-- Database: `datasoft_water_tank`
--
-- --------------------------------------------------------
--
-- Table structure for table `tank_notification`
--
CREATE TABLE `tank_notification` (
`device_id` int(3) NOT NULL,
`notification` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tank_notification`
--
INSERT INTO `tank_notification` (`device_id`, `notification`) VALUES
(1, 'Tank Id: 1 is Empty'),
(3, 'Tank Id: 3 is Empty');
-- --------------------------------------------------------
--
-- Table structure for table `tank_status`
--
CREATE TABLE `tank_status` (
`device_id` int(3) NOT NULL,
`tank_status` int(1) NOT NULL,
`owner` varchar(32) NOT NULL,
`location` text NOT NULL,
`expected_time_empty` int(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tank_status`
--
INSERT INTO `tank_status` (`device_id`, `tank_status`, `owner`, `location`, `expected_time_empty`) VALUES
(1, 0, 'Sakib', 'Rampura', 5),
(2, 1, 'Real', 'Mirpur', 3),
(3, 0, 'Hasan', 'Shamoli', 0),
(4, 1, 'Nuha', 'Dhaka', 1),
(5, 1, 'Apurba', 'Rampura', 8);
/*!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 |
320d0a04c3c09da79e29fa0e93b50e3387ea112f | SQL | mferle/DemoSF | /Scripts/Create objects/Create_tables_and_sequences.sql | UTF-8 | 3,771 | 2.515625 | 3 | [] | no_license | CREATE OR REPLACE TABLE LD_26_PLC_CANDIDATES
( "ID" NUMBER,
"SDT_ID" NUMBER,
"ZPT_ID" NUMBER,
"STEVILKA_DOKUMENTA" VARCHAR2(50),
"ISK_ID" NUMBER,
"SDT_DATVNO" DATE,
"DATVNO" DATE,
"DATUM_DO_OO" DATE,
"VELJAVNOST_SPR_OD" DATE,
"VELJAVNOST_ZAC_DOK" DATE,
"VELJAVNOST_POT_DOK" DATE,
"DATUM_STATUSA_ORG" DATE,
"ST_PLC" NUMBER,
"ST_PLC_DTL" NUMBER,
"SSK_ID" NUMBER,
"SIFRA" VARCHAR2(5),
"TP_PLC" NUMBER,
"SYS_DT" TIMESTAMP,
"RANK" NUMBER
);
CREATE OR REPLACE TABLE LD_26_PLC_CMP_42_DVOJCKI
( "SDT_ID" NUMBER,
"ZPT_ID" NUMBER,
"EXT_REF" VARCHAR2(50),
"ISK_ID" NUMBER,
"ZVE_ID" NUMBER,
"PSD_ID" NUMBER,
"PRD_EXT_REF" VARCHAR2(50),
"SDT_DATVNO" DATE,
"DT_VLD_BSN_BEG" DATE,
"DT_VLD_SRC_BEG" DATE,
"DT_VLD_SRC_BEG_INCR" TIMESTAMP,
"VELJAVNOST_ZAC_KRIT" DATE,
"VELJAVNOST_POT_KRIT" DATE,
"ST_PLC_CMP" NUMBER,
"ST_PLC_CMP_DTL" NUMBER,
"SSK_ID" NUMBER,
"TP_PLC" NUMBER,
"RN" NUMBER
);
CREATE OR REPLACE TABLE GEN_PLC
( "ID_SLOT" NUMBER,
"AGM_EXT_REF" VARCHAR2(50 ),
"AGM_ID_APL_SRC" NUMBER,
"AGM_ID_TPE" NUMBER,
"PRD_EXT_REF" VARCHAR2(50 ),
"PRD_ID_APL_SRC" NUMBER,
"PRD_ID_TPE" NUMBER,
"CODE" VARCHAR2(50 ),
"DT_BEG" DATE,
"DT_END" DATE,
"ST_PLC" NUMBER,
"ST_PLC_DTL" NUMBER,
"ID_CDE_CY" NUMBER,
"DT_CRT_PLC" DATE,
"DT_VLD_BSN_BEG" DATE,
"DT_VLD_SRC_BEG" DATE,
"SEQ_PLC_CHG" NUMBER,
"ID_APL_SRC" NUMBER,
"ID_TPE" NUMBER,
"ID_LOAD" NUMBER,
"TP_PLC" NUMBER,
ID_PRT VARCHAR2(20),
AGM_ID_PRT VARCHAR2(20),
PRD_ID_PRT VARCHAR2(20)
);
CREATE OR REPLACE TABLE GEN_PLC_CMP
( "ID_SLOT" NUMBER,
"AGM_EXT_REF_PLC" VARCHAR2(50 ),
"AGM_ID_APL_SRC_PLC" NUMBER,
"AGM_ID_TPE_PLC" NUMBER,
"AGM_EXT_REF" VARCHAR2(60 ),
"AGM_ID_APL_SRC" NUMBER,
"AGM_ID_TPE" NUMBER,
"AGM_EXT_REF_PARENT" VARCHAR2(50 ),
"AGM_ID_APL_SRC_PARENT" NUMBER,
"AGM_ID_TPE_PARENT" NUMBER,
"PRD_EXT_REF" VARCHAR2(50 ),
"PRD_ID_APL_SRC" NUMBER,
"PRD_ID_TPE" NUMBER,
"CODE" VARCHAR2(100 ),
"ST_PLC_CMP_DTL" NUMBER,
"DT_BEG" DATE,
"DT_END" DATE,
"ST_PLC_CMP" NUMBER,
"DT_VLD_BSN_BEG" DATE,
"DT_VLD_SRC_BEG" DATE,
"SEQ_PLC_CHG" NUMBER,
"ID_APL_SRC" NUMBER,
"ID_TPE" NUMBER,
"ID_LOAD" NUMBER,
"ID_PRT" VARCHAR2(81 ),
"TP_PLC_CMP" NUMBER,
"PRD_ID_PRT" VARCHAR2(9 ),
"AGM_ID_PRT_PARENT" VARCHAR2(9 ),
"AGM_ID_PRT" VARCHAR2(9 ),
"AGM_ID_PRT_PLC" VARCHAR2(9 )
)
;
CREATE OR REPLACE TABLE A_AGM
( "ID_AGM" NUMBER,
"ID_APL_SRC" NUMBER,
"ID_TPE" NUMBER,
"EXT_REF" VARCHAR2(60 ) ,
"ID_LOAD" NUMBER,
"ID_PRT" VARCHAR2(81 )
);
CREATE OR REPLACE SEQUENCE SEQ_A_AGM;
CREATE OR REPLACE TABLE PLC
( "SID_PLC" NUMBER,
"ID_AGM" NUMBER,
"ID_PRD" NUMBER,
"CODE" VARCHAR2(50 ),
"DT_BEG" DATE,
"DT_END" DATE,
"ST_PLC" NUMBER,
"ST_PLC_DTL" NUMBER,
"ID_CDE_CY" NUMBER,
"DT_CRT_PLC" DATE,
"DT_VLD_BSN_BEG" DATE,
"DT_VLD_SRC_BEG" DATE,
"DT_VLD_SRC_END" DATE,
"SEQ_PLC_CHG" NUMBER,
"ID_APL_SRC" NUMBER,
"ID_TPE" NUMBER,
"ID_LOAD" NUMBER,
"ID_PRT" VARCHAR2(81 ) ,
"TP_PLC" NUMBER
);
CREATE OR REPLACE SEQUENCE SEQ_PLC;
CREATE OR REPLACE TABLE PLC_CMP
( "SID_PLC_CMP" NUMBER,
"ID_AGM_PLC" NUMBER,
"ID_AGM" NUMBER,
"ID_AGM_PARENT" NUMBER,
"ID_PRD" NUMBER,
"CODE" VARCHAR2(100 ),
"ST_PLC_CMP_DTL" NUMBER,
"DT_BEG" DATE,
"DT_END" DATE,
"ST_PLC_CMP" NUMBER,
"DT_VLD_BSN_BEG" DATE,
"DT_VLD_SRC_BEG" DATE,
"DT_VLD_SRC_END" DATE,
"SEQ_PLC_CHG" NUMBER,
"ID_APL_SRC" NUMBER,
"ID_TPE" NUMBER,
"ID_LOAD" NUMBER,
"ID_PRT" VARCHAR2(81 ) ,
"TP_PLC_CMP" NUMBER
);
CREATE OR REPLACE SEQUENCE SEQ_PLC_CMP;
CREATE OR REPLACE TABLE LD_RID
( "RID" NUMBER,
"DT_VLD_SRC_BEG" DATE,
"DT_VLD_SRC_END" DATE
);
| true |
370012337b35898e23c8945f32c1b54545832b44 | SQL | a1is3n/oracle | /MONITOR/oracle_trace_run_details.sql | UTF-8 | 511 | 2.796875 | 3 | [] | no_license | -- -----------------------------------------------------------------------------------
-- Hazırlayan : Bugra Parlayan
-- Güncel : www.bugraparlayan.com.tr
-- -----------------------------------------------------------------------------------
SELECT e.runid
,e.event_seq
,TO_CHAR(e.event_time, 'DD-MON-YYYY HH24:MI:SS') AS event_time
,e.event_unit_owner
,e.event_unit
,e.event_unit_kind
,e.proc_line
,e.event_comment
FROM plsql_trace_events e
WHERE e.runid = & 1
ORDER BY e.runid
,e.event_seq;
| true |
2a6922a9307b8bae615386bc0e719c1fb576d599 | SQL | Dorothywilk/PHP | /agc7/bdd/sql/reqMatch.sql | UTF-8 | 144 | 2.65625 | 3 | [] | no_license | -- Requête pour taux de pertinence<br><br>
SELECT
id,
nom,
espece,
MATCH(nom)
AGAINST('bubulle') AS tx
FROM animal
ORDER BY tx DESC
| true |
9abb99b4fa3795c07226d245f03b7429b337fefa | SQL | joshiadvait8/RajhansRealEstate | /rajhansrealestate.sql | UTF-8 | 5,222 | 2.9375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 06, 2019 at 03:09 AM
-- Server version: 10.1.32-MariaDB
-- PHP Version: 7.0.30
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: `rajhansrealestate`
--
-- --------------------------------------------------------
--
-- Table structure for table `commercialproperty`
--
CREATE TABLE `commercialproperty` (
`Commercialid` int(30) NOT NULL,
`BuyRent` varchar(255) NOT NULL,
`PropertyType` varchar(255) NOT NULL,
`BuildingName` varchar(255) NOT NULL,
`Location` varchar(255) NOT NULL,
`Area` int(11) NOT NULL,
`Price` int(11) NOT NULL,
`Description` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `commercialproperty`
--
INSERT INTO `commercialproperty` (`Commercialid`, `BuyRent`, `PropertyType`, `BuildingName`, `Location`, `Area`, `Price`, `Description`, `image`) VALUES
(2, 'Buy', 'Shop', 'delta tower', 'Ulwe', 900, 20000000, 'best property', 'property-1.jpg'),
(3, 'Rent', 'Shop', 'today imperia', 'Ulwe', 900, 25000, 'best property', 'property-3.jpg'),
(4, 'Rent', 'Shop', 'Satyam', 'Ulwe', 900, 35000, 'Good Shop', 'property-4.jpg'),
(5, 'Buy', 'Office', 'L&T Seawoods', 'Seawoods', 3000, 3500000, 'best of location', 'property-5.jpg');
-- --------------------------------------------------------
--
-- Table structure for table `contactus`
--
CREATE TABLE `contactus` (
`ContactId` int(11) NOT NULL,
`Name` varchar(50) NOT NULL,
`Mobileno` varchar(15) NOT NULL,
`Email` varchar(30) NOT NULL,
`Message` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `contactus`
--
INSERT INTO `contactus` (`ContactId`, `Name`, `Mobileno`, `Email`, `Message`) VALUES
(63, 'Ani', '8425877339', 'asingh1248@gmail.com', 'asas'),
(64, 'Ani', '8425877339', 'asingh1248@gmail.com', 'asas'),
(65, 'Abhishek', '8425877339', 'a@gmail.com', 'I want it'),
(66, 'Animesh', '8425877338', 'asingh1248@gmail.com', 'I want it.'),
(67, 'Animesh', '8425877338', 'asingh1248@gmail.com', 'I want it.'),
(68, 'Abhishek', '8425877339', 'asi@gmail.com', 'Wow'),
(69, 'asas', '8425877339', 'asingh1248@mail.com', 'asas'),
(70, 'asas', '8425877339', 'asingh1248@mail.com', 'asas'),
(71, 'A', '9082804311', 'Asingh1248@12.com', 'aas'),
(72, 'A', '9082804311', 'Asingh1248@12.com', 'aas'),
(73, 'asas', '8425877339', 'asingh1248@mail.com', 'asas'),
(74, 'Abhinay', '8425877339', 'Asingh@gmail.com', 'asas'),
(75, 'Abhinay', '8425877339', 'Asingh@gmail.com', 'asas'),
(76, 'sas', '8234567890', 'sa@gma.com', 'asa'),
(77, 'sas', '8234567890', 'sa@gma.com', 'asa'),
(78, 'sas', '8234567890', 'sa@gma.com', 'asa');
-- --------------------------------------------------------
--
-- Table structure for table `residentialproperty`
--
CREATE TABLE `residentialproperty` (
`PropertyId` int(11) NOT NULL,
`BuyRent` varchar(255) NOT NULL,
`PropertyType` varchar(255) NOT NULL,
`BuildingName` varchar(255) NOT NULL,
`Location` varchar(255) NOT NULL,
`Area` int(11) NOT NULL,
`FlatType` varchar(30) NOT NULL,
`Price` int(11) NOT NULL,
`Description` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `residentialproperty`
--
INSERT INTO `residentialproperty` (`PropertyId`, `BuyRent`, `PropertyType`, `BuildingName`, `Location`, `Area`, `FlatType`, `Price`, `Description`, `image`) VALUES
(1, 'Buy', 'Flat', 'Unimont Sapphire', 'Ulwe', 690, '1BHK', 6000000, 'lavish flat', 'property-2.jpg'),
(2, 'Rent', 'Flat', 'Trinity Heights', 'Ulwe', 1650, '1BHK', 15000, 'Near Station', 'property-4.jpg'),
(3, 'Buy', 'Flat', 'Platinum Emporius', 'Ulwe', 1100, '2BHK', 9500000, '30 -metre Flat Facing', 'property-5.jpg'),
(4, 'Rent', 'Flat', 'Bhagwati Imperia', 'Ulwe', 1240, '2BHK', 15000, 'Swimming Pool 6000 sqft.Biggest Swimming Pool in Ulwe', 'property-1.jpg');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `commercialproperty`
--
ALTER TABLE `commercialproperty`
ADD PRIMARY KEY (`Commercialid`);
--
-- Indexes for table `contactus`
--
ALTER TABLE `contactus`
ADD PRIMARY KEY (`ContactId`);
--
-- Indexes for table `residentialproperty`
--
ALTER TABLE `residentialproperty`
ADD PRIMARY KEY (`PropertyId`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `commercialproperty`
--
ALTER TABLE `commercialproperty`
MODIFY `Commercialid` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `contactus`
--
ALTER TABLE `contactus`
MODIFY `ContactId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=79;
--
-- AUTO_INCREMENT for table `residentialproperty`
--
ALTER TABLE `residentialproperty`
MODIFY `PropertyId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
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 |
7a137ad662ef8f49f5d892c9238678bcf3ce73cd | SQL | linhhvo/database-modeling | /scripts.sql | UTF-8 | 8,834 | 3.71875 | 4 | [] | no_license | -- Create tables based on proposed schema
-- TRAINER
create table trainer
(employee_number integer not null,
fname varchar(25),
mname varchar(25),
lname varchar(25),
street1 varchar(30),
street2 varchar(25),
city varchar(25),
state varchar(10),
zip varchar(10),
phone_number varchar(15),
email varchar(25),
hire_date date,
termination_date date,
constraint pk_trainer primary key (employee_number));
-- SOFTWARE PROGRAM
create table software_program
(product_id varchar(25) not null,
name varchar(50),
publisher varchar(20),
number_of_license integer,
required_operating_system varchar(15),
constraint pk_software_program primary key (product_id));
-- BOOK
create table book
(isbn integer not null,
title varchar(50),
publisher varchar(30),
list_price number(5,2),
constraint pk_book primary key (isbn));
-- COURSE
create table course
(course_id varchar(20) not null,
course_name varchar(50),
hardware_requirement varchar(30),
standard_fee number(5,2),
length integer,
isbn integer,
constraint pk_course primary key (course_id),
constraint fk_usebook foreign key (isbn) references book (isbn));
-- PREREQUISITE
create table prerequisite
(course_id varchar(20) not null,
prerequisite_id varchar(20) not null,
constraint pk_prerequisite primary key (course_id, prerequisite_id),
constraint fk_maincourse foreign key (course_id) references course (course_id),
constraint fk_preqcourse foreign key (prerequisite_id) references course (course_id));
-- COURSE SOFTWARE
create table course_software
(course_id varchar(20) not null,
product_id varchar(25) not null,
constraint pk_course_software primary key (course_id, product_id),
constraint fk_usedin foreign key (course_id) references course (course_id),
constraint fk_software foreign key (product_id) references software_program (product_id));
-- QUALIFICATION
create table qualification
(employee_number integer not null,
course_id varchar(20) not null,
complete_date date,
constraint pk_qualification primary key (employee_number, course_id),
constraint fk_trainer foreign key (employee_number) references trainer (employee_number),
constraint fk_qualifyfor foreign key (course_id) references course (course_id));
-- AUTHOR
create table author
(isbn integer not null,
author_id varchar(20) not null,
fname varchar(25),
mname varchar(25),
lname varchar(25),
constraint pk_author primary key (isbn, author_id),
constraint fk_writesbook foreign key (isbn) references book (isbn));
-- VENDOR
create table vendor
(name varchar(30) not null,
vendor_id INTEGER not null,
phone_number varchar(20),
street1 varchar(30),
street2 varchar(25),
city varchar(25),
state varchar(10),
zip varchar(10),
constraint pk_vendor primary key (name));
-- VENDOR CATALOG
create table vendor_catalog
(isbn INTEGER not null,
name varchar(30) not null,
constraint pk_vendor_catalog primary key (isbn, name),
constraint fk_sells foreign key (isbn) references book (isbn),
constraint fk_from foreign key (name) references vendor (name));
-- CLIENT
create table client
(client_number INTEGER not null,
fname varchar(25),
mname varchar(25),
lname varchar(25),
phone_number varchar(20),
street1 varchar(30),
street2 varchar(25),
city varchar(25),
state varchar(10),
zip varchar(10),
initial_date date,
constraint pk_client primary key (client_number));
-- CLASSROOM
create table room
(room_number varchar(5) not null,
capacity INTEGER,
operating_system varchar(10),
constraint pk_room primary key (room_number));
-- MEMBERSHIP
create table membership
(membership_code varchar(15) not null,
price number(5,2),
duration varchar(10),
discount number(5,2),
constraint pk_membership primary key (membership_code));
-- ORDER
create table "ORDER"
(order_number INTEGER not null,
date_placed date,
status varchar(20),
name varchar(30) not null,
constraint pk_order primary key (order_number),
constraint fk_soldby foreign key (name) references vendor (name));
-- ORDERLINE
create table orderline
(order_number INTEGER not null,
isbn INTEGER not null,
quantity INTEGER,
unit_price number(5,2),
constraint pk_orderline primary key (isbn, order_number),
constraint fk_contains foreign key (isbn) references book (isbn),
constraint fk_linkto foreign key (order_number) references "ORDER" (order_number));
-- SHIPMENT
create table shipment
(shipment_id INTEGER not null,
order_number INTEGER not null,
delivery_date date,
constraint pk_shipment primary key (shipment_id),
constraint fk_shipfrom foreign key (order_number) references "ORDER" (order_number));
-- INVENTORY
create table inventory
(shipment_id INTEGER not null,
isbn INTEGER not null,
quantity_received INTEGER,
constraint pk_inventory primary key (shipment_id, isbn),
constraint fk_includes foreign key (isbn) references book (isbn),
constraint fk_receivefrom foreign key (shipment_id) references shipment (shipment_id));
-- CLASS
create table class
(reference_number integer not null,
start_date date,
end_date date,
start_time varchar(20),
capacity integer,
employee_number integer not null,
course_id varchar(20) not null,
room_number varchar(5) not null,
constraint pk_class primary key (reference_number),
constraint fk_taughtby foreign key (employee_number) references trainer (employee_number),
constraint fk_has foreign key (course_id) references course (course_id),
constraint fk_locatein foreign key (room_number) references room (room_number));
-- ENROLLMENT REQUEST
create table enrollment_request
(reference_number integer not null,
client_number integer not null,
requested_time varchar(10),
requested_date date,
status varchar(20),
payment number(10,2),
constraint pk_enrollment_request primary key (reference_number, client_number),
constraint fk_inclass foreign key (reference_number) references class (reference_number),
constraint fk_student foreign key (client_number) references client (client_number));
-- PAYMENT
create table payment
(client_number integer not null,
membership_code varchar(15) not null,
date_selected date,
payment_amount number(10),
constraint pk_payment primary key (client_number, membership_code, date_selected),
constraint fk_belongsto foreign key (client_number) references client (client_number),
constraint fk_obtains foreign key (membership_code) references membership (membership_code));
-- Data was then loaded into database using Excel Import function on Oracle
-- Views created to determine who should get free training sessions
/*
TRAINER QUALIFICATION LIST
Retrieve number of qualified trainers for each course to find courses that have no or only one qualified trainer. These courses would need more trainers to teach so that the school can meet client's demand.
This view is also used to find how many qualifications each trainer has.
*/
create view trainer_qualification_list as
select course.course_id, course.course_name, trainer.employee_number, trainer.fname as trainer_name
from (
(select employee_number, fname from trainer) trainer
full outer join
(select employee_number, course_id from qualification) qualification
on trainer.employee_number = qualification.employee_number
full outer join
(select course_id, course_name from course) course
on course.course_id = qualification.course_id)
order by course_name;
/*
COURSE DEMAND, COURSE CAPACITY, COURSE MEET DEMAND
These 3 views help find out which courses have more demand than supply, meaning the school needs to have more trainers to offer additional class sessions to clients.
*/
create view course_demand as
select course.course_id, course.course_name, client_number
from (
(select course_id, course_name from course) course
full outer join
(select course_id, reference_number from class) class
on course.course_id = class.course_id
full outer join
(select reference_number, client_number from enrollment_request) enrollment
on class.reference_number = enrollment.reference_number);
create view course_capacity as
select course.course_id, course_name, sum(capacity)as capacity
from course, class
where course.course_id = class.course_id (+)
group by course.course_id, course_name
order by course_name;
create view course_meetdemand as
select course_demand.course_id, course_demand.course_name, count(client_number) as number_of_enrollmentrequest, capacity
from course_capacity full outer join course_demand
on course_demand.course_id = course_capacity.course_id
group by course_demand.course_name, capacity, course_demand.course_id
order by course_demand.course_id;
/*
YEAR OF SERVICE
Combined with the number of qualifications each trainer has to look at the qualification progress and find out who has stayed at the school for many years but do not have as many qualifications.
*/
create view Year_of_Service
as
select fname,((sysdate-hire_date)/365) as "Year of Service"
from trainer
Where termination_date is null
group by fname,(sysdate-hire_date)/365
order by "Year of Service" desc; | true |
6f7e7d046690a55148e35de69ac13297667b5a5f | SQL | ralitsanikolova/SQL-Exercises | /Subqueries and Joins/Problem 2. Addresses with Towns.sql | UTF-8 | 226 | 3.5625 | 4 | [] | no_license | SELECT TOP(50) FirstName, LastName,Towns.Name as Name, Addresses.AddressText
FROM Employees
JOIN Addresses ON Employees.AddressID = Addresses.AddressID
JOIN Towns ON Addresses.TownID = Towns.TownID
ORDER BY FirstName, LastName | true |
095b9bae27c01996f33a35b085199ae2d1f65690 | SQL | yoe88/springboot-jpa-mybatis | /src/main/resources/how-to-set/Account.sql | UTF-8 | 1,122 | 3.375 | 3 | [] | no_license | drop table if exists account cascade;
create table account
(
id varchar(100) not null,
password varchar(100) not null,
nickname varchar(50) not null,
email varchar(300) not null,
zone_code varchar(30),
address varchar(300),
extra_address varchar(300),
detail_address varchar(500),
create_date timestamp not null default now(),
profile_image varchar(500),
enable boolean not null default '1',
role varchar(50) not null default 'ROLE_USER',
platform_type varchar(100) not null
);
alter table account add
primary key (id, platform_type);
alter table account add constraint UK_account_email
unique (email, platform_type);
INSERT INTO account (id, password, nickname, email, platform_type)
VALUES ('woo', '1234', '요!', 'woo@gmail', 'this');
INSERT INTO account (id, password, nickname, email, platform_type)
VALUES ('woop', '1234', '웁!', 'woop@gmail', 'this');
INSERT INTO account (id, password, nickname, email, platform_type)
VALUES ('navi', '88568', '네버', 'nagi@nave', 'naver'); | true |
d558ce2d7acfcb48dd2fade541be834c34db25d4 | SQL | NTXpro/NTXbases_de_datos | /DatabaseNTXpro/ERP/Stored Procedures/Procs1/Usp_Sel_Propiedad_Export.sql | UTF-8 | 460 | 3.171875 | 3 | [] | no_license | CREATE PROCEDURE [ERP].[Usp_Sel_Propiedad_Export]
@Flag bit
AS
BEGIN
SELECT
PR.ID ,
UM.ID IdUnidadMedida,
PR.Nombre NombrePropiedad,
UM.Nombre NombreUnidadMedida,
UM.CodigoSunat CodigoSunat,
PR.FechaRegistro FechaRegistro
FROM [Maestro].[Propiedad] PR
INNER JOIN [PLE].[T6UnidadMedida] UM
ON UM.ID = PR.IdUnidadMedida
WHERE PR.Flag = @Flag AND PR.FlagBorrador = 0
END | true |
8ee3b4cab988dfeb57adf9208ab7f99dd6751057 | SQL | nikolay-doichev/Csharp-Databases-Basics-September-2019 | /Databases Basics - MS SQL Server/06.Basics-Subqueries-And-JOINs/03. Sales Employees.sql | UTF-8 | 219 | 3.9375 | 4 | [] | no_license | SELECT e.EmployeeID,
e.FirstName,
e.LastName,
d.[Name] AS [DepartmentName]
FROM Employees AS e
JOIN Departments AS d
ON e.DepartmentID = d.DepartmentID
WHERE d.[Name] = 'Sales'
ORDER BY e.EmployeeID ASC | true |
856b24b2aa4a9da1e07a26eb0044bdaba8ad97ca | SQL | SDC-HRSJO1/reviews | /SchemaCassandra/cassandraReview.cql | UTF-8 | 2,724 | 3.71875 | 4 | [] | no_license | DROP KEYSPACE IF EXISTS review;
CREATE KEYSPACE review WITH replication =
{'class': 'SimpleStrategy', 'replication_factor' : 3};
USE review;
CREATE TABLE review.review (
pid int,
rid int,
user_name text,
age_range text,
create_date text,
review_title text,
recommendationYN text,
purchased_for text,
rating int,
review text,
upvotes int,
downvotes int,
play_experience int,
difficulty_level int,
money_value int,
build_hrs int,
build_mins int,
building_experience text,
PRIMARY KEY((pid),rid, create_date)
);
CREATE TABLE review.summary (
pid int,
avg_score decimal,
total_reviews int,
percent_total int,
five_star int,
five_star_percentage int,
four_star int,
four_star_percentage int,
three_star int,
three_star_percentage int,
two_star int,
two_star_percentage int,
one_star int,
one_star_percentage int,
play_experience_avg decimal,
difficulty_level_avg decimal,
money_value_avg decimal,
PRIMARY KEY((pid),total_reviews)
);
COPY review.review (pid, rid, user_name, age_range,create_date, review_title, recommendationYN, purchased_for,rating,review,upvotes,downvotes,play_experience, difficulty_level, money_value, build_hrs, build_mins, building_experience) FROM '/Users/tingling/Desktop/SDC/reviews/datagenerator/casReveiw.csv' WITH DELIMITER = '|' AND HEADER=TRUE;
COPY review.summary(pid, avg_score, total_reviews,percent_total, five_star,five_star_percentage,four_star, four_star_percentage,three_star, three_star_percentage,two_star,two_star_percentage,one_star,one_star_percentage,play_experience_avg,difficulty_level_avg, money_value_avg) FROM '/Users/tingling/Desktop/SDC/reviews/datagenerator/casSummary.csv' WITH DELIMITER = '|' AND HEADER=TRUE;
-- CREATE KEYSPACE review WITH replication =
-- {‘class’: ‘SimpleStrategy’, ‘replication_factor’ : 3};
-- CREATE TABLE review.product (
-- prodcut_id text,
-- name text,
-- PRIMARY KEY (prodcut_id)
-- WITH comment = ‘Q1. Find product’
-- AND CLUSTERING ORDER BY (prodcut_id ASC) ;
-- CREATE TABLE review.reviews (
-- id text PRIMARY KEY,
-- create_date date,
-- review_title text,
-- recommendationYN text,
-- purchased_for text,
-- review text,
-- upvotes smallint,
-- downvotes smallint,
-- play_experience smallint,
-- difficulty_level smallint,
-- money_value smallint,
-- build_hrs smallint,
-- build_mins smallint,
-- building_experience text )
-- WITH comment = ‘Q2. Find reviews of a product’;
-- CREATE TABLE review.user (
-- uid text,
-- full_name text,
-- age_range text
-- PRIMARY KEY (uid )
-- WITH comment = Q3. Find user writes the review’;
| true |
ad16581c4e105234249b868d373df9b2ade956a7 | SQL | fikepaci/alx-higher_level_programming | /0x0E-SQL_more_queries/13-count_shows_by_genre.sql | UTF-8 | 403 | 4.03125 | 4 | [] | no_license | -- Lists all genres from the database hbtn_0d_tvshows along with the number of
-- shows linked to each.
-- Does not display genres without linked shows.
-- Records are ordered by descending number of shows linked.
SELECT g.`name` AS `genre`,
COUNT(*) AS `number_of_shows`
FROM `tv_genres` AS g
INNER JOIN `tv_show_genres` AS t
ON g.`id` = t.`genre_id`
GROUP BY g.`name`
ORDER BY `number_of_shows` DESC;
| true |
854fd52e1dd82b793d66e54340b937f7f24c4915 | SQL | cornelioroyer/abaco-design | /v_cgl_financiero_cglsldocuenta.sql | UTF-8 | 628 | 3.3125 | 3 | [] | no_license | drop view v_cgl_financiero_cglsldocuenta;
create view v_cgl_financiero_cglsldocuenta as
select cglsldocuenta.compania, gralcompanias.nombre,
cgl_financiero.no_informe,
gralperiodos.inicio, cgl_financiero.d_fila, cglsldocuenta.cuenta,
cglsldocuenta.debito, cglsldocuenta.credito
from cgl_financiero, cglsldocuenta, gralperiodos, gralcompanias
where cgl_financiero.cuenta = cglsldocuenta.cuenta
and cglsldocuenta.compania = gralperiodos.compania
and cglsldocuenta.year = gralperiodos.year
and cglsldocuenta.periodo = gralperiodos.periodo
and gralperiodos.aplicacion = 'CGL'
and cglsldocuenta.compania = gralcompanias.compania;
| true |
d2d7639c72fd99fc839eba89708d571c6642c4cf | SQL | aasthakumar/FitnessFreak | /SQL/Triggers/trg_AfterInsertToUser_UpdateProgress.sql | UTF-8 | 616 | 2.953125 | 3 | [] | no_license | USE FitnessFreak;
-- =============================================
-- Author: Aastha Kumar
-- Create date: Nov, 28, 2017
-- Description: Trigger to insert record into progress
-- Version: 0.1
-- =============================================
DROP TRIGGER IF EXISTS InsertIntoProgress;
DELIMITER $$
CREATE TRIGGER InsertIntoProgress
AFTER INSERT ON User
FOR EACH ROW
BEGIN
INSERT INTO PROGRESS(CurrentWeight, EncouragingMessages,ProgressDate,UserID)
SELECT WeightAtSignUp, 'Congratulations on getting started', SignUpDate, UserID FROM USER where UserID = NEW.USERID;
END$$
DELIMITER ;
| true |
e4110e8124daf9a5bf8ef6782bcac827a7cfa029 | SQL | snakewqq/cmd | /sql/ndb/task/ndb修改task为arrange.sql | UTF-8 | 328 | 2.640625 | 3 | [] | no_license | SELECT *,FROM_UNIXTIME(createtime) FROM ndb_project_task WHERE id = 352239
SELECT *,FROM_UNIXTIME(starttime) FROM ndb_project_consultation_task WHERE id = 352239
UPDATE ndb_project_consultation_task
SET starttime=UNIX_TIMESTAMP('2015-11-24 22:00')
WHERE id = 352239
UPDATE ndb_project_task
SET `status` = 7
WHERE id = 337369 | true |
ec2d8f68fed0fd70d360588180b14e1b9d90fe02 | SQL | tormoz70/Bio.Framework.8 | /dbmodel/bioSys/BIOSYS_AI_UTL_20130125.sql | WINDOWS-1251 | 32,419 | 2.96875 | 3 | [] | no_license | -- Start of DDL Script for Package BIOSYS.AI_UTL
-- Generated 25.01.2013 15:15:07 from BIOSYS@GIVCDB_EKBS02
CREATE OR REPLACE
PACKAGE biosys.ai_utl
IS
type T_VARCHAR_TBL is table of varchar2 (4000);
type T_INLIST_REC is record (item varchar2 (4000));
type T_INLIST_TBL is table of T_INLIST_REC;
function pop_val_from_list1(
vLIST in out nocopy CLOB,
pDelimeter in varchar2 default ',')return CLOB;
procedure push_val_to_list(
vLIST in out nocopy varchar2,
pVal in varchar2,
pDelimeter in varchar2 default ',');
function trans_list(pList in varchar2, pDelimeter in varchar2 default ',')
return T_INLIST_TBL pipelined;
function pop_last_val_from_list(
vLIST in out nocopy VARCHAR2,
pDelimeter in varchar2 default ',')return VARCHAR2;
function item_in_list(p_item in varchar2, p_list in varchar2, p_delimeter in varchar2 default ',') return number;
function get_word (pSource varchar2, pIndex number, pDelimeter varchar2 := '/') return varchar2;
procedure sleep (pInterval in number);
function sleep (pInterval in number) return number;
procedure pars_tablename(full_tbl_name in varchar2, schm_name out varchar2, tbl_name out varchar2);
function split_str(pStr in varchar2, pDelimeter in varchar2 default ',') return T_VARCHAR_TBL pipelined;
function lists_is_equals(p_lst1 in varchar2, p_lst2 in varchar2, p_delimeter in varchar2) return number;
procedure compare_lists(
p_lst1 in varchar2, p_lst2 in varchar2, p_delimeter in varchar2,
v_add_to_lst1 out varchar2, v_add_to_lst2 out varchar2);
function pwd (nlength in number) return varchar2;
function decrypt_string(input_string in varchar2, key_line in varchar2) return varchar2;
function encrypt_string(input_string in varchar2, key_line in varchar2) return varchar2;
function invert_list(pStr in varchar2, pDelimeter in varchar2 default ',') return varchar2;
FUNCTION add_periods(pPeriod IN VARCHAR2, pMonths IN PLS_INTEGER) RETURN VARCHAR2;
function age_calc(borndate in date) return number;
function bitor( x in number, y in number ) return number;
function bitxor( x in number, y in number ) return number;
function next_period(pPeriod in varchar2) return varchar2;
FUNCTION num_to_word(vpr_num IN NUMBER) RETURN VARCHAR2;
function pars_time(pTime in varchar2) return number;
function period_name(pPeriod IN varchar2, pShort in number default 0) return varchar2;
function period_name0( pPeriod in varchar2) return varchar2;
function prev_period(pPeriod in varchar2) return varchar2;
function time_between_str(pDtStart in date, pDtEnd in date)return varchar2;
function vchar2num(pAttrValue in varchar2) return number;
procedure pars_login(p_login in varchar2, v_usr_name out varchar2, v_usr_pwd out varchar2);
FUNCTION add_days(pDate IN DATE, pDays IN PLS_INTEGER) RETURN DATE;
function lists_has_common(p_lst1 in varchar2, p_lst2 in varchar2, p_delimeter in varchar2) return number; --RESULT_CACHE;
function pop_val_from_list(
vLIST in out nocopy varchar2,
pDelimeter in varchar2 default ',')return varchar2;
function day_of_week(p_date in date) return number;
function nextday(p_inday date, p_weekday varchar2) return date;
procedure time_between(pDtStart in date, pDtEnd in date,
vDayDure out number, vHHDure out number, vMIDure out number, vSSDure out number);
function time_between_secs(pDtStart in date, pDtEnd in date) return number;
function db_datetime(p_date date, p_remote_time_zone number) return date;
END;
/
-- Grants for Package
GRANT EXECUTE ON biosys.ai_utl TO public
/
GRANT EXECUTE ON biosys.ai_utl TO givc_org
/
CREATE OR REPLACE
PACKAGE BODY biosys.ai_utl
IS
/* */
function pop_val_from_list1(
vLIST in out nocopy CLOB,
pDelimeter in varchar2 default ',')return CLOB
is
rslt CLOB;
vCommaPos pls_integer;
vDelimeterLen pls_integer := length(pDelimeter);
begin
rslt := null;
if length(vLIST) > 0 then
vCommaPos := instr(vLIST, pDelimeter, 1);
if vCommaPos > 0 then
rslt := substr(vLIST, 1, vCommaPos-1);
vLIST := substr(vLIST, vCommaPos+vDelimeterLen);
else
rslt := vLIST;
vLIST := null;
end if;
end if;
return rslt;
end;
function pop_val_from_list(
vLIST in out nocopy varchar2,
pDelimeter in varchar2 default ',')return varchar2
is
rslt varchar2(4000);
vCommaPos pls_integer;
vDelimeterLen pls_integer := length(pDelimeter);
begin
rslt := null;
if length(vLIST) > 0 then
vCommaPos := instr(vLIST, pDelimeter, 1);
if vCommaPos > 0 then
rslt := substr(vLIST, 1, vCommaPos-1);
vLIST := substr(vLIST, vCommaPos+vDelimeterLen);
else
rslt := vLIST;
vLIST := null;
end if;
end if;
return rslt;
end;
/* */
function pop_last_val_from_list(
vLIST in out nocopy VARCHAR2,
pDelimeter in varchar2 default ',')return VARCHAR2
is
rslt VARCHAR2(320);
vCommaPos integer;
begin
rslt := null;
if length(vLIST) > 0 then
vCommaPos := instr(vLIST, pDelimeter, -1);
if vCommaPos > 0 then
rslt := substr(vLIST, vCommaPos+1);
vLIST := substr(vLIST, 1, vCommaPos-1);
else
rslt := vLIST;
vLIST := '';
end if;
end if;
return rslt;
end;
/* n- */
function get_word (pSource varchar2, pIndex number, pDelimeter varchar2 := '/')
return varchar2
is
lStartPosition binary_integer;
lEndPosition binary_integer;
begin
if pIndex = 1 then
lStartPosition := 1;
else
lStartPosition := instr (pSource, pDelimeter, 1, pIndex - 1);
if lStartPosition = 0 then
return null;
else
lStartPosition := lStartPosition + length (pDelimeter);
end if;
end if;
lEndPosition := instr (pSource, pDelimeter, lStartPosition, 1);
if lEndPosition = 0 then
return substr (pSource, lStartPosition);
else
return substr (pSource, lStartPosition, lEndPosition - lStartPosition);
end if;
end;
/* */
function item_in_list(p_item in varchar2, p_list in varchar2, p_delimeter in varchar2 default ',') return number
is
vList varchar2(32760);
vCurItem varchar2(4000);
vDelPos integer;
begin
vList := p_list;
while Length(vList) > 0 loop
vCurItem := pop_val_from_list(vList, p_delimeter);
if upper(trim(p_item)) = upper(trim(vCurItem)) then
return 1;
end if;
end loop;
return 0;
end;
/* */
procedure push_val_to_list(
vLIST in out nocopy varchar2,
pVal in varchar2,
pDelimeter in varchar2 default ',')
is
begin
if vLIST is null then
vLIST:=pVal;
else
vLIST:=vLIST||pDelimeter||pVal;
end if;
end;
/* */
function split_str(pStr in varchar2, pDelimeter in varchar2 default ',')
return T_VARCHAR_TBL pipelined
is
vLine varchar2(32000);
vLine2Add varchar2(1000);
addLastEmptyItem boolean := false;
begin
vLine:=pStr;
if instr(vLine, pDelimeter) = 0 then
if length(vLine) > 0 then
pipe row (vLine);
end if;
vLine:='';
else
while length(vLine) > 0 loop
if instr(vLine, pDelimeter) > 0 then
vLine2Add:=substr(vLine, 1, instr(vLine, pDelimeter)-1);
vLine:=substr(vLine, instr(vLine, pDelimeter)+length(pDelimeter));
addLastEmptyItem := vLine is null;
else
vLine2Add:=vLine;
vLine:='';
end if;
--dbms_output.put_line('vLine:'||nvl(vLine, 'NULL'));
pipe row (vLine2Add);
end loop;
if addLastEmptyItem then
pipe row ('');
end if;
end if;
end;
/* */
function trans_list(pList in varchar2, pDelimeter in varchar2 default ',')
return T_INLIST_TBL pipelined
is
vList varchar2(32767);
function newItem(p_value in varchar2) return T_INLIST_REC
is
vRslt T_INLIST_REC;
begin
vRslt.item := p_value;
return vRslt;
end;
begin
vList := pList;
while vList is not null loop
pipe row(newItem(pop_val_from_list(vList,pDelimeter)));
end loop;
end;
/* */
function invert_list(pStr in varchar2, pDelimeter in varchar2 default ',')
return varchar2
is
vLine varchar2(32000);
vLine2Add varchar2(1000);
vResult varchar2(32000) := null;
begin
vLine:=pStr;
if instr(vLine, pDelimeter) = 0 then
if length(vLine) > 0 then
vResult := vLine;
end if;
vLine:='';
else
while length(vLine) > 0 loop
if instr(vLine, pDelimeter) > 0 then
vLine2Add:=substr(vLine, 1, instr(vLine, pDelimeter)-1);
vLine:=substr(vLine, instr(vLine, pDelimeter)+1);
else
vLine2Add:=vLine;
vLine:='';
end if;
if vResult is null then
vResult := vLine2Add;
else
vResult:= vLine2Add || pDelimeter || vResult;
end if;
end loop;
end if;
return vResult;
end;
/* pInterval */
function sleep (pInterval in number)
return number
is
begin
sys.dbms_lock.sleep (pInterval);
return pInterval;
end;
procedure sleep (pInterval in number)
is
begin
sys.dbms_lock.sleep (pInterval);
end;
procedure pars_tablename(full_tbl_name in varchar2, schm_name out varchar2, tbl_name out varchar2)
is
vParts T_VARCHAR_TBL;
begin
select *
bulk collect into vParts
from table(split_str(full_tbl_name, '.'));
if vParts.count = 2 then
schm_name := vParts(1);
tbl_name := vParts(2);
else
schm_name := null;
tbl_name := full_tbl_name;
end if;
end;
function lists_is_equals(p_lst1 in varchar2, p_lst2 in varchar2, p_delimeter in varchar2) return number
is
begin
for c in (select column_value from table(split_str(p_lst1, p_delimeter))) loop
if item_in_list(c.column_value,p_lst2,p_delimeter) = 0 then
return 0;
end if;
end loop;
for c in (select column_value from table(split_str(p_lst2, p_delimeter))) loop
if item_in_list(c.column_value,p_lst1,p_delimeter) = 0 then
return 0;
end if;
end loop;
return 1;
end;
function lists_has_common(p_lst1 in varchar2, p_lst2 in varchar2, p_delimeter in varchar2) return number --RESULT_CACHE
is
v_list varchar2(32000);
v_item varchar2(4000);
begin
if p_lst1 is null or p_lst2 is null then
return 0;
end if;
v_list := p_lst1;
while (v_list is not null) loop
v_item := pop_val_from_list(v_list);
if item_in_list(v_item,p_lst2) > 0 then
return 1;
end if;
end loop;
v_list := p_lst2;
while (v_list is not null) loop
v_item := pop_val_from_list(v_list);
if item_in_list(v_item,p_lst1) > 0 then
return 1;
end if;
end loop;
return 0;
end;
procedure compare_lists(
p_lst1 in varchar2, p_lst2 in varchar2, p_delimeter in varchar2,
v_add_to_lst1 out varchar2, v_add_to_lst2 out varchar2)
is
begin
for c in (select column_value from table(split_str(p_lst1, p_delimeter))) loop
if item_in_list(c.column_value,p_lst2,p_delimeter) = 0 then
push_val_to_list(v_add_to_lst1, c.column_value, p_delimeter);
end if;
end loop;
for c in (select column_value from table(split_str(p_lst2, p_delimeter))) loop
if item_in_list(c.column_value,p_lst1,p_delimeter) = 0 then
push_val_to_list(v_add_to_lst2, c.column_value, p_delimeter);
end if;
end loop;
end;
function pwd (nlength in number)
return varchar2
is
i NUMBER := 1;
strdoubleconsonants CONSTANT VARCHAR2 (12) := 'bdfglmnpst';
strconsonants CONSTANT VARCHAR2 (20) := 'bcdfghklmnpqrstv';
strvocal CONSTANT VARCHAR2 (5) := 'aeiou';
generatedpassword VARCHAR2 (50) := '';
bmadeconsonant BOOLEAN := FALSE;
nrnd NUMBER;
nsubrnd NUMBER;
c VARCHAR2 (1);
begin
for i in 1 .. nlength
loop
--get a random number number between 0 and 1
/*select dbms_random.random
into nrnd
from dual;*/
nrnd := dbms_random.value;
/*select random.rnd ()
into nsubrnd
from dual;*/
nsubrnd := dbms_random.value;
/* Simple or double consonant, or a new vocal?
* Does not start with a double consonant
* '15% or less chance for the next letter being a double consonant
*/
IF (generatedpassword <> '') AND (not bmadeconsonant) AND (nrnd < 0.15) THEN
--double consonant
c := SUBSTR (strdoubleconsonants, LENGTH (strdoubleconsonants) * nsubrnd + 1, 1);
c := c || c;
bmadeconsonant := TRUE;
ELSIF ((bmadeconsonant <> TRUE) AND (nrnd < 0.95)) THEN
--80% or less chance for the next letter being a consonant,
--depending on wether the last letter was a consonant or not.
--Simple consonant
c := SUBSTR (strconsonants, LENGTH (strconsonants) * nsubrnd + 1, 1);
bmadeconsonant := TRUE;
ELSE
--5% or more chance for the next letter being a vocal. 100% if last
--letter was a consonant - theoreticaly speaking...
--If last one was a consonant, make vocal
c := SUBSTR (strvocal, LENGTH (strvocal) * nsubrnd + 1, 1);
bmadeconsonant := FALSE;
END IF;
generatedpassword := generatedpassword || c;
END LOOP;
--Is the password long enough, or perhaps too long?
IF (LENGTH (generatedpassword) > nlength) THEN
generatedpassword := SUBSTR (generatedpassword, 1, nlength);
END IF;
RETURN generatedpassword;
END;
function encrypt_string(input_string in varchar2, key_line in varchar2) return varchar2
is
work_string varchar2(4000);
encrypted_string varchar2(4000);
begin
work_string := RPAD
( input_string
, (TRUNC(LENGTH(input_string) / 8) + 1 ) * 8
, CHR(0));
DBMS_OBFUSCATION_TOOLKIT.DESENCRYPT (
input_string => work_string
, key_string => key_line
, encrypted_string => encrypted_string);
return encrypted_string;
end;
function decrypt_string(input_string in varchar2, key_line in varchar2) return varchar2
is
work_string varchar2(4000);
decrypted_string VARCHAR2(4000);
begin
DBMS_OBFUSCATION_TOOLKIT.DESDECRYPT
(
input_string => input_string
,key_string => key_line
,decrypted_string => work_string
);
decrypted_string := RTRIM(work_string, CHR(0));
return decrypted_string;
-- exception
-- when OTHERS then
-- raise_application_error(-20000, '. : '||sqlerrm||'. key_line:['||key_line||']');
end;
/* - */
function time_between_secs(pDtStart in date, pDtEnd in date) return number
is
vDaysStart number(32);
vDaysEnd number(32);
vSecsStart number(32);
vSecsEnd number(32);
vSecsDure number(32);
begin
vDaysStart := trunc(pDtStart)-trunc(to_date('19000101', 'YYYYMMDD'));
vDaysEnd := trunc(pDtEnd)-trunc(to_date('19000101', 'YYYYMMDD'));
vSecsStart:=24*3600*vDaysStart+to_number(to_char(pDtStart, 'HH24'))*3600+to_number(to_char(pDtStart, 'MI'))*60+to_number(to_char(pDtStart, 'SS'));
vSecsEnd:=24*3600*vDaysEnd+to_number(to_char(pDtEnd, 'HH24'))*3600+to_number(to_char(pDtEnd, 'MI'))*60+to_number(to_char(pDtEnd, 'SS'));
vSecsDure:=vSecsEnd-vSecsStart;
return vSecsDure;
end;
/* - , , , */
procedure time_secs_pars(pSecsDure in number,
vDayDure out number, vHHDure out number, vMIDure out number, vSSDure out number)
is
vSecsRe number(32);
begin
vDayDure:=trunc(pSecsDure/(24*3600));
vSecsRe:=pSecsDure-(vDayDure*(24*3600));
vHHDure:=trunc(vSecsRe/(3600));
vSecsRe:=vSecsRe-(vHHDure*(3600));
vMIDure:=trunc(vSecsRe/(60));
vSecsRe:=vSecsRe-(vMIDure*(60));
vSSDure:=vSecsRe;
end;
/* - , , , */
procedure time_between(pDtStart in date, pDtEnd in date,
vDayDure out number, vHHDure out number, vMIDure out number, vSSDure out number)
is
vSecsDure number(32);
begin
vSecsDure:=time_between_secs(pDtStart, pDtEnd);
time_secs_pars(vSecsDure, vDayDure, vHHDure, vMIDure, vSSDure);
end;
/* - , , , */
function time_between_str(pDtStart in date, pDtEnd in date)return varchar2
is
vDtStart date := pDtStart;
vDtEnd date := pDtEnd;
vDayDure number(10);
vHHDure number(2);
vMIDure number(2);
vSSDure number(2);
vResult varchar2(64);
v_over varchar2(10) := null;
begin
if (pDtStart is not null) and (pDtEnd is not null) then
if(vDtStart > vDtEnd)then
vDtStart := pDtEnd;
vDtEnd := pDtStart;
v_over := '+ ';
end if;
time_between(vDtStart, vDtEnd, vDayDure, vHHDure, vMIDure, vSSDure);
vResult:='';
if vDayDure > 0 then
vResult:=vResult||to_char(vDayDure)||' . ';
end if;
vResult:=vResult||trim(to_char(vHHDure, '00'))||':'||trim(to_char(vMIDure, '00'))||':'||trim(to_char(vSSDure, '00'));
return v_over || vResult;
else
return null;
end if;
end;
/* - , , , */
function time_secs_str(pSecsDure in number)return varchar2
is
vDayDure number(3);
vHHDure number(2);
vMIDure number(2);
vSSDure number(2);
vResult varchar2(64);
begin
time_secs_pars(pSecsDure, vDayDure, vHHDure, vMIDure, vSSDure);
vResult:='';
if vDayDure > 0 then
vResult:=vResult||to_char(vDayDure)||' . ';
end if;
vResult:=vResult||trim(to_char(vHHDure, '00'))||':'||trim(to_char(vMIDure, '00'))||':'||trim(to_char(vSSDure, '00'));
return vResult;
end;
/* YYYYMM */
function period_name(pPeriod IN varchar2, pShort in number default 0) return varchar2
is
rslt varchar2(128);
type amnths is varray(12) of varchar2(32);
mnths amnths := amnths('','','','','','','','','','','','');
mnthIndx integer;
begin
rslt:='';
if pPeriod='000000' then
return ' ';
end if;
if length(pPeriod) = 6 then
mnthIndx := to_number(substr(pPeriod, 5, 2));
rslt := trim(substr(pPeriod, 1, 4)||' '||mnths(mnthIndx));
end if;
if pShort = 1 then
rslt:=substr(rslt, 1, 8);
end if;
return rslt;
exception
when others then
raise_application_error(-20003, ' "'||pPeriod||'" . : '||SQLERRM);
end;
/* YYYYMM */
function period_name0( pPeriod in varchar2) return varchar2
is
rslt varchar2(128);
type amnths is varray(12) of varchar2(32);
mnths amnths := amnths('','','','','','','','','','','','');
mnthIndx integer;
begin
rslt:='';
if pPeriod='000000' then
return ' ';
end if;
if length(pPeriod) = 6 then
mnthIndx := to_number(substr(pPeriod, 5, 2));
rslt := mnths(mnthIndx) || ' ' || trim(substr(pPeriod, 1, 4));
end if;
return rslt;
exception
when others then
raise_application_error(-20003, ' "'||pPeriod||'" . : '||SQLERRM);
end;
FUNCTION num_to_word(vpr_num IN NUMBER) RETURN VARCHAR2 IS
-- ()
--123.30 -> 30
TYPE t_numarr IS VARRAY(3) OF VARCHAR2(3);
v_numarr t_numarr;
v_number PLS_INTEGER := TRUNC(vpr_num); --123 456 789;
v_kops PLS_INTEGER := (vpr_num - v_number) * 100;
v_num_str VARCHAR2(9) := TO_CHAR(v_number);
v_dgroup PLS_INTEGER;
v_string VARCHAR2(200);
v_tmp_str VARCHAR2(50);
v_pos PLS_INTEGER;
FUNCTION get_dgword(p_num IN VARCHAR2, p_mltply IN PLS_INTEGER) RETURN VARCHAR2 IS
BEGIN
RETURN CASE WHEN p_num = '1' THEN
CASE WHEN p_mltply IN (1, 7) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' '
WHEN p_mltply IN (4) THEN ' ' END
WHEN p_num = '2' THEN
CASE WHEN p_mltply IN (1, 7) THEN ' '
WHEN p_mltply IN (2, 5, 8) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' '
WHEN p_mltply IN (4) THEN ' ' END
WHEN p_num = '3' THEN
CASE WHEN p_mltply IN (1, 4, 7) THEN ' '
WHEN p_mltply IN (2, 5, 8) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' ' END
WHEN p_num = '4' THEN
CASE WHEN p_mltply IN (1, 4, 7) THEN ' '
WHEN p_mltply IN (2, 5, 8) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' ' END
WHEN p_num = '5' THEN
CASE WHEN p_mltply IN (1, 4, 7) THEN ' '
WHEN p_mltply IN (2, 5, 8) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' ' END
WHEN p_num = '6' THEN
CASE WHEN p_mltply IN (1, 4, 7) THEN ' '
WHEN p_mltply IN (2, 5, 8) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' ' END
WHEN p_num = '7' THEN
CASE WHEN p_mltply IN (1, 4, 7) THEN ' '
WHEN p_mltply IN (2, 5, 8) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' ' END
WHEN p_num = '8' THEN
CASE WHEN p_mltply IN (1, 4, 7) THEN ' '
WHEN p_mltply IN (2, 5, 8) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' ' END
WHEN p_num = '9' THEN
CASE WHEN p_mltply IN (1, 4, 7) THEN ' '
WHEN p_mltply IN (2, 5, 8) THEN ' '
WHEN p_mltply IN (3, 6, 9) THEN ' ' END
END;
END;
FUNCTION get_tenths(p_num IN VARCHAR2) RETURN VARCHAR2 IS
BEGIN
RETURN CASE WHEN p_num = '10' THEN ' '
WHEN p_num = '11' THEN ' '
WHEN p_num = '12' THEN ' '
WHEN p_num = '13' THEN ' '
WHEN p_num = '14' THEN ' '
WHEN p_num = '15' THEN ' '
WHEN p_num = '16' THEN ' '
WHEN p_num = '17' THEN ' '
WHEN p_num = '18' THEN ' '
WHEN p_num = '19' THEN ' '
END;
END;
FUNCTION get_names(p_num IN VARCHAR2, p_mltply IN PLS_INTEGER) RETURN VARCHAR2 IS
BEGIN
RETURN CASE WHEN p_mltply = 0 THEN
CASE WHEN p_num IN ('1') THEN ' '
WHEN p_num IN ('2', '3', '4') THEN ' '
ELSE ' '
END
WHEN p_mltply = 1 THEN
CASE WHEN p_num IN ('1') THEN ' '
WHEN p_num IN ('2', '3', '4') THEN ' '
ELSE ' '
END
WHEN p_mltply = 4 THEN
CASE WHEN p_num IN ('1') THEN ' '
WHEN p_num IN ('2', '3', '4') THEN ' '
ELSE ' '
END
WHEN p_mltply = 7 THEN
CASE WHEN p_num IN ('1') THEN ' '
WHEN p_num IN ('2', '3', '4') THEN ' '
ELSE ' '
END
END;
END;
BEGIN
v_numarr := t_numarr();
WHILE v_number >= 1 LOOP
v_dgroup := MOD(v_number, 1000);
v_number := TRUNC(v_number / 1000);
v_numarr.EXTEND;
v_numarr(v_numarr.LAST) := TO_CHAR(v_dgroup);
END LOOP;
FOR idx IN 1..v_numarr.COUNT LOOP
IF SUBSTR(v_numarr(idx), -2, 1) = '1' THEN
v_tmp_str := get_tenths(SUBSTR(v_numarr(idx), -2, 2))||
get_names(SUBSTR(v_numarr(idx), -2, 2), (idx - 1) * 3 + 1);
v_string := get_dgword(SUBSTR(v_numarr(idx), -3, 1), (idx - 1) * 3 + 3)||v_tmp_str||v_string;
ELSE
v_pos := 1;
FOR i IN REVERSE 1..LENGTH(v_numarr(idx)) LOOP
v_tmp_str := get_dgword(SUBSTR(v_numarr(idx), i, 1), (idx - 1) * 3 + v_pos)||
get_names(SUBSTR(v_numarr(idx), i, 1), (idx - 1) * 3 + v_pos);
v_string := v_tmp_str||v_string;
v_pos := v_pos + 1;
END LOOP;
END IF;
END LOOP;
v_tmp_str := TRIM(TO_CHAR(v_kops, '00'));
IF SUBSTR(v_tmp_str, -2, 1) = '1' THEN
v_tmp_str := v_tmp_str||' '||get_names(0, 0);
ELSE
v_tmp_str := v_tmp_str||' '||get_names(SUBSTR(v_tmp_str, -1, 1), 0);
END IF;
v_string := v_string||v_tmp_str;
RETURN TRIM(v_string);
END;
function vchar2num(pAttrValue in varchar2) return number
is
begin
return TO_NUMBER(replace(pAttrValue, ',', '.'), '99999999.9999999');
end;
/* , YYYYMM */
FUNCTION add_periods(pPeriod IN VARCHAR2, pMonths IN PLS_INTEGER) RETURN VARCHAR2 IS
BEGIN
return to_char(add_months(to_date(pPeriod, 'YYYYMM'), pMonths), 'YYYYMM');
END;
/* */
FUNCTION add_days(pDate IN DATE, pDays IN PLS_INTEGER) RETURN DATE IS
BEGIN
return pDate + pDays;
END;
/* 1 , YYYYMM */
function next_period(pPeriod in varchar2) return varchar2 is
BEGIN
return add_periods(pPeriod, 1);
end;
/* 1 , YYYYMM */
function prev_period(pPeriod in varchar2) return varchar2 is
begin
return add_periods(pPeriod, -1);
end;
/* - */
function age_calc(borndate in date) return number
is
years number(5);
months number(5);
begin
years:=TO_NUMBER(TO_CHAR(sysdate,'yyyy'))-TO_NUMBER(TO_CHAR(borndate,'yyyy'));
months:=TO_NUMBER(TO_CHAR(sysdate,'mm'))-TO_NUMBER(TO_CHAR(borndate,'mm'));
return round(years+months/12);
end;
function bitor( x in number, y in number ) return number as
begin
return x + y - bitand(x,y);
end;
function bitxor( x in number, y in number ) return number
is
begin
return bitor(x,y) - bitand(x,y);
end;
function pars_time(pTime in varchar2) return number
is
begin
return to_date(pTime, 'HH24:MI:SS') - to_date('00:00:00', 'HH24:MI:SS');
end;
procedure pars_login(p_login in varchar2, v_usr_name out varchar2, v_usr_pwd out varchar2)
is
vResult T_VARCHAR_TBL;
begin
v_usr_name := null;
v_usr_pwd := null;
select *
bulk collect into vResult
from table(ai_utl.split_str(PSTR=>p_login, PDELIMETER=>'/'));
if(vResult.count = 2)then
v_usr_name := vResult(1);
v_usr_pwd := vResult(2);
end if;
end;
function day_of_week(p_date in date) return number
is
v_day varchar2(100);
begin
SELECT TO_CHAR (p_date, 'DAY') into v_day FROM DUAL;
v_day := trim(upper(v_day));
return case when v_day = 'MONDAY' then 1
when v_day = 'TUESDAY' then 2
when v_day = 'WEDNESDAY' then 3
when v_day = 'THURSDAY' then 4
when v_day = 'FRIDAY' then 5
when v_day = 'SATURDAY' then 6
when v_day = 'SUNDAY' then 7
else 0 end;
end;
function nextday(p_inday date, p_weekday varchar2) return date
is
type t_weekdays is varray(7) of varchar2(32);
v_weekdays t_weekdays := t_weekdays('MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY');
v_day date;
v_indx pls_integer;
v_inday_indx pls_integer;
begin
for i in 1..7 loop
if upper(p_weekday) = v_weekdays(i) then
v_indx := i;
exit;
end if;
end loop;
--dbms_output.put_line('v_indx: '||v_indx);
v_inday_indx := day_of_week(p_inday);
--dbms_output.put_line('v_inday_indx: '||v_inday_indx);
if v_inday_indx >= v_indx then
v_indx := 7 - v_inday_indx + v_indx;
else
v_indx := v_indx - v_inday_indx;
end if;
--dbms_output.put_line('v_indx1: '||v_indx);
v_day := p_inday + v_indx;
--dbms_output.put_line('p_inday:'||p_inday||'; v_day: '||v_day);
return v_day;
end;
function db_datetime(p_date date, p_remote_time_zone number) return date
is
v_db_time_zone number(4) := to_number(to_char(current_timestamp, 'TZH'));
begin
return p_date + (nvl(p_remote_time_zone, v_db_time_zone)-v_db_time_zone)/1440*60;
end;
END;
/
| true |
a4aa2bc862da63ec3d07ed11a5120289f5c509cc | SQL | oosunkeye/SQL-Oracle-DBS301 | /LAB1.SQL | WINDOWS-1250 | 550 | 3.25 | 3 | [] | no_license | 4. /*THERE ARE THREE CODING ERRORS IN THIS STATEMENT. WRITE THE CORRECT SYNTAX.
SELECT LAST_NAME LNAME, JOB_ID JOB TITLE, FROM EMPLOYEES
WHERE JOB_ID <> SA_REP
AND SALARY NOT BETWEEN (4000,8000);
*/
SELECT LAST_NAME LNAME, JOB_ID AS "JOB TITLE"
FROM EMPLOYEES
WHERE JOB_ID <> 'SA_REP'
AND SALARY NOT IN (4000,8000);
5. SELECT LOCATION_ID AS "CITY#", CITY, COUNTRY_ID AS "CO"
FROM LOCATIONS
ORDER BY LOCATION_ID DESC;
6. SELECT DISTINCT(JOB_ID), DEPARTMENT_ID
FROM EMPLOYEES;
| true |
f64c77e96f42c7962ddfb5f202c8d9dc8291a2dc | SQL | jongvin/werp | /werp/erpw/general/t_web/sql/FBS/Functions/f_recieve_file_from_van.sql | UHC | 6,854 | 3.046875 | 3 | [] | no_license | /*************************************************************************/
/* */
/* 1. ID : f_recieve_file_from_van */
/* 2. ̸ : AN翡 data file մϴ. */
/* 3. ý : ȸý */
/* 4. ý: FBS */
/* 5. : */
/* 6. : PL/SQL */
/* 7. ȯ : Windows2003 Server+ Oracle 9.2.0 */
/* 8. DBMS : Oracle */
/* 9. ֿ */
/* */
/* - ڵ/ڵ/۵Ÿ Ǵؼ VAN翡 ڷ */
/* , 丮 Էµ ϸ Ѵ. */
/* ó ȯȴ. */
/* */
/* - ó Ϸ LOGGING */
/* */
/* - ȯ */
/* OK : ó */
/* : Ÿ (DEFAULT:ERROR) */
/* */
/* 10. ۼ: LG CNS ö */
/* 11. ۼ: 20051220 */
/* 12. : */
/* 13. : */
/*************************************************************************/
CREATE OR REPLACE
FUNCTION f_recieve_file_from_van(p_file_name IN VARCHAR2 , -- ϸ
p_gubun IN VARCHAR2 , -- ۵Ÿ (C:,B:ھ,V:ھ¾ü)
p_comp_code IN VARCHAR2 , -- ڵ
p_bank_code IN VARCHAR2 ) -- ڵ
RETURN VARCHAR2 IS -- ۽Ű ó
v_command VARCHAR2(400); -- PARAMETER ڿ
v_dummy_return VARCHAR2(100):= 'OK'; -- 'OK'/'ERROR'
v_recv_dir_name VARCHAR2(100);
v_recv_dir VARCHAR2(100);
v_subject_name VARCHAR2(100);
v_filename VARCHAR2(100);
FBS_CASH_RECV_DIR VARCHAR2(100) := FBS_UTIL_PKG.FBS_CASH_RECV_DIR; -- ü
FBS_BILL_RECV_DIR VARCHAR2(100) := FBS_UTIL_PKG.FBS_BILL_RECV_DIR; -- ھ
EDI_SEND_PRG VARCHAR2(100) := 'tcpsend '; -- EDI batch ۽ EFTα
EDI_RECV_PRG VARCHAR2(100) := 'tcprecv '; -- EDI batch EFTα
rec_org_bank T_FB_ORG_BANK%ROWTYPE; -- ڵ带 RECORD
--
errmsg VARCHAR2(500); -- Error Message Edit
errflag INTEGER DEFAULT 0; -- Process Error Code
-- User Define Error
Err EXCEPTION; -- Select Data Not Found
BEGIN
-- >>>>>>>>>>>>> ó <<<<<<<<<<<<<<<<<<
IF p_gubun = 'C' THEN
v_recv_dir_name := FBS_CASH_RECV_DIR ;
ELSIF p_gubun = 'B' THEN
v_recv_dir_name := FBS_BILL_RECV_DIR ;
ELSIF p_gubun = 'V' THEN
v_recv_dir_name := FBS_BILL_RECV_DIR ;
END IF;
-- OS directory ɴϴ.(from DBA_DIRECTORIES )
SELECT DIRECTORY_PATH || '/'
INTO v_recv_dir
FROM DBA_DIRECTORIES
WHERE DIRECTORY_NAME = v_recv_dir_name ;
-- ϵ SUBJECT NAME ɴϴ.
SELECT *
INTO rec_org_bank
FROM T_FB_ORG_BANK
WHERE COMP_CODE = p_comp_code
AND BANK_MAIN_CODE = p_bank_code;
IF p_gubun = 'C' THEN
v_subject_name := rec_org_bank.cash_recv_subject_name ;
ELSIF p_gubun = 'B' THEN
v_subject_name := rec_org_bank.bill_recv_subject_name ;
ELSIF p_gubun = 'V' THEN
v_subject_name := rec_org_bank.vendor_subject_name ;
END IF;
-- Ϲڽ BATCH̸
v_filename := p_file_name;
BEGIN
-- COMMANDڿ EFTα CALL COMMAND մϴ.
v_command := 'tcprecv' || ' -o:' || rec_org_bank.bank_edi_login_id ||
' -b:A'||
' -t:' || v_subject_name ||
' -p:ITCP/IP' ||
' -F:' || v_recv_dir || v_filename ;
v_dummy_return := fbs_util_pkg.exec_os_command( v_command );
END;
IF v_dummy_return = 'OK' THEN
fbs_util_pkg.write_log('FBS','[INFO] ϼ ϷǾϴ.'||v_dummy_return );
ELSE
fbs_util_pkg.write_log('FBS','[ERROR] ϼŽ Ͽϴ.'||v_dummy_return );
END IF;
---------------------------------------------------
-- ŵ 0 óѴ.
---------------------------------------------------
--v_command := 'delete_zero_file.sh ' || v_recv_dir || v_filename;
--v_dummy_return := fbs_util_pkg.exec_os_command( v_command );
RETURN( v_dummy_return );
EXCEPTION
WHEN OTHERS THEN
fbs_util_pkg.write_log('FBS','[ERROR] ϼŽ Ͽϴ.'||v_dummy_return);
RETURN('ERROR');
END ; | true |
76d6e73f180dd029d55272388150b217bddf569b | SQL | kalex32/Hib2 | /src/main/resources/database/init1dB.sql | UTF-8 | 333 | 2.8125 | 3 | [] | no_license |
CREATE TABLE IF NOT EXISTS developers(
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
specialty VARCHAR(100) NOT NULL,
experience INT NOT NULL
);
CREATE user 'root'@'%' identified by 'root';
grant all privileges on testhib.* to olexiy;
flush privileges;
create database testhib; | true |
1912af2e8d7041fd7e98123b24c3563ca54dc541 | SQL | Pathik1973Git/MyFirstRepo | /db_Test/DB_SSISDB/catalog/Views/object_versions_1.sql | UTF-8 | 724 | 3.5625 | 4 | [] | no_license |
CREATE VIEW [catalog].[object_versions]
AS
SELECT vers.[object_version_lsn],
vers.[object_id],
vers.[object_type],
projs.[name] AS [object_name],
vers.[description],
vers.[created_by],
vers.[created_time],
vers.[restored_by],
vers.[last_restored_time]
FROM [internal].[object_versions] vers INNER JOIN [internal].[projects] projs ON
vers.[object_id] = projs.[project_id] AND vers.[object_type] = 20
WHERE vers.[object_id] in (SELECT [id] FROM [internal].[current_user_readable_projects])
OR (IS_MEMBER('ssis_admin') = 1)
OR (IS_SRVROLEMEMBER('sysadmin') = 1)
| true |
38df95405817a648cfdec6f3aa6d67a21deb0036 | SQL | lghtman/sqlzoo-solutions | /join-soccer.sql | UTF-8 | 3,525 | 4.59375 | 5 | [] | no_license | -- 1. Show the matchid and player name for all goals scored by Germany
SELECT matchid
, player
FROM goal
WHERE teamid = 'GER'
-- 2. Show id, stadium, team1, team2 for just game 1012
SELECT id
, stadium
, team1
, team2
FROM game
WHERE id = 1012
/* 3. Show the player, teamid, stadium
and mdate for every German goal. */
SELECT goal.player
, goal.teamid
, game.stadium
, game.mdate
FROM game
INNER JOIN goal
ON game.id = goal.matchid
AND game.teamid = 'GER'
-- 4. Show the team1, team2 and player for every goal scored by a player called Mario
SELECT game.team1
, game.team2
, goal.player
FROM game
INNER JOIN goal
ON game.id = goal.matchid
AND goal.player LIKE 'Mario%'
-- 5. Show player, teamid, coach, gtime for all goals scored in the first 10 minutes
SELECT goal.player
, goal.teamid
, eteam.coach
, goal.gtime
FROM goal
INNER JOIN eteam
ON goal.teamid = eteam.id
AND goal.gtime <= 10
-- 6. List the the dates of the matches and the name of the team in which 'Fernando Santos' was the team1 coach
SELECT game.mdate
, eteam.teamname
FROM game
INNER JOIN eteam
ON game.team1 = eteam.id
AND eteam.coach = 'Fernando Santos'
-- 7. List the player for every goal scored in a game where the stadium was 'National Stadium, Warsaw'
SELECT goal.player
FROM game
INNER JOIN goal
ON game.id = goal.matchid
AND game.stadium = 'National Stadium, Warsaw'
-- 8. show the name of all players who scored a goal against Germany
SELECT DISTINCT(goal.player)
FROM game
INNER JOIN goal
ON goal.matchid = game.id
AND ((team1 = 'GER' OR team2 = 'GER')
AND goal.teamid != 'GER')
-- 9. Show teamname and the total number of goals scored
SELECT eteam.teamname
, COUNT(goal.gtime)
FROM eteam
INNER JOIN goal
ON eteam.id = goal.teamid
GROUP BY eteam.teamname
-- 10. Show the stadium and the number of goals scored in each stadium
SELECT game.stadium
, COUNT(goal.gtime)
FROM game
INNER JOIN goal
ON game.id = goal.matchid
GROUP BY game.stadium
-- 11. For every match involving 'POL', show the matchid, date and the number of goals scored
SELECT goal.matchid
, game.mdate
, COUNT(goal.gtime)
FROM game
INNER JOIN goal
ON goal.matchid = game.id
AND (game.team1 = 'POL' OR game.team2 = 'POL')
GROUP BY goal.matchid, game.mdate
-- 12. For every match where 'GER' scored, show matchid, match date and the number of goals scored by 'GER'
SELECT goal.matchid
, game.mdate
, COUNT(goal.gtime)
FROM game
INNER JOIN goal
ON game.id = goal.matchid
AND goal.teamid = 'GER'
GROUP BY matchid, mdate
/* 13. List every match with the goals scored by each team as shown.
Sort your result by mdate, matchid, team1 and team2. */
SELECT game.mdate
, game.team1
, SUM(CASE
WHEN goal.teamid = game.team1 THEN 1
ELSE 0
END) AS score1
, game.team2
, SUM(CASE
WHEN goal.teamid = game.team2 THEN 1
ELSE 0
END) AS score2
FROM game
LEFT JOIN goal
ON game.id = goal.matchid
GROUP BY game.mdate, game.team1, game.team2
ORDER BY game.mdate, goal.matchid, game.team1, game.team2 | true |
2c20a9daf9c646dbaf584b2a7afa9b6d3f511068 | SQL | TimDorand/netfriends | /netfriends.sql | UTF-8 | 4,349 | 3.1875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.4.10
-- http://www.phpmyadmin.net
--
-- Client : localhost:8889
-- Généré le : Jeu 12 Novembre 2015 à 23:30
-- Version du serveur : 5.5.42
-- Version de PHP : 5.6.10
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 */;
--
-- Base de données : `netfriends`
--
-- --------------------------------------------------------
--
-- Structure de la table `billets`
--
CREATE TABLE `billets` (
`id` int(11) NOT NULL,
`titre` varchar(255) NOT NULL,
`contenu` text NOT NULL,
`date_creation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=latin1;
--
-- Contenu de la table `billets`
--
INSERT INTO `billets` (`id`, `titre`, `contenu`, `date_creation`) VALUES
(56, 'John', 'Hi everyone, this is my first post ', '2015-11-12 22:18:33'),
(57, 'Jeremie', 'Wow le site est déjà fini !', '2015-11-12 22:20:48'),
(58, 'Melissa', 'En tout cas, il est beau notre site ;)', '2015-11-12 22:22:25');
-- --------------------------------------------------------
--
-- Structure de la table `comments`
--
CREATE TABLE `comments` (
`id` int(11) NOT NULL,
`id_billet` int(11) NOT NULL,
`auteur` varchar(255) NOT NULL,
`commentaire` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`date_commentaire` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=latin1;
--
-- Contenu de la table `comments`
--
INSERT INTO `comments` (`id`, `id_billet`, `auteur`, `commentaire`, `date_commentaire`) VALUES
(36, 56, 'Tim', 'Hi ! I hope you enjoy it', '2015-11-12 22:19:09'),
(37, 57, 'Tim', 'Et ouai mon gars !', '2015-11-12 22:20:57'),
(38, 58, 'Tim', 'Et c est grace a toi !', '2015-11-12 22:26:17');
-- --------------------------------------------------------
--
-- Structure de la table `reply`
--
CREATE TABLE `reply` (
`id` int(11) NOT NULL,
`id_comments` int(11) NOT NULL,
`interloc` varchar(255) NOT NULL,
`reponse` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`date_reponse` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
--
-- Contenu de la table `reply`
--
INSERT INTO `reply` (`id`, `id_comments`, `interloc`, `reponse`, `date_reponse`) VALUES
(5, 36, 'John ', ' Yes, for a v1 its very nice !', '2015-11-12 22:20:02'),
(6, 38, 'Melissa ', ' Merci ! :3', '2015-11-12 22:26:29');
-- --------------------------------------------------------
--
-- Structure de la table `users`
--
CREATE TABLE `users` (
`id` int(10) NOT NULL,
`pseudo` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
--
-- Contenu de la table `users`
--
INSERT INTO `users` (`id`, `pseudo`, `password`) VALUES
(1, 'Jeremy', '1234567'),
(2, 'Louis', '123456'),
(3, 'Maxime', '12345'),
(4, 'Test', '1234'),
(5, 'root', 'root');
--
-- Index pour les tables exportées
--
--
-- Index pour la table `billets`
--
ALTER TABLE `billets`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `comments`
--
ALTER TABLE `comments`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `reply`
--
ALTER TABLE `reply`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT pour les tables exportées
--
--
-- AUTO_INCREMENT pour la table `billets`
--
ALTER TABLE `billets`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=59;
--
-- AUTO_INCREMENT pour la table `comments`
--
ALTER TABLE `comments`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=39;
--
-- AUTO_INCREMENT pour la table `reply`
--
ALTER TABLE `reply`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT pour la table `users`
--
ALTER TABLE `users`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
/*!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 |
b3390ba960fcde58e76d7ecfdb208f388e5570d6 | SQL | fernandocanizo/short-tips | /postgresql/postgis/add.postgis.sql | UTF-8 | 593 | 2.546875 | 3 | [
"MIT"
] | permissive | -- You only need to add the features you want:
-- Enable PostGIS (includes raster)
CREATE EXTENSION postgis;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- Enable PostGIS Advanced 3D
-- and other geoprocessing algorithms
-- sfcgal not available with all distributions
CREATE EXTENSION postgis_sfcgal;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- rule based standardizer
CREATE EXTENSION address_standardizer;
-- example rule data set
CREATE EXTENSION address_standardizer_data_us;
-- Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;
| true |
647a5359226d9544d276fb49ba2b272843e55129 | SQL | DavidDeArmon/Better-Habits | /db/getHabitDays.sql | UTF-8 | 160 | 3.421875 | 3 | [] | no_license | SELECT * FROM habits
JOIN user_habits ON(habits.habit_id=user_habits.id)
WHERE habits.user_id = $1 AND habits.date BETWEEN $2 AND $3
ORDER BY habits.date DESC; | true |
223b468c9dad15d2f9afa25a0a813349656f0035 | SQL | ErikLarsson82/smash-ladder-be | /postgres.sql | UTF-8 | 2,002 | 3.046875 | 3 | [] | no_license | DROP TABLE players;
DROP TABLE schedule;
DROP TABLE matches;
CREATE TABLE players (
id serial PRIMARY KEY,
name text,
playerslug text,
main text,
secondary text,
trend integer,
qc integer[],
rank integer
);
INSERT INTO players (name, playerslug, main, secondary, trend, qc, rank)
VALUES
('Mikael Carlen', 'mikael-carlen', 'Corrin', NULL, 0, '{}', 1),
('Viktor Kraft', 'viktor-kraft', 'Peach', 'Daisy', 0, '{3}', 2),
('Alexander Batsis', 'alexander-batsis', 'Pikachu', 'Lucina', 0, '{}', 3),
('Pontus Fransson', 'pontus-fransson', 'Young Link', NULL, 0, '{}', 4),
('Patrik Beijar', 'patrik-beijar', 'Cloud', 'Pit', 0, '{}', 5),
('Markus Hedvall', 'markus-hedvall', 'Ness', NULL, 0, '{}', 6),
('David Forssell', 'david-forssell', 'Roy', 'Captain Falcon', 0, '{}', 7),
('Mattias%20B%E4ckstr%F6m', 'mattias-backstrom', 'Shulk', 'Lucas', 0, '{1}', 8),
('Erik Larsson', 'erik-larsson', 'Mega Man', NULL, 0, '{}', 9),
('Dimitris Thanasis', 'dimitris-thanasis', 'Corrin', NULL, 0, '{}', 10),
('Victor Tuomola', 'victor-tuomola', 'Joker', NULL, 0, '{}', 11),
('Mikael Stenberg', 'mikael-stenberg', 'Ike', 'Random', 0, '{}', 12),
('Kalle Lindblom', 'kalle-lindblom', 'Mario', NULL, 0, '{}', 13),
('Emil Westenius', 'emil-westenius', 'Yoshi', 'Lucina', 0, '{}', 14),
('Martin Kustvall', 'martin-kustvall', 'Link', NULL, 0, '{}', 15),
('Victor%20L%F6vgren', 'victor-lovgren', 'Young Link', NULL, 0, '{}', 16),
('Baran Hiwakader', 'baran-hiwakader', 'Ridly', NULL, 0, '{}', 17),
('Jonas Johansson', 'jonas-johansson', 'Bowser', 'King K. Rool', 0, '{}', 18),
('Stefan Nygren', 'stefan-nygren', 'Palutena', NULL, 0, '{}', 19),
('Jimmy%20Hyt%F6nen', 'jimmy-hytonen', 'Young Link', 'Joker', 0, '{2}', 20);
CREATE TABLE schedule (
id serial PRIMARY KEY,
p1slug text,
p2slug text,
date text
);
CREATE TABLE matches (
id serial PRIMARY KEY,
p1slug text,
p2slug text,
date text,
result text[],
p1trend integer,
p2trend integer,
p1prerank integer,
p2prerank integer
);
| true |
bf1d8450d404bd0523a312af373ce72be1b412c0 | SQL | zhaoya1998/dubbo-hgshop | /hg_brand.sql | UTF-8 | 28,942 | 2.890625 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : cms
Source Server Version : 50557
Source Host : localhost:3306
Source Database : 1710d
Target Server Type : MYSQL
Target Server Version : 50557
File Encoding : 65001
Date: 2020-04-17 09:38:02
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for hg_brand
-- ----------------------------
DROP TABLE IF EXISTS `hg_brand`;
CREATE TABLE `hg_brand` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL COMMENT '品牌名称',
`first_char` varchar(1) DEFAULT NULL COMMENT '品牌首字母',
`deleted_flag` tinyint(1) DEFAULT '0' COMMENT '删除标识',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of hg_brand
-- ----------------------------
INSERT INTO `hg_brand` VALUES ('1', '新百伦', 'x', '0');
INSERT INTO `hg_brand` VALUES ('2', '小米', 'X', '0');
INSERT INTO `hg_brand` VALUES ('3', '苹果', 'P', '0');
INSERT INTO `hg_brand` VALUES ('4', '华为', 'H', '0');
INSERT INTO `hg_brand` VALUES ('5', '海信', 'H', '0');
INSERT INTO `hg_brand` VALUES ('6', '格力', 'g', '0');
INSERT INTO `hg_brand` VALUES ('8', '以纯', 'y', '0');
INSERT INTO `hg_brand` VALUES ('9', '大众', 'd', '0');
INSERT INTO `hg_brand` VALUES ('11', '丰田', 'f', '0');
INSERT INTO `hg_brand` VALUES ('12', '杂牌', 'z', '0');
-- ----------------------------
-- Table structure for hg_cart
-- ----------------------------
DROP TABLE IF EXISTS `hg_cart`;
CREATE TABLE `hg_cart` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` varchar(255) CHARACTER SET latin1 DEFAULT NULL COMMENT '用户id',
`skuid` varchar(255) CHARACTER SET latin1 DEFAULT NULL COMMENT '商品id(商品型号)',
`pnum` decimal(10,0) DEFAULT NULL COMMENT '购买数量',
`createtime` datetime DEFAULT NULL COMMENT '创建时间',
`updatetime` datetime DEFAULT NULL COMMENT '最后修改时间',
`sum_total` decimal(10,0) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of hg_cart
-- ----------------------------
INSERT INTO `hg_cart` VALUES ('20', '2', '1', '9', '2019-11-29 11:00:39', '2019-11-29 11:00:53', '74700');
INSERT INTO `hg_cart` VALUES ('21', '2', '6', '6', '2019-11-29 11:00:44', '2019-11-29 11:00:57', '6594');
INSERT INTO `hg_cart` VALUES ('22', '1', '7', '1', '2019-12-18 08:30:27', '2019-12-18 08:30:27', '279');
INSERT INTO `hg_cart` VALUES ('23', '1', '5', '1', '2019-12-18 08:30:31', '2019-12-18 08:30:31', '4999');
INSERT INTO `hg_cart` VALUES ('31', '10', '37', '1', '2020-04-11 09:11:49', '2020-04-11 09:11:49', null);
INSERT INTO `hg_cart` VALUES ('32', '10', '32', '1', '2020-04-11 20:56:49', '2020-04-11 20:56:49', null);
INSERT INTO `hg_cart` VALUES ('33', '10', '29', '1', '2020-04-13 10:50:38', '2020-04-13 10:50:38', null);
INSERT INTO `hg_cart` VALUES ('34', '10', '39', '1', '2020-04-13 18:09:11', '2020-04-13 18:09:11', null);
-- ----------------------------
-- Table structure for hg_category
-- ----------------------------
DROP TABLE IF EXISTS `hg_category`;
CREATE TABLE `hg_category` (
`id` int(20) NOT NULL AUTO_INCREMENT COMMENT '类目ID',
`parent_id` int(20) unsigned zerofill DEFAULT '00000000000000000000' COMMENT '父类目ID=0时,代表的是一级的类目',
`name` varchar(50) DEFAULT NULL COMMENT '类目名称',
`path` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `parent_id` (`parent_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1277 DEFAULT CHARSET=utf8 COMMENT='商品类目';
-- ----------------------------
-- Records of hg_category
-- ----------------------------
INSERT INTO `hg_category` VALUES ('1233', '00000000000000000000', '电器', '电器');
INSERT INTO `hg_category` VALUES ('1241', '00000000000000000000', '电子产品', '电子产品');
INSERT INTO `hg_category` VALUES ('1242', '00000000000000001241', '手机', '电子产品/手机');
INSERT INTO `hg_category` VALUES ('1243', '00000000000000001242', '智能手机', '电子产品/手机/智能手机');
INSERT INTO `hg_category` VALUES ('1244', '00000000000000001242', '老年机', '电子产品/手机/老年机');
INSERT INTO `hg_category` VALUES ('1245', '00000000000000001233', '家用电器', '电器/家用电器');
INSERT INTO `hg_category` VALUES ('1246', '00000000000000001245', '电视', '电器/家用电器/电视');
INSERT INTO `hg_category` VALUES ('1247', '00000000000000001242', '传统手机', null);
INSERT INTO `hg_category` VALUES ('1255', '00000000000000000000', '服装', '服装');
INSERT INTO `hg_category` VALUES ('1256', '00000000000000001255', '男装', null);
INSERT INTO `hg_category` VALUES ('1257', '00000000000000001255', '女装', null);
INSERT INTO `hg_category` VALUES ('1258', '00000000000000001255', '童装', null);
INSERT INTO `hg_category` VALUES ('1259', '00000000000000001256', '正装', null);
INSERT INTO `hg_category` VALUES ('1262', '00000000000000001245', '冰箱', null);
INSERT INTO `hg_category` VALUES ('1268', '00000000000000000000', '车', '大众');
INSERT INTO `hg_category` VALUES ('1269', '00000000000000001268', '年轻人', '大众');
INSERT INTO `hg_category` VALUES ('1271', '00000000000000001269', '大众', '大众/大众');
INSERT INTO `hg_category` VALUES ('1272', '00000000000000001270', '丰田', null);
INSERT INTO `hg_category` VALUES ('1274', '00000000000000001269', '丰田', '大众/丰田');
INSERT INTO `hg_category` VALUES ('1275', '00000000000000001268', '老年人', '大众/老年人');
INSERT INTO `hg_category` VALUES ('1276', '00000000000000001275', '电动车', '大众/老年人/电动车');
-- ----------------------------
-- Table structure for hg_goods
-- ----------------------------
DROP TABLE IF EXISTS `hg_goods`;
CREATE TABLE `hg_goods` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`price` decimal(10,2) DEFAULT NULL,
`level` varchar(255) DEFAULT NULL,
`sum` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of hg_goods
-- ----------------------------
INSERT INTO `hg_goods` VALUES ('1', 'ccc', '108300.00', '砖石会员', '105300');
-- ----------------------------
-- Table structure for hg_sku
-- ----------------------------
DROP TABLE IF EXISTS `hg_sku`;
CREATE TABLE `hg_sku` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '商品id,同时也是商品编号',
`title` varchar(100) NOT NULL COMMENT '商品标题',
`sell_point` varchar(500) DEFAULT NULL COMMENT '商品卖点',
`price` decimal(20,2) NOT NULL DEFAULT '0.00' COMMENT '商品价格,单位为:元',
`stock_count` int(10) DEFAULT NULL COMMENT '库存数量',
`barcode` varchar(30) DEFAULT NULL COMMENT '商品条形码',
`image` varchar(2000) DEFAULT NULL COMMENT '商品图片',
`status` varchar(1) DEFAULT NULL COMMENT '商品状态,1-正常,2-下架,3-删除',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`cost_price` decimal(10,2) DEFAULT NULL COMMENT '成本价',
`market_price` decimal(10,2) DEFAULT NULL,
`spu_id` int(11) DEFAULT NULL,
`cart_thumbnail` varchar(150) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `status` (`status`),
KEY `updated` (`update_time`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8 COMMENT='商品表';
-- ----------------------------
-- Records of hg_sku
-- ----------------------------
INSERT INTO `hg_sku` VALUES ('1', 'IphonX XMD', '内存大,实用,贵贵,猴贵侯工嘎嘎发达的范德萨发撒打发打法阿道夫撒啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊', '8300.00', '95', 'XUSxxx001', 'd801dbca8e58947c.jpg', '1', '2019-11-14 15:48:41', '2019-11-21 15:48:45', '1000.00', '100.00', '1', 'd801dbca8e58947c.jpg');
INSERT INTO `hg_sku` VALUES ('2', 'IphonX XMD', '阿斯顿发生发射点理发卡打算离开房间啊但阿斯顿发大水发大水发射点发大水发大水发是', '8500.00', '0', null, '20200409/4495a8aa-bcad-448f-8db9-c58e198d2131.jpg', '0', '2019-11-20 11:03:03', '2020-04-09 18:14:47', null, null, '1', '20200409/77f5f508-7013-4e39-8938-98d6044d086f.jpg');
INSERT INTO `hg_sku` VALUES ('3', 'Redmi 8A 5000mAh', '骁龙八核处理器 AI人脸解锁 4GB+64GB 深海蓝 游戏老人手机 小米 红米', '699.00', '100', 'xxx001111', '8b167328e1dadff8.jpg', '1', '2019-11-21 15:05:46', '2019-11-21 15:05:50', '1000.00', '100.00', '3', '8b167328e1dadff8.jpg');
INSERT INTO `hg_sku` VALUES ('4', '劳弗 红米8/8A', '骁龙八核处理器 AI人脸解锁 4GB+64GB 深海蓝 游戏老人手机 小米 红米', '300.00', '100', 'xxx001112', '8b167328e1dadff8.jpg', '1', '2019-11-21 15:06:59', '2019-11-21 15:07:02', '1000.00', '100.00', '3', '8b167328e1dadff8.jp');
INSERT INTO `hg_sku` VALUES ('5', '华为(HUAWEI)Mate 30', '麒麟990旗舰芯片全网通双卡双模手机 罗兰紫 8GB+128GB【5G版', '4999.00', null, 'xxx001113', '5356c63b4bc1300a.jpg', '1', '2019-11-21 15:11:21', '2019-11-21 15:11:24', '1000.00', '100.00', '4', '5356c63b4bc1300a.jpg');
INSERT INTO `hg_sku` VALUES ('6', ' 华为 HUAWEI Mate30 Plus', '宝石蓝 全网通 四摄超清全面屏大电池 移动联通电信4G手机 双卡双待', '1099.00', '99', 'xxx001114', '5356c63b4bc1300a.jpg', '1', '2019-11-21 15:13:45', '2019-11-21 15:13:49', '100.00', '100.00', '4', '5356c63b4bc1300a.jpg');
INSERT INTO `hg_sku` VALUES ('7', '飞利浦(PHILIPS)E218L 炫舞红 ', '移动联通 翻盖老人手机 双卡双待老年机 学生备用功能机', '279.00', '0', null, '20200409/bf14c840-e542-45d5-9d15-225c855532c5.png', '0', '2019-11-21 15:19:25', '2020-04-09 18:16:27', null, null, '5', '20200409/f2ce7a6d-486f-43ef-b6d0-49609167e203.jpg');
INSERT INTO `hg_sku` VALUES ('8', '海信(Hisense)H55E3A 55英寸', '超高清4K HDR 金属背板 人工智能液晶电视机 丰富影视教育资源', '1999.00', '0', null, '20200409/793a6946-bd05-4b64-8c2b-e7fcbcdaed6e.jpg', '0', '2019-11-22 16:04:48', '2020-04-09 18:15:37', null, null, '6', '20200409/eff2932f-a82b-4150-9c73-e996f806181a.png');
INSERT INTO `hg_sku` VALUES ('9', '小米Red老年手机白色大屏', '高端大气上档次', '666.00', '0', null, '20200408/d9e5ed08-44d9-49ee-a116-7bab32f13238.jpg', '0', '2020-03-26 10:07:54', '2020-04-08 23:25:09', null, null, '9', '20200408/83b9a301-60f8-4c23-9f8b-99e442312740.jpg');
INSERT INTO `hg_sku` VALUES ('10', '我的手机', '好用', '0.00', null, null, null, null, null, null, null, null, '1', null);
INSERT INTO `hg_sku` VALUES ('11', '我的手机', '好用', '0.00', null, null, null, null, null, null, null, null, '1', null);
INSERT INTO `hg_sku` VALUES ('14', '我的手机', '好用', '0.00', null, null, null, null, null, null, null, null, '1', null);
INSERT INTO `hg_sku` VALUES ('15', '我的手机', '好用', '0.00', null, null, null, null, null, null, null, null, '1', null);
INSERT INTO `hg_sku` VALUES ('16', '我喜欢的手机', '非常的音乐好听', '0.00', null, null, null, null, null, null, null, null, '11', null);
INSERT INTO `hg_sku` VALUES ('17', '我的小米手机', '这款手机非常的漂亮', '2300.00', null, null, null, null, null, null, null, null, '1', null);
INSERT INTO `hg_sku` VALUES ('18', 'iphoneX 11', '好看', '10000.00', null, null, null, null, null, null, null, null, '1', null);
INSERT INTO `hg_sku` VALUES ('19', 'iphoneX 112', '丑陋无比', '3000.00', null, null, null, null, null, null, null, null, '1', null);
INSERT INTO `hg_sku` VALUES ('20', '小米手机Red 学生用', '适合玩游戏', '90000.00', null, null, null, null, null, null, null, null, '53', null);
INSERT INTO `hg_sku` VALUES ('21', '小米手机Red 老年用', '便宜 铃声巨大', '500.00', null, null, null, null, null, null, null, null, '53', null);
INSERT INTO `hg_sku` VALUES ('22', 'aa', '卖点', '199.00', '0', null, '20200408/efc2799c-1ba0-4d3c-85ef-97e314f4c4d4.jpg', '0', '2020-03-12 08:15:26', '2020-04-08 23:33:05', null, null, '74', '20200408/2619db87-7918-4b68-9a4b-ab2bcfc329fb.JPG');
INSERT INTO `hg_sku` VALUES ('23', '舒适大方', '结实 耐用', '245.00', '0', null, '20200408/67094c40-0505-4b81-b2f8-9a176e167228.jpg', '0', '2020-03-12 08:52:19', '2020-04-08 23:25:26', null, null, '74', '20200312/388e59a8-9ac6-4425-af4d-bc1d0bd5e6c1.jpg');
INSERT INTO `hg_sku` VALUES ('27', '111', '1111', '11111.00', '0', null, '', '1', '2020-04-09 19:07:45', '2020-04-09 19:07:45', null, null, '99', '');
INSERT INTO `hg_sku` VALUES ('28', '好看', '1', '100.00', '-1', null, '20200409/bafcb1b6-c7d2-4b16-a4e6-f8e106fa14b2.jpg', '1', '2020-04-09 19:11:22', '2020-04-09 19:11:22', null, null, '99', '20200409/3fc6117d-f5a0-4342-8aa4-77584fd13f95.jfif');
INSERT INTO `hg_sku` VALUES ('29', '1', '1', '150.00', '-3', null, '20200409/dbdfb44b-3d16-448a-8f84-11ddb8af7801.jpg', '0', '2020-04-09 19:12:25', '2020-04-09 20:01:11', null, null, '99', '20200409/30d0c444-7ecb-4704-9c1f-0ee6978e6823.gif');
INSERT INTO `hg_sku` VALUES ('30', '电脑', '400', '5000.00', '-1', null, '20200409/891e51ef-c32a-4200-9d42-be5405637e6f.png', '0', '2020-04-09 19:13:40', '2020-04-09 19:59:58', null, null, '98', '20200409/4ebf2827-181b-4302-8993-904355ed2e11.jpg');
INSERT INTO `hg_sku` VALUES ('31', '衣服', '4', '50.00', '-1', null, '20200409/68d2bd92-ab3e-497f-a1cd-092593387836.jpg', '1', '2020-04-09 19:14:25', '2020-04-09 19:14:25', null, null, '97', '20200409/eeea4ffb-0d12-47e1-abd7-accf303ca29d.jpg');
INSERT INTO `hg_sku` VALUES ('32', '新飞47', '高清 大屏', '4000.00', '-3', null, '20200409/2ce5fc63-02cd-4e93-8780-5c7208e284a2.png', '1', '2020-04-09 19:40:23', '2020-04-09 19:40:23', null, null, '85', '20200409/cd7bd480-5a0c-4203-8f3a-84ee1dad7fa6.jfif');
INSERT INTO `hg_sku` VALUES ('33', '衣服', '春季单品', '150.00', '-1', null, '20200409/8aec553c-f1fe-4ee1-b4ad-0c199654fc75.jpg', '1', '2020-04-09 19:43:28', '2020-04-09 19:43:28', null, null, '99', '20200409/d54fce4b-c2d7-4de0-bcac-3ae258bb17f6.jpg');
INSERT INTO `hg_sku` VALUES ('34', '半袖', '夏季单品', '50.00', '0', null, '20200409/5306b212-cc99-4387-837a-a2d5a48ed1c8.jpg', '1', '2020-04-09 19:50:25', '2020-04-09 19:50:25', null, null, '94', '20200409/981fbe43-fb36-469b-839a-fc6a70c4a9b3.jpg');
INSERT INTO `hg_sku` VALUES ('35', '华为p30', '200', '5000.00', '0', null, '20200409/933ed3e5-f5e7-4cbe-b7b3-73258a200420.jpg', '0', '2020-04-09 19:58:37', '2020-04-09 19:58:59', null, null, '90', '20200409/eb71e5c3-3850-4dff-a705-f0b5368cc9fa.jpg');
INSERT INTO `hg_sku` VALUES ('36', '西服', '100', '500.00', '0', null, '20200409/b9f378d9-e509-4e35-882f-fcab381627b6.jpg', '1', '2020-04-09 20:05:12', '2020-04-09 20:05:12', null, null, '84', '');
INSERT INTO `hg_sku` VALUES ('37', '衣服', '100', '500.00', '0', null, '20200409/54876c26-fb9f-445d-830d-1fd63c8ff8fa.jpg', '1', '2020-04-09 22:31:38', '2020-04-09 22:31:38', null, null, '75', '');
INSERT INTO `hg_sku` VALUES ('38', '衬衫', '衬衫', '120.00', '0', null, '20200413/4ffddcaa-a312-4d83-822d-1e0ded60fce3.jpg', '0', '2020-04-13 10:59:59', '2020-04-13 11:06:52', null, null, '74', null);
INSERT INTO `hg_sku` VALUES ('39', '测试', '测试', '100000.00', '-1', null, '20200413/5f7accc3-4e2b-4a44-874a-77c8701daa8b.jfif', '1', '2020-04-13 18:08:20', '2020-04-13 18:08:20', null, null, '100', '');
-- ----------------------------
-- Table structure for hg_sku_spec
-- ----------------------------
DROP TABLE IF EXISTS `hg_sku_spec`;
CREATE TABLE `hg_sku_spec` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sku_id` int(11) DEFAULT NULL,
`spec_id` int(11) DEFAULT NULL,
`spec_option_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of hg_sku_spec
-- ----------------------------
INSERT INTO `hg_sku_spec` VALUES ('1', '1', '3', '10');
INSERT INTO `hg_sku_spec` VALUES ('2', '1', '4', '8');
INSERT INTO `hg_sku_spec` VALUES ('5', '3', '3', '11');
INSERT INTO `hg_sku_spec` VALUES ('6', '3', '4', '7');
INSERT INTO `hg_sku_spec` VALUES ('7', '4', '3', '11');
INSERT INTO `hg_sku_spec` VALUES ('8', '4', '4', '7');
INSERT INTO `hg_sku_spec` VALUES ('9', '5', '3', '11');
INSERT INTO `hg_sku_spec` VALUES ('10', '5', '4', '7');
INSERT INTO `hg_sku_spec` VALUES ('11', '6', '3', '11');
INSERT INTO `hg_sku_spec` VALUES ('12', '6', '4', '7');
INSERT INTO `hg_sku_spec` VALUES ('15', '15', '7', '29');
INSERT INTO `hg_sku_spec` VALUES ('16', '15', '11', '64');
INSERT INTO `hg_sku_spec` VALUES ('17', '14', '7', '29');
INSERT INTO `hg_sku_spec` VALUES ('18', '14', '11', '64');
INSERT INTO `hg_sku_spec` VALUES ('19', '16', '2', '61');
INSERT INTO `hg_sku_spec` VALUES ('20', '16', '14', '45');
INSERT INTO `hg_sku_spec` VALUES ('21', '16', '11', '67');
INSERT INTO `hg_sku_spec` VALUES ('22', '17', '15', '65');
INSERT INTO `hg_sku_spec` VALUES ('23', '17', '11', '44');
INSERT INTO `hg_sku_spec` VALUES ('24', '18', '15', '62');
INSERT INTO `hg_sku_spec` VALUES ('25', '18', '2', '28');
INSERT INTO `hg_sku_spec` VALUES ('26', '19', '15', '64');
INSERT INTO `hg_sku_spec` VALUES ('27', '19', '11', '45');
INSERT INTO `hg_sku_spec` VALUES ('28', '20', '15', '65');
INSERT INTO `hg_sku_spec` VALUES ('29', '20', '11', '61');
INSERT INTO `hg_sku_spec` VALUES ('30', '21', '15', '67');
INSERT INTO `hg_sku_spec` VALUES ('31', '21', '11', '62');
INSERT INTO `hg_sku_spec` VALUES ('44', '9', '12', '40');
INSERT INTO `hg_sku_spec` VALUES ('45', '9', '2', '61');
INSERT INTO `hg_sku_spec` VALUES ('46', '23', '6', '27');
INSERT INTO `hg_sku_spec` VALUES ('47', '23', '12', '41');
INSERT INTO `hg_sku_spec` VALUES ('48', '23', '11', '67');
INSERT INTO `hg_sku_spec` VALUES ('49', '22', '12', '40');
INSERT INTO `hg_sku_spec` VALUES ('50', '22', '6', '27');
INSERT INTO `hg_sku_spec` VALUES ('51', '2', '20', '77');
INSERT INTO `hg_sku_spec` VALUES ('52', '8', '17', '50');
INSERT INTO `hg_sku_spec` VALUES ('53', '7', '8', '32');
INSERT INTO `hg_sku_spec` VALUES ('54', '27', '2', '61');
INSERT INTO `hg_sku_spec` VALUES ('55', '28', '12', '40');
INSERT INTO `hg_sku_spec` VALUES ('58', '31', '12', '39');
INSERT INTO `hg_sku_spec` VALUES ('59', '32', '21', '80');
INSERT INTO `hg_sku_spec` VALUES ('60', '32', '7', '29');
INSERT INTO `hg_sku_spec` VALUES ('61', '33', '21', '79');
INSERT INTO `hg_sku_spec` VALUES ('62', '33', '12', '39');
INSERT INTO `hg_sku_spec` VALUES ('65', '34', '11', '84');
INSERT INTO `hg_sku_spec` VALUES ('66', '34', '12', '39');
INSERT INTO `hg_sku_spec` VALUES ('71', '35', '20', '77');
INSERT INTO `hg_sku_spec` VALUES ('72', '35', '20', '77');
INSERT INTO `hg_sku_spec` VALUES ('73', '35', '11', '85');
INSERT INTO `hg_sku_spec` VALUES ('74', '35', '11', '85');
INSERT INTO `hg_sku_spec` VALUES ('77', '30', '7', '29');
INSERT INTO `hg_sku_spec` VALUES ('78', '30', '21', '80');
INSERT INTO `hg_sku_spec` VALUES ('79', '29', '11', '85');
INSERT INTO `hg_sku_spec` VALUES ('80', '29', '11', '86');
INSERT INTO `hg_sku_spec` VALUES ('81', '36', '21', '79');
INSERT INTO `hg_sku_spec` VALUES ('82', '36', '12', '41');
INSERT INTO `hg_sku_spec` VALUES ('83', '37', '11', '86');
INSERT INTO `hg_sku_spec` VALUES ('84', '37', '12', '40');
INSERT INTO `hg_sku_spec` VALUES ('89', '38', '11', '85');
INSERT INTO `hg_sku_spec` VALUES ('90', '38', '12', '41');
INSERT INTO `hg_sku_spec` VALUES ('91', '39', '2', '63');
INSERT INTO `hg_sku_spec` VALUES ('92', '39', '21', '81');
INSERT INTO `hg_sku_spec` VALUES ('93', '39', '22', '83');
-- ----------------------------
-- Table structure for hg_spec
-- ----------------------------
DROP TABLE IF EXISTS `hg_spec`;
CREATE TABLE `hg_spec` (
`id` int(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`spec_name` varchar(255) DEFAULT NULL COMMENT '名称',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of hg_spec
-- ----------------------------
INSERT INTO `hg_spec` VALUES ('2', '体积');
INSERT INTO `hg_spec` VALUES ('7', '功率');
INSERT INTO `hg_spec` VALUES ('11', '颜色');
INSERT INTO `hg_spec` VALUES ('12', '衣服尺码');
INSERT INTO `hg_spec` VALUES ('17', '功率22');
INSERT INTO `hg_spec` VALUES ('20', '内存');
INSERT INTO `hg_spec` VALUES ('21', '价格');
INSERT INTO `hg_spec` VALUES ('22', '速度');
-- ----------------------------
-- Table structure for hg_spec_option
-- ----------------------------
DROP TABLE IF EXISTS `hg_spec_option`;
CREATE TABLE `hg_spec_option` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '规格项ID',
`option_name` varchar(200) DEFAULT NULL COMMENT '规格项名称',
`spec_id` int(11) DEFAULT NULL COMMENT '规格ID',
`orders` int(11) DEFAULT NULL COMMENT '排序值',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of hg_spec_option
-- ----------------------------
INSERT INTO `hg_spec_option` VALUES ('11', '8GB', null, null);
INSERT INTO `hg_spec_option` VALUES ('28', '40W', '7', null);
INSERT INTO `hg_spec_option` VALUES ('29', '100W', '7', null);
INSERT INTO `hg_spec_option` VALUES ('39', '42', '12', '0');
INSERT INTO `hg_spec_option` VALUES ('40', '48', '12', '0');
INSERT INTO `hg_spec_option` VALUES ('41', '50', '12', '0');
INSERT INTO `hg_spec_option` VALUES ('46', '', '15', '0');
INSERT INTO `hg_spec_option` VALUES ('50', '999', '17', '0');
INSERT INTO `hg_spec_option` VALUES ('51', '777', '17', '0');
INSERT INTO `hg_spec_option` VALUES ('61', '100ml', '2', '0');
INSERT INTO `hg_spec_option` VALUES ('62', '300ml', '2', '0');
INSERT INTO `hg_spec_option` VALUES ('63', '6L', '2', '0');
INSERT INTO `hg_spec_option` VALUES ('75', '16g', '20', '1');
INSERT INTO `hg_spec_option` VALUES ('76', '64g', '20', '2');
INSERT INTO `hg_spec_option` VALUES ('77', '128', '20', '3');
INSERT INTO `hg_spec_option` VALUES ('78', '0-100', '21', '1');
INSERT INTO `hg_spec_option` VALUES ('79', '100-1000', '21', '2');
INSERT INTO `hg_spec_option` VALUES ('80', '1000-10000', '21', '3');
INSERT INTO `hg_spec_option` VALUES ('81', '10000-100000', '21', '4');
INSERT INTO `hg_spec_option` VALUES ('82', '8km/min', '22', '1');
INSERT INTO `hg_spec_option` VALUES ('83', '80km/min', '22', '2');
INSERT INTO `hg_spec_option` VALUES ('84', '金属黑', '11', '0');
INSERT INTO `hg_spec_option` VALUES ('85', '宝石蓝', '11', '0');
INSERT INTO `hg_spec_option` VALUES ('86', '玫瑰金', '11', '0');
INSERT INTO `hg_spec_option` VALUES ('87', '罗兰紫', '11', '0');
-- ----------------------------
-- Table structure for hg_spu
-- ----------------------------
DROP TABLE IF EXISTS `hg_spu`;
CREATE TABLE `hg_spu` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`goods_name` varchar(100) DEFAULT NULL COMMENT 'SPU名',
`is_marketable` varchar(1) DEFAULT NULL COMMENT '是否上架',
`brand_id` int(11) DEFAULT NULL COMMENT '品牌',
`caption` varchar(100) DEFAULT NULL COMMENT '副标题',
`category_id` int(11) DEFAULT NULL COMMENT '一级类目',
`small_pic` varchar(150) DEFAULT NULL COMMENT '小图',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=105 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of hg_spu
-- ----------------------------
INSERT INTO `hg_spu` VALUES ('1', 'iPhone X', '1', '3', null, '1243', null);
INSERT INTO `hg_spu` VALUES ('3', 'Redmi', '1', '2', null, '1243', null);
INSERT INTO `hg_spu` VALUES ('4', '华为Mat30', '1', '4', null, '1243', null);
INSERT INTO `hg_spu` VALUES ('5', '飞利浦(PHILIPS)E218L', '1', '2', null, '1244', null);
INSERT INTO `hg_spu` VALUES ('6', '海信(Hisense)', '1', '5', null, '1246', null);
INSERT INTO `hg_spu` VALUES ('7', 'p50', null, '4', '华为高端手机', '1243', 'fde0251c-ab66-4fa8-9f9c-29753ea9fdc6_3.jpg');
INSERT INTO `hg_spu` VALUES ('8', 'VIVO X6 ', null, '4', 'vivo 拍照手机', '1243', 'b68bafcf-081d-45b8-a78a-565409567efe_4.jpg');
INSERT INTO `hg_spu` VALUES ('9', '小米REd6', null, '2', '红米 老年手机', '1244', '');
INSERT INTO `hg_spu` VALUES ('10', '手机', null, '5', '好手机', '1243', null);
INSERT INTO `hg_spu` VALUES ('11', '手机', null, '5', '好手机', '1243', '20200309/9260d06d-6815-484e-a5b2-1d1fc86d0450.jpg');
INSERT INTO `hg_spu` VALUES ('41', 'test222zz', null, '2', 'wweee', '1246', '20200309/99ac088d-1da5-49e4-81af-e429b74029b9.out');
INSERT INTO `hg_spu` VALUES ('42', '小米电脑', null, '2', '小米商务笔记本P50', '1246', '20200311/7d10c43a-d408-44f9-9060-57e4182a5fea.jpg');
INSERT INTO `hg_spu` VALUES ('43', '华为笔记本电脑', null, '4', '华为笔记本电脑P70', '1253', '20200311/bdb1a49e-8f71-4007-bfcb-f9ed47acc358.jpg');
INSERT INTO `hg_spu` VALUES ('44', '华为笔记本商务电脑', null, '4', '华为笔记本电脑P80', '1253', '20200311/1ac80186-8eeb-4d09-b605-f5ca1d04d094.jpg');
INSERT INTO `hg_spu` VALUES ('46', '华为休闲商务', null, '4', '华为LV490', '1246', '20200311/6dd7f79e-f99c-4ec7-b15b-7aef55ab5d28.jpg');
INSERT INTO `hg_spu` VALUES ('47', '小米手机', null, '2', '小米Mate0', '1243', '20200311/9e9afc3a-4631-48c1-b054-1aa923fef0f8.jpg');
INSERT INTO `hg_spu` VALUES ('48', '小米手机Note', null, '2', '小米Mate0Note', '1243', '20200311/c92941b1-6f74-4a11-aa56-1fed20f9b3bb.jpg');
INSERT INTO `hg_spu` VALUES ('53', '小米手机Red', null, '2', '小米红米', '1247', '20200311/38d6aa3d-f910-462e-a10a-ca3274eafbe4.jpg');
INSERT INTO `hg_spu` VALUES ('74', '杉杉衬衫22', null, '6', '改好了?这是一款很好的高级衬衫,防止缩水', '1243', '20200311/8b2aa9ae-bd10-4189-a8e4-398b45680ca2.jpg');
INSERT INTO `hg_spu` VALUES ('75', '非常好看的衣服', null, '6', '这个部分的东西可以完全省略掉', '1243', '20200409/f5642e32-b0ec-4f64-865b-d3178a721723.jpg');
INSERT INTO `hg_spu` VALUES ('84', '红豆西服', null, '4', '成功男士的首选西装', '1259', '20200409/6f4cd7a7-b249-4f7e-b68a-6f9273171606.jpg');
INSERT INTO `hg_spu` VALUES ('85', '新飞47', '1', '5', '清新 大屏', '1246', '20200409/17efee26-c480-46eb-a281-385b78dab66e.jpg');
INSERT INTO `hg_spu` VALUES ('88', '大众v7', '1', '5', '安全 性能好', '1246', '20200409/f536f9a2-2486-41b1-820a-fe87914cb344.png');
INSERT INTO `hg_spu` VALUES ('90', '华为p30', '1', '4', '手机降价', '1243', '20200409/c593ac53-f571-4992-9444-188bbbac9dc7.jpg');
INSERT INTO `hg_spu` VALUES ('94', '半袖', '1', '8', '便宜甩卖', '1257', '20200409/4c89336a-32ed-4255-88d9-1863f59b341d.jpg');
INSERT INTO `hg_spu` VALUES ('97', '夏季美人装', '1', '5', '非常漂亮 迷人', '1257', '20200409/2bf1b831-b6fa-4176-9e05-3e573d0b70af.jpg');
INSERT INTO `hg_spu` VALUES ('98', '小新超', '1', '2', '电脑/学习', '1243', '20200409/98b7aca3-ca8f-4c26-8d7e-0b82b0da94ad.jpg');
INSERT INTO `hg_spu` VALUES ('99', '背带裤', '1', '8', '背带裤/好看', '1257', '20200409/9437190f-4941-433a-aa7e-eab07cdbe1a2.jpg');
INSERT INTO `hg_spu` VALUES ('100', 'ceshi shangping', '1', '9', 'test caption', '1271', '20200413/eec28058-c480-4079-b349-6b57f8309355.jfif');
INSERT INTO `hg_spu` VALUES ('104', 'ceshi shangping', null, '1', 'test caption', '10', null);
-- ----------------------------
-- Table structure for hg_user
-- ----------------------------
DROP TABLE IF EXISTS `hg_user`;
CREATE TABLE `hg_user` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(20) DEFAULT NULL,
`password` varchar(60) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
`email` varchar(30) DEFAULT NULL,
`telephone` varchar(20) DEFAULT NULL,
`birthday` date DEFAULT NULL,
`sex` varchar(10) DEFAULT NULL,
`state` int(11) DEFAULT NULL,
`code` varchar(64) DEFAULT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of hg_user
-- ----------------------------
INSERT INTO `hg_user` VALUES ('1', 'chj', '123', '李四', 'chj@qq.com', null, '2019-11-07', null, null, null);
INSERT INTO `hg_user` VALUES ('2', 'chjx', '123', '李伟', 'lisi@qq.com', null, '2019-11-05', null, null, null);
INSERT INTO `hg_user` VALUES ('7', 'chjy', '123', '李达', null, null, null, null, null, null);
INSERT INTO `hg_user` VALUES ('9', 'zhangsan', 'e10adc3949ba59abbe56e057f20f883e', '张三', 'zhuag@sohu.com', '13683679291', null, '0', '0', null);
INSERT INTO `hg_user` VALUES ('10', 'bbb', '123', null, null, null, null, null, null, null);
INSERT INTO `hg_user` VALUES ('11', 'ccc', '60a12c45c664f9c3a488561930d09a82', null, null, null, null, null, null, null);
| true |
088ac3bde4fce38eae68c83c278ba297d09f1b5b | SQL | Riceyo/QA-Consulting-ONS-Academy | /PL SQL/procedure_type_output.sql | UTF-8 | 254 | 2.5625 | 3 | [] | no_license | create or replace procedure selectproduct(id in number)
is
name products.name % type;
begin
select name into name
from products
where productid = id;
dbms_output.put_line(name);
end;
set serveroutput on
execute selectproduct(301); | true |
3bb82b6895626d2a790e0802fbb1870036969a8e | SQL | AmjadMKhan/AnalyticsPipeline | /Develop/05 Data Exploration with SQLOD.sql | UTF-8 | 261 | 2.5625 | 3 | [] | no_license | SELECT
TOP 100 *
FROM
OPENROWSET(
BULK 'https://<storage_Account>.dfs.core.windows.net/<container_name>/<folder_path>/OrdersByState/part-00000-83ea4f3d-173b-413e-9b7e-45959f6b78d0-c000.snappy.parquet',
FORMAT='PARQUET'
) AS [result]
| true |
7cf1028b3f740d6249e90a90db44bf53bc4e9dd3 | SQL | stefanpfriend/Tournament-Capstone | /java/database/schema.sql | UTF-8 | 5,177 | 3.96875 | 4 | [] | no_license | BEGIN TRANSACTION;
DROP TABLE IF EXISTS team_games, tournament_games, tournament_teams, team_player, invited_players;
DROP TABLE IF EXISTS users , tournaments , games , matches , teams;
DROP SEQUENCE IF EXISTS seq_user_id;
CREATE SEQUENCE seq_user_id
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--TABLE CREATION
CREATE TABLE users (
user_id int DEFAULT nextval('seq_user_id'::regclass) NOT NULL,
username varchar(50) NOT NULL,
password_hash varchar(200) NOT NULL,
role varchar(50) NOT NULL,
CONSTRAINT PK_user PRIMARY KEY (user_id)
);
CREATE TABLE tournaments(
tournament_name varchar(64) NOT NULL,
tournament_id serial NOT NULL,
start_date timestamp ,
number_of_participants int NOT NULL,
team_id serial ,
ranking_of_teams int ,
CONSTRAINT PK_tournament_id PRIMARY KEY (tournament_id)
);
CREATE TABLE teams(
team_name varchar(64) NOT NULL,
team_id serial ,
CONSTRAINT PK_team_id_id PRIMARY KEY (team_id)
);
CREATE TABLE games(
game_name varchar(32) NOT NULL,
game_id serial NOT NULL,
start_time timestamp NOT NULL,
organizer varchar(32) NOT NULL,
number_of_players int NOT NULL,
winning_team int ,
CONSTRAINT FK_winning_team FOREIGN KEY (winning_team) REFERENCES teams(team_id),
CONSTRAINT PK_game_id PRIMARY KEY (game_id)
);
CREATE TABLE team_games(
team_id int,
game_id int,
round_number int,
CONSTRAINT PK_team_id_game_id_round_number PRIMARY KEY (team_id, game_id, round_number),
CONSTRAINT FK_team_id_id FOREIGN KEY (team_id) REFERENCES teams(team_id),
CONSTRAINT FK_game_id FOREIGN KEY (game_Id) REFERENCES games(game_id)
);
CREATE TABLE team_player(
user_id int,
team_id int,
CONSTRAINT PK_user_id_team_id PRIMARY KEY (team_id, user_id),
CONSTRAINT FK_user_id FOREIGN KEY (user_id) REFERENCES users(user_id),
CONSTRAINT FK_team_id FOREIGN KEY (team_id) REFERENCES teams(team_id)
);
CREATE TABLE tournament_games(
tournament_id int,
game_id int,
CONSTRAINT pk_tournament_id_game_id PRIMARY KEY (tournament_id, game_id),
CONSTRAINT FK_tournament_id_id FOREIGN KEY (tournament_id) REFERENCES tournaments(tournament_id),
CONSTRAINT FK_game_id_i FOREIGN KEY (game_Id) REFERENCES games(game_id)
);
CREATE TABLE tournament_teams(
team_id int,
tournament_id int,
CONSTRAINT PK_team_id_tournament_id PRIMARY KEY (team_id, tournament_id),
CONSTRAINT FK_team_id_id FOREIGN KEY (team_id) REFERENCES teams(team_id),
CONSTRAINT FK_tournament_id FOREIGN KEY (tournament_id) REFERENCES tournaments(tournament_id)
);
CREATE TABLE invited_players(
invite_id serial,
inviter_id int,
invited_id int,
isHost boolean DEFAULT false,
CONSTRAINT PK_invite_id_id PRIMARY KEY (invite_id),
CONSTRAINT FK_inviter_id_id FOREIGN KEY (inviter_id) REFERENCES users(user_id),
CONSTRAINT FK_invited_id_id FOREIGN KEY (invited_id) REFERENCES users(user_id)
);
SELECT * FROM games;
-- INSERT STATEMENTS
INSERT INTO users (username,password_hash,role) VALUES ('user','$2a$08$UkVvwpULis18S19S5pZFn.YHPZt3oaqHZnDwqbCW9pft6uFtkXKDC','ROLE_USER');
INSERT INTO users (username,password_hash,role) VALUES ('admin','$2a$08$UkVvwpULis18S19S5pZFn.YHPZt3oaqHZnDwqbCW9pft6uFtkXKDC','ROLE_ADMIN');
-- SELECT STATEMENTS
SELECT * FROM users;
SELECT * FROM tournaments;
SELECT * FROM games;
SELECT * FROM team;
INSERT INTO invited_players(inviter_id, invited_id) (
SELECT
(SELECT user_id FROM users WHERE user_id = 1),
(SELECT user_id FROM users WHERE user_id = 2)
);
GRANT ALL
ON ALL TABLES IN SCHEMA public
TO final_capstone_owner;
GRANT ALL
ON ALL SEQUENCES IN SCHEMA public
TO final_capstone_owner;
GRANT SELECT, INSERT, UPDATE, DELETE
ON ALL TABLES IN SCHEMA public
TO final_capstone_appuser;
GRANT USAGE, SELECT
ON ALL SEQUENCES IN SCHEMA public
TO final_capstone_appuser;
select username from users;
--MAY NEED
--ALTER TABLE
-- constraint name constraint-type columns value
--ADD CONSTRAINT pk_person_address PRIMARY KEY (person_id,address_id);
COMMIT TRANSACTION;
| true |
7f2b6dbdc4452a328774a572c595c204b4468ba3 | SQL | laryseptisarim/Project | /laravel.sql | UTF-8 | 13,350 | 3.03125 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 19 Jun 2021 pada 09.03
-- Versi server: 10.4.17-MariaDB
-- Versi PHP: 8.0.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `laravel`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `failed_jobs`
--
CREATE TABLE `failed_jobs` (
`id` bigint(20) UNSIGNED 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;
-- --------------------------------------------------------
--
-- Struktur dari tabel `guru`
--
CREATE TABLE `guru` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`jenis_kelamin` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`nik` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`jabatan` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`tmptlahir` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`tgllahir` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`alamat` text COLLATE utf8mb4_unicode_ci NOT NULL,
`telp` varchar(17) 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 untuk tabel `guru`
--
INSERT INTO `guru` (`id`, `name`, `jenis_kelamin`, `nik`, `jabatan`, `tmptlahir`, `tgllahir`, `alamat`, `telp`, `created_at`, `updated_at`) VALUES
(1, 'ajeng', 'L', '73789758050', 'wakasek', 'Makassar', '11 September 1986', 'Berua', '08976743553570', '2021-05-27 12:52:08', '2021-06-11 22:55:11');
-- --------------------------------------------------------
--
-- Struktur dari tabel `jurusan`
--
CREATE TABLE `jurusan` (
`id` bigint(20) UNSIGNED NOT NULL,
`nama` 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 untuk tabel `jurusan`
--
INSERT INTO `jurusan` (`id`, `nama`, `created_at`, `updated_at`) VALUES
(1, 'Perhotelan', NULL, NULL),
(2, 'Perkantoran', NULL, NULL),
(3, 'TKJ', NULL, NULL),
(4, 'Akuntansi', NULL, NULL);
-- --------------------------------------------------------
--
-- Struktur dari tabel `kelas`
--
CREATE TABLE `kelas` (
`id_kelas` int(11) NOT NULL,
`jurusan` varchar(100) NOT NULL,
`kelas` varchar(30) NOT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
`update_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `kelas`
--
INSERT INTO `kelas` (`id_kelas`, `jurusan`, `kelas`, `created_at`, `update_at`) VALUES
(1, 'TKJ', 'X', '2021-06-12 06:46:57', NULL),
(2, 'TKJ', 'XI', '2021-06-12 06:48:04', NULL),
(3, 'TKJ', 'XI', '2021-06-12 06:48:56', NULL);
-- --------------------------------------------------------
--
-- Struktur dari tabel `mapel`
--
CREATE TABLE `mapel` (
`id` bigint(20) UNSIGNED NOT NULL,
`mapel` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`guru` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`kelas` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`jurusan` varchar(100) 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 untuk tabel `mapel`
--
INSERT INTO `mapel` (`id`, `mapel`, `guru`, `kelas`, `jurusan`, `created_at`, `updated_at`) VALUES
(1, 'Sistem Komputer', 'Rosita Tampang, S.Kom', 'X', 'TJK (Teknik Komputer Jaringan)', '2021-06-11 23:11:02', '2021-06-11 22:48:06'),
(7, 'Sistem Komputer', 'Rosita Tampang, S.Kom', 'X', 'TJK (Teknik Komputer Jaringan)', '2021-06-11 22:47:33', '2021-06-11 22:47:33');
-- --------------------------------------------------------
--
-- Struktur dari tabel `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 untuk tabel `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_27_210206_create_user_table', 1),
(5, '2021_05_27_204734_create_user_table', 2),
(6, '2021_05_27_205532_create_siswa_table', 3),
(7, '2021_05_27_211806_create_guru_table', 4),
(8, '2021_06_12_065326_create_tkj10_table', 5),
(9, '2021_06_12_073637_create_mapel_table', 6),
(11, '2021_06_12_064903_create_jurusan_table', 7),
(12, '2021_06_12_065638_create_siswa_table', 7);
-- --------------------------------------------------------
--
-- Struktur dari tabel `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;
-- --------------------------------------------------------
--
-- Struktur dari tabel `siswa`
--
CREATE TABLE `siswa` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`jenis_kelamin` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`nis` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`agama` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`tmptlahir` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`tgllahir` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`alamat` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`telp` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`kelas` enum('X','XI','XII') COLLATE utf8mb4_unicode_ci NOT NULL,
`id_jurusan` bigint(20) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data untuk tabel `siswa`
--
INSERT INTO `siswa` (`id`, `name`, `jenis_kelamin`, `nis`, `agama`, `tmptlahir`, `tgllahir`, `alamat`, `telp`, `kelas`, `id_jurusan`, `created_at`, `updated_at`) VALUES
(1, 'Awal', 'L', '9976831164', 'Islam', 'Makassar', '01-01-1990', 'Sudiang', '08898989990', 'XI', 1, NULL, NULL);
-- --------------------------------------------------------
--
-- Struktur dari tabel `tkj10`
--
CREATE TABLE `tkj10` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`jenis_kelamin` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`nis` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`agama` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`tmptlahir` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`tgllahir` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`alamat` text COLLATE utf8mb4_unicode_ci NOT NULL,
`telp` varchar(17) 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 untuk tabel `tkj10`
--
INSERT INTO `tkj10` (`id`, `name`, `jenis_kelamin`, `nis`, `agama`, `tmptlahir`, `tgllahir`, `alamat`, `telp`, `created_at`, `updated_at`) VALUES
(1, 'sari', 'P', '999977857464', 'Islam', 'Makassar', '2021-06-12', 'Berua', '223', '2021-06-11 23:01:14', '2021-06-11 23:09:29'),
(2, 'Indah', 'P', '999977857464', 'Kristen', 'Makassar', '2000-03-03', 'Mangga 3', '08968794535', '2021-06-11 22:49:46', '2021-06-11 22:49:46'),
(3, 'Lary Septisari Malajong', 'P', '999977857464', 'Islam', 'Makassar', '2004-09-11', 'Berua', '08976743553570', '2021-06-18 23:04:47', '2021-06-18 23:04:47'),
(4, 'Lary Septisari Malajong', 'P', '999977857464', 'Islam', 'Makassar', '2004-09-11', 'Berua', '08976743553570', '2021-06-18 23:06:59', '2021-06-18 23:06:59'),
(5, 'Lary Septisari Malajong', 'P', '999977857464', 'Islam', 'Makassar', '2004-09-11', 'Berua', '08976743553570', '2021-06-18 23:08:15', '2021-06-18 23:08:15');
-- --------------------------------------------------------
--
-- Struktur dari tabel `user`
--
CREATE TABLE `user` (
`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;
-- --------------------------------------------------------
--
-- Struktur dari tabel `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;
--
-- Dumping data untuk tabel `users`
--
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
(1, 'Admin', 'lerilucu@gmail.com', NULL, '$2y$10$XXMzwB1v14Cr5dorLxbedesDy9ZTwenQv7HWZ/J76xAPpT.h5Ygde', NULL, '2021-05-27 13:01:48', '2021-05-27 13:01:48');
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `failed_jobs`
--
ALTER TABLE `failed_jobs`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `guru`
--
ALTER TABLE `guru`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `jurusan`
--
ALTER TABLE `jurusan`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `kelas`
--
ALTER TABLE `kelas`
ADD PRIMARY KEY (`id_kelas`);
--
-- Indeks untuk tabel `mapel`
--
ALTER TABLE `mapel`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`);
--
-- Indeks untuk tabel `siswa`
--
ALTER TABLE `siswa`
ADD PRIMARY KEY (`id`),
ADD KEY `siswa_id_jurusan_foreign` (`id_jurusan`);
--
-- Indeks untuk tabel `tkj10`
--
ALTER TABLE `tkj10`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `user_email_unique` (`email`);
--
-- Indeks untuk tabel `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT untuk tabel yang dibuang
--
--
-- AUTO_INCREMENT untuk tabel `failed_jobs`
--
ALTER TABLE `failed_jobs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT untuk tabel `guru`
--
ALTER TABLE `guru`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT untuk tabel `jurusan`
--
ALTER TABLE `jurusan`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT untuk tabel `kelas`
--
ALTER TABLE `kelas`
MODIFY `id_kelas` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT untuk tabel `mapel`
--
ALTER TABLE `mapel`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT untuk tabel `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- AUTO_INCREMENT untuk tabel `siswa`
--
ALTER TABLE `siswa`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT untuk tabel `tkj10`
--
ALTER TABLE `tkj10`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT untuk tabel `user`
--
ALTER TABLE `user`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT untuk tabel `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
--
--
-- Ketidakleluasaan untuk tabel `siswa`
--
ALTER TABLE `siswa`
ADD CONSTRAINT `siswa_id_jurusan_foreign` FOREIGN KEY (`id_jurusan`) REFERENCES `jurusan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
482275d6a88bf5345313735ab10ace5c8abec097 | SQL | eainfo/teste-sistemacadastro | /DBSISTEMACADASTRO.sql | UTF-8 | 4,298 | 3.21875 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 8.0.16, for Win64 (x86_64)
--
-- Host: localhost Database: login
-- ------------------------------------------------------
-- Server version 5.7.26-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
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 `categoria_cursos`
--
DROP TABLE IF EXISTS `categoria_cursos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `categoria_cursos` (
`COD_CATEGORIA_CURSO` int(11) NOT NULL AUTO_INCREMENT,
`DESCRICAO` varchar(45) DEFAULT NULL,
PRIMARY KEY (`COD_CATEGORIA_CURSO`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `categoria_cursos`
--
LOCK TABLES `categoria_cursos` WRITE;
/*!40000 ALTER TABLE `categoria_cursos` DISABLE KEYS */;
INSERT INTO `categoria_cursos` VALUES (1,'Comportamental'),(2,'Programacao'),(3,'Qualidade');
/*!40000 ALTER TABLE `categoria_cursos` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `cursos`
--
DROP TABLE IF EXISTS `cursos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `cursos` (
`COD_CURSO` int(11) NOT NULL AUTO_INCREMENT,
`DESCRICAO_ASSUNTO` varchar(100) NOT NULL,
`COD_CATEGORIA_CURSO` int(11) NOT NULL,
`QTD_ALUNOS` varchar(45) DEFAULT NULL,
`DATA_INICIO` date DEFAULT NULL,
`DATA_TERMINO` date DEFAULT NULL,
PRIMARY KEY (`COD_CURSO`),
KEY `FK_COD_CATEGORIA_CURSO_idx` (`COD_CATEGORIA_CURSO`),
CONSTRAINT `FK_COD_CATEGORIA_CURSO` FOREIGN KEY (`COD_CATEGORIA_CURSO`) REFERENCES `categoria_cursos` (`COD_CATEGORIA_CURSO`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `cursos`
--
LOCK TABLES `cursos` WRITE;
/*!40000 ALTER TABLE `cursos` DISABLE KEYS */;
INSERT INTO `cursos` VALUES (8,'QUALIDADE',3,'50','2020-03-23','2020-05-31');
/*!40000 ALTER TABLE `cursos` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `usuario`
--
DROP TABLE IF EXISTS `usuario`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `usuario` (
`usuario_id` int(11) NOT NULL AUTO_INCREMENT,
`usuario` varchar(200) NOT NULL,
`senha` varchar(32) NOT NULL,
`nome` varchar(100) NOT NULL,
`data_cadastro` datetime NOT NULL,
PRIMARY KEY (`usuario_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `usuario`
--
LOCK TABLES `usuario` WRITE;
/*!40000 ALTER TABLE `usuario` DISABLE KEYS */;
INSERT INTO `usuario` VALUES (1,'eliel.souza','5acc5f31e975731a8bc4c3061835a487','ELIEL PEREIRA DE SOUZA','2020-03-21 21:25:19'),(2,'amanda.martins','202cb962ac59075b964b07152d234b70','Amanda MARIANO MARTINS DE SOUZA','2020-03-22 11:05:46'),(5,'pedro','202cb962ac59075b964b07152d234b70','Pedro Silva','2020-03-22 13:20:25'),(6,'daniel.souza','5acc5f31e975731a8bc4c3061835a487','daniel','2020-03-23 00:43:51');
/*!40000 ALTER TABLE `usuario` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2020-03-23 1:03:23
| true |
c4df655919c29b067b520cafe9bf657e6fb25ad4 | SQL | davay521/IS362_Assignment-1- | /Assignment #1 .sql | UTF-8 | 1,096 | 3.875 | 4 | [] | no_license |
#Part 1
#Question 1
Select count(speed),min(speed) as 'Minimum Distance' ,max(speed) as 'Maximum distance' from planes;
#Question 2
select sum(distance) as 'Total distance' from flights
Where year ='2013' and month ='1';
#Question 3
Select planes. manufacturer, sum(flights.distance)
From flights
Inner join planes
on planes.tailnum =flights.tailnum
where flights.year = '2013'and flights.month ='7' and flights.day ='5'
group by planes.manufacturer;
#Question 4
# How many American Airlines flights came out of Newark(EWR)
#in January of 2013 where the Temperatures was 32 degrees?
Select carrier, count(carrier) as 'Number of flights' from flights
join planes
on planes.tailnum = flights.tailnum
join weather
on flights.origin = weather.origin
where carrier = 'AA' AND flights.origin ='EWR'and weather.year = '2013' and weather.month ='1' and weather.temp ='32';
#part 2
Select dep_delay from flights
where origin ='ewr'and origin ='LGA' AND origin ='JFK'
INTO outfile '/users/davidvayman/desktop/avgDelays.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'; | true |
d3d56f3c700262495ba4c556fada9a08b1a4f3f9 | SQL | l09benavides/webserver | /db.sql | UTF-8 | 1,369 | 3.3125 | 3 | [] | no_license | create table tbl_roles (
id INT(10) AUTO_INCREMENT,
nombre VARCHAR(10),
descripcion VARCHAR(100),
Primary key(id)
);
create table tbl_usuario (
id INT(10) AUTO_INCREMENT,
cedula VARCHAR(10),
nombre VARCHAR(50),
apellidos VARCHAR(50),
telefono VARCHAR(10),
email VARCHAR(50),
usuario VARCHAR(50),
password VARCHAR(15),
id_rol INT(10),
Primary key(id),
constraint unq_Ced_email Unique(cedula,email),
constraint fk_id_rol foreign key (id_rol) references tbl_roles(id)
);
create table tbl_articulo (
id INT(10) AUTO_INCREMENT,
codigo VARCHAR(10),
marca VARCHAR(45),
descripcion VARCHAR(100),
precio DOUBLE,
cantidad INT(10),
Primary key(id)
);
create table tbl_compra (
id INT(10) AUTO_INCREMENT,
id_usuario INT(10),
num_factura INT(10),
fecha_compra DateTime,
Primary key(id),
constraint fk_id_usuario foreign key (id_usuario) references tbl_usuario(id)
);
create table tbl_compra_detalle (
id INT(10) AUTO_INCREMENT,
id_compra INT(10),
id_articulo INT(10),
cantidad INT(10),
Primary key(id),
constraint fk_id_compra foreign key (id_compra) references tbl_compra(id),
constraint fx_id_articulo foreign key (id_articulo) references tbl_articulo(id)
);
insert into tbl_roles (nombre,descripcion) values ("Admin","");
insert into tbl_roles (nombre,descripcion) values ("User","");
insert into tbl_usuario (usuario,password,id_rol) values ("luis","1234",1);
| true |
5d55043b277931d70bb90a784759278d9866e887 | SQL | ferdn4ndo/infotrem | /legacy/trem_db/tblFerroviaVagaoManga.sql | UTF-8 | 1,130 | 3.375 | 3 | [
"MIT"
] | permissive | # tblFerroviaVagaoManga
#
# DESC: Tabela de armazenamento das mangas dos vagões das ferrovias
# TODO: -
# NOTES: -
#
DROP TABLE IF EXISTS tblFerroviaVagaoManga;
CREATE TABLE tblFerroviaVagaoManga (
CodFerroviaVagaoManga INT(8) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Código de indexação',
LetraVagaoMangaMetrica VARCHAR(1) NULL COMMENT 'Letra da manga na bitola métrica',
LetraVagaoMangaLarga VARCHAR(1) NULL COMMENT 'Letra da manga na bitola larga',
PesoMaximoTon INT(5) NULL COMMENT 'Peso máximo em centenas de quilos da bitola',
Ativo BOOLEAN NOT NULL DEFAULT TRUE COMMENT 'Se o registro está ativo'
) Engine = MyISAM DEFAULT CHARSET = utf8mb4 COMMENT = 'Tabela de armazenamento das mangas dos vagões das ferrovias';
INSERT INTO tblFerroviaVagaoManga (CodFerroviaVagaoManga, LetraVagaoMangaMetrica, LetraVagaoMangaLarga, PesoMaximoTon, Ativo) VALUES
(1, 'A', NULL, 300, 1),
(2, 'B', 'P', 470, 1),
(3, 'C', 'Q', 645, 1),
(4, 'D', 'R', 800, 1),
(5, 'E', 'S', 1000, 1),
(6, 'F', 'T', 1195, 1),
(7, 'G', 'U', 1430, 1),
(8, 'H', NULL, 9999, 1);
| true |
7c27e016412b4c4b9c50b3b23a03cd12f66a7827 | SQL | addyyg/cancer_data_deepdive | /aggregate-queries.sql | UTF-8 | 2,368 | 4.09375 | 4 | [] | no_license | --Looked at the average count of people per population center that had a case of cancer
-- with mortality and had an average count over 100.
select avg(count)
from cancer_stats.Cancer_By_Area_Mortality
having avg(count) > 100
--Looked at the average population of each area (state) as long as it was over 9,999,999 that had people with cancer that was fatal.
select avg(population), area
from cancer_stats.Cancer_By_Area_Mortality
group by area
having avg(population)>9999999
--Selected for the min/max population in each area that had over 1,000,000 people in atleast one major measured population center.
select min(population), max(population), area
from cancer_stats.Cancer_By_Area_Mortality
group by area
having max(population)>1000000
--Selected for the min/max population in each area that had under 1,000,000 people in atleast one major measured population center.
--also returned the total sum of all the counts regardless of year in the area.
select min(population), max(population), sum(count), area
from cancer_stats.Cancer_By_Area_Mortality
group by area
having max(population)<1000000
--selected for the sites that had sum of counts above 1,000,000 and grouped by site.
select site, sum(count), avg(population)
from cancer_stats.CancerBySiteV2
group by site
having sum(count)>1000000
--Selected for the age adjusted rate of cancer of two age divisions between 10-20 and observed changes over the years.
--the having clause was used to eliminte any "total" fields that included all of the rates and ergo had a very high upper onfidence limit.
select year, age, avg(age_adjusted_ci_upper), avg(age_adjusted_rate )
from cancer_stats.AgeRatesOver10
group by year, age
having avg(age_adjusted_ci_upper) < 100.0
--Selected for the age adjusted rate of cancer of two age divisions between 0-10 and observed changes over the years.
select year, age, avg(age_adjusted_ci_upper), avg(age_adjusted_rate )
from cancer_stats.AgeRatesOver10
group by year, age
having avg(age_adjusted_ci_upper) < 100.0
--Looked at the year and site for brain cancer patients over 20 and how many total cases there were per area of the brain affected by year.
--included the having clause to eliminate the total of all sites entries.
select year, site, sum(count), avg(population)
from cancer_stats.brain_cancer_over_twenty
group by year, site
having sum(count) <100000
| true |
032f2d33163faa0842bcfe5bcca04cb36ce82800 | SQL | edmond-dev/server-bof | /db/query/products.sql | UTF-8 | 862 | 3.921875 | 4 | [] | no_license | /* name: CreateProduct :execresult */
INSERT INTO products (
product_id,
category_id,
image_url_public_id,
image_url_secure_id,
product_name,
product_description,
price,
quantity_in_stock
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?
);
/* name: UpdateProduct :exec */
UPDATE products
SET image_url_public_id = ?,
image_url_secure_id = ?,
product_name = ?,
product_description = ?,
price = ?,
quantity_in_stock = ?
WHERE product_id = ?;
/* name: DeleteProduct :exec */
DELETE FROM products
WHERE product_id = ?;
/* name: GetProduct :one */
SELECT * FROM products p
WHERE p.product_id = ?
LIMIT 1;
/* name: ListProducts :many */
SELECT * FROM products
ORDER BY product_name;
/* name: GetCategoryAndProducts :many */
SELECT * FROM categories c
LEFT OUTER JOIN products p on c.category_id = p.category_id
WHERE c.category_id = ?; | true |
59dc282a7e5cb8bce8d70d75c9b6d0ad99a0b7d9 | SQL | mutedalien/js_chess | /chess.sql | UTF-8 | 1,258 | 2.546875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Хост: 127.0.0.1:3306
-- Время создания: Май 31 2020 г., 14:56
-- Версия сервера: 10.3.13-MariaDB-log
-- Версия PHP: 7.3.9
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 */;
--
-- База данных: `chess`
--
-- --------------------------------------------------------
--
-- Структура таблицы `board`
--
CREATE TABLE `board` (
`figures` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Дамп данных таблицы `board`
--
INSERT INTO `board` (`figures`) VALUES
('rnbqkbnrpppppppp11111111111111111111111111111111PPPPPPPPRNBQKBNR');
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 |
2329ee1ecfd81b32908c1527818de777081a28a9 | SQL | alexlatam/oxas_app | /administracion/Oxa/CreadorDB.sql | UTF-8 | 2,688 | 3.59375 | 4 | [
"MIT"
] | permissive | #CREAR BASE DE DATOS
CREATE DATABASE OXA;
#CREACION DE TABLAS
CREATE TABLE USUARIO (
IDUSUARIO int NOT NULL,
CORREO varchar(255),
SALUDO varchar(255),
DESPEDIDA varchar(255),
ACCESSTOKEN varchar(255),
REFRESTOKEN varchar(255),
PRIMARY KEY (IDUSUARIO),
UNIQUE (CORREO)
);
CREATE TABLE PUBLICACION (
IDPUBLICACION int NOT NULL AUTO_INCREMENT,
IDUSUARIO int NOT NULL,
CODIGO varchar(255),
NOMBRE varchar(60),
PRIMARY KEY (IDPUBLICACION),
FOREIGN KEY (IDUSUARIO) REFERENCES USUARIO(IDUSUARIO)
ON DELETE CASCADE
);
CREATE TABLE SINAPSIS (
IDSINAPSIS int NOT NULL AUTO_INCREMENT,
IDUSUARIO int NOT NULL,
INFO TEXT,
ESTIMULOS TEXT,
NUMPUBLICACIONES INT,
PRIMARY KEY (IDSINAPSIS),
FOREIGN KEY (IDUSUARIO) REFERENCES USUARIO(IDUSUARIO)
ON DELETE CASCADE
);
CREATE TABLE ENLACE (
IDENLACE int NOT NULL AUTO_INCREMENT,
IDSINAPSIS int NOT NULL ,
IDPUBLICACION int NOT NULL,
PRIMARY KEY (IDENLACE),
FOREIGN KEY (IDPUBLICACION) REFERENCES PUBLICACION(IDPUBLICACION) ON DELETE CASCADE,
FOREIGN KEY (IDSINAPSIS) REFERENCES SINAPSIS(IDSINAPSIS)
ON DELETE CASCADE
);
CREATE TABLE SUSCRIPCION (
IDSUSCRIPCION int NOT NULL AUTO_INCREMENT,
IDUSUARIO int,
FECHAVENCIMIENTO DATE, #yyyy-mm-dd
TIPOSUSCRIPCION int,
ESTATUS int,
PRIMARY KEY (IDSUSCRIPCION),
FOREIGN KEY (IDUSUARIO) REFERENCES USUARIO(IDUSUARIO)
ON DELETE CASCADE
);
/*
Nuevas Tablas
*/
CREATE TABLE `plan`(
`IDPLAN` int NOT NULL AUTO_INCREMENT,
`NOMBRE` varchar(30) DEFAULT NULL,
`DESCRIPCION` varchar(255) DEFAULT NULL,
`TIEMPO` INT,
`MONTO` FLOAT DEFAULT 0.0 ,
PRIMARY KEY (IDPLAN)
);
CREATE TABLE `pagos`(
`IDPAGO` int NOT NULL AUTO_INCREMENT,
`IDUSUARIO` int NOT NULL,
`BANCOE` varchar(100) DEFAULT NULL,
`BANCOR` varchar(100) DEFAULT NULL,
`FECHA` DATE,
`MONTO` FLOAT DEFAULT 0.0 ,
`REFERENCIA` BOOLEAN NULL DEFAULT FALSE,
`ESTATUS` BOOLEAN NULL DEFAULT FALSE,
PRIMARY KEY (IDPAGO),
FOREIGN KEY (IDUSUARIO) REFERENCES USUARIO(IDUSUARIO)
ON DELETE CASCADE
);
CREATE TABLE `facturas`(
`IDFACTURA` int NOT NULL AUTO_INCREMENT,
`IDUSUARIO`int NOT NULL,
`FACHAEMISION` DATETIME,
`MONTO` FLOAT DEFAULT 0.0 ,
`DESCRIPCION` varchar(255) DEFAULT NULL,
PRIMARY KEY (IDFACTURA),
FOREIGN KEY (IDUSUARIO) REFERENCES USUARIO(IDUSUARIO)
ON DELETE CASCADE
);
CREATE TABLE `servicios`(
`IDSERVICIOS` int NOT NULL AUTO_INCREMENT,
`IDUSUARIO` int NOT NULL,
`IDPLAN` int NOT NULL DEFAULT 1,
PRIMARY KEY (IDSERVICIOS),
FOREIGN KEY (IDUSUARIO) REFERENCES USUARIO(IDUSUARIO)
ON DELETE CASCADE
);
/*
Fin de Nuevas Tablas
*/
| true |
5e3994a4b34209b0a0780a5036ca92f88140e86d | SQL | RobertWSmith/TD_SQL | /PSI/PSI Monthly - Production Credits.sql | UTF-8 | 2,248 | 4.21875 | 4 | [] | no_license | /*
Daily Production Credits Query
Created: 2014-04-23
Validated against PSMS 2014-04-23 for PBU 01 and Facility N508 - Lawton -- aggregates within 1% of PSMS for the month of 2014-April
Aggregates daily credits into monthly buckets
*/
SELECT
CAST( 'Credits' AS VARCHAR(25) ) AS QRY_TYP,
CR.PROD_TYP,
CR.BUS_MTH,
CR.MATL_ID,
CR.FACILITY_ID,
CAST( NULL AS VARCHAR(18) ) AS LVL_GRP_ID,
CR.PROD_QTY
FROM (
SELECT
PC.PROD_TYP,
PC.BUS_MTH,
PC.MATL_ID,
PC.FACILITY_ID,
SUM( PC.PROD_QTY ) AS PROD_QTY,
PC.QTY_UOM
FROM (
SELECT
CAST( CASE WHEN PCD.PROD_DT / 100 = CURRENT_DATE / 100 THEN 'Current Month' ELSE 'History' END AS VARCHAR(25) ) AS PROD_TYP,
PCD.PROD_DT AS BUS_DT,
CAST( CASE
WHEN CAL.DAY_DATE > CAL.BEGIN_DT
THEN CAL.BEGIN_DT + 1
ELSE CAL.BEGIN_DT - 6
END AS DATE ) AS BUS_WK,
CAL.MONTH_DT AS BUS_MTH,
PCD.MATL_ID,
PCD.FACILITY_ID,
SUM( ZEROIFNULL( PCD.PROD_QTY ) ) AS PROD_QTY,
PCD.QTY_UOM
FROM GDYR_VWS.PROD_CREDIT_DY PCD
INNER JOIN GDYR_VWS.GDYR_CAL CAL
ON CAL.DAY_DATE = PCD.PROD_DT
AND CAL.DAY_DATE BETWEEN CAST( SUBSTR( CAST( ADD_MONTHS( CURRENT_DATE, -12 ) AS CHAR(10) ), 1, 7 ) || '-01' AS DATE ) AND ( CURRENT_DATE )
INNER JOIN GDYR_BI_VWS.NAT_MATL_HIER_DESCR_EN_CURR MATL
ON MATL.MATL_ID = PCD.MATL_ID
AND MATL.PBU_NBR IN ( '01', '03', '04', '05', '07', '08', '09' )
WHERE
PCD.PROD_DT BETWEEN CAST( SUBSTR( CAST( ADD_MONTHS( CURRENT_DATE, -12 ) AS CHAR(10) ), 1, 7 ) || '-01' AS DATE ) AND ( CURRENT_DATE )
AND PCD.SBU_ID = 2
AND PCD.SRC_SYS_ID = 2
AND PCD.PROD_QTY > 0
GROUP BY
PROD_TYP,
PCD.PROD_DT,
BUS_WK, -- MONDAY INDEXED
CAL.MONTH_DT,
PCD.MATL_ID,
PCD.FACILITY_ID,
PCD.QTY_UOM
) PC
GROUP BY
PC.PROD_TYP,
PC.BUS_MTH,
PC.MATL_ID,
PC.FACILITY_ID,
PC.QTY_UOM
) CR
| true |
9bb9062638a2f1428d3d8bf611309c3a1095936d | SQL | eobaah/pleasant-polecat | /bookstorereact/database/schema.sql | UTF-8 | 447 | 2.8125 | 3 | [] | no_license | DROP DATABASE IF EXISTS pleasantpolecat;
CREATE DATABASE pleasantpolecat;
\c pleasantpolecat
DROP TABLE IF EXISTS booklist;
CREATE TABLE booklist (
book_id SERIAL PRIMARY KEY,
title VARCHAR(150) NOT NULL,
author VARCHAR(150),
description VARCHAR(3000),
genre VARCHAR(150),
image_url VARCHAR(1000)
);
COPY booklist FROM '/Users/ryankent/Desktop/LG/pleasant-polecat/pleasant-bookstore/database/booksdata.csv' DELIMITER ',' CSV HEADER
| true |
0a7afe4eeb164c149a163a44ee660ad3cc4a1911 | SQL | lancexin/infogiga | /dbstore/mstore.sql | UTF-8 | 10,232 | 2.96875 | 3 | [] | no_license | -- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version 5.1.40-community
/*!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_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' */;
--
-- Create schema mstore
--
CREATE DATABASE IF NOT EXISTS mstore;
USE mstore;
--
-- Definition of table `equipment`
--
DROP TABLE IF EXISTS `equipment`;
CREATE TABLE `equipment` (
`equipmentid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`number` varchar(45) DEFAULT NULL,
`birth` varchar(45) DEFAULT NULL,
`status` varchar(45) DEFAULT NULL,
`macNO` varchar(45) DEFAULT NULL,
`code` varchar(45) DEFAULT NULL,
`userID` varchar(45) DEFAULT NULL,
`versionID` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`equipmentid`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `equipment`
--
/*!40000 ALTER TABLE `equipment` DISABLE KEYS */;
INSERT INTO `equipment` (`equipmentid`,`number`,`birth`,`status`,`macNO`,`code`,`userID`,`versionID`) VALUES
(1,'ok','2010-09-12 00:00:00','开启','00f50601c901','09xdfw1','1',1),
(2,'fuck','2010-09-12','未开启','000154781911','4556123','1',1),
(3,'mygod','2001-12-12','未开启','213465131321','541321321','1',1),
(4,'derr','2013-11-01','未开启','134213451235','32141234','1',1),
(5,'mather','2014-11-15','未开启','451313213213','54132131','1',1),
(6,'12313','2015-11-20','未开启','sdfasddasasgd','sdfafsgasdf','1',1),
(7,'132123','2014-11-02','未开启','sdafasdasfd','sdf23fadf','1',1),
(8,'3134','2011-02-01','未开启','sdafasdf','sdafasfd','1',1),
(9,'fasdf','2013-11-23','未开启','asdfasfd','asdfasdf','1',1),
(10,'asdfsadf','1990-12-17','未开启','asfdasfd','asdfasdfasd','1',1),
(11,'sdfasdf','1956-14-12','未开启','1341515','dsafasdf','1',1),
(12,'test','2010-05-17 13:21:22','未开启',NULL,'e436712e','1',NULL),
(13,'mack','2010-05-17 14:02:24','未开启',NULL,'94a38041','1',NULL);
/*!40000 ALTER TABLE `equipment` ENABLE KEYS */;
--
-- Definition of table `menu`
--
DROP TABLE IF EXISTS `menu`;
CREATE TABLE `menu` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`meunId` varchar(45) NOT NULL,
`funcId` varchar(45) NOT NULL,
`menuName` varchar(45) NOT NULL,
`menuDesc` text NOT NULL,
`domainId` varchar(45) NOT NULL,
`menuUrl` varchar(45) NOT NULL,
`menuPicUrl` varchar(45) NOT NULL,
`menuIdx` varchar(45) NOT NULL,
`needLogin` varchar(45) NOT NULL,
`needContract` varchar(45) NOT NULL,
`needSecPasswd` varchar(45) NOT NULL,
`stopShow` varchar(45) NOT NULL,
`notLoginShow` varchar(45) NOT NULL,
`busiKind` varchar(45) NOT NULL,
`isUsed` varchar(45) NOT NULL,
`validDate` varchar(45) NOT NULL,
`expreDate` varchar(45) NOT NULL,
`lastDayCando` varchar(45) NOT NULL,
`helpUrl` varchar(45) NOT NULL,
`channelLevel` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `menu`
--
/*!40000 ALTER TABLE `menu` DISABLE KEYS */;
/*!40000 ALTER TABLE `menu` ENABLE KEYS */;
--
-- Definition of table `renewal`
--
DROP TABLE IF EXISTS `renewal`;
CREATE TABLE `renewal` (
`renewalID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`version` varchar(45) DEFAULT NULL,
`url` varchar(45) DEFAULT NULL,
`uploadTime` varchar(45) DEFAULT NULL,
`systemID` varchar(45) DEFAULT NULL,
PRIMARY KEY (`renewalID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `renewal`
--
/*!40000 ALTER TABLE `renewal` DISABLE KEYS */;
INSERT INTO `renewal` (`renewalID`,`version`,`url`,`uploadTime`,`systemID`) VALUES
(1,'1.0','http://localhost:8080/test','2011-12-02','1'),
(2,'爱死','upload\\11s.apk','2010-05-17 09:46:32',NULL);
/*!40000 ALTER TABLE `renewal` ENABLE KEYS */;
--
-- Definition of table `scene`
--
DROP TABLE IF EXISTS `scene`;
CREATE TABLE `scene` (
`sceneID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`sceneName` varchar(45) DEFAULT NULL,
PRIMARY KEY (`sceneID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `scene`
--
/*!40000 ALTER TABLE `scene` DISABLE KEYS */;
INSERT INTO `scene` (`sceneID`,`sceneName`) VALUES
(1,'设备开启'),
(2,'设备注册'),
(3,'进入体验'),
(4,'退出体验'),
(5,'订购业务'),
(6,'软件更新');
/*!40000 ALTER TABLE `scene` ENABLE KEYS */;
--
-- Definition of table `service`
--
DROP TABLE IF EXISTS `service`;
CREATE TABLE `service` (
`serviceID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`serviceName` varchar(45) NOT NULL,
`serviceCode` varchar(45) NOT NULL,
`introduction` varchar(45) NOT NULL,
`weburl` varchar(45) NOT NULL,
PRIMARY KEY (`serviceID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `service`
--
/*!40000 ALTER TABLE `service` DISABLE KEYS */;
INSERT INTO `service` (`serviceID`,`serviceName`,`serviceCode`,`introduction`,`weburl`) VALUES
(1,'音乐随身听','1234','这是音乐随身听的介绍','http://www.ok.com'),
(2,'移动互联','11001',' 美妙的业务,不多说 ','htt://www.ok.com'),
(3,'飞信充值业务','test',' 靠,想怎么开通就怎么开通','http://www.ok.com'),
(4,'能不能添加业务','TEST',' 测试数据 ','http://localhost:8080/gun'),
(5,'测试业务','Test01',' 测试专用章 ','http://www.ok.com');
/*!40000 ALTER TABLE `service` ENABLE KEYS */;
--
-- Definition of table `servicedetil`
--
DROP TABLE IF EXISTS `servicedetil`;
CREATE TABLE `servicedetil` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_service` varchar(45) DEFAULT NULL,
`name` varchar(45) DEFAULT NULL,
`openCode` varchar(45) DEFAULT NULL,
`pay` varchar(45) DEFAULT NULL,
`info` varchar(45) DEFAULT NULL,
`method` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `servicedetil`
--
/*!40000 ALTER TABLE `servicedetil` DISABLE KEYS */;
INSERT INTO `servicedetil` (`id`,`id_service`,`name`,`openCode`,`pay`,`info`,`method`) VALUES
(1,'1','草泥马观光团','test04','500元/天','T054','发送T054到10251658'),
(2,'1','小YY套餐','XYY','50000/元每月','test',' 开通方式,测试专用 '),
(3,'5','测试专用','test','5元/月','test',' 测试专用');
/*!40000 ALTER TABLE `servicedetil` ENABLE KEYS */;
--
-- Definition of table `sms`
--
DROP TABLE IF EXISTS `sms`;
CREATE TABLE `sms` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_service` int(10) unsigned DEFAULT NULL,
`phone` varchar(45) DEFAULT NULL,
`context` varchar(45) DEFAULT NULL,
`send_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `sms`
--
/*!40000 ALTER TABLE `sms` DISABLE KEYS */;
INSERT INTO `sms` (`id`,`id_service`,`phone`,`context`,`send_time`) VALUES
(1,1,'13868140535','测试数据','2010-10-12 00:00:00');
/*!40000 ALTER TABLE `sms` ENABLE KEYS */;
--
-- Definition of table `statistics`
--
DROP TABLE IF EXISTS `statistics`;
CREATE TABLE `statistics` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_equip` int(10) unsigned DEFAULT NULL,
`time_happen` varchar(45) DEFAULT NULL,
`phone` varchar(45) DEFAULT NULL,
`id_service` int(10) unsigned DEFAULT NULL,
`id_secene` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `statistics`
--
/*!40000 ALTER TABLE `statistics` DISABLE KEYS */;
INSERT INTO `statistics` (`id`,`id_equip`,`time_happen`,`phone`,`id_service`,`id_secene`) VALUES
(1,1,'2010-09-10','13868140535',1,1),
(2,1,'2011-02-01','15927616602',1,1),
(3,1,'2011-01-02','15927616602',1,1),
(4,1,'2011-01-02','15927616602',1,1),
(5,1,'2011-01-02','15927616602',1,1),
(6,1,'2011-01-02','15927616602',1,1),
(7,1,'2011-01-02','15927616602',1,1),
(8,1,'2011-01-02','15927616602',1,1),
(9,1,'2011-01-02','15927616602',1,1),
(10,1,'2011-01-02','15927616602',1,1),
(11,1,'2011-01-02','15927616602',1,1),
(12,1,'2011-01-02','15927616602',1,1),
(13,1,'2011-01-02','15927616602',1,1),
(14,1,'2011-01-02','15927616602',1,1);
/*!40000 ALTER TABLE `statistics` ENABLE KEYS */;
--
-- Definition of table `sysinfo`
--
DROP TABLE IF EXISTS `sysinfo`;
CREATE TABLE `sysinfo` (
`systemid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`systemName` varchar(45) DEFAULT NULL,
PRIMARY KEY (`systemid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `sysinfo`
--
/*!40000 ALTER TABLE `sysinfo` DISABLE KEYS */;
/*!40000 ALTER TABLE `sysinfo` ENABLE KEYS */;
--
-- Definition of table `usertable`
--
DROP TABLE IF EXISTS `usertable`;
CREATE TABLE `usertable` (
`user_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_name` varchar(45) NOT NULL,
`user_password` varchar(45) NOT NULL,
`user_type` varchar(45) DEFAULT NULL,
`user_maxnum` varchar(45) DEFAULT NULL,
`user_birthtime` datetime DEFAULT NULL,
PRIMARY KEY (`user_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `usertable`
--
/*!40000 ALTER TABLE `usertable` DISABLE KEYS */;
INSERT INTO `usertable` (`user_ID`,`user_name`,`user_password`,`user_type`,`user_maxnum`,`user_birthtime`) VALUES
(1,'admin','admin','1','500','2010-10-12 00:00:00'),
(6,'user01','123456','2','500','2010-05-17 12:34:39');
/*!40000 ALTER TABLE `usertable` ENABLE KEYS */;
/*!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 */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
| true |
6bf4c319b730c0540d0dcdf2a1749252af772d75 | SQL | gollucomputers/sarkaree | /mysql.sql | UTF-8 | 6,477 | 2.90625 | 3 | [
"MIT"
] | permissive | -- MySQL dump 10.13 Distrib 5.7.23, for Linux (x86_64)
--
-- Host: localhost Database: mx
-- ------------------------------------------------------
-- Server version 5.7.23-0ubuntu0.16.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 `ads`
--
DROP TABLE IF EXISTS `ads`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ads` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`code` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `category`
--
DROP TABLE IF EXISTS `category`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `category` (
`cat_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
PRIMARY KEY (`cat_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `comments`
--
DROP TABLE IF EXISTS `comments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comments` (
`commnt_id` int(11) NOT NULL AUTO_INCREMENT,
`news_id` int(11) NOT NULL,
`poster_name` varchar(255) NOT NULL,
`comment` text NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`commnt_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `details`
--
DROP TABLE IF EXISTS `details`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `details` (
`fb` varchar(255) NOT NULL,
`tw` varchar(255) NOT NULL,
`ins` varchar(255) NOT NULL,
`twitterbox` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `news`
--
DROP TABLE IF EXISTS `news`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `news` (
`news_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`content` longtext NOT NULL,
`user_id` int(11) NOT NULL,
`cat_id` int(11) NOT NULL,
`image` text NOT NULL,
`youtube_video` text NOT NULL,
`dateposted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`visits` int(11) NOT NULL DEFAULT '0',
`lastdate` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`news_id`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `pages`
--
DROP TABLE IF EXISTS `pages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pagetitle` varchar(255) NOT NULL,
`pagecontent` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `relative_tags`
--
DROP TABLE IF EXISTS `relative_tags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `relative_tags` (
`tag_id` int(11) NOT NULL,
`news_id` int(11) NOT NULL,
UNIQUE KEY `fk_news_unique` (`tag_id`,`news_id`),
KEY `fk_news_id` (`news_id`),
CONSTRAINT `fk_news_id` FOREIGN KEY (`news_id`) REFERENCES `news` (`news_id`),
CONSTRAINT `fk_tags_id` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `settings`
--
DROP TABLE IF EXISTS `settings`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `settings` (
`sitename` varchar(255) NOT NULL,
`sitemail` varchar(255) NOT NULL,
`description` longtext NOT NULL,
`keywords` longtext NOT NULL,
`copyright` text NOT NULL,
`author` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tags`
--
DROP TABLE IF EXISTS `tags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tags` (
`tag_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
PRIMARY KEY (`tag_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`image` varchar(255) NOT NULL DEFAULT 'assets/resources/images/icons/user.png',
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-10-13 19:40:33
| true |
515856a01fcb89d30d0ee3bb4ea4229d8c7b2a0b | SQL | cvranjith/misc | /mick/clear_recon.sql | UTF-8 | 540 | 2.671875 | 3 | [] | no_license | undef DCN
delete mstb_dly_msg_in
where dcn = '&&DCN'
/
delete RETB_UPLOAD_STATEMENT
where UPLOAD_SOURCE_REF_NO = '&&DCN'
/
delete RETB_UPLOAD_ENTRY
where UPLOAD_SOURCE_REF_NO = '&&DCN'
/
delete retbs_external_statement
where UPLOAD_SOURCE_REF_NO = '&&DCN'
/
delete RETB_EXTERNAL_ENTRY
where EXTERNAL_ENTITY||EXTERNAL_ACCOUNT||to_char(STATEMENT_SEQ_NO)||to_char(STATEMENT_SUBSEQ_NO)
not in
(
select EXTERNAL_ENTITY||EXTERNAL_ACCOUNT||to_char(STATEMENT_SEQ_NO)||to_char(STATEMENT_SUBSEQ_NO)
from RETB_EXTERNAL_STATEMENT
)
/
undef dcn
| true |
4287d97afd3eddd008fedbc0eba57401234150e0 | SQL | JustinData/GA-WDI-Work | /w03/d03/Ann/receipt_cmd/parent.sql | UTF-8 | 315 | 3.71875 | 4 | [] | no_license | #parent name
#avg num of presents per parent
SELECT SUM(number_of_item) from receipts WHERE parent = 'Dad';
#avg present cost per parent
SELECT AVG(price) from receipts WHERE parent = 'Dad';
#order by price desc (each parent)
SELECT items from receipts WHERE parent IN ('Dad') ORDER BY price DESC;
| true |
5addac4e9e1eaf4c977220f7b74edc58ad42ba93 | SQL | emine2021/sqlCalisma | /day04_update.sql | ISO-8859-9 | 1,201 | 3.484375 | 3 | [] | no_license | CREATE TABLE tedarikCiler
(
vergi_no NUMBER(3),
firma_ismi VARCHAR2(50),
irtibat_ismi VARCHAR2(50),
CONSTRAINT pk_ted PRIMARY KEY(vergi_no) DISABLE
);
INSERT INTO tedarikciler VALUES (101 , 'IBM', 'Kim Yon');
INSERT INTO tedarikciler VALUES (102 , 'Huawei', 'Cin Li');
INSERT INTO tedarikciler VALUES (103 , 'Erikson', 'Maki Tammamen');
INSERT INTO tedarikciler VALUES (104 , 'Apple', 'Adam Eve');
SELECT * FROM tedarkcler;
CREATE TABLE urunler
(
ted_vergino NUMBER(3),
urun_id NUMBER(11),
urun_isim VARCHAR2(50),
musteri_isim VARCHAR2(50),
CONSTRAINT fk_urunler FOREIGN KEY(ted_vergino) REFERENCES tedarikciler(vergi_no)
);
drop table urunler;
INSERT INTO urunler VALUES(101, 1001,'Laptop', 'Aye Can');
INSERT INTO urunler VALUES(102, 1002,'Phone', 'Fatma Aka');
INSERT INTO urunler VALUES(102, 1003,'TV', 'Ramazan z');
INSERT INTO urunler VALUES(102, 1004,'Laptop', 'Veli Han');
INSERT INTO urunler VALUES(103, 1005,'Phone', 'Canan Ak');
INSERT INTO urunler VALUES(104, 1006,'TV', 'Ali Bak');
INSERT INTO urunler VALUES(104, 1007,'Phone', 'Aslan Ylmaz');
SELECT * FROM tedarikciler;
SELECT * FROM urunler; | true |
3f2be24a60e361ddb68e3a590fc6dd535419a592 | SQL | jsyi1995/SCU-COEN-Schoolwork | /COEN178/hw/hw2/tables.sql | UTF-8 | 565 | 3.40625 | 3 | [] | no_license | Drop table Rental;
Drop table Customer;
Drop table Car;
Create table Car (
carId varchar(10) PRIMARY KEY,
model varchar(25),
year numeric(4),
bodytype char(5) check (bodytype in ('sedan', 'van', 'suv')),
status char(10) check (status in ('available', 'out')));
Create table Customer (
custId varchar(10) PRIMARY KEY,
first_name varchar(15),
last_name varchar(15),
phone numeric(10));
Create table Rental (
carId varchar(10),
custId varchar(10),
date_rented date,
date_returned date,
foreign key (carId) references Car,
foreign key (custId) references Customer);
| true |
457f69764f0a876396fdafcfe02f1fad361e773c | SQL | dalirouissi/restaurent-project | /restaurent/src/main/resources/import.sql | UTF-8 | 4,176 | 3.25 | 3 | [] | no_license | DROP TABLE IF EXISTS authorities;
CREATE TABLE authorities (id bigint auto_increment not null, username varchar_ignorecase(50) not null, authority varchar_ignorecase(50) not null, constraint fk_authorities_users foreign key(username) references users(username));
INSERT INTO users (id, username, password,enabled) VALUES (1, 'root', 'root', true), (2, 'user', 'user', true);
INSERT INTO authorities (id, username, authority) VALUES (1, 'root', 'ROLE_user'), (2, 'root', 'ROLE_admin'), (3, 'user', 'ROLE_user');
DROP TABLE IF EXISTS customer;
DROP TABLE IF EXISTS item;
DROP TABLE IF EXISTS customerorder;
DROP TABLE IF EXISTS orderitem;
CREATE TABLE customer(id bigint auto_increment not null, name varchar_ignorecase(50));
CREATE TABLE item(id bigint auto_increment not null, name varchar_ignorecase(50), price decimal(18, 2));
CREATE TABLE customerorder(id bigint auto_increment not null, order_No varchar_ignorecase(50), customer_Id bigint, pmethod varchar_ignorecase(50), gtotal decimal(18, 2), constraint fk_customer foreign key(customer_Id) references customer(id));
CREATE TABLE orderItem(id bigint auto_increment not null, orderId bigint, itemId int, quantity int, constraint fk_order FOREIGN KEY(orderId) references customerorder(id), constraint fk_item FOREIGN KEY(itemId) references item(id));
INSERT INTO Customer(id, name) VALUES (1, N'Olivia Kathleen');
INSERT INTO Customer(id, name) VALUES (2, N'Liam Patrick');
INSERT INTO Customer(id, name) VALUES (3, N'Charlotte Rose');
INSERT INTO Customer(id, name) VALUES (4, N'Elijah Burke ');
INSERT INTO Customer(id, name) VALUES (5, N'Ayesha Ameer');
INSERT INTO Customer(id, name) VALUES (6, N'Eva Louis');
-- INSERT INTO Item (id, name, price) VALUES (1, N'Chicken Tenders', CAST(3.50 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (2, N'Chicken Tenders w/ Fries', CAST(4.99 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (3, N'Chicken Tenders w/ Onion', CAST(5.99 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (4, N'Grilled Cheese Sandwich', CAST(2.50 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (5, N'Grilled Cheese Sandwich w/ Fries', CAST(3.99 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (6, N'Grilled Cheese Sandwich w/ Onion', CAST(4.99 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (7, N'Lettuce and Tomato Burger', CAST(1.99 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (8, N'Soup', CAST(2.50 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (9, N'Onion Rings', CAST(2.99 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (10, N'Fries', CAST(1.99 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (11, N'Sweet Potato Fries', CAST(2.49 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (12, N'Sweet Tea', CAST(1.79 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (13, N'Botttle Water', CAST(1.00 AS Decimal(18, 2)));
-- INSERT INTO Item (id, name, price) VALUES (14, N'Canned Drinks', CAST(1.00 AS Decimal(18, 2)));
INSERT INTO Item (id, name, price) VALUES (1, N'Chicken Tenders', 3.50);
INSERT INTO Item (id, name, price) VALUES (2, N'Chicken Tenders w/ Fries', 4.99);
INSERT INTO Item (id, name, price) VALUES (3, N'Chicken Tenders w/ Onion', 5.99);
INSERT INTO Item (id, name, price) VALUES (4, N'Grilled Cheese Sandwich', 2.50);
INSERT INTO Item (id, name, price) VALUES (5, N'Grilled Cheese Sandwich w/ Fries', 3.99);
INSERT INTO Item (id, name, price) VALUES (6, N'Grilled Cheese Sandwich w/ Onion', 4.99);
INSERT INTO Item (id, name, price) VALUES (7, N'Lettuce and Tomato Burger', 1.99);
INSERT INTO Item (id, name, price) VALUES (8, N'Soup', 2.50);
INSERT INTO Item (id, name, price) VALUES (9, N'Onion Rings', 2.99);
INSERT INTO Item (id, name, price) VALUES (10, N'Fries', 1.99);
INSERT INTO Item (id, name, price) VALUES (11, N'Sweet Potato Fries', 2.49);
INSERT INTO Item (id, name, price) VALUES (12, N'Sweet Tea', 1.79);
INSERT INTO Item (id, name, price) VALUES (13, N'Botttle Water', 1.00);
INSERT INTO Item (id, name, price) VALUES (14, N'Canned Drinks', 1.00);
| true |
deb9ecdb76d7ff7a0dd62578b4924afe0716eafb | SQL | ferkopar/ToDoSchema | /V_EPI_SUBJ.sql | UTF-8 | 851 | 3.125 | 3 | [] | no_license | --------------------------------------------------------
-- DDL for View V_EPI_SUBJ
--------------------------------------------------------
CREATE OR REPLACE VIEW "V_EPI_SUBJ" ("EPI_ID", "PARAM_TYPE_ID", "VALUE", "UNIT_TYPE_ID", "DESCRIPTION", "CRU", "CRD", "MDU", "MM_ID", "VALUE_TYPE_ID", "ORDER_NO", "UNIT", "FROM_CODE", "GIS_ID", "SUBJ_ID", "SUBJ_NAME") AS
SELECT
-- EPI_SUBJ_PARAM_ID SUBJ_PARAM_ID,
-- SUBJ_PARAM.SUBJ_ID ,
EPI_ID,
PARAM_TYPE_ID,
VALUE,
UNIT_TYPE_ID,
SUBJ_PARAM.DESCRIPTION,
SUBJ_PARAM.CRU,
SUBJ_PARAM.CRD,
SUBJ_PARAM.MDU,
MM_ID,
VALUE_TYPE_ID,
ORDER_NO,
UNIT,
FROM_CODE,
GIS_ID,
SUBJECTIV.SUBJ_ID,
SUBJECTIV.SUBJ_NAME
FROM
EPI_SUBJ_PARAM subj_param,
subject SUBJECTIV
WHERE
SUBJECTIV.SUBJ_ID = SUBJ_PARAM.SUBJ_ID;
| true |
6bdea2ab4a7eb931d1ffebdff1b2ba00434c7a5f | SQL | Psiale/SQL-ZOO | /8 SELF JOIN.sql | UTF-8 | 1,466 | 4.46875 | 4 | [] | no_license | -- #1
SELECT COUNT(*) FROM stops
-- #2
SELECT id FROM stops
WHERE name = 'Craiglockhart'
-- #3
SELECT DISTINCT id, name FROM stops
JOIN route ON (stops.id = route.stop)
WHERE num = '4' AND company = 'LRT'
-- #4
SELECT company, num, COUNT(*)
FROM route WHERE stop=149 OR stop=53
GROUP BY company, num HAVING COUNT(*) > 1
-- #5
SELECT a.company, a.num, a.stop, b.stop
FROM route a JOIN route b ON
(a.company=b.company AND a.num=b.num)
WHERE a.stop=53 (SELECT id
-- #6
SELECT a.company, a.num, stopa.name, stopb.name
FROM route a JOIN route b ON
(a.company=b.company AND a.num=b.num)
JOIN stops stopa ON (a.stop=stopa.id)
JOIN stops stopb ON (b.stop=stopb.id)
WHERE stopa.name = 'Craiglockhart' AND stopb.name = 'London Road'
-- #7
SELECT DISTINCT a.company, a.num
FROM route a JOIN route b ON
(a.company=b.company AND a.num=b.num)
JOIN stops stopa ON (a.stop=stopa.id)
JOIN stops stopb ON (b.stop=stopb.id)
WHERE stopa.name = 'Haymarket' AND stopb.name = 'Leith'
-- #8
SELECT DISTINCT a.company, a.num
FROM route a JOIN route b ON
(a.company=b.company AND a.num=b.num)
JOIN stops stopa ON (a.stop=stopa.id)
JOIN stops stopb ON (b.stop=stopb.id)
WHERE stopa.name = 'Craiglockhart' AND stopb.name = 'Tollcross'
-- #9
SELECT DISTINCT stopb.name, b.company, b.num
FROM route a JOIN route b ON
(a.company=b.company AND a.num=b.num)
JOIN stops stopa ON (a.stop=stopa.id)
JOIN stops stopb ON (b.stop=stopb.id)
WHERE stopa.name='Craiglockhart';
| true |
0b9eda7890b41fa8109af184d89887eac752952d | SQL | cacalote/wso2-microservices-poc | /kubernetes-mysql/scripts/mysql-customer-db.sql | UTF-8 | 402 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | CREATE DATABASE customer_db;
USE customer_db;
CREATE TABLE `CUSTOMER` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`FNAME` varchar(100) DEFAULT NULL,
`LNAME` varchar(100) DEFAULT NULL,
`ADDRESS` varchar(100) DEFAULT NULL,
`STATE` varchar(45) DEFAULT NULL,
`POSTAL_CODE` varchar(45) DEFAULT NULL,
`COUNTRY` varchar(45) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | true |
b3b7e699c90d287f4bf3136eb796093a77439c7e | SQL | wiltonsg/folhams | /consultas.sql | UTF-8 | 2,532 | 3.65625 | 4 | [
"MIT"
] | permissive | # . Copyright (C) 2020 Jhonathan P. Banczek (jpbanczek@gmail.com)
#
-- DB Browser for SQL
--
-- 100 maiores salarios por remuneração base
-- :data
--
select
f.nome as NOME,
f.orgao as ORGÃO,
f.situacao as SITUAÇÃO,
F.CARGO AS CARGO,
replace(f.rem_base, '.', ',') as REM_BASE,
replace(f.outras_verbas, '.', ',') as OUTRAS_VERBAS,
replace(f.rem_posdeducoes, '.', ',') as REM_POS_DEDUCOES,
f.vinculo as VÍNCULO,
f.matricula as MATRÍCULA
from folha f where f.competencia like :data
order by f.rem_base desc
limit 100
--
-- 100 maiores salarios por Remuneração Após Deduções Obrigatórias
--
select
f.nome as NOME,
f.orgao as ORGÃO,
f.situacao as SITUAÇÃO,
F.CARGO AS CARGO,
replace(f.rem_base, '.', ',') as REM_BASE,
replace(f.outras_verbas, '.', ',') as OUTRAS_VERBAS,
replace(f.rem_posdeducoes, '.', ',') as REM_POS_DEDUCOES,
f.vinculo as VÍNCULO,
f.matricula as MATRÍCULA
from folha f where f.competencia like :data
order by f.rem_posdeducoes desc
limit 100
--
-- maiores salarios por [orgao/vinculo/situacao/
-- cargo] ordenado do Remuneração Após Deduções Obrigatórias
--
select
f.nome as NOME,
f.orgao as ORGÃO,
f.situacao as SITUAÇÃO,
F.CARGO AS CARGO,
replace(f.rem_base, '.', ',') as REM_BASE,
replace(f.outras_verbas, '.', ',') as OUTRAS_VERBAS,
replace(f.rem_posdeducoes, '.', ',') as REM_POS_DEDUCOES,
f.vinculo as VÍNCULO,
f.matricula as MATRÍCULA
from folha f where
f.competencia like :data and
:filtro like :valor_filtro
order by f.rem_posdeducoes desc
limit :quantidade
--
-- Somatório - Situação
--
select
replace(total(f.rem_posdeducoes), '.', ',') as total_REM_POS_DEDUCOES, f.situacao
from folha f where
f.competencia like '03/2020'
GROUP by f.situacao
--
-- Somatório - ORGAO
--
select
replace(total(f.rem_posdeducoes), '.', ',') as total_REM_POS_DEDUCOES, f.orgao
from folha f where
f.competencia like '03/2020'
GROUP by f.orgao
--
-- Somatório - Vinculo
--
select
replace(total(f.rem_posdeducoes), '.', ',') as total_REM_POS_DEDUCOES, f.vinculo
from folha f where
f.competencia like '03/2020'
GROUP by f.vinculo
# [TODO]
--
-- CREATE VIEW VINTEMAIORES_032020 AS
--
CREATE VIEW VINTEMAIORES_032020 AS
select
f.nome,
f.orgao,
f.situacao,
F.CARGO,
f.rem_base,
f.outras_verbas,
f.rem_posdeducoes,
f.vinculo,
f.matricula
from folha f where
f.competencia like '03/2020'
order by f.rem_posdeducoes desc
limit 15280
--
-- Somatório
-- VIEW VINTEMAIORES_032020 AS
--
select
replace(total(v.rem_posdeducoes), '.', ',') as total_REM_POS_DEDUCOES
from VINTEMAIORES_032020 v
| true |
e13cea1a7f3f53582db37121f692462d1b2fd968 | SQL | microsoft/dicom-server | /src/Microsoft.Health.Dicom.SqlServer/Features/Schema/Sql/Sprocs/GetChangeFeedLatestByTimeV39.sql | UTF-8 | 927 | 3.546875 | 4 | [
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"MS-PL",
"OFFIS",
"IJG",
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | /***************************************************************************************/
-- STORED PROCEDURE
-- GetChangeFeedLatestByTimeV39
--
-- FIRST SCHEMA VERSION
-- 36
--
-- DESCRIPTION
-- Gets the latest dicom change by timestamp
/***************************************************************************************/
CREATE OR ALTER PROCEDURE dbo.GetChangeFeedLatestByTimeV39
AS
BEGIN
SET NOCOUNT ON
SET XACT_ABORT ON
SELECT TOP(1)
c.Sequence,
c.Timestamp,
c.Action,
p.PartitionName,
c.StudyInstanceUid,
c.SeriesInstanceUid,
c.SopInstanceUid,
c.OriginalWatermark,
c.CurrentWatermark,
c.FilePath
FROM dbo.ChangeFeed c WITH (HOLDLOCK)
INNER JOIN dbo.Partition p
ON p.PartitionKey = c.PartitionKey
ORDER BY c.Timestamp DESC, c.Sequence DESC
END
| true |
64217dd912986d805886ebd954d6b5933fe65210 | SQL | rodrigofontanela/contas-pagar | /src/main/resources/db/changelog/migrations/002-create-table-contas-pagar.sql | UTF-8 | 2,278 | 3.4375 | 3 | [] | no_license | -- liquibase formatted sql
-- changeset rodrigo.fontanela:1 context:dev splitStatements:false
create table if not exists contas_pagar.contas_pagar (
id int8 not null,
owner varchar(50) not null default current_user,
nome varchar(200) not null,
valor_original numeric(14,2) null default 0,
valor_corrigido numeric(14,2) null default 0,
data_vencimento date not null,
data_pagamento date null,
criado_por varchar(50) not null,
criado_em timestamp not null default current_timestamp,
alterado_por varchar(50) not null,
alterado_em timestamp not null default current_timestamp,
versao int not null default 0,
constraint pk_contas_pagar primary key (id)
) partition by hash (id);
create table contas_pagar.contas_pagar_hpart_0 partition of contas_pagar.contas_pagar for values with (modulus 5, remainder 0);
create table contas_pagar.contas_pagar_hpart_1 partition of contas_pagar.contas_pagar for values with (modulus 5, remainder 1);
create table contas_pagar.contas_pagar_hpart_2 partition of contas_pagar.contas_pagar for values with (modulus 5, remainder 2);
create table contas_pagar.contas_pagar_hpart_3 partition of contas_pagar.contas_pagar for values with (modulus 5, remainder 3);
create table contas_pagar.contas_pagar_hpart_4 partition of contas_pagar.contas_pagar for values with (modulus 5, remainder 4);
create policy contas_pagar_owner_policy on contas_pagar.contas_pagar using (owner = current_user);
--rollback not required
-- changeset rodrigo.fontanela:2 context:dev
alter table contas_pagar.contas_pagar owner to suser_mgm;
--rollback not required
-- changeset rodrigo.fontanela:3 context:dev
grant all on table contas_pagar.contas_pagar to suser_mgm;
--rollback not required
-- changeset rodrigo.fontanela:4 context:dev
create sequence if not exists contas_pagar.seq_contas_pagar
increment by 1
minvalue 1
maxvalue 9223372036854775807
start 1
cache 1
no cycle;
--rollback not required
-- changeset rodrigo.fontanela:5 context:dev
alter sequence contas_pagar.seq_contas_pagar owner to suser_mgm;
--rollback not required
-- changeset rodrigo.fontanela:6 context:dev
grant all on sequence contas_pagar.seq_contas_pagar to suser_mgm;
--rollback not required
| true |
1731f8c29ced04b46aba934a62afe8f330c06bcc | SQL | hodefoting/lyd | /lyd/core/lyd-ops.inc | UTF-8 | 8,903 | 3.265625 | 3 | [
"ISC"
] | permissive | /* This file defines the core lyd language, adding a new line here adds
* support to both virtual machine and compiler for the new instruction.
*
* The macros used for OUT, ARG etc are documented at the top of lyd-vm.c
*
* Instructions that need to be infix need special treatment in the compiler.
*/
/* LYD_OP(name, OP_CODE, ARGC, CODE, INIT, FREE, DOC, ARGDOC) */
LYD_OP("+", ADD, 2,
OP_LOOP(OUT = ARG(0) + ARG(1);),;,;,
"Adds values together <tt>value1 + value2</tt>", "")
LYD_OP("-", SUB, 2,
OP_LOOP(OUT = ARG(0) - ARG(1);),;,;,
"Subtracts values <tt>value1 - value2</tt>","")
LYD_OP("*", MUL, 2,
OP_LOOP(OUT = ARG(0) * ARG(1);),;,;,
"Multiplies values, useful for scaling amplitude <tt>expression1 * expression2</tt>","")
LYD_OP("/", DIV, 2,
OP_LOOP(OUT = ARG(1)!=0.0 ? ARG(0) / ARG(1):0.0;),;,;,
"Divides values, <tt>value1 / value2</tt>","")
LYD_OP("min", MIN, 2,
OP_LOOP(
if (ARG(0) > ARG(1))
OUT = ARG(1);
else
OUT = ARG(0);),;,;,
"Returns the smallest of two values","(expression1, expression2)")
LYD_OP("max", MAX, 2,
OP_LOOP(
if (ARG(0) < ARG(1))
OUT = ARG(1);
else
OUT = ARG(0);),;,;,
"Returns the largest of two values","(expression1, expression2)")
LYD_OP("rcp", RCP, 1,
OP_LOOP(OUT = 1.0/ARG(0);),;,;,
"Returns the reciprocal (1/value)","(expression)")
LYD_OP("sqrt", SQRT, 1,
OP_LOOP(OUT = sqrt(ARG(0));),;,;,
"Performs a square root on the input value", "(expression)")
LYD_OP("^", POW, 2,
OP_LOOP(OUT = powf (ARG(0), ARG(1));),;,;,
"Raises the value1 to the power of value2, <tt>value1 ^ value2</tt>","")
LYD_OP("%", MOD, 2,
OP_LOOP(OUT = fmodf (ARG(0),ARG(1));),;,;,
"Floating point modulus, <tt>value1 % value2</tt>","")
LYD_OP("abs", ABS, 1,
OP_LOOP(OUT = fabsf (ARG(0));),;,;,
"Makes the input value positive","(expression)")
LYD_OP("neg", NEG, 1,
OP_LOOP(OUT = -ARG(0);),;,;,
"Negates input value","(expression)")
/* oscillators */
LYD_OP("sin", SIN, 1,
OP_LOOP(OUT = sine (PHASE * M_PI * 2);),;,;,
"Sine wave osicllator","(hz)")
LYD_OP("saw", SAW, 1,
OP_LOOP(OUT = PHASE * 2 - 1.0;),;,;,
"Sawtooth oscillator", "(hz)")
LYD_OP("ramp", RAMP, 1,
OP_LOOP(OUT = -(PHASE * 2 - 1.0);),;,;,
"Ramp oscillator, opposite of sawtooth.","(hz)")
LYD_OP("square", SQUARE, 1,
OP_LOOP(OUT = PHASE > 0.5?1.0:-1.0;),;,;,
"Square wave oscillator equivalent to a pulse with pulse width 0.5, values varying between -1.0 and 1.0","(hz)")
LYD_OP("triangle", TRIANGLE, 1,
OP_LOOP(float p = PHASE;
OUT = p < 0.25 ? 0 + p *4 : p < 0.75 ? 2 - p * 4: -4 + p * 4;),;,;,
"Triangle waveform","(hz)")
LYD_OP("pulse", PULSE, 2,
OP_LOOP(OUT = PHASE > ARG(1)?1.0:-1.0;),;,;,
"Pulse oscillator to simulate square wave use a width of 0.5","(hz, duty)cycle)")
LYD_OP("noise", NOISE, 0,
OP_FUN(op_noise),;,;,
"Noise generator produces evenly distributed values in the range 0.0 to 1.0","()")
LYD_OP("input", INPUT, 1,
OP_FUN(op_input),;,;,
"Used when implementing filters, acts as a signal source", "(buffer_no)")
LYD_OP("inputp", INPUTP, 1,
OP_FUN(op_inputp),;,;,
"Used when implementing filters, acts as a signal source", "(buffer_no)")
LYD_OP("time", GTIME, 0,
OP_LOOP(OUT = TIME;),;,;,
"current time of sample running, in seconds","()")
LYD_OP("wave", WAVE, 2,
OP_FUN(op_wave),;,;,
"PCM data oscillator, first argument is a string, second argument if"
" present is gives pitch deviation determined by desired playback hz"
" assuming sample recorded is middle-C note that this does not work well"
" if the hz deviation is larger than a couple of half notes,. <em>a relative speed would probably be better.</em>, wave('test.wav')"
" wave('test.wav', 440.0)","('wave-identifier'[, hz])")
LYD_OP("wave_loop", WAVELOOP, 2,
OP_FUN(op_wave_loop),;,;,
"Like wave() but loops the given sample, needs to be scaled with an adsr"
" to be silenced.","('test.wav', hz)")
LYD_OP("abssin", ABSSIN, 1,
OP_LOOP(OUT = fabsf (sine (PHASE * M_PI * 2));),;,;,
"OPL2 oscillator","(hz)")
LYD_OP("possin", POSSIN, 1,
OP_LOOP(OUT = PHASE < 0.5 ? sine (PHASE_PEEK * M_PI * 2) : 0.0;),;,;,
"OPL2 oscillator","(hz)")
LYD_OP("pulssin", PULSSIN, 1,
OP_LOOP(OUT = fmodf (PHASE, 0.5) < 0.25 ?
fabsf (sine (PHASE_PEEK * M_PI * 2)) :
0.0;),;,;,
"OPL2 oscillator","(hz)")
LYD_OP("evensin", EVENSIN, 1,
OP_LOOP(OUT = PHASE < 0.5 ? sine (2 * PHASE_PEEK * M_PI * 2) : 0.0;),;,;,
"OPL3 oscillator","(hz)")
LYD_OP("evenpossin", EVENPOSSIN, 1,
OP_LOOP(OUT = PHASE < 0.5 ? fabs (sine (2 * PHASE_PEEK * M_PI * 2)) : 0.0;),;,;,
"OPL3 oscillator","(hz)")
LYD_OP("adsr", ADSR, 4,
OP_FUN (op_adsr),;,;,
"ADSR Envelope - provides values in range 0.0-1.0 if oscillators are"
" multiplied with an ADSR the amplitude will sink to 0.0 after release"
" and the voice will be automatically freed after release when it no "
" longer makes audio, <tt>sin(120)*adsr(0.3,0.3,0.8,1.5)</tt>",
"(attack, decay, sustain, release)")
LYD_OP("ddadsr", DDADSR, 6,
OP_FUN (op_ddadsr),;,;,
"DDADSR Envelope - like ADSR, but with delay and duration first",
"(delay, duration, atack, decay, sustain, release)")
LYD_OP("delay", DELAY, 2,
OP_FUN (op_delay),;,
op_free(state);,
"Delay signal, slows down a signal by amount of time in seconds.",
"(time, signal)")
LYD_OP("tapped_delay", TDELAY, 8,
OP_FUN (op_tapped_delay),;,
op_free(state);,
"Delay signal, slows down a signal by amount of time in seconds, multiple delays can be done concurrently their results are averaged.",
"(signal, tap1, [tap2..7])")
LYD_OP("echo", ECHO, 3,
OP_FUN (op_echo),;,
op_free(state);,
"Echo filter, implements a single feedback delay line", "(amount, delay, signal)")
LYD_OP("tapped_echo", TECHO, 8,
OP_FUN (op_tapped_echo),;,
op_free(state);,
"Delay signal, slows down a signal by amount of time in seconds, multiple delays can be done concurrently all their results are averaged for the result, the result is fed back to the delay line used.",
"(signal, tap1, [tap2..7])")
LYD_OP("pluck", PLUCK, 3,
OP_FUN (op_pluck),;,
op_free(state);,
"Plucked string, implements the decaying of the periodic wave form of a string using karplus strong algorithm, the decay ratio allows extending the duraiton of the decay in the range 1.0..., you can specify a custom waveform that is decayed by specifying a third argument with no third argument white noise is used., v", "(hz, [decayratio, [custom-waveform]])")
/* biquad frequency filters */
LYD_OP("low_pass", LOW_PASS, 4,
OP_FUN (op_filter),;,op_filter_free(state);,
"Low pass filter, for performance reasons the parameters of filters are not varying with sample accurate precision but vary per chunk of processed audio (at least for each 128 samples).",
"(gain, hz, bandwidth, signal)")
LYD_OP("high_pass", HIGH_PASS, 4,
OP_FUN (op_filter),;,op_filter_free(state);,
"High pass filter",
"(gain, hz, bandwidth, signal)")
LYD_OP("band_pass", BAND_PASS, 4,
OP_FUN (op_filter),;,op_filter_free(state);,
"Band pass filter",
"(gain, hz, bandwidth, signal)")
LYD_OP("notch", NOTCH, 4,
OP_FUN (op_filter),;,op_filter_free(state);,
"notch filter",
"(gain, hz, bandwidth, signal)")
LYD_OP("peak_eq", PEAK_EQ, 4,
OP_FUN (op_filter),;,op_filter_free(state);,
"peak eq filter",
"(gain, hz, bandwidth, signal)")
LYD_OP("low_shelf", LOW_SHELF, 4,
OP_FUN (op_filter),;,op_filter_free(state);,
"low shelf filter",
"(gain, hz, bandwidth, signal)")
LYD_OP("high_shelf", HIGH_SHELF, 4,
OP_FUN (op_filter),;,op_filter_free(state);,
"high shelf filter",
"(gain, hz, bandwidth, signal)")
LYD_OP("mix", MIX, LYD_MAX_ARGC,
OP_FUN (op_mix),;,;,
"Mixes inputs averaging down amplitude", "(expr1,expr2[, ... expr8])")
LYD_OP("cycle", CYCLE, LYD_MAX_ARGC,
OP_FUN (op_cycle),;,;,
"Cycles between provided input streams first argument gives frequency of source hopping.",
"(frequency, expr1, expr2[, ... expr7])")
LYD_OP("nop", NOP, 2,
OP_LOOP(OUT = state->literal[0][i];),;,;,
"returns the first of it's arguments used by the compiler to implement variables", "(value)")
LYD_OP("bar", BAR, 2,
OP_LYD("square(input(0)) + sin(input(1))"),;,;,
"", "(freq1, freq2)")
| true |
2e3ef65fac4913cbf940e42bffcccbb5ec1f92c7 | SQL | NiharRan/fiverr-invoice | /invoice.sql | UTF-8 | 3,335 | 3.390625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.2.11
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Apr 07, 2021 at 04:38 PM
-- Server version: 5.6.21
-- PHP Version: 5.6.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: `invoice`
--
-- --------------------------------------------------------
--
-- Table structure for table `customers`
--
CREATE TABLE IF NOT EXISTS `customers` (
`id` int(11) NOT NULL,
`name` varchar(200) NOT NULL,
`phone` varchar(50) NOT NULL,
`email` varchar(200) NOT NULL,
`address` text NOT NULL,
`city` varchar(100) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `customers`
--
INSERT INTO `customers` (`id`, `name`, `phone`, `email`, `address`, `city`, `created_at`, `updated_at`) VALUES
(1, 'Akash Das', '01761152187', 'akashdasmu12@gmail.com', 'Tahirpur', 'Sylhet', '2021-04-05 22:58:19', '2021-04-05 21:23:51'),
(2, 'Emmanuel Oliver', '09095996151', 'ewe@dd.com', 'Jani', 'Kalkata', '2021-04-05 23:01:08', '2021-04-05 21:24:11');
-- --------------------------------------------------------
--
-- Table structure for table `invoices`
--
CREATE TABLE IF NOT EXISTS `invoices` (
`id` int(11) NOT NULL,
`customer_id` int(11) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`discount` decimal(10,2) NOT NULL,
`vat` decimal(10,2) NOT NULL,
`net_amount` decimal(10,2) NOT NULL,
`dispatched_per` int(11) NOT NULL,
`remark` text NOT NULL,
`invoice_date` datetime NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `invoice_details`
--
CREATE TABLE IF NOT EXISTS `invoice_details` (
`id` int(11) NOT NULL,
`invoice_id` int(11) NOT NULL,
`product_name` varchar(200) NOT NULL,
`unit` varchar(10) NOT NULL,
`quantity` decimal(10,2) NOT NULL,
`per_unit` decimal(10,2) NOT NULL,
`total` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `invoices`
--
ALTER TABLE `invoices`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `invoice_details`
--
ALTER TABLE `invoice_details`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `invoices`
--
ALTER TABLE `invoices`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `invoice_details`
--
ALTER TABLE `invoice_details`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
/*!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 |
4b233bf4f30051ba4091c99f051314c412f3d0fb | SQL | github188/smartbooks | /SmartThird/河南交通厅高管局网站/08河南省高管局路政信息管理系统/FreeDBScript/package/ORAHYD.PKG_PATROL_QUERY_ddl.sql | GB18030 | 2,453 | 3.609375 | 4 | [] | no_license | -- Start of DDL Script for Package ORAHYD.PKG_PATROL_QUERY
-- Generated 29--2012 14:31:34 from ORAHYD@ORAHYD
CREATE OR REPLACE
PACKAGE orahyd.pkg_patrol_query
IS
/*
----------------------------------------------------------------------------
--̰PKG_PATROL_QUERY
--ߣ
--ʱ䣺2012-5-07
--˵˰Ѳ־ݲѯ
----------------------------------------------------------------------------
*/
TYPE refcursortype IS REF CURSOR; --αͶ壬ڷݼ
PROCEDURE proc_getdeptlog (
begintime IN DATE, --ѯʼʱ
endtime IN DATE, --ѯʱ
dptcode IN NUMBER, --ű
out_cursor OUT refcursortype
);
END pkg_patrol_query; -- Package spec
/
CREATE OR REPLACE
PACKAGE BODY orahyd.pkg_patrol_query
IS
PROCEDURE proc_getdeptlog (
begintime IN DATE, --ѯʼʱ
endtime IN DATE, --ѯʱ
dptcode IN NUMBER, --ű
out_cursor OUT refcursortype
)
IS
/*
----------------------------------------------------------------------------
--洢̣proc_getdeptlog
--ߣ
--ʱ䣺2012-05-07
--˵ȡָIDŲѲ־
--
--
--------------------------------------------------------------------------
*/
BEGIN
OPEN out_cursor FOR
/*,ѲԱ,Ѳ鳵ƺ,Ѳ,,Ӱʱ,ӰѲ̱߳KM*/
SELECT b.dptname, c.username, a.busnumber, a.mileage, a.weather,
TO_DATE (a.ticktime, 'yyyy-mm-dd') AS ticktime, a.buskm
FROM base_patrol a, base_dept b, base_user c
WHERE a.deptid = b.deptid
AND a.ticktime >= begintime
AND a.ticktime <= endtime
AND a.deptid = dptcode
AND a.patroluser = c.userid;
END;
END pkg_patrol_query;
/
-- End of DDL Script for Package ORAHYD.PKG_PATROL_QUERY
| true |
47c5589b1655f78136cb0ba41e62ec202660533e | SQL | mfleitao/SQL-Language | /seneca-lab/lab 4/L04_MATHEUS_LEITAO.sql | UTF-8 | 3,103 | 4.375 | 4 | [] | no_license | -- ***********************
-- Name: Matheus Leitao
-- ID: 148 300 171
-- Date: 01/31/2019
-- Purpose: Lab 4 DBS301
-- ***********************
-- Question 1
-- Display the difference between the Average pay and Lowest pay in the company. Name this result Real Amount. Format the
-- output as currency with 2 decimal places.
SELECT to_char(avg(salary) - min(salary), '$999,999.00') AS "Real Amount"
FROM employees;
-- Question 2
-- Display the department number and Highest, Lowest and Average pay per each department. Name these results High, Low and Avg.
-- Sort the output so that the department with highest average salary is shown first. Format the output as currency where
-- appropriate.
SELECT department_id,
to_char(max(salary), '$999,999.00') AS "High",
to_char(min(salary), '$999,999.00') AS "Low",
to_char(avg(salary), '$999,999.00') AS "Avg"
FROM employees
GROUP BY department_id
ORDER BY "Avg" DESC;
-- Question 3
-- Display how many people work the same job in the same department. Name these results Dept#, Job and How Many. Include only
-- jobs that involve more than one person. Sort the output so that jobs with the most people involved are shown first.
SELECT department_id AS "Dept#",
job_id AS "Job",
count(job_id) AS "How Many"
FROM employees
GROUP BY job_id, department_id
HAVING count(job_id) > 1
ORDER BY "How Many" DESC;
-- Question 4
-- For each job title display the job title and total amount paid each month for this type of the job. Exclude titles AD_PRES
-- and AD_VP and also include only jobs that require more than $11,000. Sort the output so that top paid jobs are shown first
SELECT job_id AS "Job Title",
sum(salary) AS "Amount Paid"
FROM employees
WHERE job_id NOT IN('AD_PRES', 'AD_VP')
AND salary > 11000
GROUP BY job_id, department_id
ORDER BY "Amount Paid" DESC;
-- Question 5
-- For each manager number display how many persons he / she supervises. Exclude managers with numbers 100, 101 and 102 and
-- also include only those managers that supervise more than 2 persons. Sort the output so that manager numbers with the
-- most supervised persons are shown first.
SELECT manager_id,
count(employee_id) AS "Number of People"
FROM employees
WHERE manager_id NOT IN(100, 101, 102)
GROUP BY manager_id
HAVING count(employee_id) > 2
ORDER BY "Number of People" DESC;
-- Question 6
-- For each department show the latest and earliest hire date, BUT exclude departments 10 and 20 exclude those departments where
-- the last person was hired in this decade. (it is okay to hard code dates in this question only) Sort the output so that the
-- most recent, meaning latest hire dates, are shown first.
SELECT max(hire_date) AS "Latest Hire Date",
min(hire_date) AS "Earliest Hire Date"
FROM employees
WHERE hire_date NOT BETWEEN to_date('2011-01-01', 'YYYY-MM-DD') AND to_date('2020-12-31', 'YYYY-MM-DD')
AND department_id NOT IN(10, 20)
ORDER BY hire_date DESC;
| true |
911b6446125e595d94d262dea01d9067d533c0f5 | SQL | Seif-Abaza/BuyAndSellOnline | /database/database_schema.sql | UTF-8 | 3,346 | 3.921875 | 4 | [] | no_license | -- Drop and recreate the database.
DROP DATABASE IF EXISTS baso;
CREATE DATABASE baso;
-- Use the database.
USE baso;
-- Create groups, such as members, administrators, etc.
CREATE TABLE `groups` ( `id` INT(1) NOT NULL,
`name` VARCHAR(20) NOT NULL UNIQUE,
PRIMARY KEY(`id`)
) ENGINE=MyISAM;
CREATE TABLE `countries` ( `id` CHAR(2) NOT NULL,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY(`id`)
) ENGINE=MyISAM;
-- Create users, mostly holding OpenID and group.
CREATE TABLE `users` ( `id` integer auto_increment,
`username` varchar(20),
`password` char(40),
`email` varchar(50),
`openid` char(80),
`facebookid` char(20),
`nickname` varchar(20),
`first_name` varchar(20),
`last_name` varchar(20),
`address` varchar(30),
`country_id` char(2),
`city` varchar(20),
`zip` char(8),
`group_id` INT(1) DEFAULT 1,
`created` DATETIME,
`modified` DATETIME,
`banned` BOOLEAN DEFAULT FALSE,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
-- Create categories, that items can belong to.
CREATE TABLE `categories` ( `id` INT(2) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(20) NOT NULL UNIQUE,
`category_id` INT(2) DEFAULT NULL,
PRIMARY KEY(`id`)
) ENGINE=MyISAM;
-- Create items, that has information about items a user added.
CREATE TABLE `items` ( `id` INTEGER NOT NULL AUTO_INCREMENT,
`user_id` INTEGER NOT NULL,
`name` VARCHAR(20) NOT NULL,
`description` TEXT NOT NULL,
`category_id` INT(2) NOT NULL,
`price` DECIMAL(6,2) UNSIGNED NOT NULL,
`sold` BOOLEAN NOT NULL DEFAULT FALSE,
`paypal` VARCHAR(100) NOT NULL,
`paypalpass` VARCHAR(100),
`paypalsignature` VARCHAR(100),
`image` CHAR(36) DEFAULT NULL,
`created` DATETIME NOT NULL,
`modified` DATETIME,
`agreed` BOOLEAN NOT NULL DEFAULT 0,
PRIMARY KEY(`id`)
) ENGINE=MyISAM;
-- Create tags, that describe an item.
CREATE TABLE `tags` ( `id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(20) NOT NULL,
PRIMARY KEY(`id`)
) ENGINE=MyISAM;
-- Create table for connections between items and tags.
CREATE TABLE `items_tags` ( `id` INTEGER NOT NULL AUTO_INCREMENT,
`item_id` INTEGER NOT NULL,
`tag_id` INTEGER NOT NULL,
PRIMARY KEY(`id`)
) ENGINE=MyISAM;
-- Create purchases, that keep track of all purchases and when confirmed is set
-- to true, the payment should go to the seller.
CREATE TABLE `purchases` ( `id` INTEGER NOT NULL AUTO_INCREMENT,
`user_id` INTEGER,
`item_id` INTEGER,
`confirmed` BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY(`id`)
) ENGINE=MyISAM;
-- Create ACL tables
SOURCE db_acl.sql;
| true |
ae1ef4569fc52b63f9a8aa8592e3910897587668 | SQL | DanielOfad/showcase | /projects/bookmyshow_clone/sql/review_search.txt | UTF-8 | 353 | 2.671875 | 3 | [] | no_license | mysql> SELECT * FROM comments JOIN user ON user.id = comments.user_id WHERE user.name = 'neel';
+----+---------------+---------+----+------+
| id | name | user_id | id | name |
+----+---------------+---------+----+------+
| 3 | K3G emotional | 2 | 2 | neel |
+----+---------------+---------+----+------+
1 row in set (0.00 sec)
mysql> | true |
a3e920c1804ea5c5dac88a72e9549d02affed707 | SQL | erankitsrivastava/Algo-Trading-Strategies-PHP | /stock_monthly_values.sql | UTF-8 | 1,203 | 3.234375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Dec 14, 2019 at 08:22 AM
-- Server version: 10.3.15-MariaDB
-- PHP Version: 7.1.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
--
-- Database: `stock-market`
--
-- --------------------------------------------------------
--
-- Table structure for table `stock_daily_values`
--
CREATE TABLE `stock_monthly_values` (
`id` int(11) NOT NULL,
`stockid` int(11) NOT NULL,
`price_open` varchar(255) NOT NULL,
`price_high` varchar(255) NOT NULL,
`price_low` varchar(255) NOT NULL,
`price_close` varchar(255) NOT NULL,
`volume` varchar(255) NOT NULL,
`trade_date` date NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `stock_daily_values`
--
ALTER TABLE `stock_monthly_values`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `stock_daily_values`
--
ALTER TABLE `stock_monthly_values`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;
| true |
9c2ebb2035fc0cb0a62ab352fd24efdc32f25631 | SQL | zhanggang-24/JAVA-01 | /Week_07/2021-03-03/dataSouce/version1/table.sql | UTF-8 | 1,113 | 3.1875 | 3 | [] | no_license | -- master 库
CREATE DATABASE IF NOT EXISTS master;
USE master;
CREATE TABLE IF NOT EXISTS account(
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
name VARCHAR(100) NOT NULL,
phone VARCHAR(20) NOT NULL,
money DECIMAL(10,2) NOT NULL,
PRIMARY key(id)
);
insert into account(name,phone,money) values('master-张三','1829999999',12.12),('master-李四','1829999999',12.12);
-- slave1 库
CREATE DATABASE IF NOT EXISTS slave1;
USE slave1;
CREATE TABLE IF NOT EXISTS account(
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
name VARCHAR(100) NOT NULL,
phone VARCHAR(20) NOT NULL,
money DECIMAL(10,2) NOT NULL,
PRIMARY key(id)
);
insert into account(name,phone,money) values('slave1-张三','1829999999',12.12),('slave1-李四','1829999999',12.12);
-- slave2 库
CREATE DATABASE IF NOT EXISTS slave2;
USE slave2;
CREATE TABLE IF NOT EXISTS account(
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
name VARCHAR(100) NOT NULL,
phone VARCHAR(20) NOT NULL,
money DECIMAL(10,2) NOT NULL,
PRIMARY key(id)
);
insert into account(name,phone,money) values('slave2-张三','1829999999',12.12),('slave2-李四','1829999999',12.12); | true |
ce4955dd38b38778015b15b952f26409a776d686 | SQL | codylee02/babytivities-api | /migrations/001.do.create_project_db.sql | UTF-8 | 1,263 | 3.75 | 4 | [] | no_license | CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TYPE type AS ENUM (
'Physical',
'Literacy',
'Art',
'Sensory',
'Science'
);
CREATE TYPE age AS ENUM (
'0-3m',
'4-6m',
'7-12m',
'13-24m',
'25-36m',
'36m+'
);
CREATE TABLE babytivities_users (
id uuid DEFAULT uuid_generate_v4 () UNIQUE,
username TEXT NOT NULL UNIQUE,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
password TEXT NOT NULL,
date_created TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (id)
);
CREATE TABLE babytivities_activities (
id uuid DEFAULT uuid_generate_v4 () UNIQUE,
title TEXT NOT NULL,
instructions TEXT NOT NULL,
image TEXT,
age age,
type type,
date_created TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (id)
);
CREATE TABLE babytivities_favorites (
id uuid DEFAULT uuid_generate_v4 () UNIQUE,
user_id uuid REFERENCES babytivities_users(id) ON DELETE CASCADE NOT NULL,
activity_id uuid REFERENCES babytivities_activities(id) ON DELETE CASCADE NOT NULL,
date_created TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (id)
);
CREATE TABLE babytivities_materials (
id uuid DEFAULT uuid_generate_v4 () UNIQUE,
item TEXT NOT NULL,
activity_id uuid REFERENCES babytivities_activities(id) ON DELETE CASCADE,
PRIMARY KEY (id)
); | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.