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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
86a51643243a9b1ff8993a56961729920199777d | SQL | earthgecko/skyline | /updates/sql/luminosity-v1.2.1-beta-to-v1.2.2-stable.sql | UTF-8 | 942 | 3.15625 | 3 | [
"MIT"
] | permissive | /*
This the the SQL script to update Skyline from Luminosity (v1.2.1-beta - v1.2.1-stable)
*/
USE skyline;
# @added 20180715 - Task #2446: Optimize Ionosphere
# Branch #2270: luminosity
ALTER TABLE `ionosphere_matched` ADD COLUMN `fp_count` INT(10) DEFAULT 0 COMMENT 'the total number of features profiles for the metric which were valid to check' AFTER `minmax_anomalous_features_count`;
ALTER TABLE `ionosphere_matched` ADD COLUMN `fp_checked` INT(10) DEFAULT 0 COMMENT 'the number of features profiles checked until the match was made' AFTER `fp_count`;
ALTER TABLE `ionosphere_layers_matched` ADD COLUMN `layers_count` INT(10) DEFAULT 0 COMMENT 'the total number of layers for the metric which were valid to check' AFTER `full_duration`;
ALTER TABLE `ionosphere_layers_matched` ADD COLUMN `layers_checked` INT(10) DEFAULT 0 COMMENT 'the number of layers checked until the match was made' AFTER `layers_count`;
COMMIT;
| true |
d8fc12341cad0108f0ba21bffc8b3bec831b6d9e | SQL | ClickHouse/ClickHouse | /tests/queries/0_stateless/00411_merge_tree_where_const_in_set.sql | UTF-8 | 727 | 3.25 | 3 | [
"Apache-2.0",
"BSL-1.0"
] | permissive | DROP TABLE IF EXISTS const_in_const;
set allow_deprecated_syntax_for_merge_tree=1;
CREATE TABLE const_in_const (id UInt64, date Date, uid UInt32, name String, Sign Int8) ENGINE = CollapsingMergeTree(date, intHash32(uid), (id, date, intHash32(uid)), 8192, Sign);
INSERT INTO const_in_const VALUES(1, now(), 1, 'test1', 1);
INSERT INTO const_in_const VALUES(2, now(), 1, 'test2', 1);
INSERT INTO const_in_const VALUES(3, now(), 1, 'test3', 1);
INSERT INTO const_in_const VALUES(4, now(), 2, 'test4', 1);
INSERT INTO const_in_const VALUES(5, now(), 3, 'test5', 1);
SELECT 1 from const_in_const where 42 in (225);
SELECT name FROM const_in_const WHERE 1 IN (125, 1, 2) ORDER BY name LIMIT 1;
DROP TABLE IF EXISTS const_in_const;
| true |
d3bd9f48d5465d5d6a0ddac3521ba517826b49c4 | SQL | fnazih/Databases-in-SQL | /TP2/code.sql | UTF-8 | 2,833 | 3.734375 | 4 | [] | no_license | -- 1) Correction d’erreurs d’insertion :
--1.a)
INSERT INTO formateur VALUES(default, 'Jacques', 'Mesrine');
--(l’dentifiant 1 ayant déjà été pris, on utilise le premier disponible a la suite grace a la commande default qui a été initialisee avec l’auto-incrementation).
--1.b)
INSERT INTO inscrire VALUES(21, 'X00005', 1);
--(Il suffit simplement de mettre un numero de formation existant dans la table « formation »).
--1.c)
INSERT INTO inscrire VALUES(42, 10198, 1);
--(il suffit simplement de mettre un identifiant de stagiaire déjà present dans la table « stagiaire »).
--1.d)
INSERT INTO planifier VALUES(42, 6, '2019-01-23', 1, 2, 1, 'Matin', 'E410');
--(la valeur NULL est interdite dans la colonne « groupe », il suffit de mettre une valeur de groupe correcte).
-- 2) Modification de la date d’une formation :
UPDATE planifier
SET dateform = dateform + 9
WHERE id_formation = 37;
-- 3) Suppression de la formation « Bases de donnees (ACCESS) » :
DELETE FROM inscrire
WHERE id_formation = 35;
DELETE FROM planifier
WHERE id_formation = 35;
DELETE FROM formation
WHERE id_formation = 35;
-- 4) Conversion en minuscules :
UPDATE formateur
SET nom_formateur = LOWER(nom_formateur),
prenom_formateur = LOWER(prenom_formateur);
-- 5) Conversion en majuscules :
UPDATE formateur
SET nom_formateur = INITCAP(nom_formateur),
prenom_formateur = INITCAP(prenom_formateur);
-- 6) Modification de salle :
UPDATE planifier
SET numsalle = 'G333'
WHERE dateform BETWEEN '09-04-2006' AND '08-05-2006';
-- 7) Modification de la date de formation :
UPDATE planifier
SET dateform = dateform + 3
WHERE dateform = date '01-01-2006' + INTERVAL '138 DAY';
-- 8) Depart d’un formateur, qui sera remplace par un nouveau :
--8.A)
SELECT p.id_formation, p.id_formateur, TO_CHAR(p.dateform, 'dd/mm/YY') AS "Date formation", p.groupe, p.duree, p.numseance, p.mat_am, p.numsalle, f.nom_formateur, f.prenom_formateur, f1.intitule_formation
FROM planifier p INNER JOIN formateur f ON p.id_formateur = f.id_formateur
INNER JOIN formation f1 ON p.id_formation = f1.id_formation;
--8.B.a)
INSERT INTO formateur VALUES(default, 'Durant', 'Pierre') ;
--8.B.b)
UPDATE planifier
SET id_formateur = (SELECT id_formateur FROM formateur WHERE nom_formateur LIKE 'Durant' AND prenom_formateur LIKE 'Pierre')
WHERE id_formateur = (SELECT id_formateur FROM formateur WHERE nom_formateur LIKE 'Cancel' AND prenom_formateur LIKE 'Christophe');
--8.C)
SELECT *
FROM planifier ;
-- 9) Ajout d’une formation et inscription :
--9.A)
INSERT INTO formation VALUES(default, 'JavaScript', 12, 'Confirme');
--9.B)
INSERT INTO inscrire(id_formation, id_stagiaire, groupe)
SELECT (SELECT id_formation FROM formation WHERE intitule_formation = 'JavaScript'), id_stagiaire, groupe
FROM inscrire
WHERE id_formation = 26;
| true |
c78d27c38a43c1f876e4360f2c14ea6994b7f1d0 | SQL | tainenko/Leetcode2019 | /leetcode/editor/en/[2066]Account Balance.sql | UTF-8 | 2,486 | 4.5625 | 5 | [] | no_license | #Table: Transactions
#
#
#+-------------+------+
#| Column Name | Type |
#+-------------+------+
#| account_id | int |
#| day | date |
#| type | ENUM |
#| amount | int |
#+-------------+------+
#(account_id, day) is the primary key for this table.
#Each row contains information about one transaction, including the transaction
#type, the day it occurred on, and the amount.
#type is an ENUM of the type ('Deposit','Withdraw')
#
#
#
#
# Write an SQL query to report the balance of each user after each transaction.
#You may assume that the balance of each account before any transaction is 0 and
#that the balance will never be below 0 at any moment.
#
# Return the result table in ascending order by account_id, then by day in case
#of a tie.
#
# The query result format is in the following example.
#
#
# Example 1:
#
#
#Input:
#Transactions table:
#+------------+------------+----------+--------+
#| account_id | day | type | amount |
#+------------+------------+----------+--------+
#| 1 | 2021-11-07 | Deposit | 2000 |
#| 1 | 2021-11-09 | Withdraw | 1000 |
#| 1 | 2021-11-11 | Deposit | 3000 |
#| 2 | 2021-12-07 | Deposit | 7000 |
#| 2 | 2021-12-12 | Withdraw | 7000 |
#+------------+------------+----------+--------+
#Output:
#+------------+------------+---------+
#| account_id | day | balance |
#+------------+------------+---------+
#| 1 | 2021-11-07 | 2000 |
#| 1 | 2021-11-09 | 1000 |
#| 1 | 2021-11-11 | 4000 |
#| 2 | 2021-12-07 | 7000 |
#| 2 | 2021-12-12 | 0 |
#+------------+------------+---------+
#Explanation:
#Account 1:
#- Initial balance is 0.
#- 2021-11-07 --> deposit 2000. Balance is 0 + 2000 = 2000.
#- 2021-11-09 --> withdraw 1000. Balance is 2000 - 1000 = 1000.
#- 2021-11-11 --> deposit 3000. Balance is 1000 + 3000 = 4000.
#Account 2:
#- Initial balance is 0.
#- 2021-12-07 --> deposit 7000. Balance is 0 + 7000 = 7000.
#- 2021-12-12 --> withdraw 7000. Balance is 7000 - 7000 = 0.
#
#
# Related Topics Database 👍 62 👎 2
#leetcode submit region begin(Prohibit modification and deletion)
# Write your MySQL query statement below
select account_id, day, sum(case when type='Deposit' then amount else -amount end) over(partition by account_id order by day) balance
from transactions
order by account_id, day;
#leetcode submit region end(Prohibit modification and deletion)
| true |
e319dfeb805a81eddb278a17d32fe9c0e2f015b1 | SQL | fermi-lat/mootCore | /maint/createAncillary.sql | UTF-8 | 1,634 | 3.3125 | 3 | [
"BSD-3-Clause"
] | permissive | create table Ancillary
(Ancillary_key INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
class_fk INT UNSIGNED NOT NULL
COMMENT 'refers to row in Ancillary_class',
instrument varchar(16) not null default 'LAT'
COMMENT 'e.g. LAT, EM2 ',
source VARCHAR(255) NOT NULL
COMMENT 'path to file in Moot archive, relative to root',
source_fmt VARCHAR(32) NOT NULL
COMMENT 'could be, e.g. xml',
GMT_create_time DATETIME
COMMENT 'When file this row refers to was created',
creation_time DATETIME
COMMENT 'When this row was created',
creator VARCHAR(32) NOT NULL
COMMENT 'Who or what created the row',
quality ENUM('PROD', 'DEV', 'TEST', 'SUPSED', 'INVALID')
NOT NULL,
description VARCHAR(255) NOT NULL
COMMENT 'a place to mention anything special about this ancillary
instance',
## tower TINYINT DEFAULT '-1' NOT NULL
## COMMENT 'Ancillary info may be by tower or by entire detector',
status ENUM('STARTED', 'ABORT', 'CREATED', 'INVALID')
NOT NULL DEFAULT 'STARTED'
COMMENT 'refers to status of entry, in case file has to be copied',
inspect_state VARCHAR(32) NOT NULL DEFAULT 'NOT_INSPECTED'
COMMENT 'typical values are NOT_INSPECTED, PASSED, FAILED..',
INDEX(class_fk),
FOREIGN KEY(class_fk) REFERENCES Ancillary_class (Ancillary_class_key)
ON DELETE CASCADE
ON UPDATE CASCADE
) TYPE=InnoDB
COMMENT='a row defines an instance of one of the ancillary types in Ancillary_class';
| true |
2b8e35a3317d1332132977c1375cbbe37d75188d | SQL | tayduivn/training | /rdbms/update/.svn/text-base/sacwis_611.sql.svn-base | UTF-8 | 1,949 | 2.796875 | 3 | [] | no_license | --STGAP00015600 - Release(3.4) SQR: Enable new report APPLA Exception Cases
-- APPLA Exception SMS Req#38480 ; SMS Proj#39457
-- Dependency: DBCR 15595 (MR-057: add Placement new columns); DBCR 15596 (view Most recent placement by month)
insert into caps.reports (nm_rpt_sqr_name, nm_rpt_sqr_ver, nbr_rpt_retainage, nm_rpt_type,
txt_rpt_full_name, nm_rpt_template_name, nm_rpt_orientation, txt_rpt_email_options, nm_rpt_desc,
nm_rpt_area_type, ind_rpt_page)
values ('APPLAExceptionList', '00', 31, 'A', 'APPLA Exception Cases', 'ondport',
'L', 'W', 'A list of APPLA children whose permanency goal has not been met. Generated for a specific month with optional region, county, and unit parameters.',
'CFSR', 'Y');
insert into caps.report_parameter (nm_rpt_sqr_name, nm_rpt_sqr_ver, nbr_rpt_parm_seq,
nbr_rpt_parm_length, nm_rpt_parm_name, txt_rpt_parm_type, ind_required, nm_rpt_parm_label)
values ('APPLAExceptionList', '00', 1, 7, 'MONTHYEAR', 'CHAR', 'Y', 'Month/Year(mm/yyyy)');
insert into caps.report_parameter (nm_rpt_sqr_name, nm_rpt_sqr_ver, nbr_rpt_parm_seq,
nbr_rpt_parm_length, nm_rpt_parm_name, txt_rpt_parm_type, ind_required, nm_rpt_parm_label)
values ('APPLAExceptionList', '00', 2, 2, 'REGIONCD', 'CHAR', 'N', 'Region');
insert into caps.report_parameter (nm_rpt_sqr_name, nm_rpt_sqr_ver, nbr_rpt_parm_seq,
nbr_rpt_parm_length, nm_rpt_parm_name, txt_rpt_parm_type, ind_required, nm_rpt_parm_label)
values ('APPLAExceptionList', '00', 3, 3, 'COUNTYCD', 'CHAR', 'N', 'County');
insert into caps.report_parameter (nm_rpt_sqr_name, nm_rpt_sqr_ver, nbr_rpt_parm_seq,
nbr_rpt_parm_length, nm_rpt_parm_name, txt_rpt_parm_type, ind_required, nm_rpt_parm_label)
values ('APPLAExceptionList', '00', 4, 2, 'UNIT', 'NUMBER', 'N', 'Unit');
insert into caps.schema_version(id_schema_version,application_version,comments)
values (612, 'SacwisRev3', 'Release 3.4 - DBCR 15600');
commit;
| true |
ee6f4396f867d3714e5b2a59ca7cb553f2766e14 | SQL | nigelbayliss/oracle-db-examples | /machine-learning/sql/21c/oml4sql-feature-extraction-text-mining-nmf.sql | UTF-8 | 5,834 | 3.34375 | 3 | [
"UPL-1.0",
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | -----------------------------------------------------------------------
-- Oracle Machine Learning for SQL (OML4SQL) 21c
--
-- Feature Extraction - NMF Algorithm with Text Mining - dmtxtnmf.sql
--
-- Copyright (c) 2021 Oracle Corporation and/or its affilitiates.
--
-- The Universal Permissive License (UPL), Version 1.0
--
-- https://oss.oracle.com/licenses/upl/
-----------------------------------------------------------------------
SET serveroutput ON
SET trimspool ON
SET pages 10000
SET echo ON
-----------------------------------------------------------------------
-- SAMPLE PROBLEM
-----------------------------------------------------------------------
-- Mine text features using NMF algorithm.
-----------------------------------------------------------------------
-- SET UP AND ANALYZE THE DATA
-----------------------------------------------------------------------
-- Create a policy for text feature extraction
-- The policy will include stemming
begin
ctx_ddl.drop_policy('dmdemo_nmf_policy');
exception when others then null;
end;
/
begin
ctx_ddl.drop_preference('dmdemo_nmf_lexer');
exception when others then null;
end;
/
begin
ctx_ddl.create_preference('dmdemo_nmf_lexer', 'BASIC_LEXER');
ctx_ddl.set_attribute('dmdemo_nmf_lexer', 'index_stems', 'ENGLISH');
-- ctx_ddl.set_attribute('dmdemo_nmf_lexer', 'index_themes', 'YES');
end;
/
begin
ctx_ddl.create_policy('dmdemo_nmf_policy', lexer=>'dmdemo_nmf_lexer');
end;
/
-----------------------------------------------------------------------
-- BUILD THE MODEL
-----------------------------------------------------------------------
-- Cleanup old model and objects for repeat runs
BEGIN DBMS_DATA_MINING.DROP_MODEL('T_NMF_Sample');
EXCEPTION WHEN OTHERS THEN NULL; END;
/
BEGIN EXECUTE IMMEDIATE 'DROP TABLE t_nmf_sample_settings';
EXCEPTION WHEN OTHERS THEN NULL; END;
/
-------------------------------------------
-- CREATE A NEW MODEL USING SETTINGS TABLE
-- Note the transform makes the 'comments' attribute
-- to be treated as unstructured text data
--
-- Create settings table to choose text policy and auto data prep
CREATE TABLE t_nmf_sample_settings (
setting_name VARCHAR2(30),
setting_value VARCHAR2(4000));
BEGIN
-- Populate settings table
INSERT INTO t_nmf_sample_settings VALUES
(dbms_data_mining.prep_auto, dbms_data_mining.prep_auto_on);
INSERT INTO t_nmf_sample_settings VALUES(
dbms_data_mining.odms_text_policy_name, 'DMDEMO_NMF_POLICY');
--(dbms_data_mining.nmfs_conv_tolerance,0.05);
--(dbms_data_mining.nmfs_num_iterations,50);
--(dbms_data_mining.nmfs_random_seed,-1);
--(dbms_data_mining.nmfs_stop_criteria,dbms_data_mining.nmfs_sc_iter_or_conv);
COMMIT;
END;
/
DECLARE
xformlist dbms_data_mining_transform.TRANSFORM_LIST;
BEGIN
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'comments', null, 'comments', null, 'TEXT(TOKEN_TYPE:STEM)');
-- xformlist, 'comments', null, 'comments', null, 'TEXT(TOKEN_TYPE:THEME)');
DBMS_DATA_MINING.CREATE_MODEL(
model_name => 'T_NMF_Sample',
mining_function => dbms_data_mining.feature_extraction,
data_table_name => 'mining_build_text',
case_id_column_name => 'cust_id',
settings_table_name => 't_nmf_sample_settings',
xform_list => xformlist);
END;
/
--------------------------------------------------------
-- CREATE A NEW MODEL USING V_SETLST (NO SETTINGS TABLE)
-- Note the transform makes the 'comments' attribute
-- to be treated as unstructured text data
--
DECLARE
v_setlst DBMS_DATA_MINING.SETTING_LIST;
xformlist dbms_data_mining_transform.TRANSFORM_LIST;
BEGIN
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'comments', null, 'comments', null, 'TEXT(TOKEN_TYPE:STEM)');
-- xformlist, 'comments', null, 'comments', null, 'TEXT(TOKEN_TYPE:THEME)');
v_setlst('PREP_AUTO') := 'ON';
v_setlst('ALGO_NAME') := 'ALGO_NMF';
V_setlst('odms_text_policy_name' := 'DMDEMO_NMF_POLICY';
DBMS_DATA_MINING.CREATE_MODEL2(
'T_NMF_Sample',
'FEATURE_EXTRACTION',
'SELECT * FROM mining_build_text',
v_setlst,
'cust_id',
'AFFINITY_CARD');
END;
-------------------------
-- DISPLAY MODEL SETTINGS
--
column setting_name format a30;
column setting_value format a30;
SELECT setting_name, setting_value
FROM user_mining_model_settings
WHERE model_name = 'T_NMF_SAMPLE'
ORDER BY setting_name;
--------------------------
-- DISPLAY MODEL SIGNATURE
--
column attribute_name format a40
column attribute_type format a20
SELECT attribute_name, attribute_type
FROM user_mining_model_attributes
WHERE model_name = 'T_NMF_SAMPLE'
ORDER BY attribute_name;
------------------------
-- DISPLAY MODEL DETAILS
--
-- Get a list of model views
col view_name format a30
col view_type format a50
SELECT view_name, view_type FROM user_mining_model_views
WHERE model_name='T_NMF_SAMPLE'
ORDER BY view_name;
column attribute_name format a30;
column attribute_value format a20;
column coefficient format 9.99999;
set pages 15;
SET line 120;
break ON feature_id;
SELECT * FROM (
SELECT feature_id,
nvl2(attribute_subname,
attribute_name||'.'||attribute_subname,
attribute_name) attribute_name,
attribute_value,
coefficient
FROM DM$VET_NMF_SAMPLE
WHERE feature_id < 3
ORDER BY 1,2,3,4)
WHERE ROWNUM < 21;
-----------------------------------------------------------------------
-- APPLY THE MODEL
-----------------------------------------------------------------------
-- See dmnmdemo.sql for examples.
| true |
2a458a399fe6a45f36c12534afba125dc8039b6a | SQL | librar127/PythonDS | /Leetcode/SQL/Hard/1127.sql | UTF-8 | 937 | 4.5 | 4 | [] | no_license | -- Write your MySQL query statement below
WITH distinct_platform AS
(
SELECT "desktop" AS platform
UNION ALL
SELECT "mobile" AS platform
UNION ALL
SELECT "both" AS platform
),
date_platform AS
(
SELECT
DISTINCT(A.spend_date)spend_date ,
B.platform
FROM
Spending A, distinct_platform B
),
user_platform AS
(
SELECT
user_id,
spend_date,
CASE WHEN GROUP_CONCAT(platform) like "%,%" THEN "both" else GROUP_CONCAT(platform) END AS platform,
SUM(amount) total_amount
FROM
Spending
GROUP BY
user_id,
spend_date
)
SELECT
A.spend_date,
A.platform,
ifnull(SUM(B.total_amount), 0) total_amount,
ifnull(count(distinct B.user_id), 0)total_users
FROM
date_platform A
LEFT JOIN
user_platform B
ON
A.spend_date = B.spend_date
AND
A.platform = B.platform
GROUP BY
A.platform,
A.spend_date | true |
eca911f1b7309156a2933d6460901fe4d4915d6f | SQL | asciiu/polo | /conf/evolutions/default/2.sql | UTF-8 | 1,066 | 3.09375 | 3 | [
"MIT"
] | permissive | #
# --- !Ups
DROP TABLE IF EXISTS poloniex_messages;
DROP TABLE IF EXISTS poloniex_candles;
CREATE TABLE poloniex_messages (
id serial PRIMARY KEY,
crypto_currency text NOT NULL,
last NUMERIC(12, 8) NOT NULL,
lowest_ask NUMERIC(12, 8) NOT NULL,
highest_bid NUMERIC(12, 8) NOT NULL,
percent_change NUMERIC(12, 8) NOT NULL,
base_volume NUMERIC(24, 8) NOT NULL,
quote_volume NUMERIC(24, 8) NOT NULL,
is_frozen BOOLEAN NOT NULL,
high_24hr NUMERIC(12, 8) NOT NULL,
low_24hr NUMERIC(12, 8) NOT NULL,
created_at timestamp without time zone not null default now(),
updated_at timestamp without time zone not null default now()
);
CREATE TABLE poloniex_candles (
id serial PRIMARY KEY,
crypto_currency text NOT NULL,
open NUMERIC(12, 8) NOT NULL,
close NUMERIC(12, 8) NOT NULL,
lowest_ask NUMERIC(12, 8) NOT NULL,
highest_bid NUMERIC(12, 8) NOT NULL,
created_at timestamp without time zone not null default now()
);
# --- !Downs
DROP TABLE poloniex_messages;
DROP TABLE poloniex_candles;
| true |
b29e5917b9f6cc1f3655602e98d4c314d728491d | SQL | MrDanao/tradint | /bdd_backup/sql_script_build_db_from_scratch.sql | UTF-8 | 6,418 | 3.25 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.6deb4
-- https://www.phpmyadmin.net/
--
-- Client : localhost:3306
-- Généré le : Sam 24 Février 2018 à 23:45
-- Version du serveur : 10.1.26-MariaDB-0+deb9u1
-- Version de PHP : 7.0.27-0+deb9u1
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 : `tradint`
--
-- --------------------------------------------------------
--
-- Structure de la table `annonce`
--
CREATE TABLE `annonce` (
`reference` int(10) NOT NULL,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
`descriptif` varchar(2000) COLLATE utf8_bin NOT NULL,
`prix` int(11) DEFAULT NULL,
`dateAjout` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`photo1` varchar(1000) COLLATE utf8_bin NOT NULL,
`photo2` varchar(1000) COLLATE utf8_bin DEFAULT NULL,
`photo3` varchar(1000) COLLATE utf8_bin DEFAULT NULL,
`pseudo` varchar(50) COLLATE utf8_bin NOT NULL,
`idTypeAnnonce` int(11) NOT NULL,
`idCat` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Structure de la table `categorie`
--
CREATE TABLE `categorie` (
`idCat` int(11) NOT NULL,
`descCat` varchar(100) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Doublure de structure pour la vue `dataAnnonce`
-- (Voir ci-dessous la vue réelle)
--
CREATE TABLE `dataAnnonce` (
`reference` int(10)
,`nom` varchar(255)
,`descriptif` varchar(2000)
,`prix` int(11)
,`photo1` varchar(1000)
,`photo2` varchar(1000)
,`photo3` varchar(1000)
,`descTypeAnnonce` varchar(100)
,`idTypeAnnonce` int(11)
,`descCat` varchar(100)
,`idCat` int(11)
,`dateAjout` datetime
,`pseudo` varchar(50)
,`email` varchar(100)
,`numeroTel` char(10)
,`idLocal` int(11)
,`descLocal` varchar(100)
);
-- --------------------------------------------------------
--
-- Structure de la table `localisation`
--
CREATE TABLE `localisation` (
`idLocal` int(11) NOT NULL,
`descLocal` varchar(100) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Structure de la table `type_annonce`
--
CREATE TABLE `type_annonce` (
`idTypeAnnonce` int(11) NOT NULL,
`descTypeAnnonce` varchar(100) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Structure de la table `utilisateur`
--
CREATE TABLE `utilisateur` (
`pseudo` varchar(50) COLLATE utf8_bin NOT NULL,
`passwd` varchar(255) COLLATE utf8_bin NOT NULL,
`email` varchar(100) COLLATE utf8_bin NOT NULL,
`numeroTel` char(10) COLLATE utf8_bin NOT NULL,
`salt` binary(128) NOT NULL,
`idLocal` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Structure de la vue `dataAnnonce`
--
DROP TABLE IF EXISTS `dataAnnonce`;
CREATE ALGORITHM=UNDEFINED DEFINER=`admintradint`@`localhost` SQL SECURITY DEFINER VIEW `dataAnnonce` AS select `ann`.`reference` AS `reference`,`ann`.`nom` AS `nom`,`ann`.`descriptif` AS `descriptif`,`ann`.`prix` AS `prix`,`ann`.`photo1` AS `photo1`,`ann`.`photo2` AS `photo2`,`ann`.`photo3` AS `photo3`,`typ`.`descTypeAnnonce` AS `descTypeAnnonce`,`ann`.`idTypeAnnonce` AS `idTypeAnnonce`,`cat`.`descCat` AS `descCat`,`ann`.`idCat` AS `idCat`,`ann`.`dateAjout` AS `dateAjout`,`ann`.`pseudo` AS `pseudo`,`user`.`email` AS `email`,`user`.`numeroTel` AS `numeroTel`,`user`.`idLocal` AS `idLocal`,`local`.`descLocal` AS `descLocal` from ((((`annonce` `ann` join `type_annonce` `typ`) join `categorie` `cat`) join `utilisateur` `user`) join `localisation` `local`) where ((`ann`.`idTypeAnnonce` = `typ`.`idTypeAnnonce`) and (`ann`.`idCat` = `cat`.`idCat`) and (`ann`.`pseudo` = `user`.`pseudo`) and (`user`.`idLocal` = `local`.`idLocal`)) order by `ann`.`reference` desc ;
--
-- Index pour les tables exportées
--
--
-- Index pour la table `annonce`
--
ALTER TABLE `annonce`
ADD PRIMARY KEY (`reference`),
ADD KEY `FK_annonce_pseudo` (`pseudo`),
ADD KEY `FK_annonce_idTypeAnnonce` (`idTypeAnnonce`),
ADD KEY `FK_annonce_idCat` (`idCat`);
--
-- Index pour la table `categorie`
--
ALTER TABLE `categorie`
ADD PRIMARY KEY (`idCat`);
--
-- Index pour la table `localisation`
--
ALTER TABLE `localisation`
ADD PRIMARY KEY (`idLocal`);
--
-- Index pour la table `type_annonce`
--
ALTER TABLE `type_annonce`
ADD PRIMARY KEY (`idTypeAnnonce`);
--
-- Index pour la table `utilisateur`
--
ALTER TABLE `utilisateur`
ADD PRIMARY KEY (`pseudo`),
ADD KEY `FK_utilisateur_idLocal` (`idLocal`);
--
-- AUTO_INCREMENT pour les tables exportées
--
--
-- AUTO_INCREMENT pour la table `annonce`
--
ALTER TABLE `annonce`
MODIFY `reference` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=70;
--
-- AUTO_INCREMENT pour la table `categorie`
--
ALTER TABLE `categorie`
MODIFY `idCat` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT pour la table `localisation`
--
ALTER TABLE `localisation`
MODIFY `idLocal` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT pour la table `type_annonce`
--
ALTER TABLE `type_annonce`
MODIFY `idTypeAnnonce` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Contraintes pour les tables exportées
--
--
-- Contraintes pour la table `annonce`
--
ALTER TABLE `annonce`
ADD CONSTRAINT `FK_annonce_idCat` FOREIGN KEY (`idCat`) REFERENCES `categorie` (`idCat`),
ADD CONSTRAINT `FK_annonce_idTypeAnnonce` FOREIGN KEY (`idTypeAnnonce`) REFERENCES `type_annonce` (`idTypeAnnonce`),
ADD CONSTRAINT `FK_annonce_pseudo` FOREIGN KEY (`pseudo`) REFERENCES `utilisateur` (`pseudo`);
--
-- Contraintes pour la table `utilisateur`
--
ALTER TABLE `utilisateur`
ADD CONSTRAINT `FK_utilisateur_idLocal` FOREIGN KEY (`idLocal`) REFERENCES `localisation` (`idLocal`);
/*!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 |
f2c406696cabe814ac005e38db2dc4dded2c81ea | SQL | NeotomaDB/Neotoma_SQL | /function/ti/getcontextdatasettypecount.sql | UTF-8 | 329 | 3.03125 | 3 | [
"MIT"
] | permissive | CREATE OR REPLACE FUNCTION ti.getcontextdatasettypecount(_datasettypeid integer, _variablecontextid integer)
RETURNS TABLE(count bigint)
LANGUAGE sql
AS $function$
SELECT COUNT(datasettypeid) AS count
FROM ndb.contextsdatasettypes
WHERE datasettypeid = _datasettypeid AND variablecontextid = _variablecontextid;
$function$
| true |
9a84c71da1c5028b8265543d25a5d314644571a2 | SQL | absuite/suite-amiba | /database/presqls/2017_00_08_100010_sp_amiba_data_distribute.sql | UTF-8 | 3,978 | 3.890625 | 4 | [] | no_license | DELIMITER $$
DROP PROCEDURE IF EXISTS sp_amiba_data_distribute$$
CREATE PROCEDURE sp_amiba_data_distribute(IN p_ent CHAR(200),IN p_purpose CHAR(200),IN p_period CHAR(200),IN p_level INT)
BEGIN
DECLARE v_loop INT DEFAULT 1;
/*待分配数据*/
DROP TEMPORARY TABLE IF EXISTS tml_result_allocated;
CREATE TEMPORARY TABLE IF NOT EXISTS tml_result_allocated(
`purpose_id` NVARCHAR(100),
`period_id` NVARCHAR(100),
`group_id` NVARCHAR(100),
`element_id` NVARCHAR(100),
`method_id` NVARCHAR(100),
`currency_id` NVARCHAR(100),
`money` DECIMAL(30,9) DEFAULT 0
);
DROP TEMPORARY TABLE IF EXISTS suite_amiba_allot_total;
CREATE TEMPORARY TABLE IF NOT EXISTS suite_amiba_allot_total(
`purpose_id` NVARCHAR(100),
`group_id` NVARCHAR(100),
`element_id` NVARCHAR(100),
`total` DECIMAL(30,9) DEFAULT 0
);
DROP TEMPORARY TABLE IF EXISTS suite_amiba_allot_line;
CREATE TEMPORARY TABLE IF NOT EXISTS suite_amiba_allot_line(
`purpose_id` NVARCHAR(100),
`group_id` NVARCHAR(100),
`element_id` NVARCHAR(100),
`to_group_id` NVARCHAR(100),
`to_element_id` NVARCHAR(100),
`total` DECIMAL(30,9) DEFAULT 0,
`radix` DECIMAL(30,9) DEFAULT 0,
`rate` DECIMAL(30,9) DEFAULT 0
);
SET v_loop=1;
/*
核算 待分配数据
*/
INSERT INTO tml_result_allocated(purpose_id,period_id,group_id,element_id,currency_id,money)
SELECT d.purpose_id,d.period_id,d.fm_group_id,d.element_id,MAX(currency_id),SUM(d.money) AS money
FROM `suite_amiba_data_docs` AS d
WHERE d.`purpose_id`=p_purpose AND d.`period_id`=p_period
AND d.src_type_enum IN ('interface','manual')
AND EXISTS (SELECT ar.id FROM suite_amiba_allot_rules AS ar
INNER JOIN suite_amiba_allot_levels AS le ON ar.purpose_id=le.purpose_id AND ar.`group_id`=le.`group_id`
WHERE d.purpose_id=ar.purpose_id AND d.fm_group_id=ar.group_id AND d.element_id=ar.element_id
AND le.`period_id`=d.period_id
AND ar.bizkey=le.bizkey
AND le.`level`=p_level
)
GROUP BY d.purpose_id,d.period_id,d.fm_group_id,d.element_id;
/*
计算分配比例
*/
INSERT INTO suite_amiba_allot_line(purpose_id,group_id,element_id,to_group_id,to_element_id,radix)
SELECT r.purpose_id,r.group_id,r.element_id,rl.group_id,rl.`element_id`,SUM(ml.rate) AS radix
FROM suite_amiba_allot_rules AS r
INNER JOIN `suite_amiba_allot_rule_lines` AS rl ON r.id=rl.rule_id
INNER JOIN `suite_amiba_allot_methods` AS m ON r.method_id=m.id
INNER JOIN `suite_amiba_allot_method_lines` AS ml ON m.id=ml.method_id AND ml.group_id=rl.group_id
WHERE r.purpose_id=p_purpose AND m.purpose_id=p_purpose
GROUP BY r.purpose_id,r.group_id,r.element_id,rl.group_id,rl.`element_id`;
INSERT INTO suite_amiba_allot_total(purpose_id,group_id,element_id,total)
SELECT l.purpose_id,l.group_id,l.element_id,SUM(radix) FROM suite_amiba_allot_line AS l GROUP BY l.purpose_id,l.group_id,l.element_id;
UPDATE suite_amiba_allot_line AS l INNER JOIN suite_amiba_allot_total AS t ON l.purpose_id=t.purpose_id AND l.element_id=t.element_id AND l.group_id=t.group_id
SET l.total=t.total,l.rate=CASE WHEN t.total=0 THEN 0 ELSE l.radix/t.total END;
/*删除之前分配的数据*/
DELETE l FROM suite_amiba_data_docs AS l WHERE l.ent_id=p_ent AND l.purpose_id=p_purpose AND l.period_id=p_period AND src_type_enum ='allot';
-- 插入数据
INSERT INTO `suite_amiba_data_docs`(id,ent_id,doc_no,doc_date,src_type_enum,purpose_id,period_id,fm_group_id,element_id,currency_id,state_enum,money)
SELECT MD5(REPLACE(UUID_SHORT(),'-','')) AS id,p_ent,CONCAT('allot',DATE_FORMAT(NOW(),'%Y%m%d'),(@rownum:=@rownum+1)+1000),NOW() AS doc_date,'allot',
a.purpose_id,p_period AS period_id,a.group_id,IFNULL(a.to_element_id,l.element_id) AS element_id,l.currency_id,'approved',
SUM(l.money*a.rate) AS money
FROM tml_result_allocated AS l
INNER JOIN suite_amiba_allot_line AS a ON l.purpose_id=a.purpose_id AND l.element_id=a.element_id,
(SELECT @rownum:=0) AS r
GROUP BY a.purpose_id,a.group_id,IFNULL(a.to_element_id,l.element_id),l.currency_id;
END$$
DELIMITER ; | true |
29fd1261cae65df98201bb17cd29fbf50243bc25 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day15/select1740.sql | UTF-8 | 178 | 2.65625 | 3 | [] | no_license |
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-14T17:40:00Z' AND timestamp<'2017-11-15T17:40:00Z' AND temperature>=10 AND temperature<=20
| true |
c8c5c479b430c409066146d3dc4e322423c916a4 | SQL | owlscout/GIt | /Workspace_WEB/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Jsp14_Test/WEB-INF/classes/com/poosil/comment/freeboarddb/freeboardcomment.sql | UTF-8 | 447 | 3.203125 | 3 | [] | no_license | DROP SEQUENCE FREECOMMENTSEQ;
DROP TABLE FREECOMMENT;
CREATE SEQUENCE FREECOMMENTSEQ
CREATE TABLE FREECOMMENT(
FREECOMSEQ NUMBER NOT NULL,
FREECOMBOARDSEQ NUMBER NOT NULL,
FREECOMNICKNAME VARCHAR2(100),
FREECOMREGDATE DATE NOT NULL,
FREECOMPARENT NUMBER,
FREECOMCONTENT VARCHAR2(1000) NOT NULL,
CONSTRAINT FREECOMMENT_PK PRIMARY KEY (FREECOMSEQ),
CONSTRAINT FREECOMMENT_FK FOREIGN KEY (FREECOMBOARDSEQ) REFERENCES FREEBOARD (BOARDSEQ)
); | true |
8af884c46e9a7f00db46cd9b81fed71d6d8fe396 | SQL | JHarvin/SIRA | /BD/sira_bd.sql | UTF-8 | 25,311 | 2.734375 | 3 | [] | no_license | SET FOREIGN_KEY_CHECKS=0;
CREATE DATABASE IF NOT EXISTS sira_bd;
USE sira_bd;
DROP TABLE IF EXISTS talquiler;
CREATE TABLE `talquiler` (
`fecha_alquiler` varchar(25) COLLATE utf8_spanish_ci NOT NULL,
`fecha_devolucion` varchar(25) COLLATE utf8_spanish_ci NOT NULL,
`numero_de_placa` varchar(8) COLLATE utf8_spanish_ci NOT NULL,
`dui` varchar(11) COLLATE utf8_spanish_ci NOT NULL,
`status` int(11) NOT NULL,
KEY `fk_vehiculo` (`numero_de_placa`),
KEY `fk_dui` (`dui`),
CONSTRAINT `fk_dui` FOREIGN KEY (`dui`) REFERENCES `tclientes` (`dui`),
CONSTRAINT `fk_vehiculo` FOREIGN KEY (`numero_de_placa`) REFERENCES `tvehiculos` (`numero_de_placa`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO talquiler VALUES("24/10/2018","31/10/2018","P989-988","09894555-4","1");
INSERT INTO talquiler VALUES("24/10/2018","30/10/2018","P980-454","55466777-8","1");
INSERT INTO talquiler VALUES("24/10/2018","24/10/2018","P787-444","22233988-7","1");
INSERT INTO talquiler VALUES("28/11/2018","30/11/2018","P111-111","90000444-4","1");
INSERT INTO talquiler VALUES("29/11/2018","04/12/2018","P989-988","09894555-4","1");
INSERT INTO talquiler VALUES("29/11/2018","06/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("30/11/2018","08/12/2018","P787-444","09894555-4","1");
INSERT INTO talquiler VALUES("30/11/2018","05/12/2018","P980-454","90000444-4","1");
INSERT INTO talquiler VALUES("19/12/2018","25/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("19/12/2018","31/12/2018","P787-444","09894555-4","1");
INSERT INTO talquiler VALUES("19/12/2018","31/12/2018","P989-988","55466777-8","1");
INSERT INTO talquiler VALUES("19/12/2018","25/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("20/12/2018","30/12/2018","P787-444","09894555-4","1");
INSERT INTO talquiler VALUES("19/12/2018","30/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("20/12/2018","31/12/2018","P787-444","09894555-4","1");
INSERT INTO talquiler VALUES("19/12/2018","31/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("21/12/2018","01/01/2019","P787-444","09894555-4","1");
INSERT INTO talquiler VALUES("19/12/2018","31/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("21/01/2019","29/01/2019","P787-444","09894555-4","1");
INSERT INTO talquiler VALUES("19/12/2018","31/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("20/12/2018","30/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("20/12/2018","30/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("20/12/2018","31/12/2018","P980-454","09894555-4","1");
INSERT INTO talquiler VALUES("20/12/2018","31/12/2018","P404-404","55466777-8","1");
INSERT INTO talquiler VALUES("20/12/2018","31/12/2018","P202-205","09894555-4","1");
INSERT INTO talquiler VALUES("20/12/2018","30/12/2018","P404-404","55466777-8","1");
INSERT INTO talquiler VALUES("20/12/2018","30/12/2018","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("20/12/2018","31/12/2018","P404-404","09894555-4","1");
INSERT INTO talquiler VALUES("03/01/2019","30/01/2019","P111-111","55466777-8","1");
INSERT INTO talquiler VALUES("09/01/2019","30/01/2019","P404-404","09894555-4","1");
INSERT INTO talquiler VALUES("15/01/2019","31/01/2019","P111-111","09894555-4","1");
DROP TABLE IF EXISTS tbitacora;
CREATE TABLE `tbitacora` (
`idbitacora` int(11) NOT NULL AUTO_INCREMENT,
`fecha` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`acciones` text COLLATE utf8_spanish_ci NOT NULL,
`idpersonal` int(11) NOT NULL,
PRIMARY KEY (`idbitacora`),
KEY `fk_personal` (`idpersonal`),
CONSTRAINT `fk_personal` FOREIGN KEY (`idpersonal`) REFERENCES `tpersonal` (`idpersonal`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tbitacora VALUES("6","2019-01-11 23:38:11","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("7","2019-01-11 23:47:36","Se actualizo el precio de alquiler del vehiculo placas: P202-205 a un precio de: 27","2");
INSERT INTO tbitacora VALUES("8","2019-01-11 23:48:24","Se actualizo el precio de alquiler del vehiculo placas: P202-205 a un precio de: 22","2");
INSERT INTO tbitacora VALUES("9","2019-01-12 00:11:45","Se actualizo el precio de alquiler del vehiculo placas: P787-444 a un precio de: 15","2");
INSERT INTO tbitacora VALUES("10","2019-01-12 00:42:06","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("11","2019-01-12 10:02:19","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("12","2019-01-12 10:02:38","Se actualizo el precio de alquiler del vehiculo placas: P404-404 a un precio de: 25","2");
INSERT INTO tbitacora VALUES("13","2019-01-13 12:04:34","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("14","2019-01-13 15:43:41","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("15","2019-01-14 14:26:55","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("16","2019-01-14 15:23:34","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("17","2019-01-14 17:16:51","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("18","2019-01-14 21:54:04","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("19","2019-01-15 09:23:30","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("20","2019-01-15 11:10:33","Inicio de sesión","2");
INSERT INTO tbitacora VALUES("21","2019-01-15 11:23:37","Se realizó el registro de una bateria ","2");
INSERT INTO tbitacora VALUES("22","2019-01-15 11:28:11","Se realizó el registro de una bateria ","2");
INSERT INTO tbitacora VALUES("23","2019-01-15 11:29:47","Se realizó el registro de una bateria ","2");
INSERT INTO tbitacora VALUES("24","2019-01-15 11:30:09","Se realizó el registro de una bateria ","2");
DROP TABLE IF EXISTS tclientes;
CREATE TABLE `tclientes` (
`nombre` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`telefono` varchar(10) COLLATE utf8_spanish_ci NOT NULL,
`dui` varchar(11) COLLATE utf8_spanish_ci NOT NULL,
`licencia_de_conducir` varchar(20) COLLATE utf8_spanish_ci NOT NULL,
`direccion` varchar(175) COLLATE utf8_spanish_ci NOT NULL,
`genero` varchar(2) COLLATE utf8_spanish_ci NOT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`dui`,`licencia_de_conducir`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tclientes VALUES("Gloria Ines Mejia","2333-2223","09894555-4","8899-988888-888-8","san bartolo san salvador ucran","F","1");
INSERT INTO tclientes VALUES("Ulises Daniel Martinez","8884-4558","22233988-7","1234-888899-447-7","zacatecoluca la paz","M","1");
INSERT INTO tclientes VALUES("Gerson Bladimir Martinez Vazquez","7666-6667","55466777-8","1010-011100-222-0","san salvador colonia loma linda distrito federal","M","0");
INSERT INTO tclientes VALUES("Katherine Rodriguez","7323-4444","90000444-4","9009-445544-444-4","San Sebastian San vicente","M","0");
DROP TABLE IF EXISTS tcontrol_bitacora;
CREATE TABLE `tcontrol_bitacora` (
`idbitacora` int(11) NOT NULL,
`actividad` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`hora` datetime NOT NULL,
KEY `fk_bitacora` (`idbitacora`),
CONSTRAINT `fk_bitacora` FOREIGN KEY (`idbitacora`) REFERENCES `tbitacora` (`idbitacora`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
DROP TABLE IF EXISTS tdevoluciones;
CREATE TABLE `tdevoluciones` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`codigo` varchar(9) COLLATE utf8_spanish_ci NOT NULL,
`tipo` varchar(10) COLLATE utf8_spanish_ci NOT NULL,
`importe` varchar(10) COLLATE utf8_spanish_ci NOT NULL,
`fecha` date NOT NULL,
`estado` varchar(15) COLLATE utf8_spanish_ci NOT NULL,
`cliente` varchar(80) COLLATE utf8_spanish_ci NOT NULL,
`fecha_fin` varchar(50) COLLATE utf8_spanish_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tdevoluciones VALUES("28","44444 ","CHIASO","11.11","2019-01-29","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("29","32F2R","STARI","0","2018-11-29","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("30","10086","AMERICA","0","2018-11-29","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("31","44444","CHIASO","","2018-11-30","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("32","99922","STARI","0","2018-11-30","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("33","20000","AMAROCK","0","2019-11-30","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("34","10000","AMERICA","0","0000-00-00","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("35","77E8E","AMAROCK","0","2019-01-13","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("36","50333","RAYO","0","2019-01-13","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("37","91919","RAYO","0","2019-01-13","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("38","20199","RAYO","0","0000-00-00","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("39","22222","RAYO","0","2019-01-13","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("40","12121","SANGL","0","0000-00-00","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("41","77565","SANGL","0","0000-00-00","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("42","22333","SANGL","0","2019-01-14","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("43","09822","SANGL","0","2019-01-14","DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("44","22333","SANGL","0","0000-00-00","NO DEVUELTA","","");
INSERT INTO tdevoluciones VALUES("45","43553","SANGL","0","0000-00-00","NO DEVUELTA","43553","");
INSERT INTO tdevoluciones VALUES("46","43553","SANGL","0","2019-01-15","NO DEVUELTA","12133","");
INSERT INTO tdevoluciones VALUES("47","12133","SANGL","0","0000-00-00","NO DEVUELTA","12133","");
INSERT INTO tdevoluciones VALUES("48","12133","SANGL","0","0000-00-00","NO DEVUELTA","00999","");
INSERT INTO tdevoluciones VALUES("49","00999","SANGL","0","0000-00-00","DEVUELTA","00999","15/01/2019");
INSERT INTO tdevoluciones VALUES("50","00999","SANGL","0","0000-00-00","DEVUELTA","Jackeline Rodriguez","15/01/2019");
DROP TABLE IF EXISTS testado_vehiculo;
CREATE TABLE `testado_vehiculo` (
`numero_de_placa` varchar(8) COLLATE utf8_spanish_ci NOT NULL,
`estado` varchar(45) COLLATE utf8_spanish_ci NOT NULL,
KEY `fk_estado` (`numero_de_placa`),
CONSTRAINT `fk_estado` FOREIGN KEY (`numero_de_placa`) REFERENCES `tvehiculos` (`numero_de_placa`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
DROP TABLE IF EXISTS tfactura;
CREATE TABLE `tfactura` (
`idfactura` int(11) NOT NULL AUTO_INCREMENT,
`fecha_emision` datetime NOT NULL,
`importe` float NOT NULL,
`idproducto` int(11) NOT NULL,
`idpersonal` int(11) NOT NULL,
PRIMARY KEY (`idfactura`),
KEY `fk_producto` (`idproducto`),
KEY `fk_personalt` (`idpersonal`),
CONSTRAINT `fk_personalt` FOREIGN KEY (`idpersonal`) REFERENCES `tpersonal` (`idpersonal`),
CONSTRAINT `fk_producto` FOREIGN KEY (`idproducto`) REFERENCES `tproductos` (`idproducto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
DROP TABLE IF EXISTS tkilometraje;
CREATE TABLE `tkilometraje` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cada_cuantos_meses_revision` int(11) NOT NULL,
`cada_cuantos_kilometros` int(11) NOT NULL,
`numero_de_placa` varchar(8) COLLATE utf8_spanish_ci NOT NULL,
`fecha` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `fk_placa_km` (`numero_de_placa`),
CONSTRAINT `fk_placa_km` FOREIGN KEY (`numero_de_placa`) REFERENCES `tvehiculos` (`numero_de_placa`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tkilometraje VALUES("5","6","2000","P111-111","2018-11-30 00:29:21");
INSERT INTO tkilometraje VALUES("6","3","55555","P787-444","2018-11-30 00:29:28");
INSERT INTO tkilometraje VALUES("7","5","4000","P111-111","2018-11-30 00:29:33");
INSERT INTO tkilometraje VALUES("8","1","6000","P980-454","2018-12-18 21:08:59");
INSERT INTO tkilometraje VALUES("11","5","5","P980-454","2018-11-30 00:21:17");
INSERT INTO tkilometraje VALUES("12","5","5000","P980-454","2018-12-20 10:41:21");
DROP TABLE IF EXISTS tmantenimiento;
CREATE TABLE `tmantenimiento` (
`numero_de_placa` varchar(8) COLLATE utf8_spanish_ci NOT NULL,
`fecha` varchar(25) COLLATE utf8_spanish_ci NOT NULL,
`tipomantenimiento` varchar(25) COLLATE utf8_spanish_ci NOT NULL,
`status` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `fk_numero_de_placa` (`numero_de_placa`),
CONSTRAINT `fk_numero_de_placa` FOREIGN KEY (`numero_de_placa`) REFERENCES `tvehiculos` (`numero_de_placa`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tmantenimiento VALUES("P980-454","30/11/2018","Preventivo","0","7");
INSERT INTO tmantenimiento VALUES("P980-454","30/11/2018","Correctivo","0","8");
INSERT INTO tmantenimiento VALUES("P980-454","30/11/2018","Preventivo","0","9");
INSERT INTO tmantenimiento VALUES("P980-454","19/12/2018","Preventivo","0","10");
INSERT INTO tmantenimiento VALUES("P980-454","19/12/2018","Correctivo","0","11");
INSERT INTO tmantenimiento VALUES("P980-454","19/12/2018","Kilometraje","0","12");
INSERT INTO tmantenimiento VALUES("P111-111","20/12/2018","Correctivo","0","13");
INSERT INTO tmantenimiento VALUES("P111-111","20/12/2018","Preventivo","0","14");
INSERT INTO tmantenimiento VALUES("P989-988","20/12/2018","Preventivo","0","15");
INSERT INTO tmantenimiento VALUES("P980-454","20/12/2018","Preventivo","0","16");
INSERT INTO tmantenimiento VALUES("P404-404","20/12/2018","Preventivo","0","17");
INSERT INTO tmantenimiento VALUES("P202-205","20/12/2018","Preventivo","0","18");
INSERT INTO tmantenimiento VALUES("P787-444","20/12/2018","Preventivo","0","19");
INSERT INTO tmantenimiento VALUES("P202-205","20/12/2018","Preventivo","0","20");
INSERT INTO tmantenimiento VALUES("P980-454","20/12/2018","Preventivo","0","21");
INSERT INTO tmantenimiento VALUES("P980-454","20/12/2018","Preventivo","0","22");
INSERT INTO tmantenimiento VALUES("P989-988","20/12/2018","Preventivo","0","23");
INSERT INTO tmantenimiento VALUES("P989-988","20/12/2018","Preventivo","0","24");
INSERT INTO tmantenimiento VALUES("P989-988","20/12/2018","Preventivo","0","25");
DROP TABLE IF EXISTS tpersonal;
CREATE TABLE `tpersonal` (
`idpersonal` int(11) NOT NULL AUTO_INCREMENT,
`nombre` varchar(165) NOT NULL,
`telefono` varchar(10) NOT NULL,
`direccion` varchar(175) NOT NULL,
`username` varchar(16) NOT NULL,
`password` varchar(16) NOT NULL,
`genero` varchar(2) NOT NULL,
`email` varchar(165) NOT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`idpersonal`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
INSERT INTO tpersonal VALUES("2","Francisco Javier Martinez Vazquez","7256-5678","SAN PETES BURGO","clark","root","M","jeffethramos@gmail.com","1");
INSERT INTO tpersonal VALUES("3","Dominga Mejia ","7334-4335","san salvador san salvador distrito federal","inesm","root","F","bersafbe@hotmail.com","0");
INSERT INTO tpersonal VALUES("4","Erick Antonio Ticas","7844-9554","apastepeque el centro, departamento san vicente","tikistikis","cuenta","M","ticas@hotmail.com","0");
INSERT INTO tpersonal VALUES("5","Juan Alfaro de martinez","7756-4647","la avenida 69 la curazao","montoyajuan","root","F","demontoya@hotmail.com","0");
INSERT INTO tpersonal VALUES("6","Mayra Beatriz Quintanilla","7212-2221","calle a san miguel puente cuscatlan","mayquinta","pinocha","F","mayraguzman093@hotmail.com","1");
INSERT INTO tpersonal VALUES("7","Erick Alexander Ticas Prad","7764-7484","san vicente colonia el progreso","pradticas","root","M","erickticas7@gmail.com","1");
INSERT INTO tpersonal VALUES("8","Mayra Beatriz Flores","7766-4554","puente cuscatlan san miguel","quintanilla","root","F","mbqg93@gmail.com","1");
INSERT INTO tpersonal VALUES("9","Saul Arcangel Reyes","7757-5884","colonia santa maria san sebastian san vicente","kaneki","kaneki","M","saulr1016.sr@gmail.com","1");
DROP TABLE IF EXISTS tprecios;
CREATE TABLE `tprecios` (
`numero_de_placa` varchar(8) COLLATE utf8_spanish_ci NOT NULL,
`precio` double NOT NULL,
KEY `fk_placa` (`numero_de_placa`),
CONSTRAINT `fk_placa` FOREIGN KEY (`numero_de_placa`) REFERENCES `tvehiculos` (`numero_de_placa`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tprecios VALUES("P111-111","25");
INSERT INTO tprecios VALUES("P980-454","25");
INSERT INTO tprecios VALUES("P989-988","55");
INSERT INTO tprecios VALUES("P787-444","15");
INSERT INTO tprecios VALUES("P404-404","25");
INSERT INTO tprecios VALUES("P202-205","22");
DROP TABLE IF EXISTS tprecios_alquiler;
CREATE TABLE `tprecios_alquiler` (
`idtprecios_alquiler` int(11) NOT NULL,
`precio_alquiler_por_dia` float DEFAULT NULL,
`numero_de_placa` varchar(8) COLLATE utf8_spanish_ci NOT NULL,
PRIMARY KEY (`idtprecios_alquiler`),
KEY `fk_precio` (`numero_de_placa`),
CONSTRAINT `fk_precio` FOREIGN KEY (`numero_de_placa`) REFERENCES `tvehiculos` (`numero_de_placa`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
DROP TABLE IF EXISTS tproductos;
CREATE TABLE `tproductos` (
`idproducto` int(11) NOT NULL AUTO_INCREMENT,
`tipo` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`codigo` varchar(5) COLLATE utf8_spanish_ci NOT NULL,
`en_existencias` int(11) NOT NULL,
`precio_unitario` float NOT NULL,
`idproveedor` int(11) NOT NULL,
`precio_venta` float NOT NULL,
`fecha_venta` date NOT NULL,
PRIMARY KEY (`idproducto`),
KEY `fk_proveedores` (`idproveedor`),
CONSTRAINT `fk_proveedores` FOREIGN KEY (`idproveedor`) REFERENCES `tproveedores` (`idproveedor`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tproductos VALUES("5","AUTO","YY666","0","66","4","88","2019-01-15");
INSERT INTO tproductos VALUES("6","AUTO","I8755","0","77","10","222","2019-01-15");
DROP TABLE IF EXISTS tproveedores;
CREATE TABLE `tproveedores` (
`idproveedor` int(11) NOT NULL AUTO_INCREMENT,
`nombre` varchar(45) COLLATE utf8_spanish_ci NOT NULL,
`telefono` varchar(9) COLLATE utf8_spanish_ci NOT NULL,
`email` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`direccion` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`idproveedor`,`nombre`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tproveedores VALUES("4","AMERICA","9918-8111","saul@hotmail.com"," san miguel la avenida","0");
INSERT INTO tproveedores VALUES("5","AMAROCK","3333-3444","amarock@hotmail.com","san salvador colonia","0");
INSERT INTO tproveedores VALUES("6","CHIASO","5445-4544","asoidjf@hotmail.com","ñasidjfaipoi p apsoidjfiejq as","0");
INSERT INTO tproveedores VALUES("7","STARI","7746-7554","stari@hotmail.com","santa ana metapan","0");
INSERT INTO tproveedores VALUES("8","RADIOCHACK","7746-6464","radioch@hotmail.com","plaza mundo soyapango","0");
INSERT INTO tproveedores VALUES("9","RAYO","7759-9595","rayo@rayo.com","san salvador vulevar venezuela","0");
INSERT INTO tproveedores VALUES("10","SANGL","8475-9009","sangl@yahoo.com","san salvador calle loma linda","0");
DROP TABLE IF EXISTS trevision;
CREATE TABLE `trevision` (
`idrevision` int(11) NOT NULL AUTO_INCREMENT,
`fechasalida` varchar(25) COLLATE utf8_spanish_ci NOT NULL,
`encargadoservicio` varchar(35) COLLATE utf8_spanish_ci NOT NULL,
`servicio` text COLLATE utf8_spanish_ci NOT NULL,
`numero_de_placa` varchar(8) COLLATE utf8_spanish_ci NOT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`idrevision`),
KEY `fk_placavhiculo` (`numero_de_placa`),
CONSTRAINT `fk_placavhiculo` FOREIGN KEY (`numero_de_placa`) REFERENCES `tvehiculos` (`numero_de_placa`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO trevision VALUES("7","14/12/2018","Jonathan Eulises","reparacion por choque de vehiculos","P980-454","1");
INSERT INTO trevision VALUES("8","08/12/2018","Alejandro Garcia","cambio de aceite","P980-454","1");
INSERT INTO trevision VALUES("9","05/12/2018","Raul Ramos","cambio de bujillas","P980-454","1");
INSERT INTO trevision VALUES("10","28/12/2018","Nelson Morales Bonilla","revision de aceite, power, y caja de velocidades","P980-454","1");
INSERT INTO trevision VALUES("12","27/12/2018","Sonia Felicita Alfaro","cambio de timon y caja automatica por secuencial","P980-454","1");
INSERT INTO trevision VALUES("13","28/12/2018","Marcelo Larin","cambio de baleros de las llantas, cambio de aire acondicionado y ajuste de motor","P111-111","1");
INSERT INTO trevision VALUES("14","28/12/2018","Alvaro Rivas","chekeo de llantas, aceite","P111-111","1");
INSERT INTO trevision VALUES("15","29/12/2018","Raul Ramos","revision normal","P989-988","1");
INSERT INTO trevision VALUES("16","27/12/2018","Edgardo Ramos","revison por ruido del motor","P980-454","1");
INSERT INTO trevision VALUES("17","27/12/2018","Sandra Yesenia Landaverde","revison de motor","P404-404","1");
INSERT INTO trevision VALUES("18","31/12/2018","Oscar Batres","cambio de aceite","P202-205","1");
INSERT INTO trevision VALUES("19","29/12/2018","Samuel Orellana","cambio de aceite de motor y de caja","P787-444","0");
INSERT INTO trevision VALUES("20","03/01/2019","Oscar Antonio Flores Batres","cambio de pastillas","P202-205","0");
INSERT INTO trevision VALUES("21","26/12/2018","Alexis flores","reparacino de llanta pinchada","P989-988","1");
DROP TABLE IF EXISTS tvehiculos;
CREATE TABLE `tvehiculos` (
`numero_de_placa` varchar(8) COLLATE utf8_spanish_ci NOT NULL,
`marca` varchar(65) COLLATE utf8_spanish_ci NOT NULL,
`tipo` varchar(25) COLLATE utf8_spanish_ci NOT NULL,
`color` varchar(25) COLLATE utf8_spanish_ci NOT NULL,
`numeromotor` varchar(16) COLLATE utf8_spanish_ci NOT NULL,
`numerochasis` varchar(16) COLLATE utf8_spanish_ci NOT NULL,
`tipocombustible` varchar(65) COLLATE utf8_spanish_ci NOT NULL,
`imagen` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`imagen2` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`imagen3` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`imagen4` varchar(165) COLLATE utf8_spanish_ci NOT NULL,
`year` int(11) NOT NULL,
PRIMARY KEY (`numero_de_placa`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tvehiculos VALUES("P111-111","toyota hilux","camioneta","azul","3232323323233443","4344433333333333","Diesel","../vehicles/toyota1.jpg","../vehicles/toyota2.jpg","../vehicles/toyota3.jpg","../vehicles/c1.jpg","2010");
INSERT INTO tvehiculos VALUES("P202-205","nissan sentra b15 ","sedan","verde oscuro","0094776674838374","5545548939398838","Especial","../vehicles/aviso.jpg","../vehicles/mitsu2.jpg","../vehicles/Grid Graphic Design Course Certificate (2).png","../vehicles/mitsu.jpg","2002");
INSERT INTO tvehiculos VALUES("P404-404","mitsubichi lancer","sedan","azul","1223344485854995","0099887333444222","Especial","../vehicles/LogoSample_ByTailorBrands.jpg","../vehicles/tech.jpg","../vehicles/technology_background_blue_flat_backdrop_round_branches_decoration_6827658.jpg","../vehicles/Grid Graphic Design Course Certificate.png","2012");
INSERT INTO tvehiculos VALUES("P787-444","toyota prado","camioneta","roja","1222223333098777","0999987744443332","Diesel","../vehicles/sentra2.jpg","../vehicles/CapturaHidro.PNG","../vehicles/catura4.PNG","../vehicles/f2.PNG","2018");
INSERT INTO tvehiculos VALUES("P980-454","hyunday elantra4","sedan","negro","2222333334444444","4444444499999999","Especial","../vehicles/hilux2.jpg","../vehicles/co1.jpg","../vehicles/co4.jpg","../vehicles/co3.jpg","2010");
INSERT INTO tvehiculos VALUES("P989-988","Honda civic","camioneta","cafe","9545454545454545","4544454545454545","Diesel","../vehicles/holo plantilla.png","../vehicles/holo plantilla.png","../vehicles/holo plantilla.png","../vehicles/holo plantilla.png","2003");
DROP TABLE IF EXISTS tventas;
CREATE TABLE `tventas` (
`idventa` int(11) NOT NULL AUTO_INCREMENT,
`cliente` varchar(60) COLLATE utf8_spanish_ci NOT NULL,
`direccion` varchar(150) COLLATE utf8_spanish_ci NOT NULL,
`fecha` date NOT NULL,
`codigo` varchar(5) COLLATE utf8_spanish_ci NOT NULL,
`tipo` varchar(50) COLLATE utf8_spanish_ci NOT NULL,
`proveedor` varchar(50) COLLATE utf8_spanish_ci NOT NULL,
`precio` float NOT NULL,
`garantia` int(11) NOT NULL,
PRIMARY KEY (`idventa`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
INSERT INTO tventas VALUES("17","qqqqqqq","aaaaaaa","2018-11-29","89898","MOTO","4","20","0");
INSERT INTO tventas VALUES("21","","","2018-11-30","89898","AUTO","4","66.66","0");
INSERT INTO tventas VALUES("22","Gerson Bladimir","Colonia Santa Maria Ostuma","2019-01-12","89898","AUTO","5","99.99","6");
INSERT INTO tventas VALUES("23","Juan Perez","Ilobasco Cabañas","2019-01-13","89898","AUTO","9","99.99","4");
INSERT INTO tventas VALUES("24","Marcia Aguilar","colonia los cocos san salvador","2019-01-13","89898","AUTO","9","99.99","3");
INSERT INTO tventas VALUES("25","William Medrano","Ilobasco Cabañas","2019-01-13","89898","AUTO","9","90","3");
INSERT INTO tventas VALUES("26","Machado","santo domingo","2019-01-13","89898","AUTO","6","75.55","4");
INSERT INTO tventas VALUES("27","Samuel","santo domingo","2019-01-13","89898","AUTO","9","33.33","5");
INSERT INTO tventas VALUES("28","Claudia Casco","San Salvador","2019-01-14","89898","AUTO","9","90","6");
INSERT INTO tventas VALUES("29","Mayra Carolina","puente cuscatlan","2019-01-14","YY666","AUTO","10","55.55","6");
INSERT INTO tventas VALUES("30","Yanci Flores","san miguel","2019-01-14","YY666","AUTO","10","55.55","6");
INSERT INTO tventas VALUES("31","Jackeline Rodriguez","San Sebastian San Vicente colonia santa fe","2019-01-15","YY666","AUTO","10","200","6");
SET FOREIGN_KEY_CHECKS=1; | true |
a4504448887998d81ac3a87323879e7b283fbfb1 | SQL | PIRO-DEV/Servlet_Apps | /user_roles.sql | UTF-8 | 1,475 | 3.03125 | 3 | [] | no_license | /*
SQLyog Ultimate v13.1.1 (64 bit)
MySQL - 8.0.17 : Database - app_test
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`app_test` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `app_test`;
/*Table structure for table `user_roles` */
DROP TABLE IF EXISTS `user_roles`;
CREATE TABLE `user_roles` (
`id` int(11) NOT NULL,
`uemail` varchar(255) DEFAULT NULL,
`umno` varchar(255) DEFAULT NULL,
`uname` varchar(255) DEFAULT NULL,
`urole` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Data for the table `user_roles` */
insert into `user_roles`(`id`,`uemail`,`umno`,`uname`,`urole`) values
(1,'john@xyz.com','102345678','John Doe','admin'),
(2,'jane@xyz.com','1478523690','Jane Doe','user'),
(3,'meliodas@xyz.com','1432718459','Meilodas','admin');
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
| true |
8dc1dc7cdd63b773afee3832c78ab119a26e6476 | SQL | dagibbins186/Pewlett-Hackard-Analysis | /Pewlett-Hackard-Analysis Folder/Queries/Employee_Database_Challenge.sql | UTF-8 | 3,559 | 4.5625 | 5 | [] | no_license | -- Creating tables for PH-EmployeeDB
CREATE TABLE departments (
dept_no VARCHAR(4) NOT NULL,
dept_name VARCHAR(40) NOT NULL,
PRIMARY KEY (dept_no),
UNIQUE (dept_name)
);
CREATE TABLE employees (
emp_no INT NOT NULL,
birth_date DATE NOT NULL,
first_name VARCHAR NOT NULL,
last_name VARCHAR NOT NULL,
gender VARCHAR NOT NULL,
hire_date DATE NOT NULL,
PRIMARY KEY (emp_no)
);
CREATE TABLE dept_manager (
dept_no VARCHAR(4) NOT NULL,
emp_no INT NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
FOREIGN KEY (emp_no) REFERENCES employees (emp_no),
FOREIGN KEY (dept_no) REFERENCES departments (dept_no),
PRIMARY KEY (emp_no, dept_no)
);
CREATE TABLE salaries (
emp_no INT NOT NULL,
salary INT NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
FOREIGN KEY (emp_no) REFERENCES employees (emp_no),
PRIMARY KEY (emp_no)
);
CREATE TABLE dept_emp (
emp_no int not null,
dept_no varchar not null,
from_date date not null,
to_date date not null,
foreign key (emp_no) references employees (emp_no),
foreign key (dept_no) references departments (dept_no),
primary key (emp_no, dept_no)
);
CREATE TABLE titles (
emp_no int not null,
title varchar not null,
from_date date not null,
to_date date not null,
foreign key (emp_no) references employees (emp_no),
primary key (emp_no, from_date)
);
--Create a table of current employees eligible for retirement
select e.emp_no,
e.first_name,
e.last_name,
de.to_date
into current_emp_challenge
from employees as e
left join dept_emp as de
on e.emp_no = de.emp_no
where (e.birth_date between '1952-01-01' and '1955-12-31')
and (e.hire_date between '1985-01-01' and '1988-12-31')
and de.to_date = ('9999-01-01');
--Select the titles of current employees eligible for retirement
select
c.emp_no,
c.first_name,
c.last_name,
t.title,
t.to_date,
t.from_date,
s.salary
into titles_retiring_challenge
from current_emp_challenge as c
inner join titles as t
on (c.emp_no = t.emp_no)
inner join salaries as s
on (c.emp_no = s.emp_no)
order by t.from_date DESC;
--Count the number of current employees retiring by their titles
select
count (title),
title
into count_titles_retiring_challenge
from titles_retiring_challenge
group by
title
order by count desc;
--Re order and separate data to show most recent titles
select
emp_no,
first_name,
last_name,
to_date,
title
into unique_titles_retiring_challenge
from
(select emp_no,
first_name,
last_name,
to_date,
title, row_number() over
(partition by (first_name, last_name)
order by to_date DESC) rn
from titles_retiring_challenge
) tmp where rn = 1
order by emp_no;
--Count the number of employees per title
select
count(title),
title
into count_unique_titles_retiring_challenge
from unique_titles_retiring_challenge
group by
title
order by count desc;
select * from unique_titles_retiring_challenge;
select * from count_unique_titles_retiring_challenge;
--Create mentorship eligibility table
select
e.emp_no,
e.last_name,
e.first_name,
e.birth_date,
string_agg(t.title, '/') as titles,
de.from_date,
de.to_date
into mentor_challenge
from employees as e
left join titles as t
on e.emp_no = t.emp_no
left join dept_emp as de
on e.emp_no = de.emp_no
where e.birth_date between '1965-01-01' and '1965-12-31'
and de.to_date = ('9999-01-01')
group by
e.emp_no,
e.first_name,
e.last_name,
de.from_date,
de.to_date
order by last_name;
select * from mentor_challenge;
select count(*) from mentor_challenge;
| true |
d74b194b043199e975c3ea2f07b2673da187fd92 | SQL | qianbin0205/data_analysis | /meituan_analysis/meituan_mysql_script.sql | UTF-8 | 1,867 | 3.859375 | 4 | [] | no_license | #sql1
select distinct
b.poi_id,b.title,b.avg_price,b.avg_score,b.comment_num,b.address,b.stamp from meituan_classify_info as a
inner join meituan_shop_info as b on a.sub_id = b.sub_id and a.class_type = b.class_type
where a.class_type = 1 and a.sub_id not in(24,393,395) and b.avg_price <> 0 and b.avg_score <> 0
order by avg_price desc;
#sql2
select distinct sub_id,sub_name from meituan_classify_info
where class_type = 1 and sub_id not in(24,393,395);
select distinct poi_id,avg_price from meituan_shop_info
where sub_id = 35 and class_type = 1;
-- sql3
select distinct a.sub_id,a.sub_name,
b.poi_id,b.title,b.avg_price,b.avg_score,b.comment_num,b.address from meituan_classify_info as a
inner join meituan_shop_info as b on a.sub_id = b.sub_id and a.class_type = b.class_type
where a.class_type = 1 and a.sub_id not in(24,393,395) and b.avg_price <> 0 and b.avg_score <> 0
and CONCAT(b.sub_id,b.poi_id) not in ('6342030772','4050576755','6350576755','4052163162','2006068147006','5452800270','4087812358','6387812358','543311762')
order by b.comment_num desc limit 10;
-- sql4
select sub_id,sub_name ,count(*) as cnt from (
select distinct a.sub_id,a.sub_name,
b.poi_id,b.title,b.avg_price,b.avg_score,b.comment_num,b.address,b.stamp from meituan_classify_info as a
inner join meituan_shop_info as b on a.sub_id = b.sub_id and a.class_type = b.class_type
where a.class_type = 1 and a.sub_id in (55,56,57,58,59,60,62,227,233,20003,20059,20060)
and b.avg_price <> 0 and b.avg_score <> 0
) as x
group by sub_id,sub_name;
-- sql4
select distinct a.sub_id,a.sub_name,
b.poi_id,b.title,b.avg_price,b.avg_score,b.comment_num,b.address,b.stamp from meituan_classify_info as a
inner join meituan_shop_info as b on a.sub_id = b.sub_id and a.class_type = b.class_type
where a.class_type = 1 and a.sub_id = 20059 and b.avg_price <> 0 and b.avg_score <> 0; | true |
4a5be20afad8cdac321f4f993b69583bdbada710 | SQL | dengsauve/College-Work | /2017 Winter/CIS126 DBMSSQL/ModifyDataAssignmentCreateTable.sql | UTF-8 | 726 | 2.8125 | 3 | [] | no_license | create table DogLicense(
License int not null primary key,
Expires date not null,
constraint ck_expires check (Expires > '01/01/1990'),
Sex varchar(2) not null,
constraint ck_sex check (Sex in ('M', 'F', 'NM', 'SF')),
PetName varchar(255),
Breed varchar(255),
OwnerLastName varchar(255) not null,
OwnerFirstName varchar(255),
"Address" varchar(50) not null,
City varchar(30) default 'Spokane',
State varchar(2) default 'WA',
Zip varchar(5), /*Needs to be in range of 99201 - 99212*/
constraint ch_zip check (Zip in ('99201', '99202', '99203', '99204',
'99205', '99206', '99207', '99208', '99209', '99210', '99211', '99212')),
Phone varchar(14),
Fee varchar(3) not null,
AggressiveDog varchar(1) default 'F'
) | true |
346b65aeabe46bd0439c4a3a1b8bbc41d30cf290 | SQL | DominicWrege/elenco | /sql/insert/comment.sql | UTF-8 | 296 | 3.125 | 3 | [
"MIT"
] | permissive | WITH inserted AS (
INSERT INTO comment(content, user_id, feed_id)
VALUES ($1, $2, $3 ) RETURNING id, user_id, feed_id, created, content
)
SELECT inserted.id, content, account.username, inserted.user_id, feed_id, inserted.created
FROM inserted, account
WHERE account.id = inserted.user_id; | true |
799a144d4450094be0acf273bcdff4f96d5563f6 | SQL | anandeka/my-project | /DBScripts/DataCorrectionScripts/data_correction_script_24.sql | UTF-8 | 2,643 | 3.5625 | 4 | [] | no_license |
DECLARE
CURSOR cr_ash_record
IS
SELECT ash.assay_ref_no, ash.internal_gmr_ref_no,
ash.internal_grd_ref_no
FROM ash_assay_header ash
WHERE ash.assay_type = 'Weighing and Sampling Assay'
GROUP BY ash.assay_ref_no,
ash.internal_gmr_ref_no,
ash.internal_grd_ref_no;
BEGIN
FOR cur_record_rows IN cr_ash_record
LOOP
UPDATE ash_assay_header ash
SET ash.wnsrefno = cur_record_rows.assay_ref_no,
ash.dry_weight = (SELECT SUM (asm.dry_weight)
FROM asm_assay_sublot_mapping asm
WHERE ash.ash_id = asm.ash_id),
ash.qty_unit_name =
pkg_general.f_get_quantity_unit
((SELECT DISTINCT asm.net_weight_unit
FROM asm_assay_sublot_mapping asm
WHERE ash.ash_id =
asm.ash_id))
WHERE ash.internal_gmr_ref_no = cur_record_rows.internal_gmr_ref_no
AND ash.internal_grd_ref_no = cur_record_rows.internal_grd_ref_no
AND ash.assay_type NOT IN
('Provisional Assay', 'Shipment Assay', 'Contractual Assay');
END LOOP;
END;
/
DECLARE
CURSOR ash_cursor
IS
SELECT ash.internal_gmr_ref_no, ash.assay_type,
ash.internal_grd_ref_no
FROM ash_assay_header ash
WHERE ash.assay_type = 'Provisional Assay'
GROUP BY ash.internal_gmr_ref_no,
ash.internal_grd_ref_no,
ash.assay_type;
BEGIN
FOR ash_cur_rows IN ash_cursor
LOOP
UPDATE ash_assay_header ash
SET ash.dry_weight = (SELECT SUM (asm.dry_weight)
FROM asm_assay_sublot_mapping asm
WHERE ash.ash_id = asm.ash_id),
ash.qty_unit_name =
pkg_general.f_get_quantity_unit
((SELECT DISTINCT asm.net_weight_unit
FROM asm_assay_sublot_mapping asm
WHERE ash.ash_id =
asm.ash_id))
WHERE ash.internal_gmr_ref_no = ash_cur_rows.internal_gmr_ref_no
AND ash.internal_grd_ref_no = ash_cur_rows.internal_grd_ref_no
AND ash.assay_type IN ('Provisional Assay');
END LOOP;
END;
/ | true |
ce7aafc7e591730cadf16c2ec31ffdec7b36cfb2 | SQL | andrewmanq/cs262 | /Lab08/commands.sql | UTF-8 | 1,097 | 4.25 | 4 | [] | no_license | --EXERCISE 8.1
--sort games by ascending time
SELECT *
FROM Game
ORDER BY time ASC;
--selects games in the past week
SELECT *
FROM Game
WHERE time > '2018-10-19 01:00:00';
--finds players with no name
SELECT *
FROM Player
WHERE name IS NOT NULL;
--finds the id of players with scores above 2000
SELECT playerID
FROM PlayerGame
WHERE score > 2000;
--finds all players with a gmail account
SELECT *
FROM Player
WHERE emailAddress LIKE '%@gmail.edu%';
--EXERCISE 8.2
--finds all scores from dogbreath
SELECT score
FROM Player, PlayerGame
WHERE Player.ID = PlayerGame.playerID
AND Player.name = 'Dogbreath';
--finds the winner of the game that happened on 2006-06-28 13:20:00
SELECT Player.name
FROM Player, PlayerGame, Game
WHERE Game.time = '2006-06-28 13:20:00'
AND PlayerGame.gameID = Game.ID
AND Player.ID = PlayerGame.playerID
ORDER BY PlayerGame.score DESC
LIMIT 1;
--ANSWER C: P1.ID < P2.ID ensures that the two players are not the same player. Otherwise, it would compare a player to itself.
--ANSWER D: Joining a table to itself makes it possible to compare two items from the same table. | true |
87808fbeba0465f7e9623fdb0201d176e3f90b0b | SQL | fmaraujo1981/phpmysql | /with-query/data.sql | UTF-8 | 940 | 2.78125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 28, 2015 at 12:31 PM
-- Server version: 5.1.36
-- PHP Version: 5.3.0
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!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: `dbtest`
--
-- --------------------------------------------------------
--
-- Table structure for table `data`
--
CREATE TABLE IF NOT EXISTS `data` (
`id` int(5) NOT NULL AUTO_INCREMENT,
`fn` varchar(50) NOT NULL,
`ln` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `data`
--
INSERT INTO `data` (`id`, `fn`, `ln`) VALUES
(1, 'pradeep', 'khodke'),
(2, 'cleartuts', 'blog');
| true |
13b23e08694ae6af1df485750d0be65a6980e235 | SQL | CUBRID/cubrid-testcases | /sql/_22_news_service_mysql_compatibility/_04_regular_expression/cases/_dev_02_regex_test_cf.sql | UTF-8 | 1,246 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | -- CBRD-24563 : default regexp library change from cppstd to RE2
set system parameters 'regexp_engine=cppstd';
-- regular expression tests (constant folding)
select (null rlike 'a');
select ('a' rlike null);
select (null rlike null);
select ('' rlike 'a');
select ('a' rlike '');
select ('' rlike '');
select (null rlike '');
select ('' rlike null);
select ('a' rlike '^a$'), ('b' rlike '^a$');
select ('' rlike '^a*$'), ('aaa' rlike '^a*$'), ('baa' rlike '^a*$');
select ('a' rlike '^a+$'), ('aaa' rlike '^a+$'), ('' rlike '^a+$');
select ('' rlike '^a?$'), ('a' rlike '^a?$'), ('aa' rlike '^a?$');
select ('abbaababab' rlike '^(ab|ba)*$'), ('abb' rlike '^(ab|ba)*$');
select ('aaa' rlike '^a{3,5}$'), ('aaaaa' rlike '^a{3,5}$'), ('aa' rlike '^a{3,5}$');
select ('abcbabababc' rlike '^[abc]+$'), ('a' rlike '^[abc]+$'), ('abcdbcbcbabc' rlike '^[abc]+$');
select ('abcxacbxax' rlike '^[a-cx]+$'), ('xxaba' rlike '^[a-cx]+$'), ('dabcx' rlike '^[a-cx]+$');
select ('xyz' rlike '^[^a-w]*$'), ('xyz123!@#' rlike '^[^a-w]*$'), ('wxyz' rlike '^[^a-w]*$');
select ('~' rlike '^[[.tilde.]]$'), ('a' rlike '^[[.tilde.]]$');
select ('a fox is cute' rlike '\bfox\b'), ('a foxx is cute' rlike '\bfox\b');
set system parameters 'regexp_engine=default';
| true |
73cfd3a943966175da0f9e00f08061bab333ac60 | SQL | gravesmw/RiskManager | /GravesConsultingLLC.RiskManager.Database/Report/Views/DimObjectType.sql | UTF-8 | 170 | 2.734375 | 3 | [] | no_license | CREATE VIEW [Report].[DimObjectType]
AS
SELECT ObjectTypeID AS ObjectTypeKey,
Name,
ParentObjectTypeID AS ParentObjectTypeKey
FROM Content.ObjectType WITH (NOLOCK) | true |
45cb13868a537b674546406180822fa4ae2d252f | SQL | DaniilTuruhanov/my-projects | /Front/task 11/13.sql | UTF-8 | 172 | 3.78125 | 4 | [] | no_license | SELECT USER_NAME FROM Users
INNER JOIN Posts ON Posts.USER_ID = Users.USER_ID
WHERE date(CREATION_DATE) = CURDATE()
GROUP BY Users.USER_ID
HAVING COUNT(Posts.POST_ID) > 3; | true |
157d7e7f7194d5d2e634f857dbade093fba94040 | SQL | paulgheorghecristian/cubrid-testcases | /sql/_27_banana_qa/issue_16066_BINARY_charset/_00_String_Functions_and_Operators/cases/translate002.sql | UTF-8 | 1,412 | 3 | 3 | [
"BSD-3-Clause"
] | permissive | --+ holdcas on;
set names utf8;
drop table if exists t1;
create table t1 (col_binary varchar(10) collate binary, col_euckr varchar(10) collate euckr_bin, col_utf8 varchar(10) collate utf8_bin, col_iso varchar(10) collate iso88591_bin);
insert into t1 values('문자열', '문자열', '문자열', 'ÀÏ');
insert into t1 values(cast( _utf8'문자열' as string charset euckr), '문자열', '문자열', 'ÀÏ');
insert into t1 values(cast( _utf8'ÀÏ' as string charset iso88591), '문자열', '문자열', 'ÀÏ');
SELECT translate(col_binary , col_euckr,col_utf8) from t1;
SELECT translate(col_binary , col_utf8,col_euckr ) from t1;
SELECT translate(col_binary , col_iso,'' ) from t1;
SELECT translate(col_euckr , col_utf8,'' ) from t1;
SELECT translate(col_euckr , col_iso,'' ) from t1;
SELECT translate(col_utf8 , col_iso ,'' ) from t1;
SELECT translate(col_binary , chr(0),chr(0)) from t1;
SELECT translate(col_euckr , chr(0),chr(0)) from t1;
SELECT translate(col_iso , chr(0),chr(0)) from t1;
set names binary;
SELECT translate(col_binary , col_euckr,col_utf8) from t1;
SELECT translate(col_binary , col_utf8,col_euckr ) from t1;
SELECT translate(col_binary , col_iso,'' ) from t1;
SELECT translate(col_euckr , col_utf8,'' ) from t1;
SELECT translate(col_euckr , col_iso,'' ) from t1;
SELECT translate(col_utf8 , col_iso ,'' ) from t1;
drop table t1;
set names iso88591;
commit;
--+ holdcas off;
| true |
39f33794557a2c5dfd2cd7fe629084572486bb3e | SQL | AdmiJW/SQL | /SQL Cheat Sheet/1.2 INSERTING DATA.sql | UTF-8 | 1,003 | 3.21875 | 3 | [] | no_license | # INSERTING DATA IN ALL FIELDS
/* ======================================================================
If we are going to insert the data into ALL the fields, we use the
syntax
INSERT INTO <table> VALUES ( <...values> )
where the values are exactly number of columns in the table
====================================================================== */
INSERT INTO students VALUES (10, 'Kate', 14); # Setting ID ourselves will work
# INSERTING DATA IN SOME FIELDS
/* ======================================================================
If we only want to fill in some fields and omit some other ones, we
first put the field names in a parenthesis after the <table>,
then only follows by VALUES ( <...values> )
INSERT INTO <table> ( <...fields> ) VALUES ( <...values> )
====================================================================== */
INSERT INTO students ( student_name, age ) VALUES ( 'Cindy', 18 );
SELECT * FROM students;
| true |
2722f18dff555042bc803a1a97bd67c9ba91f384 | SQL | AbdelGhania/PostgresSQL-Challenge | /Schemas.sql | UTF-8 | 1,622 | 3.890625 | 4 | [
"MIT"
] | permissive | # Creating employees table:
Create Table employees (
emp_no INT NOT NULL,
birth_date DATE NOT NULL,
first_name VARCHAR(14) NOT NULL,
last_name VARCHAR (16) NOT NULL,
gender VARCHAR (1) NOT NULL,
hire_date DATE NOT NULL,
primary key (emp_no));
# Creating departments table:
Create Table departments (
dept_no VARCHAR(4) NOT NULL,
dept_name VARCHAR(40) NOT NULL,
Primary KEY (dept_no),
UNIQUE (dept_name));
# Creating dept_manager table:
Create Table dept_manager (
dept_No VARCHAR(4) NOT NULL,
emp_no INT NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
Foreign KEY (emp_no) references employees(emp_no),
FOREIGN KEY (dept_no) references departments (dept_no),
PRIMARY KEY (emp_no, dept_no));
# Creating dept_ emp table:
Create Table dept_emp (
emp_no INT NOT NULL,
dept_no VARCHAR(4) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
Foreign KEY (emp_no) REFERENCES employees (emp_no),
Foreign KEY (dept_no) REFERENCES departments (dept_no),
Primary KEY (emp_no, dept_no)
);
# Creating titles table:
Create table titles (
emp_no INT NOT NULL,
title VARCHAR (50) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
FOREIGN Key (emp_no) REFERENCES employees (emp_no),
PRIMARY KEY (emp_no, title, from_date)
);
# Creating Salaries table:
Create table titles (
emp_no INT NOT NULL,
title VARCHAR (50) NOT NULL,
from_date DATE NOT NULL,
to_date DATE NOT NULL,
Foreign Key (emp_no) REFERENCES employees (emp_no),
PRIMARY KEY (emp_no, title, from_date)
);
| true |
295b6d19bccdbf018e0765d94291395051dcb5c4 | SQL | S205334/ProgettoPWR | /DB/informatica.sql | UTF-8 | 1,717 | 3.453125 | 3 | [] | no_license | --
-- database: `informatica`
--
DROP DATABASE IF EXISTS `informatica`;
CREATE DATABASE `informatica` DEFAULT CHARACTER SET latin1 COLLATE latin1_general_cs;
USE `informatica`;
--
-- structure for table `prodotti`
--
DROP TABLE IF EXISTS `prodotti`;
CREATE TABLE `prodotti` (
`pid` int unsigned NOT NULL AUTO_INCREMENT,
`nome` varchar(64) NOT NULL,
`prezzo` int unsigned NOT NULL,
`qty` smallint unsigned NOT NULL,
PRIMARY KEY (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
--
-- data for table `prodotti`
--
INSERT INTO `prodotti` (`pid`, `nome`, `prezzo`, `qty`) VALUES
(1, 'display 21.5" 1920x1080 HDMI', 8856, 3),
(2, 'mouse USB', 283, 20),
(3, 'HDD USB3 1TB', 4800, 5),
(4, 'HDD USB3 2TB', 6610, 5),
(5, 'USB pen 2GB', 390, 10),
(6, 'USB pen 4GB', 406, 20);
--
-- structure for table 'utenti'
--
DROP TABLE IF EXISTS `utenti`;
CREATE TABLE `utenti` (
`userid` int unsigned NOT NULL AUTO_INCREMENT,
`nick` varchar(8) NOT NULL,
`pass` varchar(10) NOT NULL,
PRIMARY KEY (`userid`)
) ENGINE=InnoDB;
--
-- data for table 'utenti'
--
INSERT INTO `utenti` (`userid`, `nick`, `pass`) VALUES
(1, 'alex1990', '2016'),
(2, '$007', '1960');
--
-- Permessi DB user: uNormal; pwd: posso_solo_leggere (solo SELECT)
--
GRANT USAGE ON `informatica`.* TO 'uNormal'@'localhost' IDENTIFIED BY PASSWORD '*0FBF5C395B1E6B971E9CBB18F95041B49D0B0947';
GRANT SELECT ON `informatica`.* TO 'uNormal'@'localhost';
--
-- Permessi DB user: uPower; pwd: SuperPippo!!! (solo SELECT, INSERT, UPDATE)
--
GRANT USAGE ON `informatica`.* TO 'uPower'@'localhost' IDENTIFIED BY PASSWORD '*400BF58DFE90766AF20296B3D89A670FC66BEAEC';
GRANT SELECT, INSERT, UPDATE ON `informatica`.* TO 'uPower'@'localhost';
| true |
93bd70845da89991a478d2d5e808fcbc7efdd02b | SQL | dcdimas/simpleHMS | /SQL.sql | UTF-8 | 14,073 | 2.859375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 30, 2020 at 10:37 AM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.4.6
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: `covidhsm`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin_login`
--
CREATE TABLE `admin_login` (
`ID` int(20) NOT NULL,
`aUsername` varchar(255) NOT NULL,
`aPassword` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin_login`
--
INSERT INTO `admin_login` (`ID`, `aUsername`, `aPassword`) VALUES
(1, 'admin', 'admin123');
-- --------------------------------------------------------
--
-- Table structure for table `doctor_register`
--
CREATE TABLE `doctor_register` (
`ID` int(20) NOT NULL,
`dFull_name` varchar(255) NOT NULL,
`dBirthday` date NOT NULL,
`dSpecialization` varchar(255) NOT NULL,
`dSchedule` varchar(255) NOT NULL,
`dAddress` varchar(255) NOT NULL,
`dContact_no` varchar(200) NOT NULL,
`dEmail_Add` varchar(255) NOT NULL,
`dUsername` varchar(255) NOT NULL,
`dPassword` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `doctor_register`
--
INSERT INTO `doctor_register` (`ID`, `dFull_name`, `dBirthday`, `dSpecialization`, `dSchedule`, `dAddress`, `dContact_no`, `dEmail_Add`, `dUsername`, `dPassword`) VALUES
(1, 'Daisylee Dimas', '1999-10-23', 'Allergist / Immunologist', '6:00 am - 2:00 pm / Monday, Wednesday\r\n2:00 pm - 10:00 pm / Friday', 'Chico St., Violeta Village, Sta.Cruz, Guiguinto, Bulacan', '09364061427', 'Daisylee@gmail.com', 'daisylee123', 'sampledoctor'),
(2, 'Mary Grace Dimacali', '1999-10-16', 'Hematologist', '2:00 pm - 10:00 pm / Tuesday, Thursday, Friday', '930 Purok 4, Tabe, Guiguinto, Bulacan', '09353031678', 'Grace.dimacali.7@gmail.com', 'GraceDimacali', 'dimacali789'),
(3, 'Ricca Manlangit', '1985-09-03', 'Cardiologist', '2:00 pm - 10:00 pm / Saturday, Sunday\r\n6:00 am - 2:00 pm / Monday', '970 Punong Gubat, Bulacan', '09564827367', 'riccabeh@gmail.com', 'riCcAhBeH', 'riccacute'),
(4, 'Kimmy Reyes', '1982-01-01', 'Pulmonologist', '6:00 am - 2:00 pm / Tuesday, Thursday\r\n2:00 pm - 10:00 pm / Saturday', '43 Nasaniban, Sto.Cristo, Manila', '09648362891', 'kimmy@yahoo.com', 'Kimmy', '123'),
(5, 'Ana Marie Querol', '1984-03-01', 'Infectious Disease Specialist', '2:00 pm - 10:00 pm / Sunday\r\n10:00 pm - 6:00am / Tuesday', '678 Tuktukan, Guiguinto, Bulacan', '09674836282', 'anamarie@gmail.com', 'doc.ana', '456123');
-- --------------------------------------------------------
--
-- Table structure for table `nurse_register`
--
CREATE TABLE `nurse_register` (
`ID` int(11) NOT NULL,
`nFull_name` varchar(255) NOT NULL,
`nBirthday` date NOT NULL,
`nSchedule` varchar(255) NOT NULL,
`nAddress` varchar(255) NOT NULL,
`nContact_no` varchar(200) NOT NULL,
`nEmail_Add` varchar(255) NOT NULL,
`nUsername` varchar(255) NOT NULL,
`nPassword` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `nurse_register`
--
INSERT INTO `nurse_register` (`ID`, `nFull_name`, `nBirthday`, `nSchedule`, `nAddress`, `nContact_no`, `nEmail_Add`, `nUsername`, `nPassword`) VALUES
(1, 'Jaymee De Vegas', '1984-08-10', '6:00 am - 2:00 pm / Monday, Friday\r\n2:00 pm - 10:00 pm / Wednesday\r\n', '374 Purok 2, Sampung Palay, Quezon City', '09150976481', 'JaymeeDV@gmail.com', 'Jaymee#10', 'samplenurse'),
(2, 'Alexandro Mendoza', '1979-12-01', '2:00 pm - 10:00 pm / Tuesday, Friday\r\n10:00 pm - 6:00 am / Thursday', '10 Marikit Village, Makati City', '09467643691', 'NurseAlex@yahoo.com', 'NurseAlex', 'alexmouhh#123'),
(3, 'Samantha Reyes', '1988-05-27', '2:00 pm - 10:00 pm / Sunday\r\n6:00 am - 2:00 pm / Tuesday, Thursday', 'Santol St., Violeta Village, Guiguinto, Bulacan', '09654789561', 'susan@yahoo.com', 'Susan789', '789'),
(4, 'Shane Ashley Lacbay', '1992-08-19', '6:00 am - 2:00 pm / Tuesday\r\n2:00 pm - 10:00pm / Thursday, Saturday', '258 Pinalad, Sta.Cruz, Manila', '09356476624', 'ShaneAshley@gmail.com', 'Shane', '321'),
(5, 'Pablo Agustin', '1989-03-15', '10:00 pm - 6:00 am / Sunday, Tuesday, Thursday', '76 July st., Sinangag, Binagoongan, Bulacan', '09277456790', 'Pablo15@yahoo.com', 'PabloAgustin', 'pogiako');
-- --------------------------------------------------------
--
-- Table structure for table `patient_medhis`
--
CREATE TABLE `patient_medhis` (
`diagnosisID` int(20) NOT NULL,
`NurseID` int(20) NOT NULL,
`Nurse_name` varchar(255) NOT NULL,
`ID` int(20) NOT NULL,
`pVisit_date` datetime NOT NULL,
`pFull_name` varchar(255) NOT NULL,
`pAge` varchar(20) NOT NULL,
`pWeight` varchar(20) NOT NULL,
`pHeight` varchar(20) NOT NULL,
`pBlood_pressure` varchar(20) NOT NULL,
`pBlood_sugar` varchar(20) NOT NULL,
`pBody_temperature` varchar(20) NOT NULL,
`pSymptoms` text NOT NULL,
`pDate_admitted` datetime NOT NULL,
`pRoom_no` varchar(50) NOT NULL,
`pDate_discharged` datetime NOT NULL,
`pTravel_history` varchar(255) NOT NULL,
`pModified_classification` varchar(255) NOT NULL,
`pDate_confirmed` datetime NOT NULL,
`pTest_results` varchar(200) NOT NULL,
`pCondition` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `patient_medhis`
--
INSERT INTO `patient_medhis` (`diagnosisID`, `NurseID`, `Nurse_name`, `ID`, `pVisit_date`, `pFull_name`, `pAge`, `pWeight`, `pHeight`, `pBlood_pressure`, `pBlood_sugar`, `pBody_temperature`, `pSymptoms`, `pDate_admitted`, `pRoom_no`, `pDate_discharged`, `pTravel_history`, `pModified_classification`, `pDate_confirmed`, `pTest_results`, `pCondition`) VALUES
(1, 1, 'Jaymee De Vegas', 1, '2020-07-29 15:00:00', 'Barry Cartery', '50', '55 kg', '5`5 ft', '100 / 90', '100', '37 deg', 'Chest tightness, shortness of breath, coughing', '0000-00-00 00:00:00', '', '0000-00-00 00:00:00', 'None', 'SUSPECT', '2020-08-04 18:00:00', 'NEGATIVE', 'ASTHMA'),
(2, 2, 'Alexandro Mendoza', 2, '2020-07-17 14:30:00', 'Candace Jackson', '45', '47 kg', '5 ft', ' 90 / 75', '90', '35 deg', 'Headache, pale skin, cold hands, extreme fatigue', '0000-00-00 00:00:00', '', '0000-00-00 00:00:00', '', '', '0000-00-00 00:00:00', '', ''),
(3, 3, 'Samantha Reyes', 3, '2020-07-25 09:25:00', 'Robert Evins', '42', ' 50 kg', '5`4 ft', '135 / 90', '112', '34 deg', 'Rapid heartbeat, sudden chest pain, fainting', '0000-00-00 00:00:00', '', '0000-00-00 00:00:00', '', '', '0000-00-00 00:00:00', '', ''),
(4, 4, 'Shane Ashley Lacbay', 4, '2020-08-06 10:23:00', 'Ronaldo Mitchell', '33', '60 kg', '5`6 ft', '120 / 80', '120', '42 deg', 'Fever, Headache, Coughing, Shortness of breath, fatigue', '2020-08-06 12:00:00', 'Quarantine room no.1', '2020-08-20 10:00:00', 'Quezon City', 'CONFIRMED', '2020-08-10 06:30:00', 'POSITIVE', 'Mild case'),
(5, 5, 'Pablo Agustin', 5, '2020-07-04 16:00:00', 'Deborah Estrella', '70', '49 kg', '4`9 ft', '100 / 80', '95', '43 deg', 'Fever, Headache, dry cough, sore throat', '2020-07-04 16:10:00', 'Quarantine room no.2', '2020-07-20 15:00:00', 'Wuhan, China', 'CONFIRMED', '2020-07-10 16:00:00', 'POSITIVE', 'SEVERE CASE, Intubated'),
(6, 4, 'Shane Ashley Lacbay', 6, '2020-07-19 09:30:00', 'Elvira Pacheco', '38', '52 kg', '5`3 ft', '120 / 80', '100', '35 deg', 'Itchy throat, sneezing, runny nose', '0000-00-00 00:00:00', '', '0000-00-00 00:00:00', '', '', '0000-00-00 00:00:00', '', ''),
(7, 2, 'Alexandro Mendoza', 7, '2020-07-17 15:30:00', 'Betty Garibay', '20', '45 kg', '4`8 ft', '90 / 80 ', '85', '35 deg', 'Excessive bleeding, blood in urine or stool, nosebleed', '2020-07-17 16:00:00', '202', '2020-07-29 07:00:00', '', '', '0000-00-00 00:00:00', '', ''),
(8, 1, 'Jaymee De Vegas', 8, '2020-08-03 11:00:00', 'Andrei Philis', '45', '56 kg', '5`5 ft', '120 / 20 ', '100', '34 deg', 'Pain in the other area of the upper body including the left shoulder and back,\r\nSweating,\r\ndizziness\r\n\r\n\r\n\r\n', '0000-00-00 00:00:00', '', '0000-00-00 00:00:00', '', '', '0000-00-00 00:00:00', '', '');
-- --------------------------------------------------------
--
-- Table structure for table `patient_register`
--
CREATE TABLE `patient_register` (
`ID` int(20) NOT NULL,
`pFull_name` varchar(255) NOT NULL,
`pBirthday` date NOT NULL,
`pAge` varchar(20) NOT NULL,
`pSex` varchar(255) NOT NULL,
`pAddress` varchar(255) NOT NULL,
`pContact_no` varchar(200) NOT NULL,
`pEmail_add` varchar(255) NOT NULL,
`pUsername` varchar(255) NOT NULL,
`pPassword` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `patient_register`
--
INSERT INTO `patient_register` (`ID`, `pFull_name`, `pBirthday`, `pAge`, `pSex`, `pAddress`, `pContact_no`, `pEmail_add`, `pUsername`, `pPassword`) VALUES
(1, 'Barry Cartery', '1970-10-08', '50', 'Male', 'Cruz, Guiguinto, Bulacan', '09784569871', 'barry@yahoo.com', 'BarryCartery08', 'samplepatient'),
(2, 'Candace Jackson', '1947-11-21', '45', 'Female', 'Matungao, Bulakan, Bulacan', '09784561236', 'cj@yahoo.com', 'Candace123', 'candacecute'),
(3, 'Robert Evins', '1977-08-06', '42', 'Male', 'Sto.Cristo, Panginay, Balagtas', '09784561254', 'evins@yahoo.com', 'RobertPogi', '753951'),
(4, 'Ronaldo Mitchell', '1987-10-21', '33', 'Male', 'Baliuag, Bulacan', '09895641236', 'ronaldo@gmail.com', 'mitchelll', 'mitch456'),
(5, 'Deborah Estrella', '1949-07-25', '70', 'Female', 'Marilao, Bulacan', '09561239874', '', 'deborah07', '789632'),
(6, 'Elvira Pacheco', '1982-01-30', '38', 'Female', 'Purok 6, Cutcut, Guiguinto, Bulacan', '09124567892', 'pacheco30@yahoo.com', 'elvirapacheco', 'chico123'),
(7, 'Betty Garaibay', '2000-06-27', '19', 'Female', 'San Jose del Monte, Bulacan', '09124563987', 'Betty@yahoo.com', 'bGaribay', 'garibay123'),
(8, 'Andrei Philis', '1975-03-17', '49', 'Male', 'San Rafael, Bulacan', '09754563217', '', 'adra123', '753159');
-- --------------------------------------------------------
--
-- Table structure for table `recep_register`
--
CREATE TABLE `recep_register` (
`ID` int(20) NOT NULL,
`rFull_name` varchar(255) NOT NULL,
`rBirthday` varchar(255) NOT NULL,
`rSchedule` text NOT NULL,
`rAddress` varchar(255) NOT NULL,
`rContact_no` varchar(200) NOT NULL,
`rEmail_Add` varchar(255) NOT NULL,
`rUsername` varchar(255) NOT NULL,
`rPassword` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `recep_register`
--
INSERT INTO `recep_register` (`ID`, `rFull_name`, `rBirthday`, `rSchedule`, `rAddress`, `rContact_no`, `rEmail_Add`, `rUsername`, `rPassword`) VALUES
(1, 'Mateo San Diego', '1988-09-11', '6:00 am - 12:00 pm / Monday, Wednesday, Friday\r\n', '648 Purok 3, Sampaloc, Manila', '09637298499', 'Sandiego@yahoo.com', 'MateoSD', 'matty456'),
(2, 'Yumie San Francisco', '1978-11-13', '12:00 pm - 6:00 pm / Tuesday, Thursday, Saturday, Sunday\r\n', '789 Sakitan, Kamuning City', '0978456235', 'yumisan@gmai.com', 'yumisan', '789456');
-- --------------------------------------------------------
--
-- Table structure for table `wb_register`
--
CREATE TABLE `wb_register` (
`ID` int(20) NOT NULL,
`wFull_name` varchar(255) NOT NULL,
`wBirthday` date NOT NULL,
`wSchedule` text NOT NULL,
`wAddress` varchar(255) NOT NULL,
`wContact_no` varchar(255) NOT NULL,
`wEmail_Add` varchar(255) NOT NULL,
`wUsername` varchar(255) NOT NULL,
`wPassword` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `wb_register`
--
INSERT INTO `wb_register` (`ID`, `wFull_name`, `wBirthday`, `wSchedule`, `wAddress`, `wContact_no`, `wEmail_Add`, `wUsername`, `wPassword`) VALUES
(1, 'Samantha Loraine Santos', '1978-06-19', '6:00 am - 2:00 pm / Monday, Tuesday\r\n2:00 pm - 10:00 pm / Wednesday', '645 San Cristobal City', '09737272837', 'SamanthaLoraine@gmail.com', 'Sammy', 'samplewb'),
(2, 'Jefferson Ipa', '1980-02-15', '10:00 pm- 6:00am / Wednesday, Thursday, Friday\r\n', '480 Purok 1 Katapang, San Jose, Bocaue', '0973282974', 'jeff15ipa@gmail.com', 'jeff15ipa', '456789'),
(3, 'Emily Calipre', '1982-09-19', '2:00 pm - 10:00 pm / Monday, Tuesday\r\n6:00 am - 2:00 pm / Wednesday', '213 Sinumpong, Bocaue, Bulacan', '09637372837', 'EmilyCalipre@yahoo.com', 'caliprecutie', '123789');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin_login`
--
ALTER TABLE `admin_login`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `doctor_register`
--
ALTER TABLE `doctor_register`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `nurse_register`
--
ALTER TABLE `nurse_register`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `patient_medhis`
--
ALTER TABLE `patient_medhis`
ADD PRIMARY KEY (`diagnosisID`);
--
-- Indexes for table `patient_register`
--
ALTER TABLE `patient_register`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `recep_register`
--
ALTER TABLE `recep_register`
ADD PRIMARY KEY (`ID`);
--
-- Indexes for table `wb_register`
--
ALTER TABLE `wb_register`
ADD PRIMARY KEY (`ID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin_login`
--
ALTER TABLE `admin_login`
MODIFY `ID` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `doctor_register`
--
ALTER TABLE `doctor_register`
MODIFY `ID` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `nurse_register`
--
ALTER TABLE `nurse_register`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `patient_medhis`
--
ALTER TABLE `patient_medhis`
MODIFY `diagnosisID` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `patient_register`
--
ALTER TABLE `patient_register`
MODIFY `ID` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `recep_register`
--
ALTER TABLE `recep_register`
MODIFY `ID` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `wb_register`
--
ALTER TABLE `wb_register`
MODIFY `ID` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
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 |
7e1550fe5c634c995f271dbd6c446adab60e7f6b | SQL | LucaContri/dataanalysis | /SFReportEngine/resources/coles.dashboard.reports.sql | UTF-8 | 2,810 | 4.0625 | 4 | [] | no_license | use salesforce;
create or replace view coles_dashboard_data_last_month_sub as
select a.Name as 'Account Name', c.AccountId, c.Id, c.Name, c.FirstName, c.LastName, date_format(min(r.Class_Begin_Date__c ), '%Y-%m') as 'First Registration Period'
from training.registration__c r
inner join training.contact c on r.Attendee__c = c.Id
inner join training.account a on c.AccountId = a.Id
where r.Status__c = 'Confirmed'
and (r.Course_Number__c like '%a%' or r.Course_Number__c like '%f%')
and r.Course_Number__c not in ('f32','f30')
and (r.Coles__c = 1 or r.Coles_Brand_Employee__c = 1)
and r.Class_Begin_Date__c >= '2012-07-01'
#and date_format(r.Class_Begin_Date__c, '%Y-%m') in (date_format(date_add(now(), interval -1 month), '%Y-%m'), date_format(now(), '%Y-%m'))
group by a.Name;
create or replace view coles_dashboard_data_last_month as
# Supplier Company Engagement
(select t.`First Registration Period` as 'Period', 'Supplier Company Engagement' as 'Metric', count(t.`Account Name`) as 'Value'
from coles_dashboard_data_last_month_sub t
where t.`First Registration Period` in (date_format(date_add(now(), interval 1 month), '%Y-%m'), date_format(date_add(now(), interval -1 month), '%Y-%m'), date_format(now(), '%Y-%m'))
group by t.`First Registration Period`
order by t.`First Registration Period` desc limit 3)
union
# Supplier Company Subscriptions
(select date_format(r.Class_Begin_Date__c, '%Y-%m') as 'Period', 'Supplier Company Subscriptions' as 'Metric', count(distinct ba.Name) as 'Value'
from training.registration__c r
inner join training.course__c c on r.Course_Name__c = c.Id
inner join training.account ba on r.Billing_Account__c = ba.Id
where
c.CQA_Connect__c = 1
and r.Status__c = 'Confirmed'
and date_format(r.Class_Begin_Date__c, '%Y-%m') in (date_format(date_add(now(), interval 1 month), '%Y-%m'), date_format(date_add(now(), interval -1 month), '%Y-%m'), date_format(now(), '%Y-%m'))
group by `Period`)
union
# User Engagement
(select date_format((r.Class_Begin_Date__c ), '%Y-%m') as 'Period',
if(r.Coles_Brand_Employee__c = 1, 'Staff Engagement', 'Supplier Engagement') as 'Metric',
count(r.Id) as 'Value'
from training.registration__c r
where r.Status__c = 'Confirmed'
and (r.Course_Number__c like '%a%' or r.Course_Number__c like '%f%')
and r.Course_Number__c not in ('f32','f30')
and (r.Coles__c = 1 or r.Coles_Brand_Employee__c = 1)
and date_format(r.Class_Begin_Date__c, '%Y-%m') in (date_format(date_add(now(), interval 1 month), '%Y-%m'), date_format(date_add(now(), interval -1 month), '%Y-%m'), date_format(now(), '%Y-%m'))
group by `Period`, `Metric`);
select * from salesforce.coles_dashboard_data_last_month;
select r.Name, r.Reporting_Business_Units__c from salesforce.resource__c r
where
r.Name like '%Lee%'
r.Reporting_Business_Units__c like 'AUS-Product%';
| true |
05dc63dbaf5f73f16e1663bca94577c06d803e6d | SQL | mucollabo/SQL200 | /176.sql | UTF-8 | 911 | 3.171875 | 3 | [] | no_license | set serveroutput on
set verify off
accept p_num prompt '랜덤으로 생성할 숫자들의 개수를 입력하세요 ~ '
accept p_a prompt '검색할 숫자를 입력하세요 ~ '
declare
type array_t is varray(1000) of number(30);
array_s array_t := array_t();
v_cnt number(10) := &p_num;
v_a number(10) := &p_a;
v_chk number(10) := 0;
begin
array_s.extend(v_cnt);
for i in 1 .. v_cnt loop
array_s(i) := round(dbms_random.value(1, v_cnt));
dbms_output.put(array_s(i) || ',');
end loop;
dbms_output.new_line;
for i in array_s.first .. array_s.last loop
if v_a = array_s(i) then
v_chk := 1;
dbms_output.put(i || '번째에서 숫자 ' || v_a || '를 발견했습니다.');
end if;
end loop;
dbms_output.new_line;
if v_chk = 0 then
dbms_output.put_line('숫자를 발견하지 못했습니다.');
end if;
end;
/ | true |
22e38237d7f74d8d14435241ff15157a053cd94e | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/low/day17/select1926.sql | UTF-8 | 262 | 2.9375 | 3 | [] | no_license |
SELECT sen.name
FROM SENSOR sen, SENSOR_TYPE st, COVERAGE_INFRASTRUCTURE ci
WHERE sen.SENSOR_TYPE_ID=st.id AND st.name='WeMo' AND sen.id=ci.SENSOR_ID AND ci.INFRASTRUCTURE_ID=ANY(array['4082','4100_1','3084','5241','5064','4029','2028','3032','2044','1420'])
| true |
5775fe9c441f9a718d562dcf18e9f4bc52236926 | SQL | BiSAPPD/ECAD_sync | /2017/local_server_lp&mx.sql | UTF-8 | 929 | 3.75 | 4 | [] | no_license |
select distinct ppd.salon_code,
lp.brand, lp.id, lp.id_ecad, lp.salon_code, count(Concat('LP',lp.brand)) over ( order by Concat(lp.salon_code, lp.brand) ), lp.name, lp.address, lp.street, lp.com_mreg, lp.city_name_geographic, lp.region_name_geographic, lp.phone_sln, lp.email_sln, lp.full_name, lp.mobile_number_mng, lp.email_mng,
mx.brand, mx.id, mx.id_ecad, mx.salon_code, count(Concat('LP',lp.brand)) over ( order by Concat(lp.salon_code, lp.brand) ), mx.name, mx.address, mx.street, mx.com_mreg, mx.city_name_geographic, mx.region_name_geographic, mx.phone_sln, mx.email_sln, mx.full_name, mx.mobile_number_mng, mx.email_mng
from clients_ppd as ppd
left join clients_ppd as lp ON ppd.salon_code = lp.salon_code and lp.brand = 'LP'
left join clients_ppd as mx ON ppd.salon_code = mx.salon_code and mx.brand = 'MX'
where char_length(ppd.salon_code) = 9 and lp.salon_code = mx.salon_code
order by ppd.salon_code | true |
6178701ebc281b630c4bc50dc917266436b3d2e0 | SQL | akim004/SoundCloudParser | /db.sql | UTF-8 | 933 | 3.015625 | 3 | [] | no_license | -- Adminer 4.7.8 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS `tbl_track`;
CREATE TABLE `tbl_track` (
`id` int NOT NULL AUTO_INCREMENT,
`duration` int DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`playback_count` int DEFAULT NULL,
`comment_count` int DEFAULT NULL,
`sound_track_id` int NOT NULL DEFAULT '0',
`user_id` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `tbl_user`;
CREATE TABLE `tbl_user` (
`id` int NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`city` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`followers_count` int NOT NULL DEFAULT '0',
`sound_user_id` int NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2021-10-12 10:34:21
| true |
551b10aa29814964c83f67cb8a1ea23fe9950577 | SQL | hwa1049/kobis-utils | /KobisUtils/quries/Temporary.sql | UTF-8 | 4,045 | 3.765625 | 4 | [] | no_license | select * from T1_ClassificationSystemTable a right outer join X1_GbifTaxonomyName b
on a.scientific_name=b.name_txt;
-- 4,416,348
select count(*) from X1_GbifTaxonomyName;
-- 501,206
select count(*) from X1_ItisTaxonomyName;
-- 1,265,377
select count(*) from X1_NcbiTaxonomyName;
select name_txt from X1_ItisTaxonomyName
select scientific_name from T1_ClassificationSystemTable
;
select * from T1_ClassificationSystemTable a right outer join X1_ItisTaxonomyName b
on a.scientific_name=b.name_txt;
select * from X1_NcbiTaxonomyName a, X1_NcbiTaxonomyNode b
where a.tax_id=b.tax_id and a.name_txt='Abietinella';
select name_txt , count(*) cnt from X1_NcbiTaxonomyName
group by name_txt
having count(*) > 1;
select * from X1_GbifTaxonomyName
where match(name_txt) against('Troximon heterophyllum heterophyllum' in boolean mode)
having name_txt='Troximon heterophyllum heterophyllum';
select * from ITIS.NCBI_names
where name_txt='Acremonium'
select * from ITIS.GBIF_taxon
where canonicalName = ''
select * from (
select name_txt, count(*) cnt from X1_GbifTaxonomyName
group by name_txt
having count(*) > 1
) AA, (
select name_txt, count(*) cnt from X1_NcbiTaxonomyName
group by name_txt
having count(*) > 1
) BB
where AA.name_txt=BB.name_txt;
select name_txt, count(*) from X1_NcbiTaxonomyName
where instr(name_txt, ' ') > 0
group by name_txt
having count(*) > 1;
show variables like 'c%';
INSERT INTO T2_UnMappedCommon( accession_num, family, genus, subgenus, species, synonym, common_name, kor_name, in_species_type, in_species_name, line_name, variety_name, taxonomy, institution, category_1, category_2, category_3, detail_url, gene_name, accession_no, sequence, keywords, img_url_1, ins_user_email, ins_cd )
VALUES( '001-002-3423', 'Aquifoliaceae (Family)', 'Ilex', '', 'integra', '', '', '감탕나무' , '', '', '', '', '', '한국생명공학연구원', '식물' , '추출물(파생물)', '추출물(파생물)', 'http://extract.kribb.re.kr', '', '', '', 'plant extract' , '', 'plantext@kribb.re.kr', 'INS00001' )
SELECT
CONCAT( trim(substring_index(genus, '|', 1)), ' ', trim(substring_index(species, '|', 1))) scientific_name
FROM X1_PhylogeneticTree WHERE CONCAT( trim(substring_index(genus, '|', 1)), ' ', trim(substring_index(species, '|', 1))) = 'yedoense var. poukhanense'
SELECT
'NCBI'
, name_txt
FROM X1_NcbiTaxonomyName
WHERE MATCH(name_txt) AGAINST('Penicillium camemberti' IN BOOLEAN MODE)
HAVING name_txt='Penicillium camemberti'
union all
SELECT
'GBIF'
, name_txt
FROM X1_GbifTaxonomyName
WHERE MATCH(name_txt) AGAINST('Trachelospermum' IN BOOLEAN MODE)
-- HAVING name_txt='yedoense var. poukhanense'
union all
SELECT
'ITIS'
, name_txt
FROM X1_NcbiTaxonomyName
WHERE MATCH(name_txt) AGAINST('Trachelospermum' IN BOOLEAN MODE)
-- HAVING name_txt='yedoense var. poukhanense'
SELECT
CODE tax_id
, CONCAT( trim(substring_index(genus, '|', 1)), ' ', trim(substring_index(species, '|', 1))) name_txt
FROM X1_PhylogeneticTree
WHERE CONCAT( trim(substring_index(genus, '|', 1)), ' ', trim(substring_index(species, '|', 1))) = 'Ligustrum japonicum'
select * from X1_GbifTaxonomyNode a, X1_GbifTaxonomyName b
where a.rank in ('genus', 'superfamily', 'family', 'species', 'subspecies', 'infraspecificname', 'variety', 'form', 'subvariety', 'subform', 'infrasubspecificna')
and a.tax_id=b.tax_id
and name_txt='Acalypha filiformis filiformis'
select name_txt, count(*) cnt from X1_GbifTaxonomyNode a, X1_GbifTaxonomyName b
where a.rank in ('genus', 'superfamily', 'family', 'species', 'subspecies', 'infraspecificname', 'variety', 'form', 'subvariety', 'subform', 'infrasubspecificna')
and a.tax_id=b.tax_id
group by name_txt
having count(*) > 1;
delete from T1_ClassificationSystemTable;
delete from ITIS.T2_UnMappedCommon;
create table ITIS.T2_UnMappedCommon
select * from T2_UnMappedCommon;
create table ITIS.T2_MappedCommon
select * from T2_MappedCommon;
create table ITIS.T1_ClassificationSystemTable
select * from T1_ClassificationSystemTable; | true |
b66b8ef0c96008bd1b156098cddf10f14a15b363 | SQL | brunosouza502/SyService | /cliclo3_consultas.sql | UTF-8 | 3,943 | 3.328125 | 3 | [] | no_license | ALTER TABLE syservice.user ADD COLUMN datacadastro TIMESTAMP WITH TIME ZONE default 'now'
ALTER TABLE syservice.requisita alter column dt_inicio set default 'now'
ALTER TABLE syservice.requisita ADD COLUMN dtreq TIMESTAMP WITH TIME ZONE DEFAULT 'now'
ALTER TABLE syservice.requisita drop column dt_inicio
ALTER TABLE syservice.requisita alter column dt_inicio drop default
ALTER TABLE syservice.trab_em ADD COLUMN dtcadastrocateg TIMESTAMP WITH TIME ZONE DEFAULT 'now'
SELECT * FROM syservice.trab_em WHERE nome_categ_pai = 'Limpeza'
SELECT COUNT(prest_login) FROM syservice.trab_em
SELECT * FROM syservice.trab_em ORDER BY dtcadastrocateg USING >
SELECT * FROM syservice.concluido
SELECT * FROM syservice.user
SELECT * FROM syservice.user
SELECT * FROM syservice.avaliar_prestador WHERE prestador_login = 'lagreca'
SELECT * FROM syservice.agendamento
SELECT * FROM syservice.requisita ORDER BY dtreq USING >
SELECT prestador_login, nota_preco FROM syservice.avaliar_prestador ORDER BY nota_preco USING >
--1 top 1 de cada categoria
SELECT p.prestador_login, p.nota_preco, t.nome_categ_pai, t.nome_serv FROM syservice.avaliar_prestador p JOIN syservice.trab_em t
ON(t.prest_login = p.prestador_login) WHERE t.nome_categ_pai = 'Luthier' ORDER BY nota_preco USING > limit 5
SELECT p.prestador_login, p.nota_preco, t.nome_categ_pai, t.nome_serv FROM syservice.avaliar_prestador p JOIN syservice.trab_em t
ON(t.prest_login = p.prestador_login) WHERE t.nome_categ_pai = 'Limpeza' GROUP BY p.prestador_login, p.nota_preco, t.nome_categ_pai, t.nome_serv
SELECT MAX(p.nota_preco), t.prest_login, p.prestador_login FROM syservice.avaliar_prestador p JOIN syservice.trab_em t
ON(t.prest_login = p.prestador_login) WHERE t.nome_categ_pai = 'Limpeza' group by (t.prest_login = p.prestador_login)
--OS ULTIMOS 5 PRESTADORES CADASTRADOS
SELECT u.login, u.datacadastro, t.nome_serv, t.nome_categ_pai FROM syservice.user u JOIN syservice.trab_em t ON u.login = t.prest_login
ORDER BY datacadastro using > limit 5
SELECT prest_login, dtcadastrocateg, nome_categ_pai FROM syservice.trab_em ORDER BY dtcadastrocateg USING > limit 10
--Os ultimos 10 prestadores que tiveram alguma prestação contratada
SELECT dt_inicio, cliente, prestador FROM syservice.requisita ORDER BY dt_inicio USING > limit 10
--LISTANDO POR CATEGORIA Nota por preco
SELECT p.prestador_login, p.nota_preco, t.nome_categ_pai, t.nome_serv FROM syservice.avaliar_prestador p JOIN syservice.trab_em t
ON(t.prest_login = p.prestador_login) WHERE t.nome_categ_pai = 'Limpeza' ORDER BY nota_preco USING > limit 5
SELECT p.prestador_login, p.nota_atendimento, t.nome_categ_pai, t.nome_serv FROM syservice.avaliar_prestador p JOIN syservice.trab_em t
ON(t.prest_login = p.prestador_login) WHERE t.nome_categ_pai = 'Obras' ORDER BY p.nota_atendimento USING > limit 5
SELECT p.prestador_login, p.nota_servico, t.prest_login, t.nome_categ_pai, t.nome_serv FROM syservice.avaliar_prestador p JOIN syservice.trab_em t
ON(t.prest_login = p.prestador_login) WHERE t.nome_categ_pai = 'Obras' ORDER BY p.nota_servico USING > limit 5
--Ultimos 5 prestadores cadastrados na categoria
SELECT prest_login, dtcadastrocateg, nome_categ_pai FROM syservice.trab_em WHERE nome_categ_pai = 'Luthier' ORDER BY dtcadastrocateg USING > limit 10
--Últimos 10 prestadores contratados na categoria
SELECT r.prestador, r.cliente, r.dtreq, t.nome_categ_pai FROM syservice.requisita r JOIN syservice.trab_em t ON r.prestador = t.prest_login
WHERE t.nome_categ_pai = 'Obras' ORDER BY r.dtreq USING > LIMIT 10
--Combinacao linear dos criterios
SELECT (AVG(nota_preco)+AVG(nota_prazo_cobrado))/2
FROM syservice.avaliar_prestador WHERE prestador_login = 'brian'
--COMBINACAO LINEAR
SELECT a.prestador_login, t.prest_login, (AVG(nota_preco)+AVG(nota_prazo_cobrado))/2 AS media
FROM syservice.avaliar_prestador a JOIN (syservice.trab_em t GROUP BY t.prest_login)ON a.prestador_login = t.prest_login
ORDER BY media | true |
39134c0b277578590aa7bf9bfa952da66b85eda0 | SQL | potch/spenses | /db/purchase.sql | UTF-8 | 1,571 | 3.109375 | 3 | [] | no_license | -- *************************** 1. row ***************************
-- purchaseid: 1
-- description: test
-- purchase_amount: 10.00
-- date_updated: 0000-00-00 00:00:00
-- date_created: 2010-07-28 18:44:52
-- date_of: 2010-07-28 00:00:00
-- is_settle: 0
-- creator_userid: 1
-- creator_nick: Andrew
-- payer_userid: 1
-- payer_nick: Andrew
-- payee_userid: 2
-- payee_nick: Potch
-- iou_amount: 4.00
-- *************************** 2. row ***************************
-- purchaseid: 1
-- description: test
-- purchase_amount: 10.00
-- date_updated: 0000-00-00 00:00:00
-- date_created: 2010-07-28 18:44:52
-- date_of: 2010-07-28 00:00:00
-- is_settle: 0
-- creator_userid: 1
-- creator_nick: Andrew
-- payer_userid: 1
-- payer_nick: Andrew
-- payee_userid: 3
-- payee_nick: Nick
-- iou_amount: 6.00
SELECT
purchase.purchaseid,
purchase.description,
purchase.amount AS purchase_amount,
purchase.date_updated AS date_updated,
purchase.date_created AS date_created,
purchase.date_of AS date_of,
is_settle,
purchase.userid AS creator_userid,
creator.nick AS creator_nick,
purchase.userid_payer AS payer_userid,
payer.nick AS payer_nick,
payee.userid AS payee_userid,
payee.nick AS payee_nick,
iou.amount AS iou_amount
FROM purchase
LEFT JOIN user AS creator ON creator.userid=purchase.userid
LEFT JOIN user AS payer ON payer.userid=userid_payer
LEFT JOIN iou USING(purchaseid)
LEFT JOIN user AS payee ON payee.userid=userid_payee
WHERE purchaseid IN (1) \G | true |
c184bec5c5a11899cfa67e2c2cb66abda2653cf4 | SQL | omarhassanhub/Dropit | /Database/dropit.sql | UTF-8 | 1,300 | 2.71875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.2.7.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Dec 17, 2014 at 11:09 PM
-- Server version: 5.6.20
-- PHP Version: 5.5.15
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: `dropit`
--
-- --------------------------------------------------------
--
-- Table structure for table `members`
--
CREATE TABLE IF NOT EXISTS `members` (
`Firstname` varchar(25) NOT NULL,
`Lastname` varchar(25) NOT NULL,
`Email` varchar(40) NOT NULL,
`Username` varchar(25) NOT NULL,
`Password` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `members`
--
INSERT INTO `members` (`Firstname`, `Lastname`, `Email`, `Username`, `Password`) VALUES
('omar', 'omar', 'omarhass92@hotmail.com', 'omar', '7699fb3d6c48db480f12c305fdb3f0b7'),
('san', 'coran', 'san@yahoo.com', 'san', '734276015e186864edc9b3bad43ea9dc');
/*!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 |
018d821967b81e3138ac307a08da3df4f54d0002 | SQL | CUBRID/cubrid-testcases | /sql/_33_elderberry/cbrd_23916/cases/partition_cascade_03.sql | UTF-8 | 886 | 4.09375 | 4 | [
"BSD-3-Clause"
] | permissive | drop table if exists a cascade constraints;
drop table if exists b cascade constraints;
drop table if exists c cascade constraints;
create table a (a int primary key, c int NULL) partition by hash(a) partitions 2;
create table b (a int NULL, b int primary key, foreign key (a) references a(a) on delete CASCADE) partition by hash(b) partitions 2;
create table c (c int primary key, b int NULL, foreign key (b) references b(b) on delete CASCADE) partition by hash(c) partitions 2;
insert into a values (0,0), (1,1), (2,2), (3,3);
insert into b values (0,0), (1,1), (2,2), (3,3);
insert into c values (0,0), (1,1), (2,2), (3,3);
alter table a add constraint foreign key (c) references c(c) on delete cascade;
truncate a cascade;
select count(*) from a;
select count(*) from b;
select count(*) from c;
drop a cascade constraints;
drop b cascade constraints;
drop c cascade constraints;
| true |
4f4f40ee2b0d7e69c1199c710c4626f661e41126 | SQL | patilanup246/Merkle | /VTWC/CRM/api_customer/Views/CampaignHistory.sql | UTF-8 | 824 | 3.484375 | 3 | [] | no_license |
CREATE VIEW [api_customer].[CampaignHistory] AS
SELECT ch.CustomerID,
km.CustomerID AS CBECustomerID,
ch.LegacyCampaignID AS CampaignID,
ch.ContactDate AS ContactDate,
c.Name AS CampaignName,
'Email' AS Channel,
c.Description AS Proposition,
ea.[HashedAddress] AS EncryptedEmail
FROM Production.LegacyContactHistory ch INNER JOIN Production.LegacyCampaign c WITH (NOLOCK) ON CH.LegacyCampaignID = C.LegacyCampaignID
INNER JOIN Staging.STG_ElectronicAddress ea WITH (NOLOCK) ON ea.CustomerID = ch.CustomerID and ea.PrimaryInd = 1 and ea.AddressTypeID = 3
LEFT JOIN Staging.STG_KeyMapping AS km WITH (NOLOCK) ON ea.CustomerID = km.CustomerID
WHERE ea.ArchivedInd = 0 | true |
ce07176d4c57187f0f062adac27afd64e3cc9f86 | SQL | TheDariusz/InGoodHands | /src/main/resources/db/migration/V1_1_0__CreateTables.sql | UTF-8 | 1,124 | 3.65625 | 4 | [] | no_license | create
sequence hibernate_sequence start
1 increment 1;
create table category
(
id int4 not null,
name varchar(255),
primary key (id)
);
create table institution
(
id int8 not null,
description varchar(255),
name varchar(255),
primary key (id)
);
create table donation
(
id int8 not null,
street varchar(255),
city varchar(255),
pick_up_comment varchar(255),
pick_up_date date,
pick_up_time time,
quantity int4 not null,
phone varchar(64),
zip_code varchar(255),
institution_id int8 not null,
primary key (id),
constraint fk_institution
foreign key (institution_id)
references institution
);
create table donation_categories
(
donation_id int8 not null,
categories_id int4 not null,
primary key (donation_id, categories_id),
constraint fk_category
foreign key (categories_id)
references category,
constraint fk_donation
foreign key (donation_id)
references donation
);
| true |
092d79e53c30280039037b4472c132dc04e5c46f | SQL | TonyLeeIT/hopital_management | /schema/insert_table.sql | UTF-8 | 8,137 | 2.609375 | 3 | [] | no_license | use
HospitalManagement;
#doctor
insert into doctor value('BS01', 'Identity_Number01_BS', 'Ninh Xuan Huan', '1998-05-20','Ha Noi',5,'DaiHoc','Than Kinh','Bac Si');
insert into doctor value('BS02', 'Identity_Number02_BS', 'Nguyen HaiPhuong', '1994-07-31','Ha Noi',10,'DaiHoc','Tim','Truong Khoa');
insert into doctor value('BS03', 'Identity_Number03_BS', 'Bui Thi Thu Huong', '1994-12-31','Ha Noi',15,'DaiHoc','Phoi','Truong Phong');
insert into doctor value('BS04', 'Identity_Number04-BS', 'Nguyen Si Dinh', '1996-05-20','Ha Noi',4,'DaiHoc','Than Kinh','Bac Si');
insert into doctor value('BS05', 'Identity_Number05-BS', 'Vu Manh Cuong', '1996-07-31','Ha Noi',7,'DaiHoc','Tim','Truong Phong');
insert into doctor value('BS06', 'Identity_Number06-BS', 'Nguyen Huong Giang', '1991-12-31','Ha Noi',15,'DaiHoc','Phoi','Truong Khoa');
insert into doctor value('BS07', 'Identity_Number07-BS', 'Nguyen Duc Truong', '1994-05-20','Ha Noi',5,'DaiHoc','Than Kinh','Truong Khoa');
insert into doctor value('BS08', 'Identity_Number08-BS', 'Trinh Van Dai', '1999-07-31','Ha Noi',10,'DaiHoc','Tim','Bac Si');
insert into doctor value('BS09', 'Identity_Number09-BS', 'Nguyen Hong Thom', '1996-12-31','Ha Noi',15,'DaiHoc','Phoi','Bac Si');
insert into doctor value('BS10', 'Identity_Number10-BS', 'Le Duc Nam', '1998-12-31','Ha Noi',15,'DaiHoc','Tim','Bac Si');
#patient
insert into patient value('BN01', 'Identity_Number11_BN', 'Pham Phuong Nam ', '1997-12-31','Ha Noi','123456789');
insert into patient value('BN02', 'Identity_Number12_BN', 'Nguyen Dang Trua', '1999-12-31','Ha Noi','123456787');
insert into patient value('BN03', 'Identity_Number13_BN', 'Do Tien Dat', '1998-12-31','Ha Noi','123456788');
insert into patient value('BN04', 'Identity_Number14_BN', 'Tran Thanh Binh', '1996-12-31','Ha Noi','123456789');
insert into patient value('BN05', 'Identity_Number15_BN', 'Tran Van Phuong', '1998-12-31','Ha Noi','123456787');
insert into patient value('BN06', 'Identity_Number16_BN', 'Le Minh Tien', '1997-12-31','Ha Noi','123456788');
insert into patient value('BN07', 'Identity_Number17_BN', 'Vu Ngoc Sang', '1998-12-31','Ha Noi','123456789');
insert into patient value('BN08', 'Identity_Number18_BN', 'Tran Thu Nguyet', '1998-12-31','Ha Noi','123456787');
insert into patient value('BN09', 'Identity_Number19_BN', 'Pham The Duy', '1998-12-31','Ha Noi','123456788');
insert into patient value('BN10', 'Identity_Number20_BN', 'Nguyen Duc Hieu', '1998-12-31','Ha Noi','123456788');
#nurse
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone) values ("YT01","Identity_Number21_YT","Vu Van Minh","1993-09-01","Dong Da","3","Dai Hoc","0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT02", "Identity_Number22_YT", "Nghiem Tuan Anh", "1993-09-01", "Hoan Kiem", "5", "Dai Hoc", "0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT03", "Identity_Number23_YT", "Ha Van Chieu", "1993-09-01", "Ha Cau", "7", "Dai Hoc", "0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT04", "Identity_Number24_YT", "Do Toan Thang", "1993-09-01", "Thanh Xuan", "4", "Dai Hoc", "0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT05", "Identity_Number25_YT", "Luu Hai Son", "1993-09-01", "Van Khe", "2", "Dai Hoc", "0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT06", "Identity_Number26_YT", "Vuong Dinh Bac", "1993-09-01", "Dong Da", "2", "Dai Hoc", "0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT07", "Identity_Number27_YT", "Hoang Van Giap", "1993-09-01", "Hanoi", "6", "Dai Hoc", "0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT08", "Identity_Number28_YT", "Duong Tuan Anh", "1993-09-01", "Van Khe", "2", "Dai Hoc", "0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT09", "Identity_Number29_YT", "Hoang The Nam", "1993-09-01", "Dong Da", "2", "Dai Hoc", "0983000000");
insert into nurse(ID_Nurse, Identity_Number, Name_Nurse, DOB, Address, Exp, Diploma, Phone)
values ("YT10", "Identity_Number30_YT", "Hoang Anh Tu", "1993-09-01", "Hanoi", "6", "Dai Hoc", "0983000000");
#disease
insert into disease value('Tam than phan liet');
insert into disease value('Tim');
insert into disease value('Soi than');
insert into disease value('Tieu duong');
insert into disease value('Roi loan tien liet tuyen');
insert into disease value('Roi loan tien dinh');
insert into disease value('Tri');
#examination
insert into examination ( id_doctor , id_patient , name_disease , at_time) values ('BS01', 'BN01','Tam than phan liet','2020-07-31');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS01', 'BN02', 'Soi than', '2020-07-03');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS02', 'BN03', 'Tieu duong', '2020-07-31');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS02', 'BN04', 'Tieu duong', '2020-07-03');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS03', 'BN05', 'Soi than', '2020-07-31');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS03', 'BN06', 'Soi than', '2020-07-03');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS04', 'BN07', 'Roi loan tien liet tuyen', '2020-07-31');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS04', 'BN08', 'Roi loan tien dinh', '2020-07-03');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS01', 'BN01', 'Tri', '2020-07-05');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS05', 'BN09', 'Tim', '2020-06-05');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS05', 'BN05', 'Tim', '2020-05-05');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS06', 'BN10', 'Tieu duong', '2020-04-05');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS04', 'BN04', 'Tam than phan liet', '2020-06-15');
insert into examination (id_doctor, id_patient, name_disease, at_time)
values ('BS02', 'BN10', 'Tieu duong', '2020-06-05');
#med
insert into medicine values('ACB',12000,'uong');
insert into medicine
values ('DEF', 15000, 'uong');
insert into medicine
values ('GHI', 17000, 'tiem');
insert into medicine
values ('KLM', 11000, 'tiem');
#treatment
insert into treatment(id_examination,id_doctor_cure,id_nurse,at_time,status) value(1,'BS02','YT01','2020-08-12',0);
insert into treatment(id_examination, id_doctor_cure, id_nurse, at_time, status) value(1,'BS02','YT01','2020-08-12',0);
insert into treatment(id_examination, id_doctor_cure, id_nurse, at_time, status) value(1,'BS02','YT01','2020-08-12',1);
insert into treatment(id_examination, id_doctor_cure, id_nurse, at_time, status) value(1,'BS03','YT03','2020-08-12',1);
insert into treatment(id_examination, id_doctor_cure, id_nurse, at_time, status) value(3,'BS02','YT03','2020-08-12',1);
insert into treatment(id_examination, id_doctor_cure, id_nurse, at_time, status) value(3,'BS02','YT02','2020-08-12',0);
insert into treatment(id_examination, id_doctor_cure, id_nurse, at_time, status) value(3,'BS03','YT02','2020-08-14',1);
#medlist
insert into medicine_list(name_medicine,id_treatment,id_nurse) values('ACB',1,'YT01');
insert into medicine_list(name_medicine, id_treatment, id_nurse)
values ('DEF', 1, 'YT01');
insert into medicine_list(name_medicine, id_treatment, id_nurse)
values ('GHI', 2, 'YT01');
insert into medicine_list(name_medicine, id_treatment, id_nurse)
values ('KLM', 2, 'YT01');
#service
insert into service values('Chup X quang',120000);
insert into service
values ('Xet nghiem mau', 150000);
#servicelist
insert into service_list(name_service , id_treatment) values('Chup X quang',1);
insert into service_list(name_service, id_treatment)
values ('Xet nghiem mau', 1);
| true |
d1775339f07e3d624d4e0e380666341871e3e4f0 | SQL | mj6meron/SQL--Creating-and-populating-a-database. | /pupulatingMyDatabase.sql | UTF-8 | 3,082 | 3.171875 | 3 | [] | no_license | USE nba;
INSERT INTO arenas VALUES('Barclays Center', 'Brooklyn, New York', 19000);
INSERT INTO arenas VALUES('Toyota Center', 'Houston, Texas', 18000);
INSERT INTO arenas VALUES('Scotiabank Arena', 'Toronto, Ontario', 19800);
INSERT INTO arenas VALUES('STAPLES Center', 'Los Angeles, California', 20000);
INSERT INTO arenas VALUES('Chase Center', 'San Francisco, California', 18064);
INSERT INTO arenas VALUES('United Center', 'Chicago, Illinois', 23500);
INSERT INTO teams VALUES('Los Angeles Lakers', 'Pacific', 17, 'Gold', 'STAPLES Center');
INSERT INTO teams VALUES('Toronto Raptors', 'Atlantic', 1, 'Red', 'Scotiabank Arena');
INSERT INTO teams VALUES('Houston Rockets', 'South West', 2, 'Red', 'Toyota Center');
INSERT INTO teams VALUES('Golden State Warriors', 'Pacific', 6, 'Royal Blue', 'Chase Center');
INSERT INTO teams VALUES('Brooklyn Nets', 'Atlantic', 0, 'Black', 'Barclays Center');
INSERT INTO teams VALUES('Chicago Bulls', 'Central', 6, 'Red', 'United Center');
INSERT INTO coaches VALUES(101, 'Nick Nurse', 1967, 1989, 'Toronto Raptors');
INSERT INTO coaches VALUES(102, 'Frank Vogel', 1973, 2001, 'Los Angeles Lakers');
INSERT INTO coaches VALUES(103, 'Billy Donovan', 1965, 1989, 'Chicago Bulls');
INSERT INTO coaches VALUES(104, 'Steve Kerr', 1965, 2014, 'Golden State Warriors');
INSERT INTO coaches VALUES(105, 'Stephen Silas', 1973, 2000, 'Houston Rockets');
INSERT INTO coaches VALUES(106, 'Steve Nash', 1974, 2020, 'Brooklyn Nets');
INSERT INTO players VALUES(43, 'Pascal Siakam', 6.9, 1994, 29000000, 'Toronto Raptors');
INSERT INTO players VALUES(30, 'Stephen Curry', 6.3, 1988, 43006362, 'Golden State Warriors');
INSERT INTO players VALUES(23, 'LeBron James', 6.9, 1984, 39219565, 'Los Angeles Lakers');
INSERT INTO players VALUES(23, 'Fred VanVleet', 6.1, 1994, 21000000, 'Toronto Raptors');
INSERT INTO players VALUES(7, 'Kyle Lowry', 6.0, 1986, 30000000, 'Toronto Raptors');
INSERT INTO players VALUES(10, 'Eric Gordon', 6.3, 1988, 16869276, 'Houston Rockets');
INSERT INTO players VALUES(11, 'Klay Thompson', 6.6, 1990, 35361360, 'Golden State Warriors');
INSERT INTO players VALUES(23, 'Anthony Davis', 6.10, 1993, 32742000, 'Los Angeles Lakers');
INSERT INTO players VALUES(17, 'Dennis Schröder', 6.3, 1993, 15500000, 'Los Angeles Lakers');
INSERT INTO players VALUES(22, 'Andrew Wiggins', 6.7, 1995, 29542010, 'Golden State Warriors');
INSERT INTO players VALUES(11, 'Kyrie Irving', 6.10, 1992, 33329100, 'Brooklyn Nets');
INSERT INTO players VALUES(5, 'Victor Oladipo', 6.4, 1992, 21000000, 'Houston Rockets');
INSERT INTO players VALUES(8, 'Zach LaVine', 6.5, 1995, 19500000, 'Chicago Bulls');
INSERT INTO players VALUES(22, 'Otto Porter', 6.8, 1993, 28489239, 'Chicago Bulls');
INSERT INTO players VALUES(35, 'Kevin Durant', 6.10, 1988, 39058950, 'Brooklyn Nets');
INSERT INTO players VALUES(13, 'James Harden', 6-5, 1989, 40824000, 'Brooklyn Nets');
INSERT INTO players VALUES(1, 'John Wall', 6.3, 1990, 41254920, 'Houston Rockets');
INSERT INTO players VALUES(21, 'Thaddeus Young', 6.8, 1988, 13545000, 'Chicago Bulls');
SELECT * FROM players;
SELECT * FROM arenas;
SELECT * FROM coaches;
SELECT * FROM teams;
SELECT COUNT(*) FROM teams;
| true |
039d6d0bab64ce1e8c87f354819f4dcf32906061 | SQL | heerokim/Portfolio-Massage | /community/src/main/webapp/WEB-INF/sql/note.sql | UTF-8 | 506 | 3.40625 | 3 | [] | no_license | create table note_tb(
note_no number PRIMARY KEY
,send_id varchar2(30) NOT NULL
,recv_id varchar2(30) NOT NULL
,note_title varchar2(200) NOT NULL
,note_content varchar2(3000) NOT NULL
,note_type char(1) DEFAULT 0
,note_read char(1) DEFAULT 0
,note_date date DEFAULT sysdate
,constraint note_fk1 foreign key(send_id)
references member_tb(member_id)
,constraint note_fk2 foreign key(recv_id)
references member_tb(member_id)
);
CREATE SEQUENCE note_seq;
| true |
e68702f4541389df46e7f858279cdb9742219600 | SQL | catarinacci/proyecto_p_p | /database/tigergym_1.sql | UTF-8 | 18,403 | 3.1875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 14-02-2020 a las 00:30:43
-- Versión del servidor: 10.1.36-MariaDB
-- Versión de PHP: 7.2.10
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 */;
--
-- Base de datos: `tigergym_1`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `actividad`
--
CREATE TABLE `actividad` (
`ID_ACTIVIDAD` int(11) NOT NULL,
`nombre_actividad` varchar(20) NOT NULL,
`precio_actividad` float(12,2) NOT NULL,
`ID_USUARIO_INSTRUCTOR` int(12) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `actividad`
--
INSERT INTO `actividad` (`ID_ACTIVIDAD`, `nombre_actividad`, `precio_actividad`, `ID_USUARIO_INSTRUCTOR`) VALUES
(1, 'aparatos', 1000.00, 11),
(2, 'zumba', 400.00, 4),
(3, 'step', 400.00, NULL),
(4, 'pilates', 400.00, NULL),
(5, 'yoga', 400.00, NULL),
(7, 'jump_fit', 500.00, NULL),
(8, 'funcional', 500.00, NULL),
(9, 'vale todo', 500.00, 10),
(10, 'aikido', 500.00, 12),
(11, 'bike', 400.00, NULL),
(12, 'run', 400.00, NULL);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `actividad_usuario`
--
CREATE TABLE `actividad_usuario` (
`ID_ACTIVIDAD_USUARIO` int(11) NOT NULL,
`ID_ACTIVIDAD` int(11) NOT NULL,
`ID_USUARIO` int(6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `actividad_usuario`
--
INSERT INTO `actividad_usuario` (`ID_ACTIVIDAD_USUARIO`, `ID_ACTIVIDAD`, `ID_USUARIO`) VALUES
(1, 2, 9),
(2, 1, 9),
(3, 10, 3),
(4, 1, 3),
(5, 5, 9);
-- --------------------------------------------------------
--
-- Estructura Stand-in para la vista `consultas`
-- (Véase abajo para la vista actual)
--
CREATE TABLE `consultas` (
`nombre` varchar(15)
,`apellido` varchar(15)
,`DNI` int(8)
,`fecha` date
,`hora_entrada` time
,`hora_salida` time
);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `dia`
--
CREATE TABLE `dia` (
`ID_DIA` int(4) NOT NULL,
`nombre_dia` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `dia`
--
INSERT INTO `dia` (`ID_DIA`, `nombre_dia`) VALUES
(1, 'Lunes'),
(2, 'Martes'),
(3, 'Miércoles'),
(4, 'Jueves'),
(5, 'Viernes'),
(6, 'Sábado'),
(7, 'Lunes / Vi');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `horario`
--
CREATE TABLE `horario` (
`ID_HORARIO` int(10) NOT NULL,
`ID_ACTIVIDAD` int(11) NOT NULL,
`ID_DIA` int(4) NOT NULL,
`hora_entrada` time DEFAULT NULL,
`hora_salida` time DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `horario`
--
INSERT INTO `horario` (`ID_HORARIO`, `ID_ACTIVIDAD`, `ID_DIA`, `hora_entrada`, `hora_salida`) VALUES
(1, 10, 1, '09:30:00', '10:30:00'),
(2, 10, 1, '17:30:00', '18:30:00'),
(3, 10, 3, '09:30:00', '10:30:00'),
(4, 10, 3, '17:30:00', '18:30:00'),
(5, 10, 5, '09:30:00', '10:30:00'),
(6, 10, 5, '17:30:00', '18:30:00'),
(7, 2, 1, '10:30:00', '11:30:00'),
(8, 2, 1, '16:30:00', '17:30:00'),
(9, 2, 3, '10:30:00', '11:30:00'),
(10, 2, 3, '16:30:00', '17:30:00'),
(11, 2, 5, '10:30:00', '11:30:00'),
(12, 2, 5, '17:30:00', '18:30:00'),
(13, 1, 7, '08:00:00', '22:00:00'),
(14, 1, 6, '08:00:00', '12:00:00'),
(15, 5, 2, '09:00:00', '10:30:00'),
(16, 5, 4, '09:00:00', '10:30:00');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `pago`
--
CREATE TABLE `pago` (
`ID_PAGO` int(12) NOT NULL,
`ID_USUARIO` int(6) NOT NULL,
`fecha_pago` date NOT NULL,
`fecha_vencimiento` date NOT NULL,
`monto` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `pago`
--
INSERT INTO `pago` (`ID_PAGO`, `ID_USUARIO`, `fecha_pago`, `fecha_vencimiento`, `monto`) VALUES
(1, 3, '2019-09-21', '2020-02-04', 1500),
(2, 9, '2019-09-21', '2019-10-23', 1800);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `registro_e_s`
--
CREATE TABLE `registro_e_s` (
`ID_REGISTRO_E_S` int(255) NOT NULL,
`ID_USUARIO` int(6) NOT NULL,
`ID_PAGO` int(255) DEFAULT NULL,
`fecha` date NOT NULL,
`hora_entrada` time DEFAULT NULL,
`hora_salida` time DEFAULT NULL,
`estado` tinyint(1) DEFAULT '0',
`fechavenc` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `registro_e_s`
--
INSERT INTO `registro_e_s` (`ID_REGISTRO_E_S`, `ID_USUARIO`, `ID_PAGO`, `fecha`, `hora_entrada`, `hora_salida`, `estado`, `fechavenc`) VALUES
(3, 9, NULL, '2019-10-20', '17:00:00', '17:48:00', 1, NULL),
(4, 9, NULL, '2019-10-20', '17:00:00', '17:48:00', 0, NULL),
(5, 3, NULL, '2019-10-20', '17:00:00', '11:30:00', 0, NULL),
(6, 3, NULL, '2019-10-20', '17:00:00', '22:59:24', 0, NULL),
(13, 1, NULL, '2019-10-20', '22:54:36', '22:58:41', 0, NULL),
(14, 1, NULL, '2019-10-20', '23:00:01', '23:00:54', 0, NULL),
(15, 1, NULL, '2019-10-20', '23:20:13', '23:23:39', 0, NULL),
(16, 1, NULL, '2019-10-20', '23:25:09', '23:25:15', 0, NULL),
(17, 1, NULL, '2019-10-20', '23:28:36', '23:28:43', 0, NULL),
(18, 1, NULL, '2019-10-20', '23:40:16', '23:40:21', 0, NULL),
(19, 1, NULL, '2019-10-20', '23:40:26', '23:40:31', 0, NULL),
(20, 1, NULL, '2019-10-20', '23:40:36', '23:40:49', 0, NULL),
(21, 1, NULL, '2019-10-20', '23:40:57', '23:41:04', 0, NULL),
(22, 1, NULL, '2019-10-20', '23:45:15', '23:48:21', 0, NULL),
(23, 3, NULL, '2019-10-20', '23:48:42', '23:51:13', 0, NULL),
(24, 1, NULL, '2019-10-20', '23:52:40', '23:57:07', 0, NULL),
(25, 3, NULL, '2019-10-20', '23:54:54', '23:55:07', 0, NULL),
(26, 3, NULL, '2019-10-20', '23:56:30', '23:56:46', 0, NULL),
(27, 1, NULL, '2019-10-20', '23:57:13', '00:01:06', 0, NULL),
(28, 3, NULL, '2019-10-21', '00:01:56', '01:00:30', 0, NULL),
(29, 1, NULL, '2019-10-21', '01:00:38', '17:16:38', 0, NULL),
(30, 3, NULL, '2019-10-21', '18:55:04', '21:51:22', 0, NULL),
(31, 3, NULL, '2019-10-22', '21:51:29', '17:23:48', 0, NULL),
(32, 3, NULL, '2019-10-23', '17:26:20', '17:28:20', 0, NULL),
(33, 3, NULL, '2019-10-23', '17:28:40', '17:29:34', 0, NULL),
(34, 3, NULL, '2019-10-23', '17:30:06', '17:32:28', 0, NULL),
(35, 3, NULL, '2019-10-23', '17:33:14', '17:34:36', 0, NULL),
(36, 3, NULL, '2019-10-23', '17:35:22', '17:36:28', 0, NULL),
(37, 3, NULL, '2019-10-23', '17:36:49', '17:39:20', 0, NULL),
(38, 3, NULL, '2019-10-23', '17:42:45', NULL, 0, NULL),
(39, 3, NULL, '2019-10-23', '17:43:21', NULL, 0, NULL),
(40, 3, NULL, '2019-10-23', '17:44:22', '17:45:25', 0, NULL),
(41, 3, NULL, '2019-10-23', '17:45:58', '17:46:13', 0, NULL),
(42, 3, NULL, '2019-10-23', '17:53:28', '17:52:58', 0, NULL),
(43, 3, NULL, '2019-10-23', '17:54:43', '17:54:03', 0, NULL),
(44, 3, NULL, '2019-10-23', NULL, '17:55:08', 1, NULL),
(45, 3, NULL, '2019-10-23', NULL, '17:56:13', 1, NULL),
(46, 3, NULL, '2019-10-23', NULL, '17:56:31', 1, NULL),
(47, 3, NULL, '2019-10-23', NULL, '17:57:11', 1, NULL),
(48, 3, NULL, '2019-10-23', '17:58:15', NULL, 1, NULL),
(49, 3, NULL, '2019-10-23', '17:58:32', NULL, 1, NULL),
(50, 3, NULL, '2019-10-23', '18:00:37', NULL, 1, NULL),
(51, 3, NULL, '2019-10-23', '18:01:07', '18:03:59', 0, NULL),
(52, 3, NULL, '2019-10-23', '18:04:30', '18:04:47', 0, NULL),
(53, 3, NULL, '2019-10-23', '18:05:15', '18:08:46', 0, NULL),
(54, 1, NULL, '2019-10-23', '18:07:59', '18:16:05', 0, NULL),
(55, 3, NULL, '2019-10-23', '18:09:50', '18:12:34', 0, NULL),
(56, 3, NULL, '2019-10-23', '18:12:54', '18:14:39', 0, NULL),
(57, 1, NULL, '2019-10-23', '18:17:13', '18:18:05', 0, NULL),
(58, 3, NULL, '2019-10-23', '18:17:32', '18:21:23', 0, NULL),
(59, 1, NULL, '2019-10-23', '18:18:36', '18:20:24', 0, NULL),
(60, 3, NULL, '2019-10-23', '18:21:39', '20:28:07', 0, NULL),
(61, 9, NULL, '2019-10-23', '18:25:01', '18:59:44', 0, NULL),
(62, 1, NULL, '2019-10-23', '18:59:21', '21:18:28', 0, NULL),
(63, 3, NULL, '2019-10-23', '20:29:52', '20:30:07', 0, NULL),
(64, 3, NULL, '2019-10-23', '20:32:49', '21:17:34', 0, NULL),
(65, 3, NULL, '2019-11-04', '20:30:53', '20:37:37', 0, NULL),
(66, 6, NULL, '2019-11-04', '20:34:40', '20:34:51', 0, NULL),
(67, 6, NULL, '2019-11-04', '20:35:32', '20:35:38', 0, NULL),
(68, 9, NULL, '2019-11-04', '20:35:49', '20:36:18', 0, NULL),
(69, 3, NULL, '2019-11-04', '20:52:48', '20:52:56', 0, NULL),
(70, 3, NULL, '2019-11-04', '20:57:30', '20:57:49', 0, NULL),
(71, 3, NULL, '2019-11-04', '21:00:05', '21:14:14', 0, NULL),
(72, 9, NULL, '2019-11-04', '21:13:14', '13:32:35', 0, NULL),
(73, 3, NULL, '2019-11-05', '20:19:43', '20:19:49', 0, NULL),
(74, 1, NULL, '2019-12-05', '10:45:04', '10:45:25', 0, NULL),
(75, 3, NULL, '2019-12-05', '12:05:13', '12:22:30', 0, NULL),
(76, 3, NULL, '2019-12-05', '12:36:47', '12:38:22', 0, NULL),
(77, 3, NULL, '2019-12-05', '12:39:37', '12:59:31', 0, NULL),
(78, 3, NULL, '2019-12-05', '13:00:17', '13:01:26', 0, NULL),
(79, 3, NULL, '2019-12-05', '13:02:42', '13:03:27', 0, NULL),
(80, 3, NULL, '2019-12-05', '13:04:44', '13:05:54', 0, NULL),
(81, 3, NULL, '2019-12-05', '13:06:30', '13:08:41', 0, NULL),
(82, 3, NULL, '2019-12-05', '13:09:04', '13:10:20', 0, NULL),
(83, 3, NULL, '2019-12-05', '13:11:28', '13:12:34', 0, NULL),
(84, 3, NULL, '2019-12-05', '13:22:18', '13:23:37', 0, NULL),
(85, 3, NULL, '2019-12-05', '13:23:56', '13:30:37', 0, NULL),
(86, 3, NULL, '2019-12-05', '13:31:17', '13:32:10', 0, NULL),
(87, 3, NULL, '2019-12-05', '13:36:42', '13:37:58', 0, NULL),
(88, 3, NULL, '2019-12-05', '13:40:51', '13:41:31', 0, NULL),
(89, 3, NULL, '2019-12-05', '13:48:02', '13:49:43', 0, NULL),
(90, 9, NULL, '2019-12-05', '13:50:02', '13:53:26', 0, NULL),
(91, 3, NULL, '2019-12-05', '13:54:15', '13:55:53', 0, NULL),
(92, 9, NULL, '2019-12-05', '13:55:09', '13:56:27', 0, NULL),
(93, 3, NULL, '2019-12-05', '13:57:35', '14:03:20', 0, NULL),
(94, 3, NULL, '2019-12-05', '14:05:00', '14:06:15', 0, NULL),
(95, 3, NULL, '2019-12-05', '14:08:14', '14:12:44', 0, NULL),
(96, 3, NULL, '2019-12-05', '14:21:21', '14:21:44', 0, NULL),
(97, 3, NULL, '2019-12-05', '14:23:57', '14:27:08', 0, NULL),
(98, 9, NULL, '2019-12-05', '14:27:18', '14:39:26', 0, NULL),
(99, 3, NULL, '2019-12-05', '14:29:52', '14:34:25', 0, NULL),
(100, 3, NULL, '2019-12-05', '14:35:03', '14:41:30', 0, NULL),
(101, 3, NULL, '2019-12-05', '14:43:41', '14:44:26', 0, NULL),
(102, 3, NULL, '2019-12-05', '15:00:34', '15:03:09', 0, NULL),
(103, 1, NULL, '2019-12-05', '15:00:43', '15:03:44', 0, NULL),
(104, 1, NULL, '2020-01-27', '20:44:20', NULL, 1, NULL),
(105, 3, NULL, '2020-01-28', '17:26:12', '18:18:23', 0, NULL),
(106, 3, NULL, '2020-01-28', '18:18:36', '18:24:27', 0, NULL),
(107, 3, NULL, '2020-01-28', '18:24:32', '18:29:28', 0, NULL);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `tipo`
--
CREATE TABLE `tipo` (
`ID_TIPO` int(4) NOT NULL,
`nombre` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `tipo`
--
INSERT INTO `tipo` (`ID_TIPO`, `nombre`) VALUES
(1, 'admin'),
(2, 'recepcionista'),
(3, 'rrhh'),
(4, 'instructor'),
(5, 'tesoreria'),
(6, 'marketing'),
(7, 'cliente'),
(8, 'mantenimiento');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `usuario`
--
CREATE TABLE `usuario` (
`ID_USUARIO` int(6) NOT NULL,
`ID_TIPO` int(4) NOT NULL,
`DNI` int(8) NOT NULL,
`nombre` varchar(15) NOT NULL,
`apellido` varchar(15) NOT NULL,
`email` varchar(50) NOT NULL,
`telefono` varchar(15) NOT NULL,
`direccion` varchar(30) NOT NULL,
`sexo` varchar(10) NOT NULL,
`fecha_alta` date NOT NULL,
`pass` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Volcado de datos para la tabla `usuario`
--
INSERT INTO `usuario` (`ID_USUARIO`, `ID_TIPO`, `DNI`, `nombre`, `apellido`, `email`, `telefono`, `direccion`, `sexo`, `fecha_alta`, `pass`) VALUES
(1, 1, 31340423, 'admin', 'admin', 'admin@admin.com', '341-3183130', 'santiago 844', 'h', '2019-09-19', '1234'),
(2, 2, 33333333, 'Nicholas', 'Danelón', 'nicholas@gmail.com', '341-33333333', 'santiago 844', 'h', '2019-09-19', '1234'),
(3, 7, 20984653, 'Daniel', 'Rodriguez', 'rodriguez@gmail.com', '341-9876543', 'callao 1743', 'h', '2019-09-21', '1234'),
(4, 4, 22345897, 'Daniela', 'Vega', 'vega@gmail.com', '341-5678876', 'salta 2234', 'm', '2019-09-21', '1234'),
(5, 8, 22456876, 'Roberto', 'Sánchez', 'sanchez@gmail.com', '341- 3465785', 'rioja 6700', 'h', '2019-09-21', '1234'),
(6, 6, 33456879, 'Javier', 'Luiseli', 'luiseli@gmail.com', '341-6789876', 'cordoba 8900', 'h', '2019-09-21', '1234'),
(7, 3, 33789987, 'Estevan', 'Alvarado', 'alvarado@gmail.com', '341-5786543', 'esmeralda 3457', 'h', '2019-09-21', '1234'),
(8, 5, 21340987, 'Romina', 'Rosales', 'rosales@gmail.com', '341-890098', 'santa fe 756', 'm', '2019-09-21', '1234'),
(9, 7, 31340888, 'Jimena', 'Andrada', 'baron@gmail.com', '341-2222222', 'rioja 4385', 'm', '2019-09-21', '1234'),
(10, 4, 30546534, 'Ezequiel', 'Gutierrez', 'gutierrez@gmail.com', '341-3654543', 'italia 890', 'h', '2019-09-21', '1234'),
(11, 4, 1111111, 'Roberto', 'Carrillo', 'carrillo@gmail.com', '341-3183130', 'santiago 844', 'h', '2019-10-16', '1234'),
(12, 4, 22987373, 'Roberto', 'Gomez', 'gomez@gmail.com', '341-3344556', 'santiago 844', 'h', '2019-10-17', '1234');
-- --------------------------------------------------------
--
-- Estructura para la vista `consultas`
--
DROP TABLE IF EXISTS `consultas`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `consultas` AS select `u`.`nombre` AS `nombre`,`u`.`apellido` AS `apellido`,`u`.`DNI` AS `DNI`,`r`.`fecha` AS `fecha`,`r`.`hora_entrada` AS `hora_entrada`,`r`.`hora_salida` AS `hora_salida` from (`registro_e_s` `r` join `usuario` `u` on((`r`.`ID_USUARIO` = `u`.`ID_USUARIO`))) order by `r`.`ID_REGISTRO_E_S` desc ;
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `actividad`
--
ALTER TABLE `actividad`
ADD PRIMARY KEY (`ID_ACTIVIDAD`),
ADD UNIQUE KEY `uq_nombre_actividad` (`nombre_actividad`),
ADD KEY `fk_usuario_actividad_instructor` (`ID_USUARIO_INSTRUCTOR`);
--
-- Indices de la tabla `actividad_usuario`
--
ALTER TABLE `actividad_usuario`
ADD PRIMARY KEY (`ID_ACTIVIDAD_USUARIO`),
ADD KEY `fk_actividad_usuario_actividad` (`ID_ACTIVIDAD`),
ADD KEY `fk_usuario_actividad_usuario` (`ID_USUARIO`);
--
-- Indices de la tabla `dia`
--
ALTER TABLE `dia`
ADD PRIMARY KEY (`ID_DIA`);
--
-- Indices de la tabla `horario`
--
ALTER TABLE `horario`
ADD PRIMARY KEY (`ID_HORARIO`),
ADD KEY `fk_horario_actividad` (`ID_ACTIVIDAD`),
ADD KEY `fk_horario_dia` (`ID_DIA`);
--
-- Indices de la tabla `pago`
--
ALTER TABLE `pago`
ADD PRIMARY KEY (`ID_PAGO`),
ADD KEY `fk_PAGO_usuario` (`ID_USUARIO`);
--
-- Indices de la tabla `registro_e_s`
--
ALTER TABLE `registro_e_s`
ADD PRIMARY KEY (`ID_REGISTRO_E_S`),
ADD KEY `fk_registroES_usuario` (`ID_USUARIO`),
ADD KEY `fk_registroES_pago` (`ID_PAGO`);
--
-- Indices de la tabla `tipo`
--
ALTER TABLE `tipo`
ADD PRIMARY KEY (`ID_TIPO`);
--
-- Indices de la tabla `usuario`
--
ALTER TABLE `usuario`
ADD PRIMARY KEY (`ID_USUARIO`),
ADD UNIQUE KEY `uq_usuarios` (`DNI`),
ADD UNIQUE KEY `uq_email` (`email`),
ADD KEY `fk_usuario_actividad` (`ID_TIPO`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `actividad`
--
ALTER TABLE `actividad`
MODIFY `ID_ACTIVIDAD` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- AUTO_INCREMENT de la tabla `actividad_usuario`
--
ALTER TABLE `actividad_usuario`
MODIFY `ID_ACTIVIDAD_USUARIO` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT de la tabla `dia`
--
ALTER TABLE `dia`
MODIFY `ID_DIA` int(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT de la tabla `horario`
--
ALTER TABLE `horario`
MODIFY `ID_HORARIO` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
--
-- AUTO_INCREMENT de la tabla `pago`
--
ALTER TABLE `pago`
MODIFY `ID_PAGO` int(12) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT de la tabla `registro_e_s`
--
ALTER TABLE `registro_e_s`
MODIFY `ID_REGISTRO_E_S` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=108;
--
-- AUTO_INCREMENT de la tabla `tipo`
--
ALTER TABLE `tipo`
MODIFY `ID_TIPO` int(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT de la tabla `usuario`
--
ALTER TABLE `usuario`
MODIFY `ID_USUARIO` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- Restricciones para tablas volcadas
--
--
-- Filtros para la tabla `actividad`
--
ALTER TABLE `actividad`
ADD CONSTRAINT `fk_usuario_actividad_instructor` FOREIGN KEY (`ID_USUARIO_INSTRUCTOR`) REFERENCES `usuario` (`ID_USUARIO`) ON DELETE SET NULL ON UPDATE CASCADE;
--
-- Filtros para la tabla `actividad_usuario`
--
ALTER TABLE `actividad_usuario`
ADD CONSTRAINT `fk_actividad_usuario_actividad` FOREIGN KEY (`ID_ACTIVIDAD`) REFERENCES `actividad` (`ID_ACTIVIDAD`),
ADD CONSTRAINT `fk_usuario_actividad_usuario` FOREIGN KEY (`ID_USUARIO`) REFERENCES `usuario` (`ID_USUARIO`);
--
-- Filtros para la tabla `horario`
--
ALTER TABLE `horario`
ADD CONSTRAINT `fk_horario_actividad` FOREIGN KEY (`ID_ACTIVIDAD`) REFERENCES `actividad` (`ID_ACTIVIDAD`),
ADD CONSTRAINT `fk_horario_dia` FOREIGN KEY (`ID_DIA`) REFERENCES `dia` (`ID_DIA`);
--
-- Filtros para la tabla `pago`
--
ALTER TABLE `pago`
ADD CONSTRAINT `fk_PAGO_usuario` FOREIGN KEY (`ID_USUARIO`) REFERENCES `usuario` (`ID_USUARIO`);
--
-- Filtros para la tabla `registro_e_s`
--
ALTER TABLE `registro_e_s`
ADD CONSTRAINT `fk_registroES_pago` FOREIGN KEY (`ID_PAGO`) REFERENCES `pago` (`ID_PAGO`),
ADD CONSTRAINT `fk_registroES_usuario` FOREIGN KEY (`ID_USUARIO`) REFERENCES `usuario` (`ID_USUARIO`);
--
-- Filtros para la tabla `usuario`
--
ALTER TABLE `usuario`
ADD CONSTRAINT `fk_usuario_actividad` FOREIGN KEY (`ID_TIPO`) REFERENCES `tipo` (`ID_TIPO`);
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 |
566142cd6b3cb9395811c601fac542575fa1565c | SQL | zetarus/Americano | /Server/CGSF/ThirdParty/fastdb-375/fastdb/ruby/clitest.sql | UTF-8 | 331 | 2.71875 | 3 | [] | no_license | open 'clitest';
create table Person(name string,
salary int8,
address string,
rating real8,
pets array of string,
subordinates array of reference to Person);
create index on Person.salary;
create hash on Person.name;
start server 'localhost:6100' 4
| true |
2094f061fb4ba2d3e4e0e414a45204e770a8417d | SQL | adriangrahl/classic-models-spring-boot-jpa | /src/main/resources/db/migration/V2020031503__create_location_tables.sql | UTF-8 | 640 | 3.859375 | 4 | [] | no_license | create table cities (
id bigint not null auto_increment,
name varchar(255),
stateCode bigint,
primary key (id)
) engine=InnoDB;
create table countries (
id bigint not null auto_increment,
name varchar(255),
primary key (id)
) engine=InnoDB;
create table states (
id bigint not null auto_increment,
name varchar(255),
countryCode bigint,
primary key (id)
) engine=InnoDB;
alter table cities
add constraint FK_City_State
foreign key (stateCode)
references states (id);
alter table states
add constraint FK_State_Country
foreign key (countryCode)
references countries (id); | true |
831e257e1648ca0e164147e24f26dce7077c71c8 | SQL | Anemone95/dissertation-MLonSAST | /extra/msca.sql | UTF-8 | 23,539 | 3.53125 | 4 | [] | no_license | /*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 80012
Source Host : localhost:3306
Source Schema : msca
Target Server Type : MySQL
Target Server Version : 80012
File Encoding : 65001
Date: 11/02/2020 18:00:14
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for auth_group
-- ----------------------------
DROP TABLE IF EXISTS `auth_group`;
CREATE TABLE `auth_group` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `name`(`name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for auth_group_permissions
-- ----------------------------
DROP TABLE IF EXISTS `auth_group_permissions`;
CREATE TABLE `auth_group_permissions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL,
`permission_id` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `auth_group_permissions_group_id_permission_id_0cd325b0_uniq`(`group_id`, `permission_id`) USING BTREE,
INDEX `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm`(`permission_id`) USING BTREE,
CONSTRAINT `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `auth_group_permissions_group_id_b120cbf9_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for auth_permission
-- ----------------------------
DROP TABLE IF EXISTS `auth_permission`;
CREATE TABLE `auth_permission` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`content_type_id` int(11) NOT NULL,
`codename` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `auth_permission_content_type_id_codename_01ab375a_uniq`(`content_type_id`, `codename`) USING BTREE,
CONSTRAINT `auth_permission_content_type_id_2f476e4b_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 85 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for auth_user
-- ----------------------------
DROP TABLE IF EXISTS `auth_user`;
CREATE TABLE `auth_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`password` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`last_login` datetime(6) NULL DEFAULT NULL,
`is_superuser` tinyint(1) NOT NULL,
`username` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`first_name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`last_name` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`email` varchar(254) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`is_staff` tinyint(1) NOT NULL,
`is_active` tinyint(1) NOT NULL,
`date_joined` datetime(6) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `username`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for auth_user_groups
-- ----------------------------
DROP TABLE IF EXISTS `auth_user_groups`;
CREATE TABLE `auth_user_groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`group_id` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `auth_user_groups_user_id_group_id_94350c0c_uniq`(`user_id`, `group_id`) USING BTREE,
INDEX `auth_user_groups_group_id_97559544_fk_auth_group_id`(`group_id`) USING BTREE,
CONSTRAINT `auth_user_groups_group_id_97559544_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `auth_user_groups_user_id_6a12ed8b_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for auth_user_user_permissions
-- ----------------------------
DROP TABLE IF EXISTS `auth_user_user_permissions`;
CREATE TABLE `auth_user_user_permissions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`permission_id` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `auth_user_user_permissions_user_id_permission_id_14a6b632_uniq`(`user_id`, `permission_id`) USING BTREE,
INDEX `auth_user_user_permi_permission_id_1fbb5f2c_fk_auth_perm`(`permission_id`) USING BTREE,
CONSTRAINT `auth_user_user_permi_permission_id_1fbb5f2c_fk_auth_perm` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `auth_user_user_permissions_user_id_a95ead1b_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_admin_log
-- ----------------------------
DROP TABLE IF EXISTS `django_admin_log`;
CREATE TABLE `django_admin_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`action_time` datetime(6) NOT NULL,
`object_id` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
`object_repr` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`action_flag` smallint(5) UNSIGNED NOT NULL,
`change_message` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`content_type_id` int(11) NULL DEFAULT NULL,
`user_id` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `django_admin_log_content_type_id_c4bce8eb_fk_django_co`(`content_type_id`) USING BTREE,
INDEX `django_admin_log_user_id_c564eba6_fk_auth_user_id`(`user_id`) USING BTREE,
CONSTRAINT `django_admin_log_content_type_id_c4bce8eb_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `django_admin_log_user_id_c564eba6_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 44 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_celery_beat_clockedschedule
-- ----------------------------
DROP TABLE IF EXISTS `django_celery_beat_clockedschedule`;
CREATE TABLE `django_celery_beat_clockedschedule` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`clocked_time` datetime(6) NOT NULL,
`enabled` tinyint(1) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_celery_beat_crontabschedule
-- ----------------------------
DROP TABLE IF EXISTS `django_celery_beat_crontabschedule`;
CREATE TABLE `django_celery_beat_crontabschedule` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`minute` varchar(240) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`hour` varchar(96) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`day_of_week` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`day_of_month` varchar(124) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`month_of_year` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`timezone` varchar(63) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_celery_beat_intervalschedule
-- ----------------------------
DROP TABLE IF EXISTS `django_celery_beat_intervalschedule`;
CREATE TABLE `django_celery_beat_intervalschedule` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`every` int(11) NOT NULL,
`period` varchar(24) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_celery_beat_periodictask
-- ----------------------------
DROP TABLE IF EXISTS `django_celery_beat_periodictask`;
CREATE TABLE `django_celery_beat_periodictask` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`task` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`args` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`kwargs` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`queue` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`exchange` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`routing_key` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`expires` datetime(6) NULL DEFAULT NULL,
`enabled` tinyint(1) NOT NULL,
`last_run_at` datetime(6) NULL DEFAULT NULL,
`total_run_count` int(10) UNSIGNED NOT NULL,
`date_changed` datetime(6) NOT NULL,
`description` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`crontab_id` int(11) NULL DEFAULT NULL,
`interval_id` int(11) NULL DEFAULT NULL,
`solar_id` int(11) NULL DEFAULT NULL,
`one_off` tinyint(1) NOT NULL,
`start_time` datetime(6) NULL DEFAULT NULL,
`priority` int(10) UNSIGNED NULL DEFAULT NULL,
`headers` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`clocked_id` int(11) NULL DEFAULT NULL,
`expire_seconds` int(10) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `name`(`name`) USING BTREE,
INDEX `django_celery_beat_p_crontab_id_d3cba168_fk_django_ce`(`crontab_id`) USING BTREE,
INDEX `django_celery_beat_p_interval_id_a8ca27da_fk_django_ce`(`interval_id`) USING BTREE,
INDEX `django_celery_beat_p_solar_id_a87ce72c_fk_django_ce`(`solar_id`) USING BTREE,
INDEX `django_celery_beat_p_clocked_id_47a69f82_fk_django_ce`(`clocked_id`) USING BTREE,
CONSTRAINT `django_celery_beat_p_clocked_id_47a69f82_fk_django_ce` FOREIGN KEY (`clocked_id`) REFERENCES `django_celery_beat_clockedschedule` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `django_celery_beat_p_crontab_id_d3cba168_fk_django_ce` FOREIGN KEY (`crontab_id`) REFERENCES `django_celery_beat_crontabschedule` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `django_celery_beat_p_interval_id_a8ca27da_fk_django_ce` FOREIGN KEY (`interval_id`) REFERENCES `django_celery_beat_intervalschedule` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `django_celery_beat_p_solar_id_a87ce72c_fk_django_ce` FOREIGN KEY (`solar_id`) REFERENCES `django_celery_beat_solarschedule` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_celery_beat_periodictasks
-- ----------------------------
DROP TABLE IF EXISTS `django_celery_beat_periodictasks`;
CREATE TABLE `django_celery_beat_periodictasks` (
`ident` smallint(6) NOT NULL,
`last_update` datetime(6) NOT NULL,
PRIMARY KEY (`ident`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_celery_beat_solarschedule
-- ----------------------------
DROP TABLE IF EXISTS `django_celery_beat_solarschedule`;
CREATE TABLE `django_celery_beat_solarschedule` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`event` varchar(24) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`latitude` decimal(9, 6) NOT NULL,
`longitude` decimal(9, 6) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `django_celery_beat_solar_event_latitude_longitude_ba64999a_uniq`(`event`, `latitude`, `longitude`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_celery_results_taskresult
-- ----------------------------
DROP TABLE IF EXISTS `django_celery_results_taskresult`;
CREATE TABLE `django_celery_results_taskresult` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`task_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`status` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`content_type` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`content_encoding` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`result` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
`date_done` datetime(6) NOT NULL,
`traceback` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
`meta` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
`task_args` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
`task_kwargs` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
`task_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`worker` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`date_created` datetime(6) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `task_id`(`task_id`) USING BTREE,
INDEX `django_celery_results_taskresult_date_done_49edada6`(`date_done`) USING BTREE,
INDEX `django_celery_results_taskresult_status_cbbed23a`(`status`) USING BTREE,
INDEX `django_celery_results_taskresult_task_name_90987df3`(`task_name`) USING BTREE,
INDEX `django_celery_results_taskresult_worker_f8711389`(`worker`) USING BTREE,
INDEX `django_celery_results_taskresult_date_created_099f3424`(`date_created`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_content_type
-- ----------------------------
DROP TABLE IF EXISTS `django_content_type`;
CREATE TABLE `django_content_type` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`app_label` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`model` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `django_content_type_app_label_model_76bd3d3b_uniq`(`app_label`, `model`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_migrations
-- ----------------------------
DROP TABLE IF EXISTS `django_migrations`;
CREATE TABLE `django_migrations` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`app` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`applied` datetime(6) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 41 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for django_session
-- ----------------------------
DROP TABLE IF EXISTS `django_session`;
CREATE TABLE `django_session` (
`session_key` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`session_data` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`expire_date` datetime(6) NOT NULL,
PRIMARY KEY (`session_key`) USING BTREE,
INDEX `django_session_expire_date_a5c62663`(`expire_date`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ml_app_clienttoken
-- ----------------------------
DROP TABLE IF EXISTS `ml_app_clienttoken`;
CREATE TABLE `ml_app_clienttoken` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`token` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`create_time` datetime(6) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `token`(`token`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ml_app_label
-- ----------------------------
DROP TABLE IF EXISTS `ml_app_label`;
CREATE TABLE `ml_app_label` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`is_safe` tinyint(1) NOT NULL,
`create_time` datetime(6) NOT NULL,
`update_time` datetime(6) NOT NULL,
`taint_flow_id` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `taint_flow_id`(`taint_flow_id`) USING BTREE,
CONSTRAINT `ml_app_label_taint_flow_id_2424f7f0_fk_ml_app_taintflow_id` FOREIGN KEY (`taint_flow_id`) REFERENCES `ml_app_taintflow` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ml_app_location
-- ----------------------------
DROP TABLE IF EXISTS `ml_app_location`;
CREATE TABLE `ml_app_location` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`source_file` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`start_line` int(10) UNSIGNED NOT NULL,
`end_line` int(10) UNSIGNED NOT NULL,
`create_time` datetime(6) NOT NULL,
`project_id` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `ml_app_location_source_file_start_line_e_dbeb1d1c_uniq`(`source_file`, `start_line`, `end_line`, `project_id`) USING BTREE,
INDEX `ml_app_location_project_id_09f51480_fk_ml_app_project_id`(`project_id`) USING BTREE,
CONSTRAINT `ml_app_location_project_id_09f51480_fk_ml_app_project_id` FOREIGN KEY (`project_id`) REFERENCES `ml_app_project` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ml_app_methoddescription
-- ----------------------------
DROP TABLE IF EXISTS `ml_app_methoddescription`;
CREATE TABLE `ml_app_methoddescription` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`clazz` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`method` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`sig` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` datetime(6) NOT NULL,
`project_id` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `ml_app_methoddescription_clazz_method_sig_project_3118cbc7_uniq`(`clazz`, `method`, `sig`, `project_id`) USING BTREE,
INDEX `ml_app_methoddescrip_project_id_f920bbfe_fk_ml_app_pr`(`project_id`) USING BTREE,
CONSTRAINT `ml_app_methoddescrip_project_id_f920bbfe_fk_ml_app_pr` FOREIGN KEY (`project_id`) REFERENCES `ml_app_project` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ml_app_mlmodel
-- ----------------------------
DROP TABLE IF EXISTS `ml_app_mlmodel`;
CREATE TABLE `ml_app_mlmodel` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`token_dict_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`model_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` datetime(6) NOT NULL,
`config_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `ml_app_mlmodel_config_id_549f8bf7_fk_ml_app_modelconfig_name`(`config_id`) USING BTREE,
CONSTRAINT `ml_app_mlmodel_config_id_549f8bf7_fk_ml_app_modelconfig_name` FOREIGN KEY (`config_id`) REFERENCES `ml_app_modelconfig` (`name`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ml_app_modelconfig
-- ----------------------------
DROP TABLE IF EXISTS `ml_app_modelconfig`;
CREATE TABLE `ml_app_modelconfig` (
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`slice_dir` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`label_dir` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`embedding_dim` int(10) UNSIGNED NOT NULL,
`hidden_dim` int(10) UNSIGNED NOT NULL,
`word_freq_gt` int(10) UNSIGNED NOT NULL,
`early_stop_patience` int(10) UNSIGNED NOT NULL,
`base_learning_rate` double NOT NULL,
`batch_size` int(10) UNSIGNED NOT NULL,
`epoch` int(10) UNSIGNED NOT NULL,
`create_time` datetime(6) NOT NULL,
`update_time` datetime(6) NOT NULL,
PRIMARY KEY (`name`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ml_app_project
-- ----------------------------
DROP TABLE IF EXISTS `ml_app_project`;
CREATE TABLE `ml_app_project` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` datetime(6) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ml_app_taintflow
-- ----------------------------
DROP TABLE IF EXISTS `ml_app_taintflow`;
CREATE TABLE `ml_app_taintflow` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`hash` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`slice_file` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` datetime(6) NOT NULL,
`entry_id` int(11) NULL DEFAULT NULL,
`point_id` int(11) NULL DEFAULT NULL,
`project_id` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `hash`(`hash`) USING BTREE,
INDEX `ml_app_taintflow_entry_id_c426b239_fk_ml_app_me`(`entry_id`) USING BTREE,
INDEX `ml_app_taintflow_point_id_4c5f9051_fk_ml_app_location_id`(`point_id`) USING BTREE,
INDEX `ml_app_taintflow_project_id_61f2d8fb_fk_ml_app_project_id`(`project_id`) USING BTREE,
CONSTRAINT `ml_app_taintflow_entry_id_c426b239_fk_ml_app_me` FOREIGN KEY (`entry_id`) REFERENCES `ml_app_methoddescription` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `ml_app_taintflow_point_id_4c5f9051_fk_ml_app_location_id` FOREIGN KEY (`point_id`) REFERENCES `ml_app_location` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `ml_app_taintflow_project_id_61f2d8fb_fk_ml_app_project_id` FOREIGN KEY (`project_id`) REFERENCES `ml_app_project` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
| true |
54c6d49b7d9c19bc9a37d068fe216f0f3fa9b31e | SQL | rafaferruz/cpuz | /web/WEB-INF/config/scripts/alter.sql | UTF-8 | 166 | 2.90625 | 3 | [] | no_license | alter table userroles ADD FOREIGN KEY user (usu_user) REFERENCES users (usu_user);
alter table userroles ADD FOREIGN KEY role (usr_role) REFERENCES roles (rol_role); | true |
9e30f73acd10b1e16c3bee28e4a6a0369533b0a7 | SQL | evandromaster/mysql | /2 - Carga/2 - Carga - notebook/Importar dim_populacao.sql | UTF-8 | 374 | 2.71875 | 3 | [] | no_license | LOAD DATA LOCAL INFILE 'c:/Mysql/Tbl_Dimensao/dim_populacao.csv' -- Aqui vc especifica o local do arquivo
into table dim_populacao -- Aqui você especifica o nome da tabela
fields terminated by ';'
LINES TERMINATED by '\n'
ignore 1 lines
(
UEOP,
COD_MUNI,
FRACAO,
POP2017,
POP2018
); -- Aqui você coloca os campos na mesma sequencia das células do arquivo.csv
| true |
cdee8cb64a084473f656406020ee981916a93616 | SQL | postgrespro/tsvector2 | /init.sql | UTF-8 | 10,906 | 3.265625 | 3 | [
"PostgreSQL"
] | permissive | -- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION tsvector2" to load this file. \quit
CREATE TYPE tsvector2;
CREATE FUNCTION tsvector2in(cstring)
RETURNS tsvector2
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2out(tsvector2)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2recv(internal)
RETURNS tsvector2
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2send(tsvector2)
RETURNS bytea
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE TYPE tsvector2 (
INPUT = tsvector2in,
OUTPUT = tsvector2out,
RECEIVE = tsvector2recv,
SEND = tsvector2send,
INTERNALLENGTH = -1,
STORAGE = EXTENDED
);
-- functions
CREATE FUNCTION tsvector2_concat(tsvector2, tsvector2)
RETURNS tsvector2
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_lt(tsvector2, tsvector2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_le(tsvector2, tsvector2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_eq(tsvector2, tsvector2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_ne(tsvector2, tsvector2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_ge(tsvector2, tsvector2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_gt(tsvector2, tsvector2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_cmp(tsvector2, tsvector2)
RETURNS int
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_match_tsquery(tsvector2, tsquery)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsquery_match_tsvector2(tsquery, tsvector2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_matchsel(internal, oid, internal, int4)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE FUNCTION tsvector2_matchjoinsel(internal, oid, internal, int2, internal)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
-- operators
CREATE OPERATOR < (
LEFTARG = tsvector2,
RIGHTARG = tsvector2,
PROCEDURE = tsvector2_lt,
COMMUTATOR = '>',
NEGATOR = '>=',
RESTRICT = scalarltsel,
JOIN = scalarltjoinsel
);
CREATE OPERATOR <= (
LEFTARG = tsvector2,
RIGHTARG = tsvector2,
PROCEDURE = tsvector2_le,
COMMUTATOR = '>=',
NEGATOR = '>',
RESTRICT = scalarltsel,
JOIN = scalarltjoinsel
);
CREATE OPERATOR = (
LEFTARG = tsvector2,
RIGHTARG = tsvector2,
PROCEDURE = tsvector2_eq,
COMMUTATOR = '=',
NEGATOR = '<>',
RESTRICT = eqsel,
JOIN = eqjoinsel,
HASHES,
MERGES
);
CREATE OPERATOR <> (
LEFTARG = tsvector2,
RIGHTARG = tsvector2,
PROCEDURE = tsvector2_ne,
COMMUTATOR = '<>',
NEGATOR = '=',
RESTRICT = neqsel,
JOIN = neqjoinsel
);
CREATE OPERATOR >= (
LEFTARG = tsvector2,
RIGHTARG = tsvector2,
PROCEDURE = tsvector2_ge,
COMMUTATOR = '<=',
NEGATOR = '<',
RESTRICT = scalargtsel,
JOIN = scalargtjoinsel
);
CREATE OPERATOR > (
LEFTARG = tsvector2,
RIGHTARG = tsvector2,
PROCEDURE = tsvector2_gt,
COMMUTATOR = '<',
NEGATOR = '<=',
RESTRICT = scalargtsel,
JOIN = scalargtjoinsel
);
CREATE OPERATOR || (
LEFTARG = tsvector2,
RIGHTARG = tsvector2,
PROCEDURE = tsvector2_concat
);
CREATE OPERATOR @@ (
LEFTARG = tsvector2,
RIGHTARG = tsquery,
PROCEDURE = tsvector2_match_tsquery,
COMMUTATOR = '@@',
RESTRICT = tsvector2_matchsel,
JOIN = tsvector2_matchjoinsel
);
CREATE OPERATOR @@ (
LEFTARG = tsquery,
RIGHTARG = tsvector2,
PROCEDURE = tsquery_match_tsvector2,
COMMUTATOR = '@@',
RESTRICT = tsvector2_matchsel,
JOIN = tsvector2_matchjoinsel
);
-- tsvector2 functions
CREATE FUNCTION length(tsvector2)
RETURNS int
AS 'MODULE_PATHNAME', 'tsvector2_length'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION strip(tsvector2)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'tsvector2_strip'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION unnest(tsvector2, OUT lexeme text, OUT positions smallint[],
OUT weights text[])
RETURNS SETOF RECORD
AS 'MODULE_PATHNAME', 'tsvector2_unnest'
LANGUAGE C STRICT IMMUTABLE;
/* TODO: documentation should mention that ts_stat is not applicable to tsvector2 */
CREATE FUNCTION tsvector2_stat(sqlquery text, OUT word text, OUT ndoc integer,
OUT nentry integer)
RETURNS SETOF RECORD
AS 'MODULE_PATHNAME', 'tsvector2_stat1'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_stat(sqlquery text, weights text,
OUT word text, OUT ndoc integer, OUT nentry integer)
RETURNS SETOF RECORD
AS 'MODULE_PATHNAME', 'tsvector2_stat2'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION setweight(tsvector2, "char")
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'tsvector2_setweight'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION setweight(tsvector2, "char", text[])
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'tsvector2_setweight_by_filter'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION to_tsvector2(text)
RETURNS tsvector2
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION to_tsvector2(regconfig, text)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'to_tsvector2_byid'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION ts_filter(tsvector2, "char"[])
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'tsvector2_filter'
LANGUAGE C STRICT IMMUTABLE;
-- array conversion
CREATE FUNCTION array_to_tsvector2(text[])
RETURNS tsvector2
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION tsvector2_to_array(tsvector2)
RETURNS text[]
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
-- jsonb conversion
CREATE FUNCTION jsonb_to_tsvector2(jsonb, jsonb)
RETURNS tsvector2
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION jsonb_to_tsvector2(regconfig, jsonb, jsonb)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'jsonb_to_tsvector2_byid'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION json_to_tsvector2(json, jsonb)
RETURNS tsvector2
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION json_to_tsvector2(regconfig, json, jsonb)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'json_to_tsvector2_byid'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION to_tsvector2(regconfig, json, jsonb)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'json_to_tsvector2_byid'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION to_tsvector2(jsonb)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'jsonb_string_to_tsvector2'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION to_tsvector2(json)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'json_string_to_tsvector2'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION to_tsvector2(regconfig, jsonb)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'jsonb_string_to_tsvector2_byid'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION to_tsvector2(regconfig, json)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'json_string_to_tsvector2_byid'
LANGUAGE C STRICT IMMUTABLE;
-- ts_delete
CREATE FUNCTION ts_delete(tsvector2, text[])
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'tsvector2_delete_arr'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION ts_delete(tsvector2, text)
RETURNS tsvector2
AS 'MODULE_PATHNAME', 'tsvector2_delete_str'
LANGUAGE C STRICT IMMUTABLE;
-- ts_rank_cd
CREATE FUNCTION ts_rank_cd(float4[], tsvector2, tsquery, int4)
RETURNS float4
AS 'MODULE_PATHNAME', 'tsvector2_rankcd_wttf'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION ts_rank_cd(float4[], tsvector2, tsquery)
RETURNS float4
AS 'MODULE_PATHNAME', 'tsvector2_rankcd_wtt'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION ts_rank_cd(tsvector2, tsquery, int4)
RETURNS float4
AS 'MODULE_PATHNAME', 'tsvector2_rankcd_ttf'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION ts_rank_cd(tsvector2, tsquery)
RETURNS float4
AS 'MODULE_PATHNAME', 'tsvector2_rankcd_tt'
LANGUAGE C STRICT IMMUTABLE;
-- ts_rank
CREATE FUNCTION ts_rank(float4[], tsvector2, tsquery, int4)
RETURNS float4
AS 'MODULE_PATHNAME', 'tsvector2_rank_wttf'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION ts_rank(float4[], tsvector2, tsquery)
RETURNS float4
AS 'MODULE_PATHNAME', 'tsvector2_rank_wtt'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION ts_rank(tsvector2, tsquery, int4)
RETURNS float4
AS 'MODULE_PATHNAME', 'tsvector2_rank_ttf'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION ts_rank(tsvector2, tsquery)
RETURNS float4
AS 'MODULE_PATHNAME', 'tsvector2_rank_tt'
LANGUAGE C STRICT IMMUTABLE;
-- tsvector2_update_trigger
CREATE FUNCTION tsvector2_update_trigger()
RETURNS trigger
AS 'MODULE_PATHNAME', 'tsvector2_update_trigger_byid'
LANGUAGE C;
CREATE FUNCTION tsvector2_update_trigger_column()
RETURNS trigger
AS 'MODULE_PATHNAME', 'tsvector2_update_trigger_bycolumn'
LANGUAGE C;
-- operator families for various types of indexes
CREATE OPERATOR FAMILY tsvector2_ops USING btree;
CREATE OPERATOR FAMILY tsvector2_ops USING gist;
CREATE OPERATOR FAMILY tsvector2_ops USING gin;
-- btree support
CREATE OPERATOR CLASS bt_tsvector2_ops DEFAULT
FOR TYPE tsvector2 USING btree FAMILY tsvector2_ops AS
OPERATOR 1 < (tsvector2, tsvector2),
OPERATOR 2 <= (tsvector2, tsvector2),
OPERATOR 3 = (tsvector2, tsvector2),
OPERATOR 4 >= (tsvector2, tsvector2),
OPERATOR 5 > (tsvector2, tsvector2),
FUNCTION 1 tsvector2_cmp(tsvector2, tsvector2);
-- gin support
CREATE FUNCTION gin_extract_tsvector2(tsvector2, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE OPERATOR CLASS gin_tsvector2_ops DEFAULT
FOR TYPE tsvector2 USING gin FAMILY tsvector2_ops AS
OPERATOR 1 @@ (tsvector2, tsquery),
FUNCTION 1 gin_cmp_tslexeme(text,text),
FUNCTION 2 gin_extract_tsvector2(tsvector2,internal,internal),
FUNCTION 3 gin_extract_tsquery(tsquery,internal,int2,internal,internal,internal,internal),
FUNCTION 4 gin_tsquery_consistent(internal,int2,tsquery,int4,internal,internal,internal,internal),
FUNCTION 5 gin_cmp_prefix(text,text,int2,internal),
FUNCTION 6 gin_tsquery_triconsistent(internal,int2,tsvector,int4,internal,internal,internal);
-- gist support
CREATE FUNCTION gist_tsvector2_compress(internal,tsquery,int2,oid,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
-- don't mind tsvector mentioning, it's actually expecting tsquery anyway
CREATE OPERATOR CLASS gist_tsvector2_ops DEFAULT
FOR TYPE tsvector2 USING gist FAMILY tsvector2_ops AS
OPERATOR 1 @@ (tsvector2, tsquery),
FUNCTION 1 gtsvector_consistent(internal,tsvector,int2,oid,internal),
FUNCTION 2 gtsvector_union(internal,internal),
FUNCTION 3 gist_tsvector2_compress(internal,tsquery,int2,oid,internal),
FUNCTION 4 gtsvector_decompress(internal),
FUNCTION 5 gtsvector_penalty(internal,internal,internal),
FUNCTION 6 gtsvector_picksplit(internal,internal),
FUNCTION 7 gtsvector_same(gtsvector,gtsvector,internal);
| true |
54447d368cca697ad172c2753562f0d44418ab48 | SQL | nanda199/UTS-FP-SMT6 | /data_surat.sql | UTF-8 | 1,568 | 2.96875 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 22, 2021 at 05:35 PM
-- Server version: 10.1.39-MariaDB
-- PHP Version: 7.3.5
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: `data_surat`
--
-- --------------------------------------------------------
--
-- Table structure for table `tb_surat`
--
CREATE TABLE `tb_surat` (
`id` int(11) NOT NULL,
`nomor_surat` int(11) NOT NULL,
`tanggal_surat` varchar(11) NOT NULL,
`pengirim` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tb_surat`
--
INSERT INTO `tb_surat` (`id`, `nomor_surat`, `tanggal_surat`, `pengirim`) VALUES
(3, 123, '7 maret', 'joyo'),
(7, 14775, '8 Agustus', 'Ahmad');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tb_surat`
--
ALTER TABLE `tb_surat`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tb_surat`
--
ALTER TABLE `tb_surat`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
| true |
88737437eec1d958c4a896b7c1844c613badcdc2 | SQL | st-decker/lahman-baseball-st-decker | /queries/1_question.sql | UTF-8 | 783 | 3.59375 | 4 | [] | no_license | /*
QUESTION ::
What range of years does the provided database cover?
SOURCES ::
* Batting, pitching, fielding
DIMENSIONS ::
* ...
FACTS ::
* min year
* max year
FILTERS ::
* Using specific tables
DESCRIPTION ::
Assumptions from README: Stats 1871-2016
Do a check from the 3 main tables as specified in the data dictionary
Batting, pitching, fielding
ANSWER ::
...
*/
SELECT min(min), max(max), max(max) - min(min) AS years_covered
FROM
(SELECT min(yearid), max(yearid)
FROM appearances
UNION ALL
SELECT min(yearid), max(yearid)
FROM batting
UNION ALL
SELECT min(yearid), max(yearid)
FROM pitching
UNION ALL
SELECT min(yearid), max(yearid)
FROM fielding) AS subquery
| true |
e80ba0c849b4687b81c25dc750c13ea1602b416f | SQL | tbhaijee/Literacy-Data-ETL-project | /SQL Files/querries.sql | UTF-8 | 237 | 3.359375 | 3 | [] | no_license | Select country,countryname,sex, suicidedata.year, literacydata.year, age, suicide_no,literacy_number
from suicidedata
JOIN literacydata on
country = countryname AND
suicidedata.year = literacydata.year
where literacy_number is not null
| true |
3cd91391760103cb8f6961d280d2de61b77e66fb | SQL | AmadouSY/Compta-Theatre | /tests/annuler_reservation.sql | UTF-8 | 293 | 2.515625 | 3 | [
"MIT"
] | permissive | \echo ********** PAIEMENT RESERVATION **********
SELECT * FROM BILLET WHERE statut_billet='RESERVE' ;
\prompt 'Tapez le numero de la RESERVATION a annuler : ' num_billet
\echo 'BILLER SUPPRIMER ':num_billet
DELETE FROM billet WHERE id_billet=billets.id_billet;
SELECT(f_ajouter_place(:num_billet));
| true |
490efbc7e3d3216749cd983f2195116e8fc38c7b | SQL | darsal09/walkforourwater | /data/posts.sql | UTF-8 | 1,305 | 3 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.1.12
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 24, 2015 at 03:36 AM
-- Server version: 5.6.16
-- PHP Version: 5.5.11
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: `thewalk`
--
-- --------------------------------------------------------
--
-- Table structure for table `posts`
--
CREATE TABLE IF NOT EXISTS `posts` (
`post_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(250) NOT NULL,
`body` text NOT NULL,
`added_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` enum('Published','Draft','Completed') NOT NULL DEFAULT 'Draft',
`modefied_on` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(11) NOT NULL,
`published_by` int(11) NOT NULL,
PRIMARY KEY (`post_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!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 |
7dcd546156b516862e0c56ca3645db4b132bc58b | SQL | promisethedeveloper/SQL-joins-exercise | /queries.sql | UTF-8 | 578 | 4.375 | 4 | [] | no_license | -- write your queries here
-- first query
SELECT * FROM owners o
FULL OUTER JOIN vehicles v
ON o.id=v.owner_id;
-- second query
SELECT first_name, last_name,
COUNT(owner_id) FROM owners o
JOIN vehicles v on o.id=v.owner_id
GROUP BY (first_name, last_name)
ORDER BY first_name;
-- third query
SELECT
first_name, last_name,
ROUND(AVG(price)) as average_price,
COUNT(owner_id)
FROM owners o
JOIN vehicles v on o.id=v.owner_id
GROUP BY
(first_name, last_name)
HAVING
COUNT(owner_id) > 1 AND ROUND(AVG(price)) > 10000
ORDER BY first_name DESC; | true |
e84940235e4d0f6d158bc4d0fd4d03cba8699d32 | SQL | smukashev/essp | /usci/db_oracle_scripts/vw_simple_attribute.sql | UTF-8 | 222 | 2.796875 | 3 | [] | no_license | create or replace view vw_simple_attribute as
select sa.id, classes.name as class_name, sa.name as attribute_name
from eav_m_simple_attributes sa,
eav_m_classes classes
where sa.containing_id = classes.id;
| true |
00606ebc34cd1429d6a90d414791b9fcad5536c4 | SQL | cmswafford/uiucrehome | /uiucsd.sql | UTF-8 | 3,422 | 3.84375 | 4 | [] | no_license | CREATE DATABASE uiucsd DEFAULT CHARACTER SET = utf8 DEFAULT COLLATE = utf8_general_ci;
GRANT ALL PRIVILEGES ON uiucsd.* TO 'uiucsd'@'localhost' IDENTIFIED BY 'uiuc$d2011';
USE uiucsd;
CREATE TABLE categories ( category_id INT UNSIGNED AUTO_INCREMENT
,category_name VARCHAR(255) DEFAULT NULL
,PRIMARY KEY (category_id)
) ENGINE=InnoDB;
INSERT INTO categories( category_name ) VALUES ('lights'), ('appliances'), ('electronics');
/*
lights = all [monitored] lights from every room
appliances = refrigerator, freezer,
electronics = TV, server, computer, tablet
*/
CREATE TABLE rooms ( room_id INT UNSIGNED AUTO_INCREMENT
,room_name VARCHAR(255) DEFAULT NULL
,PRIMARY KEY (room_id)
) ENGINE=InnoDB;
INSERT INTO rooms( room_name ) VALUES ('bathroom'), ('bedroom'), ('living room'), ('kitchen'), ('office'), ('outside');
CREATE TABLE devices ( device_id INT UNSIGNED AUTO_INCREMENT
,category_id INT UNSIGNED DEFAULT NULL
,room_id INT UNSIGNED DEFAULT NULL
,off_or_on TINYINT(1) DEFAULT 0
,metadata TEXT DEFAULT ''
,FOREIGN KEY (category_id) REFERENCES categories(category_id)
,FOREIGN KEY (room_id) REFERENCES rooms(room_id)
,PRIMARY KEY(device_id)
) ENGINE=InnoDB;
INSERT INTO devices( category_id, room_id, metadata )
VALUES ( 2, 4, NULL /* Serialized associative array in format of $kField => $vValue */ )
;
/* Some metadata fields might include:
- manufacturer
- lifetime (probably in W*h e.g. to show how much life a lightbulb has left)
*/
CREATE TABLE power_logs ( power_log_id INT UNSIGNED AUTO_INCREMENT
,device_id INT UNSIGNED DEFAULT NULL
,RMS_voltage FLOAT DEFAULT NULL
,RMS_current FLOAT DEFAULT NULL
,apparent_power FLOAT DEFAULT NULL
,real_power FLOAT DEFAULT NULL
,PF FLOAT DEFAULT NULL
,PF_angle FLOAT DEFAULT NULL
,created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
,PRIMARY KEY (power_log_id)
,FOREIGN KEY (device_id) REFERENCES devices(device_id)
) ENGINE=InnoDB;
CREATE TABLE temperature_logs ( temperature_log_id INT UNSIGNED AUTO_INCREMENT
,device_id INT UNSIGNED DEFAULT NULL
,value FLOAT DEFAULT NULL
,created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
,PRIMARY KEY (temperature_log_id)
,FOREIGN KEY (device_id) REFERENCES devices(device_id)
) ENGINE=InnoDB;
CREATE TABLE water_logs ( water_log_id INT UNSIGNED AUTO_INCREMENT
,device_id INT UNSIGNED DEFAULT NULL
,value FLOAT DEFAULT NULL
,created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
,PRIMARY KEY (water_log_id)
,FOREIGN KEY (device_id) REFERENCES devices(device_id)
) ENGINE=InnoDB;
| true |
af9f87299d176f2471415349a00fcf96b4a258f1 | SQL | 201411096/study_flask | /flask/ex_03_flask_board/ver_01/backup_dbsql/210125_db.sql | UTF-8 | 15,529 | 3.171875 | 3 | [] | no_license | -- --------------------------------------------------------
-- 호스트: 192.168.0.13
-- 서버 버전: 10.5.5-MariaDB - mariadb.org binary distribution
-- 서버 OS: Win64
-- HeidiSQL 버전: 11.0.0.5919
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- kimyongseon 데이터베이스 구조 내보내기
CREATE DATABASE IF NOT EXISTS `kimyongseon` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `kimyongseon`;
-- 테이블 kimyongseon.board 구조 내보내기
CREATE TABLE IF NOT EXISTS `board` (
`board_content_id` int(11) NOT NULL AUTO_INCREMENT,
`board_content_pid` varchar(100) DEFAULT NULL,
`member_id` varchar(100) DEFAULT NULL,
`board_id` varchar(100) DEFAULT NULL,
`board_content_title` varchar(100) DEFAULT NULL,
`board_content_body` varchar(1000) DEFAULT NULL,
`board_content_regdatetime` datetime DEFAULT NULL,
`board_content_edtdatetime` datetime DEFAULT NULL,
`board_content_num` varchar(100) DEFAULT NULL,
`board_content_deleted` varchar(10) DEFAULT NULL,
PRIMARY KEY (`board_content_id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8;
-- 테이블 데이터 kimyongseon.board:~33 rows (대략적) 내보내기
/*!40000 ALTER TABLE `board` DISABLE KEYS */;
INSERT IGNORE INTO `board` (`board_content_id`, `board_content_pid`, `member_id`, `board_id`, `board_content_title`, `board_content_body`, `board_content_regdatetime`, `board_content_edtdatetime`, `board_content_num`, `board_content_deleted`) VALUES
(1, '-1', 'abc', '01', 'aa', 'aa', '2021-01-20 15:31:29', '2021-01-20 15:31:29', NULL, 'N'),
(2, '-1', 'abc', '01', 'bb', 'bb', '2021-01-20 15:51:50', '2021-01-20 15:51:50', NULL, 'Y'),
(3, '2', 'abc', '01', 'rebb', 'bb', '2021-01-20 15:52:02', '2021-01-20 15:52:02', NULL, 'N'),
(4, '3', 'abc', '01', 'rerebb', 'ree', '2021-01-20 15:54:44', '2021-01-20 15:54:44', NULL, 'N'),
(5, '-1', 'abc', '01', 'cc', 'cc', '2021-01-20 15:59:23', '2021-01-20 15:59:23', NULL, 'Y'),
(6, '2', 'abc', '01', 're2bbb', 'bbb', '2021-01-20 15:59:41', '2021-01-20 15:59:41', NULL, 'N'),
(7, '-1', 'abc', '01', 'bbb', 'bbb', '2021-01-20 16:00:19', '2021-01-20 16:00:19', NULL, 'Y'),
(8, '-1', 'abc', '02', 'dd', 'dd', '2021-01-20 16:00:26', '2021-01-20 16:00:26', NULL, 'N'),
(9, '-1', 'abc', '01', 'ee', 'ee', '2021-01-20 16:00:32', '2021-01-20 16:00:32', NULL, 'N'),
(10, '9', 'abc', '01', 'reaa', 're', '2021-01-20 16:00:42', '2021-01-20 16:00:42', NULL, 'Y'),
(11, '-1', 'abc', '01', 'bb', 'bb', '2021-01-20 16:06:03', '2021-01-20 16:06:03', NULL, 'Y'),
(12, '-1', 'abc', '01', 'ds', 'ds', '2021-01-20 16:06:08', '2021-01-20 16:06:08', NULL, 'Y'),
(13, '10', 'abc', '01', '5시', 'ㅇ', '2021-01-20 17:01:39', '2021-01-20 17:01:39', NULL, 'N'),
(14, '-1', 'bcd', '01', 'bcd', 'bcde', '2021-01-21 10:47:21', '2021-01-25 03:45:17', NULL, 'N'),
(15, '-1', 'abc', '01', 'ee', 'ee', '2021-01-21 12:20:19', '2021-01-21 12:20:19', NULL, 'N'),
(16, '-1', 'abc', '01', 'gg', 'gg', '2021-01-21 13:30:29', '2021-01-21 13:30:29', NULL, 'N'),
(17, '-1', 'abc', '01', 'hh', 'hh', '2021-01-21 13:30:34', '2021-01-21 13:30:34', NULL, 'N'),
(18, '-1', 'abc', '01', 'ii', 'iii', '2021-01-21 13:30:41', '2021-01-21 13:30:41', NULL, 'N'),
(19, '-1', 'abc', '01', 'jj', 'jjjj', '2021-01-21 13:30:48', '2021-01-21 13:30:48', NULL, 'N'),
(20, '-1', 'abc', '01', 'kk', 'kk', '2021-01-21 13:30:53', '2021-01-21 13:30:53', NULL, 'Y'),
(21, '-1', 'abc', '01', 'kkㄷㄷ', 'kkㄷㄷ', '2021-01-21 14:38:57', '2021-01-21 14:38:57', NULL, 'Y'),
(22, '-1', 'abc', '01', 'kkㄷㄷㄷ', 'kkㄷ', '2021-01-21 14:39:08', '2021-01-21 14:39:08', NULL, 'Y'),
(23, '-1', 'abc', '01', 'kkㄷ', 'kkㄷㄷ', '2021-01-21 14:41:12', '2021-01-21 14:42:28', NULL, 'N'),
(24, '-1', 'abc', '01', 'ee', 'eeggffff', '2021-01-22 13:16:25', '2021-01-25 03:41:02', NULL, 'N'),
(25, '-1', 'admin', '02', 'bb', 'bb', '2021-01-22 14:50:56', '2021-01-22 14:50:56', NULL, 'N'),
(26, '-1', 'admin', '01', 'aabb', 'aabbb', '2021-01-22 14:51:12', '2021-01-22 14:51:12', NULL, 'N'),
(27, '8', 'admin', '02', 'asdf', 'asdf', '2021-01-22 15:10:34', '2021-01-22 15:10:34', NULL, 'N'),
(28, '-1', 'admin', '02', 'sdf', 'sd', '2021-01-22 15:58:51', '2021-01-22 15:58:51', NULL, 'N'),
(29, '-1', 'admin', '02', '11', '11', '2021-01-22 16:01:40', '2021-01-22 16:01:40', NULL, 'N'),
(30, '24', 'abc', '01', '0124', '11', '2021-01-24 23:51:00', '2021-01-24 23:51:00', NULL, 'N'),
(31, '-1', 'admin', '02', '0125', 'ee', '2021-01-25 03:39:29', '2021-01-25 03:39:29', NULL, 'N'),
(32, '-1', 'abc', '01', 'bbb', 'ccc', '2021-01-25 03:55:48', '2021-01-25 03:55:48', NULL, 'N'),
(33, '32', 'abc', '01', 'ccc', 'ddd', '2021-01-25 03:55:56', '2021-01-25 03:55:56', NULL, 'N');
/*!40000 ALTER TABLE `board` ENABLE KEYS */;
-- 테이블 kimyongseon.board_list 구조 내보내기
CREATE TABLE IF NOT EXISTS `board_list` (
`board_id` varchar(100) NOT NULL,
`board_name` varchar(100) DEFAULT NULL,
`board_des` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`board_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 테이블 데이터 kimyongseon.board_list:~5 rows (대략적) 내보내기
/*!40000 ALTER TABLE `board_list` DISABLE KEYS */;
INSERT IGNORE INTO `board_list` (`board_id`, `board_name`, `board_des`) VALUES
('01', 'board_01', 'board_01 설명...'),
('02', 'board_02', 'board_02 설명..'),
('03', 'board_03', 'board_03 설명...'),
('04', 'board_04', 'board_04 설명.'),
('05', 'board_05', 'board_05 설명..');
/*!40000 ALTER TABLE `board_list` ENABLE KEYS */;
-- 테이블 kimyongseon.comment 구조 내보내기
CREATE TABLE IF NOT EXISTS `comment` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
`comment_pid` varchar(100) DEFAULT NULL,
`member_id` varchar(100) DEFAULT NULL,
`board_content_id` varchar(100) DEFAULT NULL,
`comment_body` varchar(1000) DEFAULT NULL,
`comment_regdatetime` datetime DEFAULT NULL,
`comment_edtdatetime` datetime DEFAULT NULL,
`comment_deleted` varchar(10) DEFAULT NULL,
PRIMARY KEY (`comment_id`)
) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8;
-- 테이블 데이터 kimyongseon.comment:~35 rows (대략적) 내보내기
/*!40000 ALTER TABLE `comment` DISABLE KEYS */;
INSERT IGNORE INTO `comment` (`comment_id`, `comment_pid`, `member_id`, `board_content_id`, `comment_body`, `comment_regdatetime`, `comment_edtdatetime`, `comment_deleted`) VALUES
(45, '0', 'abc', '14', 'aa', '2021-01-21 11:30:19', '2021-01-21 11:30:19', 'N'),
(46, '0', 'abc', '14', 'bb', '2021-01-21 11:30:22', '2021-01-21 11:30:22', 'N'),
(47, '45', 'abc', '14', 'aa', '2021-01-21 11:30:26', '2021-01-21 11:30:26', 'N'),
(48, '45', 'abc', '14', 'reaa', '2021-01-21 11:30:37', '2021-01-21 11:30:37', 'N'),
(49, '47', 'abc', '14', 'rereaa', '2021-01-21 11:30:43', '2021-01-21 11:30:43', 'N'),
(50, '48', 'abc', '14', 'rere2aa', '2021-01-21 12:03:53', '2021-01-21 12:03:53', 'N'),
(51, '50', 'abc', '14', 'rerere2aa', '2021-01-21 12:03:58', '2021-01-21 12:03:58', 'N'),
(52, '0', 'abc', '15', 'aa', '2021-01-21 12:20:26', '2021-01-21 12:20:26', 'N'),
(53, '0', 'abc', '15', 'aabb', '2021-01-21 12:20:29', '2021-01-21 12:20:29', 'N'),
(54, '0', 'abc', '20', 'aa', '2021-01-21 13:33:27', '2021-01-21 13:33:27', 'N'),
(55, '0', 'abc', '20', 'aabb', '2021-01-21 13:36:40', '2021-01-21 13:36:40', 'Y'),
(56, '0', 'abc', '20', 'reaa', '2021-01-21 13:36:45', '2021-01-21 13:36:45', 'Y'),
(57, '54', 'abc', '20', '답aa', '2021-01-21 13:36:57', '2021-01-21 13:36:57', 'Y'),
(58, '0', 'abc', '20', 'bb', '2021-01-21 14:02:05', '2021-01-21 14:02:05', 'Y'),
(59, '0', 'abc', '20', 'cc', '2021-01-21 14:02:10', '2021-01-21 14:02:10', 'Y'),
(60, '0', 'abc', '20', 'ccd', '2021-01-21 14:02:13', '2021-01-21 14:02:13', 'N'),
(61, '57', 'abc', '20', 'bb', '2021-01-21 14:13:34', '2021-01-21 14:13:34', 'Y'),
(62, '61', 'abc', '20', 'bbbb', '2021-01-21 14:13:38', '2021-01-21 14:13:38', 'N'),
(63, '57', 'abc', '20', 'cc', '2021-01-21 14:13:47', '2021-01-21 14:13:47', 'N'),
(64, '0', 'admin', '23', 'abc', '2021-01-22 13:06:38', '2021-01-22 13:06:38', 'N'),
(65, '0', 'abc', '23', 'bbb', '2021-01-22 13:07:02', '2021-01-22 13:07:02', 'N'),
(66, '0', 'abc', '23', 'cc', '2021-01-22 13:12:29', '2021-01-22 13:12:29', 'N'),
(67, '0', 'abc', '23', 'dd', '2021-01-22 13:13:29', '2021-01-22 13:13:29', 'N'),
(68, '0', 'admin', '8', 'dd', '2021-01-22 13:15:43', '2021-01-22 13:15:43', 'N'),
(69, '0', 'abc', '24', 'dd', '2021-01-22 13:16:32', '2021-01-22 13:16:32', 'N'),
(70, '0', 'abc', '8', 'aa', '2021-01-22 13:19:46', '2021-01-22 13:19:46', 'N'),
(71, '70', 'abc', '8', 'aabb', '2021-01-22 13:19:56', '2021-01-22 13:19:56', 'N'),
(72, '0', 'abc', '8', 'cd', '2021-01-22 13:40:25', '2021-01-22 13:40:25', 'N'),
(73, '0', 'abc', '8', 'cd', '2021-01-22 13:40:25', '2021-01-22 13:40:25', 'N'),
(74, '0', 'abc', '8', 'dd', '2021-01-22 13:41:51', '2021-01-22 13:41:51', 'N'),
(75, '73', 'abc', '8', 'ddee', '2021-01-22 13:42:16', '2021-01-22 13:42:16', 'N'),
(76, '0', 'abc', '24', 'ss', '2021-01-22 13:44:29', '2021-01-22 13:44:29', 'N'),
(77, '0', 'admin', '8', 'ss', '2021-01-22 13:44:50', '2021-01-22 13:44:50', 'N'),
(78, '0', 'bcd', '24', 'cde', '2021-01-22 14:18:25', '2021-01-22 14:18:25', 'Y'),
(79, '0', 'admin', '24', 'abc', '2021-01-25 01:04:28', '2021-01-25 01:04:28', 'N'),
(80, '0', 'abc', '32', 'ㄴㄴ', '2021-01-25 10:57:17', '2021-01-25 10:57:17', 'N');
/*!40000 ALTER TABLE `comment` ENABLE KEYS */;
-- 테이블 kimyongseon.file 구조 내보내기
CREATE TABLE IF NOT EXISTS `file` (
`file_id` varchar(100) NOT NULL,
`board_content_id` varchar(100) DEFAULT NULL,
`member_id` varchar(100) DEFAULT NULL,
`file_name` varchar(100) DEFAULT NULL,
`file_path` varchar(100) DEFAULT NULL,
`file_type` varchar(100) DEFAULT NULL,
`file_regdatetime` datetime DEFAULT NULL,
`file_edtdatetime` datetime DEFAULT NULL,
PRIMARY KEY (`file_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 테이블 데이터 kimyongseon.file:~0 rows (대략적) 내보내기
/*!40000 ALTER TABLE `file` DISABLE KEYS */;
/*!40000 ALTER TABLE `file` ENABLE KEYS */;
-- 테이블 kimyongseon.group_authority 구조 내보내기
CREATE TABLE IF NOT EXISTS `group_authority` (
`group_code` varchar(100) NOT NULL,
`authority_board_create` varchar(10) DEFAULT NULL,
`authority_board_update` varchar(10) DEFAULT NULL,
`authority_board_delete` varchar(10) DEFAULT NULL,
PRIMARY KEY (`group_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 테이블 데이터 kimyongseon.group_authority:~2 rows (대략적) 내보내기
/*!40000 ALTER TABLE `group_authority` DISABLE KEYS */;
INSERT IGNORE INTO `group_authority` (`group_code`, `authority_board_create`, `authority_board_update`, `authority_board_delete`) VALUES
('00', '1', '1', '1'),
('01', '0', '0', '0');
/*!40000 ALTER TABLE `group_authority` ENABLE KEYS */;
-- 테이블 kimyongseon.group_board_authority 구조 내보내기
CREATE TABLE IF NOT EXISTS `group_board_authority` (
`group_code` varchar(100) DEFAULT NULL,
`board_id` varchar(100) DEFAULT NULL,
`authority_board_content_read` varchar(10) DEFAULT NULL,
`authority_board_content_write` varchar(10) DEFAULT NULL,
`authority_board_content_update` varchar(10) DEFAULT NULL,
`authority_board_content_delete` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 테이블 데이터 kimyongseon.group_board_authority:~4 rows (대략적) 내보내기
/*!40000 ALTER TABLE `group_board_authority` DISABLE KEYS */;
INSERT IGNORE INTO `group_board_authority` (`group_code`, `board_id`, `authority_board_content_read`, `authority_board_content_write`, `authority_board_content_update`, `authority_board_content_delete`) VALUES
('00', '01', '2', '2', '2', '2'),
('00', '02', '2', '2', '2', '2'),
('01', '01', '1', '1', '1', '1'),
('01', '02', '0', '0', '0', '0'),
('00', '03', '2', '2', '2', '2'),
('00', '04', '2', '2', '2', '2'),
('00', '05', '2', '2', '2', '2'),
('01', '03', '1', '0', '0', '0'),
('01', '04', '1', '1', '0', '0'),
('01', '05', '1', '1', '1', '0');
/*!40000 ALTER TABLE `group_board_authority` ENABLE KEYS */;
-- 테이블 kimyongseon.member 구조 내보내기
CREATE TABLE IF NOT EXISTS `member` (
`member_id` varchar(100) NOT NULL,
`group_code` varchar(100) DEFAULT NULL,
`member_pw` varchar(100) DEFAULT NULL,
`member_name` varchar(100) DEFAULT NULL,
`member_birthday` datetime DEFAULT NULL,
`member_phonenumber` varchar(100) DEFAULT NULL,
`member_nickname` varchar(100) DEFAULT NULL,
PRIMARY KEY (`member_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 테이블 데이터 kimyongseon.member:~9 rows (대략적) 내보내기
/*!40000 ALTER TABLE `member` DISABLE KEYS */;
INSERT IGNORE INTO `member` (`member_id`, `group_code`, `member_pw`, `member_name`, `member_birthday`, `member_phonenumber`, `member_nickname`) VALUES
('abc', '01', 'abc', 'abcname', '2021-01-12 00:00:00', '11', 'abcnname'),
('admin', '00', 'admin', 'admin_name', '2021-01-15 13:18:22', '111111', 'admin_nickname'),
('bcd', '01', 'bcd', '123', '2021-01-11 00:00:00', '12312', '123'),
('cde', '01', 'cde', 'cddd', '2021-01-05 00:00:00', '111', '111'),
('eee', '01', 'eee', 'eeee', '2021-01-06 00:00:00', '111', '123'),
('ef', '01', 'ef', 'ef', '2020-12-29 00:00:00', 'ef', 'ef'),
('fff', '01', '123', '123', '2021-01-04 00:00:00', '123', '123'),
('ggg', '01', '123', '123', '2021-01-15 00:00:00', '123', '213'),
('ggg1', '01', '123', 'dd', '2021-01-14 00:00:00', 'dd', 'dd'),
('가나다', '01', '가나다', '간다ㅏ', '2021-01-16 00:00:00', 'ㅇ', 'ㅇ');
/*!40000 ALTER TABLE `member` ENABLE KEYS */;
-- 테이블 kimyongseon.member_group 구조 내보내기
CREATE TABLE IF NOT EXISTS `member_group` (
`group_code` varchar(100) NOT NULL,
`group_name` varchar(100) DEFAULT NULL,
`group_des` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`group_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 테이블 데이터 kimyongseon.member_group:~2 rows (대략적) 내보내기
/*!40000 ALTER TABLE `member_group` DISABLE KEYS */;
INSERT IGNORE INTO `member_group` (`group_code`, `group_name`, `group_des`) VALUES
('00', 'admin', 'admin..'),
('01', 'group_01', 'group_01');
/*!40000 ALTER TABLE `member_group` ENABLE KEYS */;
-- 테이블 kimyongseon.test_recursive 구조 내보내기
CREATE TABLE IF NOT EXISTS `test_recursive` (
`id` int(11) NOT NULL,
`pid` int(11) DEFAULT NULL,
`nm` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- 테이블 데이터 kimyongseon.test_recursive:~16 rows (대략적) 내보내기
/*!40000 ALTER TABLE `test_recursive` DISABLE KEYS */;
INSERT IGNORE INTO `test_recursive` (`id`, `pid`, `nm`) VALUES
(1, 0, 'root'),
(2, 1, 'A'),
(3, 1, 'B'),
(4, 1, 'C'),
(5, 2, 'AA'),
(6, 2, 'AB'),
(7, 2, 'AC'),
(8, 5, 'AAA'),
(9, 5, 'AAB'),
(10, 5, 'AAC'),
(11, 6, 'ABA'),
(12, 2, 'ABB'),
(13, 8, 'AAAA'),
(14, 0, 'xxx'),
(15, 14, 'XXXX'),
(16, 1, 'XX-A');
/*!40000 ALTER TABLE `test_recursive` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
| true |
37a87e87dd34ab457cd332c6d33cbb951dd95372 | SQL | yifeng2019uwb/DataCampAndCodePractice | /Data-Analyst-with-SQL-Server/01-Introduction-to-SQL-Server/02-Groups-strings-and-counting-things/10-GROUP_BY.sql | UTF-8 | 1,030 | 4.46875 | 4 | [] | no_license | /*
GROUP BY
In an earlier exercise, you wrote a separate WHERE query to determine the amount of demand lost for a specific region. We wouldn't want to have to write individual queries for every region. Fortunately,you don't have to write individual queries for every region. With GROUP BY, you can obtain a sum of all the unique values for your chosen column, all at once.
You'll return to the grid table here and calculate the total lost demand for all regions.
*/
/*
Select nerc_region and the sum of demand_loss_mw for each region.
Exclude values where demand_loss_mw is NULL.
Group the results by nerc_region.
Arrange in descending order of demand_loss.
*/
-- Select the region column
SELECT
nerc_region,
-- Sum the demand_loss_mw column
SUM(demand_loss_mw) AS demand_loss
FROM
grid
-- Exclude NULL values of demand_loss
WHERE
demand_loss_mw IS NOT NULL
-- Group the results by nerc_region
GROUP BY
nerc_region
-- Order the results in descending order of demand_loss
ORDER BY
demand_loss DESC;
| true |
c41071176d4227f79936413a194bcba0455cf55f | SQL | amaitpaul2255/atp3-lab | /Lab task 6/labtask6ff.sql | UTF-8 | 1,754 | 3.046875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 30, 2022 at 06:20 PM
-- Server version: 10.4.16-MariaDB
-- PHP Version: 7.4.12
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: `labtask6ff`
--
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`id` int(10) NOT NULL,
`fname` varchar(20) NOT NULL,
`lname` varchar(20) NOT NULL,
`gender` varchar(10) NOT NULL,
`email` varchar(30) NOT NULL,
`phone` varchar(16) NOT NULL,
`password` varchar(16) NOT NULL,
`conpassword` varchar(16) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`id`, `fname`, `lname`, `gender`, `email`, `phone`, `password`, `conpassword`) VALUES
(1, 'Moona', 'Hosen', 'Female', 'monna@gmail.com', '017788665544', '1234', '1234'),
(3, 'Jam', 'Mil', 'Male', 'jammil@gmail.com', '01778445566', '1234', '1234');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
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 |
3371968d445598d0f0993fe76a0f6c3d68295d0c | SQL | halmasieh/Pewlett-Hackard-Analysis | /silver_tsunami.sql | UTF-8 | 2,335 | 4.59375 | 5 | [] | no_license | -------------------------------------------------------------------------
--Written Analysis-Summary
--------------------------------------------------------------------------
-- Create tables employees
CREATE TABLE employees (
emp_no INT NOT NULL,
birth_date DATE NOT NULL,
first_name VARCHAR NOT NULL,
last_name VARCHAR NOT NULL,
gender VARCHAR NOT NULL,
hire_date DATE NOT NULL,
PRIMARY KEY (emp_no)
);
--Create tables titles
CREATE TABLE titles(
emp_no INT Not Null,
title varchar Not Null,
from_date DATE Not Null,
to_date DATE Not Null,
FOREIGN KEY (emp_no) REFERENCES Employees (emp_no)
);
--Create a table called silver tsunami and join employees in title
SELECT Distinct on (e.emp_no)
e.emp_no,
e.first_name,
e.last_name,
e.birth_date,
ti.title
INTO silver_tsunami
FROM employees AS e
INNER JOIN titles AS ti
ON (e.emp_no = ti.emp_no);
--Filter the data on bith_date to get the employees over 65 years
--Select * from silver_tsunami
--where birth_date <= '1956-01-01';
--Drop table if exists
DROP TABLE IF EXISTS over_sixtyFive;
DROP TABLE IF EXISTS under_sixtyFive;
DROP TABLE IF EXISTS totalCountByTitle;
--Count the total number of employees by title
Select Count(title) as total_count, title
into totalCountByTitle
from silver_tsunami
group by title;
--Count the total number of employees equal or older than 65 years old by title
Select Count(title) as over65_count, title
into over_sixtyfive
from silver_tsunami
where birth_date <= '1956-01-01'
group by title;
--Count the total number of employees younger than 65 years old by title
Select Count(title) as under65_count, title
into under_sixtyfive
from silver_tsunami
where birth_date > '1956-01-01'
group by title;
--Join total, over_sixtyfive and under_sixtyfive
select total.title, total_count, over65_count, under65_count
from totalCountByTitle as total
inner join over_sixtyfive as o
ON (total.title = o.title)
inner join under_sixtyfive as u
ON (total.title = u.title);
-- Count the number of employees participated in mentorship eligibility
Select Count(title) as mentorship_count, title
into mentorship_eligibility_count
from mentorship_eligibility
group by title;
--View the mentorship_eligibility_count
Select * From mentorship_eligibility_count;
| true |
4a28872f5f7f29488d9aec43960632925be8ae8d | SQL | sdramsey89/Pewlett-Hackard-Analysis | /Queries/Employee_Database_challenge.sql | UTF-8 | 3,024 | 4.4375 | 4 | [] | no_license | --Deliverable 1
-- Retreive Employee Number, First Name, Last Name
SELECT e.emp_no,
e.first_name,
e.last_name,
t.title,
t.from_date,
t.to_date
INTO retirement_titles
From employees as e
Join titles as t
ON (e.emp_no = t.emp_no)
WHERE (e.birth_date BETWEEN '1952-01-01' AND '1955-12-31')
ORDER BY e.emp_no
;
-- Use Dictinct with Orderby to remove duplicate rows
SELECT DISTINCT ON (rt.emp_no) rt.emp_no,
rt.first_name,
rt.last_name,
rt.title
INTO unique_titles
FROM retirement_titles as rt
ORDER BY rt.emp_no, rt.to_date DESC;
-- Retrieve number of employees about to retire by recent job title
SELECT COUNT(title), title
INTO retiring_titles
FROM unique_titles
GROUP BY title
ORDER BY COUNT(title) DESC;
-- Deliverable 2
--Mentorship Eligibility
SELECT DISTINCT ON (e.emp_no)e.emp_no,
e.first_name,
e.last_name,
e.birth_date,
de.from_date,
de.to_date,
t.title
INTO mentorship_eligibility
FROM employees AS e
JOIN dept_emp AS de
ON (e.emp_no = de.emp_no)
JOIN titles AS t
ON (e.emp_no = t.emp_no)
WHERE de.to_date = '9999-01-01' AND (e.birth_date BETWEEN '1965-01-01' AND '1965-12-31')
ORDER BY e.emp_no;
-- Additional Tables and Queries
-- Create table with salaries of all eligible mentors
SELECT DISTINCT ON (e.emp_no)e.emp_no,
e.first_name,
e.last_name,
e.birth_date,
de.from_date,
de.to_date,
t.title,
s.salary
INTO mentorship_eligibility_salary
FROM employees AS e
JOIN dept_emp AS de
ON (e.emp_no = de.emp_no)
JOIN titles AS t
ON (e.emp_no = t.emp_no)
JOIN salaries AS s on (e.emp_no = s.emp_no)
WHERE de.to_date = '9999-01-01' AND (e.birth_date BETWEEN '1965-01-01' AND '1965-12-31')
ORDER BY e.emp_no;
-- Create table with Avg Salary by role
SELECT COUNT(title),title, Avg(salary)::numeric(10,2)
INTO mentorship_salary_avg
FROM mentorship_eligibility_salary
GROUP BY title
ORDER BY COUNT(title) DESC;
--Get Employee info for all Current employees
SELECT e.emp_no,
e.first_name,
e.last_name,
e.birth_date,
t.title,
t.from_date,
t.to_date
--into all_titles
From employees as e
Join titles as t
ON (e.emp_no = t.emp_no)
ORDER BY e.emp_no
;
-- Use Dictinct with Orderby to remove duplicate rows and calculate Age
SELECT DISTINCT ON (t.emp_no) t.emp_no,
t.first_name,
t.last_name,
t.birth_date,
AGE('2021-04-22',t.birth_date) as age,
t.title
INTO all_unique_titles
FROM all_titles as t
ORDER BY t.emp_no, t.to_date DESC;
-- Create table of Age statistics by title
SELECT title, COUNT(title), avg(age), min(age), max(age)
INTO title_age_stats
FROM all_unique_titles
GROUP BY title
ORDER BY COUNT(title) DESC;
-- Mentor title Count
select * from mentorship_eligibility;
SELECT DISTINCT ON (me.emp_no) me.emp_no,
me.first_name,
me.last_name,
me.title
INTO unique_titles_mentors
FROM mentorship_eligibility as me
ORDER BY me.emp_no, me.to_date DESC;
-- Retrieve number of employees eligilbe for Mentor Program by recent job title
SELECT COUNT(title), title
INTO mentoring_titles
FROM unique_titles_mentors
GROUP BY title
ORDER BY COUNT(title) DESC; | true |
5afa823c12c1faeb9f8f7b5e15c97e1e8b295cff | SQL | annemaku/weatherdiary | /src/main/resources/omaschema.sql | UTF-8 | 509 | 2.703125 | 3 | [] | no_license | CREATE TABLE IF NOT EXISTS weatheruser (
id int NOT NULL PRIMARY KEY,
user_name varchar(50),
password varchar(20),
name varchar(50),
role varchar(50)
);
CREATE TABLE IF NOT EXISTS weather (
weather_id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
weatherdate date NOT NULL,
location varchar(50),
temperature varchar(20),
description varchar(50)
);
CREATE TABLE IF NOT EXISTS user (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
username varchar(10),
password varchar(100),
role varchar(10)
); | true |
3e4730332529d15f07d169cb481ba6d9f9eb346c | SQL | amyelmer92/GWS-SQL | /ethos.sql | UTF-8 | 1,561 | 3.890625 | 4 | [] | no_license | --first, check if tablename exists - if so, drop it
IF OBJECT_ID('dbo.DimEthnos') IS NOT NULL
BEGIN
DROP TABLE dbo.DimEthnos
END
--then select the IDs from the relevant column, create table, adding description (use case statement, and values from data dictionary)
SELECT DISTINCT
ETHNOS as ID,
CASE
WHEN ETHNOS = 'H' THEN 'Indian (Asian or Asian British) '
WHEN ETHNOS = 'A' THEN 'British (White)'
WHEN ETHNOS = 'B' THEN 'Irish (White)'
WHEN ETHNOS = 'K' THEN 'Bangladeshi (Asian or Asian British)'
WHEN ETHNOS = 'D' THEN 'White and Black Caribbean (Mixed)'
WHEN ETHNOS = 'N' THEN 'African (Black or Black British)'
WHEN ETHNOS = 'L' THEN 'Any other Asian background'
WHEN ETHNOS = 'F' THEN 'White and Asian (Mixed)'
WHEN ETHNOS Is null THEN 'Not Known'
WHEN ETHNOS = 'C' then 'Other White background'
WHEN ETHNOS = 'E' then 'White and Black African (Mixed)'
WHEN ETHNOS = 'G' then 'Any other Mixed background'
WHEN ETHNOS = 'J' then 'Pakistani (Asian or Asian British)'
WHEN ETHNOS = 'M' then 'Caribbean (Black or Black British)'
WHEN ETHNOS = 'P' then 'Any other Black background'
WHEN ETHNOS = 'R' then 'Chinese (other ethnic group)'
WHEN ETHNOS = 'S' then 'Any other ethnic group'
WHEN ETHNOS = 'Z' then 'Not stated'
WHEN ETHNOS = 'X' then 'Not known'
WHEN ETHNOS = '99' then 'Not known'
else 'Not Known' --the original data uses 'Not Known' for a lot of null values/non-sensible values
END
AS DESCRIPTION
INTO dbo.DimEthnos
FROM RawDataset | true |
8d87f074b673215ff86aced9d26726ba3371ab74 | SQL | saga1015/db_refresh | /sql/DB_Refresh_Restore_Script_Ddboost.sql | UTF-8 | 706 | 3.234375 | 3 | [] | no_license | select
'gpssh -h ' || hostname || ' -v -e '''
||'gpddboost --readFile --from-file=' || file_name || ' | '
|| 'PGOPTIONS="-c gp_session_role=utility" psql -h '|| hostname || ' -p ' || port || ' -d ' || :v_Target_DB || ' -U gpadmin '
|| E'''&\n'
|| 'plist['|| id_file ||']=$!'
from (select row_number() over() as id_file,file_name
from db_refresh.refresh_list_dump_file
where dump_timestampkey = :v_dump_timestampkey) S1
inner join (select *, max(content) over () as max_content
,row_number() over(order by port,hostname) as id_content_join
from gp_segment_configuration
where role = 'p'
and content >=0 ) T1
on mod(S1.id_file,T1.max_content + 1 ) + 1 = T1.id_content_join
order by id_file
| true |
bf336774acfe4f33fc972ff9d0dc7a4e0fad6b2b | SQL | royiwanhamonanganpasaribu/Amor | /1.sql | UTF-8 | 2,232 | 2.921875 | 3 | [] | no_license |
DROP VIEW public.perhitungan_sisa_amor_final;
DROP VIEW public.perhitungan_sisa_deposito;
-- View: public.perhitungan_sisa_deposito
-- DROP VIEW public.perhitungan_sisa_deposito;
CREATE OR REPLACE VIEW public.perhitungan_sisa_deposito AS
SELECT sum(hitung_komisi_deposito_3.sisa_amor) AS komisi_dep
FROM hitung_komisi_deposito_3;
ALTER TABLE public.perhitungan_sisa_deposito
OWNER TO postgres;
-- View: public.perhitungan_sisa_amor_final
-- DROP VIEW public.perhitungan_sisa_amor_final;
CREATE OR REPLACE VIEW public.perhitungan_sisa_amor_final AS
SELECT sekarang() AS sekarang,
perhitungan_sisa_pa_mk.pa_mk,
perhitungan_sisa_mk_mk.mk_mk,
perhitungan_sisa_pa_inv.pa_inv,
perhitungan_sisa_mk_inv.mk_inv,
perhitungan_sisa_pa_ksm.pa_ksm,
perhitungan_sisa_mk_ksm.mk_ksm,
coa_13011.coa_13011,
coa_13012.coa_13012,
coa_13021.coa_13021,
coa_13031.coa_13031,
coa_13022.coa_13022,
coa_13032.coa_13032,
coa_16001.coa_16001,
perhitungan_sisa_deposito.komisi_dep
FROM perhitungan_sisa_pa_mk,
perhitungan_sisa_mk_mk,
perhitungan_sisa_pa_inv,
perhitungan_sisa_mk_inv,
perhitungan_sisa_pa_ksm,
perhitungan_sisa_mk_ksm,
coa_13011,
coa_13012,
coa_13021,
coa_13031,
coa_13022,
coa_13032,
coa_16001,
perhitungan_sisa_deposito;
ALTER TABLE public.perhitungan_sisa_amor_final
OWNER TO postgres;
-- View: public.hitung_komisi_deposito_3
-- DROP VIEW public.hitung_komisi_deposito_3;
CREATE OR REPLACE VIEW public.hitung_komisi_deposito_3 AS
SELECT hitung_komisi_deposito_2.id_dep,
hitung_komisi_deposito_2.amor_per_bln,
hitung_komisi_deposito_2.amor_terakhir,
hitung_komisi_deposito_2.awal_dep,
hitung_komisi_deposito_2.maturity_dep,
hitung_komisi_deposito_2.sekarang,
hitung_komisi_deposito_2.bln_dep,
hitung_komisi_deposito_2.bln_lewat,
hitung_komisi_deposito_2.sisa_bln,
hitung_komisi_deposito_2.sisa_amor,
deposito.komisi_deposito,
hitung_komisi5.akhir_nilai_amor
FROM hitung_komisi_deposito_2
JOIN deposito USING (id_dep)
JOIN hitung_komisi5 USING (id_dep)
where deposito.active_Dep;
ALTER TABLE public.hitung_komisi_deposito_3
OWNER TO postgres;
| true |
fa0bcf67327b532151eb8d53e18fe9e43d89267b | SQL | pawurb/ruby-pg-extras | /lib/ruby_pg_extras/queries/db_settings.sql | UTF-8 | 381 | 2.5625 | 3 | [
"MIT"
] | permissive | /* Values of selected PostgreSQL settings */
SELECT name, setting, unit, short_desc FROM pg_settings
WHERE name IN (
'max_connections', 'shared_buffers', 'effective_cache_size',
'maintenance_work_mem', 'checkpoint_completion_target', 'wal_buffers',
'default_statistics_target', 'random_page_cost', 'effective_io_concurrency',
'work_mem', 'min_wal_size', 'max_wal_size'
);
| true |
02659184a7912be3e886cf1b12f265601cdb8427 | SQL | sandylcruz/aa-algorithms | /recap/sql/sql-zoo/difficult.sql | UTF-8 | 1,707 | 4.3125 | 4 | [] | no_license | -- 1. The example query shows all goals scored in the Germany-Greece quarterfinal.
-- Instead show the name of all players who scored a goal against Germany.
SELECT DISTINCT player
FROM goal JOIN game ON matchid = id
WHERE (team1='GER' OR team2='GER')
AND teamid <> 'GER'
-- 2. Show teamname and the total number of goals scored.
SELECT teamname, COUNT(player) as goals_scored
FROM eteam JOIN goal ON eteam.id = goal.teamid
GROUP BY teamname
-- 3. Show the stadium and the number of goals scored in each stadium.
SELECT stadium, COUNT(player) as goals_scored
FROM game
JOIN goal ON goal.matchid = game.id
GROUP BY stadium
-- 4. For every match involving 'POL', show the matchid, date and the number of goals scored.
SELECT matchid,mdate, COUNT(teamid) as goals_scored
FROM game JOIN goal ON goal.matchid = game.id
WHERE (team1 = 'POL' OR team2 = 'POL')
GROUP BY matchid, mdate
-- 5. For every match where 'GER' scored, show matchid, match date and the number of goals scored by 'GER'
SELECT matchid, mdate, COUNT(player)
FROM game
JOIN goal ON goal.matchid = game.id
WHERE teamid = 'GER'
GROUP BY matchid, mdate
-- 6. List every match with the goals scored by each team as shown. This will use "CASE WHEN" which has not been explained in any previous exercises.
SELECT mdate, team1, score1, team2, score2
FROM game
JOIN goal ON game.id = goal.matchid
GROUP BY mdate
-- Find the continents where all countries have a population <= 25000000. Then find the names of the countries associated with these continents. Show name, continent and population.
-- Some countries have populations more than three times that of any of their neighbours (in the same continent). Give the countries and continents. | true |
1570d1cfeb0f2137cbc6fb46df4c6c0e59bdf5c0 | SQL | lautaro1990/Base-de-datos-2 | /ejercicios/clase 13.sql | UTF-8 | 1,239 | 3.4375 | 3 | [] | no_license | use sakila;
-- 1
insert into customer
(store_id, first_name, last_name, email, address_id, active, create_date, last_update)
select 1, 'Juan', 'Perez', 'juanperez@gmail.com', MAX(address_id), 1, current_timestamp, current_timestamp FROM address
inner join city on address.city_id = city.city_id
inner join country on city.country_id = country.country_id
where country = 'United States';
-- 2
insert into rental
(rental_date, inventory_id, customer_id, staff_id)
select current_timestamp, MAX(inventory_id), 1, (SELECT MAX(staff_id) FROM staff WHERE staff.store_id = inventory.store_id) from inventory
inner join film on inventory.film_id = film.film_id
where film.title = 'ALICE FANTASIA'
AND store_id = 2;
-- 3
update film
set release_year = 2001
where rating = 'PG';
update film
set release_year = 2002
where rating = 'G';
update film
set release_year = 2003
where rating = 'NC-17';
update film
set release_year = 2004
where rating = 'PG-13';
update film
set release_year = 2005
where rating = 'R';
-- 4
-- 5
delete from film_actor
where film_id = 2;
delete from film_category
where film_id = 2;
delete from inventory
where film_id = 2;
delete from film
where film_id = 2;
-- 6
| true |
1e6e941487de4e56212884fb383367a8e0753717 | SQL | yeahframeoff/course-db | /department_curriculums_dump.sql | UTF-8 | 6,947 | 3.421875 | 3 | [
"MIT"
] | permissive | CREATE DATABASE IF NOT EXISTS `department_curriculum` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `department_curriculum`;
-- MySQL dump 10.13 Distrib 5.6.13, for Win32 (x86)
--
-- Host: 127.0.0.1 Database: department_curriculum
-- ------------------------------------------------------
-- Server version 5.5.38-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `curriculums`
--
DROP TABLE IF EXISTS `curriculums`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `curriculums` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`subject_id` int(11) NOT NULL,
`type` varchar(16) NOT NULL,
`hours` mediumint(9) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_curriculum_subjects1_idx` (`subject_id`),
CONSTRAINT `fk_curriculum_subjects1` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `curriculums`
--
LOCK TABLES `curriculums` WRITE;
/*!40000 ALTER TABLE `curriculums` DISABLE KEYS */;
INSERT INTO `curriculums` (`id`, `subject_id`, `type`, `hours`) VALUES (1,1,'LEC',45),(2,1,'PRA',45),(3,1,'LAB',45),(4,3,'LEC',180),(5,3,'PRA',90),(6,4,'LEC',145),(7,4,'PRA',45),(8,5,'LEC',145),(9,5,'PRA',90);
/*!40000 ALTER TABLE `curriculums` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `positions`
--
DROP TABLE IF EXISTS `positions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `positions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`position` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `positions`
--
LOCK TABLES `positions` WRITE;
/*!40000 ALTER TABLE `positions` DISABLE KEYS */;
INSERT INTO `positions` (`id`, `position`) VALUES (1,'Профессор'),(2,'Доцент'),(3,'Ассистент'),(4,'Старший преподаватель');
/*!40000 ALTER TABLE `positions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `subjects`
--
DROP TABLE IF EXISTS `subjects`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `subjects` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `subjects`
--
LOCK TABLES `subjects` WRITE;
/*!40000 ALTER TABLE `subjects` DISABLE KEYS */;
INSERT INTO `subjects` (`id`, `title`) VALUES (1,'Организация Баз Данных и Знаний'),(2,'Объектно-Ориентированное Программироние'),(3,'Математические Методы Исследования операций'),(4,'Теория Алгоритмов'),(5,'Дискретная Математика');
/*!40000 ALTER TABLE `subjects` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `teachers`
--
DROP TABLE IF EXISTS `teachers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `teachers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(16) NOT NULL,
`name2` varchar(16) NOT NULL,
`surname` varchar(16) NOT NULL,
`date_of_birth` datetime NOT NULL,
`gender` varchar(1) NOT NULL,
`position_id` int(11) NOT NULL,
`department` varchar(6) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_teachers_positions_idx` (`position_id`),
CONSTRAINT `fk_teachers_positions` FOREIGN KEY (`position_id`) REFERENCES `positions` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `teachers`
--
LOCK TABLES `teachers` WRITE;
/*!40000 ALTER TABLE `teachers` DISABLE KEYS */;
INSERT INTO `teachers` (`id`, `name`, `name2`, `surname`, `date_of_birth`, `gender`, `position_id`, `department`) VALUES (1,'Владимир','Дмитриевич','Попенко','1970-06-15 00:00:00','М',2,'АСОИУ'),(2,'Жданова','Елена','Григорьевна','1970-08-25 00:00:00','Ж',2,'АСОИУ'),(3,'Молчановский','Алексей','Игоревич','1980-04-10 00:00:00','М',4,'АСОИУ'),(4,'Василий','Петрович','Блощичкий','1960-06-12 00:00:00','М',3,'АСУ');
/*!40000 ALTER TABLE `teachers` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `teachers_curriculums`
--
DROP TABLE IF EXISTS `teachers_curriculums`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `teachers_curriculums` (
`teacher_id` int(11) NOT NULL,
`curriculum_id` int(11) NOT NULL,
`hours` mediumint(9) NOT NULL,
PRIMARY KEY (`teacher_id`,`curriculum_id`),
KEY `fk_teachers_has_curriculum_curriculum1_idx` (`curriculum_id`),
KEY `fk_teachers_has_curriculum_teachers1_idx` (`teacher_id`),
CONSTRAINT `fk_teachers_has_curriculum_curriculum1` FOREIGN KEY (`curriculum_id`) REFERENCES `curriculums` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_teachers_has_curriculum_teachers1` FOREIGN KEY (`teacher_id`) REFERENCES `teachers` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `teachers_curriculums`
--
LOCK TABLES `teachers_curriculums` WRITE;
/*!40000 ALTER TABLE `teachers_curriculums` DISABLE KEYS */;
/*!40000 ALTER TABLE `teachers_curriculums` 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 2014-12-13 15:51:45
| true |
22fc54db6edb301c7174032045a720b03efd54de | SQL | huidh123/SoftWarePKYanZhiBin | /《同学帮帮忙》源码-岩志彬/数据库文件/shm.sql | UTF-8 | 5,900 | 3.140625 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : ess
Source Server Version : 50096
Source Host : localhost:3307
Source Database : shm
Target Server Type : MYSQL
Target Server Version : 50096
File Encoding : 65001
Date: 2015-05-25 21:15:33
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `advice`
-- ----------------------------
DROP TABLE IF EXISTS `advice`;
CREATE TABLE `advice` (
`username` varchar(20) NOT NULL,
`advice` text NOT NULL,
`id` int(11) NOT NULL auto_increment,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of advice
-- ----------------------------
INSERT INTO `advice` VALUES ('131110323', '不错的平台', '1');
-- ----------------------------
-- Table structure for `problems`
-- ----------------------------
DROP TABLE IF EXISTS `problems`;
CREATE TABLE `problems` (
`id` int(11) NOT NULL auto_increment,
`title` text NOT NULL,
`content` text NOT NULL,
`username` varchar(9) NOT NULL,
`name` varchar(10) NOT NULL,
`sex` int(1) NOT NULL,
`givedpoints` int(11) NOT NULL,
`picid` int(11) NOT NULL,
`time` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of problems
-- ----------------------------
INSERT INTO `problems` VALUES ('19', '啦啦啦啦啦啦啦啦了', '浓浓', '131110323', '岩志彬', '0', '60', '0', '2015-04-28 17:31:13');
INSERT INTO `problems` VALUES ('23', '啦啦啦啦啦', 'hhhgg', '131110323', '岩志彬', '0', '0', '0', '2015-05-05 16:44:37');
INSERT INTO `problems` VALUES ('27', '我想卖自行车', '一个车子要卖了', '131110109', '李晓颖', '1', '22', '5', '2015-05-05 17:23:54');
-- ----------------------------
-- Table structure for `solve`
-- ----------------------------
DROP TABLE IF EXISTS `solve`;
CREATE TABLE `solve` (
`id` int(11) NOT NULL auto_increment,
`solve_username` varchar(9) NOT NULL,
`solve_name` varchar(10) NOT NULL,
`problemid` int(11) NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`username` varchar(9) NOT NULL,
`name` varchar(10) NOT NULL,
`sex` int(1) NOT NULL,
`givedpoints` int(11) NOT NULL,
`picid` int(11) NOT NULL,
`time` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of solve
-- ----------------------------
-- ----------------------------
-- Table structure for `the_deleted_problems`
-- ----------------------------
DROP TABLE IF EXISTS `the_deleted_problems`;
CREATE TABLE `the_deleted_problems` (
`id` int(11) NOT NULL auto_increment,
`solve_username` varchar(9) default NULL,
`solve_name` varchar(10) default NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`username` varchar(9) NOT NULL,
`name` varchar(10) NOT NULL,
`sex` int(1) NOT NULL,
`givedpoints` int(11) NOT NULL,
`picid` int(11) NOT NULL,
`time` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of the_deleted_problems
-- ----------------------------
INSERT INTO `the_deleted_problems` VALUES ('1', null, null, '111111', '111111', '131110323', '岩志彬', '1', '0', '1', '2015-04-23 23:21:07');
INSERT INTO `the_deleted_problems` VALUES ('2', '131110323', '岩志彬', '100的积分', '100的积分', '131110323', '岩志彬', '1', '100', '1', '2015-04-24 20:59:23');
INSERT INTO `the_deleted_problems` VALUES ('3', null, null, '500的积分', '500的积分', '131110323', '岩志彬', '1', '500', '1', '2015-04-24 20:59:01');
INSERT INTO `the_deleted_problems` VALUES ('4', '131110323', '岩志彬', '测试', '测试', '131110323', '岩志彬', '1', '0', '1', '2015-04-23 23:20:08');
INSERT INTO `the_deleted_problems` VALUES ('5', '131110323', '岩志彬', '利民', '利民', '131110323', '岩志彬', '1', '0', '1', '2015-05-04 16:52:02');
INSERT INTO `the_deleted_problems` VALUES ('6', null, null, '同学helpme', '还是技术监督局大酒店', '131110109', '李晓颖', '1', '22', '2', '2015-05-05 16:52:47');
-- ----------------------------
-- Table structure for `users`
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(9) NOT NULL,
`password` varchar(20) NOT NULL,
`name` varchar(10) NOT NULL,
`picid` int(11) NOT NULL,
`signature` text,
`academe` text NOT NULL,
`profession` text NOT NULL,
`sex` int(1) NOT NULL,
`qqnumber` varchar(20) default NULL,
`points` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO `users` VALUES ('1', '131110323', '123', '岩志彬', '0', '心情不错', '计院', '软件工程', '0', '821845901', '1238');
INSERT INTO `users` VALUES ('2', '131110321', '123', '向往', '1', null, '计院', '软件工程', '0', null, '220');
INSERT INTO `users` VALUES ('3', '131110320', '123', '王喆', '1', null, '计院', '软件工程', '0', null, '260');
INSERT INTO `users` VALUES ('4', '131110322', '1234', '许杨昕', '1', null, '信院', '电气工程及其自动化', '0', null, '210');
INSERT INTO `users` VALUES ('5', '131110109', '123', '李晓颖', '5', null, '计院', '软件工程', '1', null, '404');
-- ----------------------------
-- Table structure for `versionupdate`
-- ----------------------------
DROP TABLE IF EXISTS `versionupdate`;
CREATE TABLE `versionupdate` (
`url` text,
`id` int(11) NOT NULL auto_increment,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of versionupdate
-- ----------------------------
INSERT INTO `versionupdate` VALUES ('', '1');
| true |
06a88f79fa06bb72051170c3ba1f34599b2f447e | SQL | thorwbm/lixiera_sql | /organizar/genericos/cursor basico.sql | UTF-8 | 1,167 | 2.625 | 3 | [] | no_license | /*****************************************************************************************************************
* IMPORTACAO DA CARGA HORARIA *
* *
* CURSOR QUE CORRE A TABELA TMP_CARGA_HORARIA E INSERE OS VALORES NA TABELA PFSALCMP. *
* OS ERROS IRAM SER INSERIDOS EM UMA TABELA DE LOG COM AS INFORMACOES SEPRADAS POR VIRGULA *
* *
* AUTOR: WEMERSON BITTORI MADURO DATA:14/01/2014 *
******************************************************************************************************************/
declare CUR_ cursor for
SELECT * FROM
open CUR_
fetch next from CUR_ into CAMPOS NA ORDEM DO SELECT
while @@FETCH_STATUS = 0
BEGIN
ACOES A SEREM TOMADAS
fetch next from CUR_ into CAMPOS NA ORDEM DO SELECT
END
close CUR_
deallocate CUR_ | true |
fce011138bbac74d0894df35dcf16d81bd256c77 | SQL | etnewell/12-MySQL-db | /emp.sql | UTF-8 | 499 | 3.28125 | 3 | [] | no_license |
DROP DATABASE IF EXISTS emp_manage_db;
CREATE DATABASE emp_manage_db;
USE emp_manage_db;
CREATE TABLE department (
id INT NOT NULL,
name VARCHAR(30) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE role (
id INT NOT NULL,
title VARCHAR(30) NOT NULL,
salary INT NULL,
department_id INT NULL,
PRIMARY KEY (id)
);
CREATE TABLE employee (
id INT NOT NULL,
first_name VARCHAR(30) NULL,
last_name VARCHAR(30) NULL,
role_id INT NULL,
manager_id INT NULL,
PRIMARY KEY (id)
);
| true |
fdef0fc36aca43485c1af6fa5c027aabc5baa883 | SQL | silence-do-good/stress-test-Postgres-and-MySQL | /dump/high/day25/select1617.sql | UTF-8 | 178 | 2.640625 | 3 | [] | no_license |
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o
WHERE timestamp>'2017-11-24T16:17:00Z' AND timestamp<'2017-11-25T16:17:00Z' AND temperature>=11 AND temperature<=57
| true |
5fddb363b4c472f8385b03ad6bbd3aa387309632 | SQL | klk083/hapi | /src/Hapi/database.sql | UTF-8 | 4,857 | 3.5625 | 4 | [] | no_license | -- noinspection SqlNoDataSourceInspectionForFile
DROP TABLE IF EXISTS subscription_menu;
DROP TABLE IF EXISTS subscription_customer;
DROP TABLE IF EXISTS order_chauffeur;
DROP TABLE IF EXISTS order_cook;
DROP TABLE IF EXISTS menu_order;
DROP TABLE IF EXISTS menu_ingredient;
DROP TABLE IF EXISTS ingredient;
DROP TABLE IF EXISTS order_chauffeur;
DROP TABLE IF EXISTS orders;
DROP TABLE IF EXISTS customer;
DROP TABLE IF EXISTS statistics;
DROP TABLE IF EXISTS menu;
DROP TABLE IF EXISTS employee;
DROP TABLE IF EXISTS role;
DROP TABLE IF EXISTS sub_delivery_days;
DROP TABLE IF EXISTS subscription;
CREATE TABLE customer(
customer_id INTEGER AUTO_INCREMENT,
customer_name VARCHAR(30) NOT NULL,
customer_address VARCHAR(30),
customer_tlf VARCHAR(8) UNIQUE NOT NULL,
customer_discount INTEGER NOT NULL,
is_company BOOLEAN NOT NULL,
CONSTRAINT customer_pk PRIMARY KEY(customer_id));
CREATE TABLE menu(
menu_id INTEGER AUTO_INCREMENT,
menu_name VARCHAR(30) NOT NULL,
menu_price INTEGER NOT NULL,
menu_description VARCHAR(100),
CONSTRAINT menu_pk PRIMARY KEY(menu_id));
CREATE TABLE orders(
order_id INTEGER AUTO_INCREMENT,
customer_id INTEGER NOT NULL,
delivery_time DATETIME,
ready BOOLEAN NOT NULL,
delivered BOOLEAN NOT NULL,
CONSTRAINT order_pk PRIMARY KEY(order_id));
CREATE TABLE menu_order(
order_id INTEGER NOT NULL,
menu_id INTEGER NOT NULL,
quantity INTEGER NOT NULL,
description VARCHAR(100),
ready BOOLEAN NOT NULL,
CONSTRAINT menu_order_pk PRIMARY KEY (order_id, menu_id),
CONSTRAINT menu_order_fk1 FOREIGN KEY (order_id) REFERENCES orders(order_id),
CONSTRAINT menu_order_fk2 FOREIGN KEY (menu_id) REFERENCES menu(menu_id));
CREATE TABLE role(
role_id INTEGER AUTO_INCREMENT,
role VARCHAR(30) NOT NULL,
CONSTRAINT role_pk PRIMARY KEY (role_id));
CREATE TABLE employee(
employee_id INTEGER AUTO_INCREMENT,
role_id INTEGER NOT NULL,
name VARCHAR(30) NOT NULL,
username VARCHAR(12) UNIQUE NOT NULL,
password_hash VARCHAR(106) NOT NULL,
password_salt VARCHAR(16) NOT NULL,
CONSTRAINT employee_pk PRIMARY KEY(employee_id),
CONSTRAINT employee_fk FOREIGN KEY (role_id) REFERENCES role(role_id));
CREATE TABLE subscription(
subscription_id INTEGER AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
price INTEGER NOT NULL,
description VARCHAR(100),
CONSTRAINT subscription_pk PRIMARY KEY(subscription_id));
CREATE TABLE subscription_customer(
subscription_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
from_date DATE,
to_date DATE,
CONSTRAINT subscription_customer_pk PRIMARY KEY(subscription_id, customer_id),
CONSTRAINT subscription_customer_fk1 FOREIGN KEY(subscription_id) REFERENCES subscription(subscription_id),
CONSTRAINT subscription_customer_fk2 FOREIGN KEY(customer_id) REFERENCES customer(customer_id));
CREATE TABLE subscription_menu(
subscription_id INTEGER NOT NULL,
menu_id INTEGER NOT NULL,
quantity INTEGER NOT NULL,
CONSTRAINT subscription_menu_pk PRIMARY KEY(subscription_id, menu_id),
CONSTRAINT subscription_menu_fk1 FOREIGN KEY(subscription_id) REFERENCES subscription(subscription_id),
CONSTRAINT subscription_menu_fk2 FOREIGN KEY(menu_id) REFERENCES menu(menu_id));
CREATE TABLE sub_delivery_days(
subscription_id INTEGER NOT NULL,
monday BOOLEAN NOT NULL,
tuesday BOOLEAN NOT NULL,
wednesday BOOLEAN NOT NULL,
thursday BOOLEAN NOT NULL,
friday BOOLEAN NOT NULL,
saturday BOOLEAN NOT NULL,
sunday BOOLEAN NOT NULL,
CONSTRAINT sub_delivery_days_pk PRIMARY KEY(subscription_id),
CONSTRAINT sub_delivery_days_fk FOREIGN KEY(subscription_id) REFERENCES subscription(subscription_id));
CREATE TABLE ingredient(
ingredient_id INTEGER AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
unit VARCHAR(5) NOT NULL,
price INTEGER NOT NULL,
CONSTRAINT ingredient_pk PRIMARY KEY(ingredient_id));
CREATE TABLE menu_ingredient(
ingredient_id INTEGER NOT NULL,
menu_id INTEGER NOT NULL,
quantity INTEGER NOT NULL,
CONSTRAINT menu_ingredient_pk PRIMARY KEY (ingredient_id, menu_id),
CONSTRAINT menu_ingredient_fk1 FOREIGN KEY (ingredient_id) REFERENCES ingredient(ingredient_id),
CONSTRAINT menu_ingredient_fk2 FOREIGN KEY (menu_id) REFERENCES menu(menu_id));
CREATE TABLE order_chauffeur(
order_id INTEGER NOT NULL,
employee_id INTEGER NOT NULL,
CONSTRAINT order_chauffeur_pk PRIMARY KEY (order_id),
CONSTRAINT order_chauffeur_fk1 FOREIGN KEY (order_id) REFERENCES orders(order_id),
CONSTRAINT order_chauffeur_fk2 FOREIGN KEY (employee_id) REFERENCES employee(employee_id));
CREATE TABLE order_cook(
order_id INTEGER NOT NULL,
employee_ID INTEGER NOT NULL,
CONSTRAINT order_cook_pk PRIMARY KEY (order_id),
CONSTRAINT order_cook_fk1 FOREIGN KEY (order_id) REFERENCES orders(order_id),
CONSTRAINT order_cook_fk2 FOREIGN KEY (employee_id) REFERENCES employee(employee_id)); | true |
ad1dcef95395c418ad06887b9d94798fbaee1017 | SQL | 1725136424/tmall-ssm | /src/main/resources/sql/order_.sql | UTF-8 | 1,520 | 2.84375 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : study
Source Server Version : 80016
Source Host : localhost:3306
Source Database : tmall
Target Server Type : MYSQL
Target Server Version : 80016
File Encoding : 65001
Date: 2021-05-10 15:22:03
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for order_
-- ----------------------------
DROP TABLE IF EXISTS `order_`;
CREATE TABLE `order_` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
`post` varchar(255) DEFAULT NULL,
`receiver` varchar(255) DEFAULT NULL,
`mobile` varchar(255) DEFAULT NULL,
`user_message` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`create_date` datetime DEFAULT NULL,
`pay_date` datetime DEFAULT NULL,
`delivery_date` datetime DEFAULT NULL,
`confirm_date` datetime DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_order_user` (`uid`),
CONSTRAINT `fk_order_user` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of order_
-- ----------------------------
INSERT INTO `order_` VALUES ('16', '202009232154108337019', '12', '23', '44', '555', '', '2020-09-23 13:54:11', '2020-09-23 13:54:14', '2020-09-23 13:54:28', '2020-09-23 13:54:58', '12', 'waitReview');
| true |
4b987d6c3387cc96560c7fce4231babd6f3cf42c | SQL | AmitTheBest/atk4-codepad | /doc/agileproject.001.sql | UTF-8 | 418 | 2.71875 | 3 | [] | no_license | -- This is your inital structure for the prject. Put all tables here and also
-- insert some data into your tables
--
-- Remember that it's recommended to have "id int not null primary key auto_increment"
-- on all tables. Also if you are not sure about filed length, use 255.
--
create table user (
id int not null primary key auto_increment,
email varchar(255),
name varchar(255),
surname varchar(255)
);
| true |
5c1ef2d4cf037cedad4f9eb1385c6424d9999a94 | SQL | Dr1N/NotesOrganizer | /db/tbl_note_tags.sql | UTF-8 | 379 | 3.453125 | 3 | [] | no_license | CREATE TABLE tbl_note_tags
(
id INT NOT NULL AUTO_INCREMENT,
note_id INT NOT NULL,
tag_id INT NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (note_id) REFERENCES tbl_notes(id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (tag_id) REFERENCES tbl_tags(id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; | true |
69692ae70758847f477733aa5fda7979a82bc574 | SQL | kangqi0421/Oracle | /monitoring_worker_serv_hot.sql | UTF-8 | 541 | 3.203125 | 3 | [] | no_license | select /*+RULE*/
s.username,
dl.SID,
s.SID,
s.SERIAL#,
dl.JOB,
p.spid,
'kill -9 ' || p.SPID,
'alter system kill session ''' || s.sid || ',' || s.serial# || '''' || ';'
from dba_jobs_running dl, v$session s, v$process p
where
--dl.name like 'INV_INV%' and
s.paddr = p.addr
and dl.sid = s.SID
and dl.JOB in
(select job
from dba_jobs
where what like '%inv_swch_serv_worker_serv_hot(I_PARTITION=>%') --122--28814--767 and dl.JOB<=22781--in (27577,27576,27575)--=24900-- and dl.JOB <= 24075
order by 5
| true |
55e8c973b9e7f03e67ebe8fc7c0d94dc4b741673 | SQL | DonThomas98/safeplusDjango | /Github/SQL/triggers/trigger_pagos.sql | UTF-8 | 667 | 3.21875 | 3 | [] | no_license | --ESTE TRIGGER SE INVOCA AL MOMENTO DE CREAR UN CLIENTE , SE LE CREA UN CONTRATO
create or replace trigger trg_crearcontrato
after insert on auth_user
for each row
begin
if :NEW.is_staff=0 then
insert into contrato (descripcion,costo,fecha_contratacion,rut_cliente_id)
values ('Plan Universal',150000,CURRENT_DATE,:NEW.id);
prc_pagos_base();
end if;
end;
--TRIGGER INVOCADO AL MOMENTO DE HACER UN INSERT DE UN PAGO , INVOCA EL PROCEDURE QUE VERIFICA LOS PAGOS CON EL MES
CREATE OR REPLACE TRIGGER trg_pago_realizado
AFTER INSERT
ON registro_pagos
FOR EACH ROW
DECLARE
BEGIN
prc_pagos();
END;
| true |
4680ae7474988b191a25614a28644539687729cb | SQL | atmospherer/aqi | /xici_proxy/schema.sql | UTF-8 | 2,561 | 3.71875 | 4 | [] | no_license | PRAGMA foreign_keys = OFF;
-- ----------------------------
-- Table structure for aqi
-- ----------------------------
DROP TABLE IF EXISTS "main"."aqi";
CREATE TABLE aqi (
ID INTEGER NOT NULL PRIMARY KEY,
division UNSIGNED BIG INT(10) NOT NULL,
areaName VARCHAR(12) DEFAULT NULL,
value INTEGER NOT NULL,
pollutant INTEGER DEFAULT NULL,
recordDate DATE NOT NULL,
_fetchDate DATE NOT NULL,
source VARCHAR(8) DEFAULT NULL
);
-- ----------------------------
-- Indexes structure for table aqi
-- ----------------------------
CREATE INDEX "main"."aqiAreaNameIdx"
ON "aqi" ("areaName" ASC);
CREATE INDEX "main"."aqiDivisionIdx"
ON "aqi" ("division" ASC);
CREATE INDEX "main"."aqiRecordTimeIdx"
ON "aqi" ("recordDate" ASC);
-- ----------------------------
-- Table structure for aqi_data
-- ----------------------------
DROP TABLE IF EXISTS "main"."aqi_data";
CREATE TABLE "aqi_data" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"area" TEXT NOT NULL,
"value" INTEGER NOT NULL,
"pollutant" TEXT,
"record_date" INTEGER,
"fetch_date" INTEGER
);
-- ----------------------------
-- Indexes structure for table aqi_data
-- ----------------------------
CREATE INDEX "main"."idx_aqi_data_record_date"
ON "aqi_data" ("record_date" ASC);
CREATE UNIQUE INDEX "main"."uk_aqi_data_area_record_date"
ON "aqi_data" ("area" ASC, "record_date" ASC);
-- ----------------------------
-- Table structure for areas
-- ----------------------------
DROP TABLE IF EXISTS "main"."areas";
CREATE TABLE areas (
ID INTEGER NOT NULL PRIMARY KEY,
division UNSIGNED BIG INT(10) NOT NULL,
name VARCHAR(12) NOT NULL,
engName VARCHAR(64),
pinyinName VARCHAR(64),
bottom BOOLEAN DEFAULT FALSE,
superior UNSIGNED BIG INT(10)
);
-- ----------------------------
-- Indexes structure for table areas
-- ----------------------------
CREATE INDEX "main"."areaDivisionIdx"
ON "areas" ("division" ASC);
CREATE INDEX "main"."areaNameIdx"
ON "areas" ("name" ASC);
-- ----------------------------
-- Table structure for pollutant
-- ----------------------------
DROP TABLE IF EXISTS "main"."pollutant";
CREATE TABLE pollutant (
ID INTEGER NOT NULL PRIMARY KEY,
name VARCHAR(32) NOT NULL
);
-- ----------------------------
-- Indexes structure for table pollutant
-- ----------------------------
CREATE INDEX "main"."aqiPollutantNameIdx"
ON "pollutant" ("name" ASC);
| true |
eaff22a2fdf875d2e7819b9f2dea74860956c859 | SQL | vsarathy1/ch2 | /ch2driver/pytpcc/util/cbcrindexcollection_replicas.sql | UTF-8 | 1,730 | 2.875 | 3 | [] | no_license | drop index cu_w_id_d_id_last on default.tpcc.customer USING GSI
drop index di_id_w_id on default.tpcc.district USING GSI
drop index no_o_id_d_id_w_id on default.tpcc.neworder USING GSI
drop index or_id_d_id_w_id_c_id on default.tpcc.orders USING GSI
drop index or_w_id_d_id_c_id on default.tpcc.orders USING GSI
drop index wh_id on USING GSI default.tpcc.warehouse USING GSI
drop primary index on default.tpcc.customer USING GSI
drop primary index on default.tpcc.district USING GSI
drop primary index on default.tpcc.history USING GSI
drop primary index on default.tpcc.item USING GSI
drop primary index on default.tpcc.neworder USING GSI
drop primary index on default.tpcc.orders USING GSI
drop primary index on default.tpcc.stock USING GSI
drop primary index on default.tpcc.warehouse USING GSI
create index cu_w_id_d_id_last on default.tpcc.customer(c_w_id, c_d_id, c_last) using gsi with {"defer_build": false, "num_replica":replicas}
create index di_id_w_id on default.tpcc.district(d_id, d_w_id) using gsi with {"defer_build": false, "num_replica":replicas}
create index no_o_id_d_id_w_id on default.tpcc.neworder(no_o_id, no_d_id, no_w_id) using gsi with {"defer_build": false, "num_replica":replicas}
create index or_id_d_id_w_id_c_id on default.tpcc.orders(o_id, o_d_id, o_w_id, o_c_id) using gsi with {"defer_build": false, "num_replica":replicas}
create index or_w_id_d_id_c_id on default.tpcc.orders(o_w_id, o_d_id, o_c_id) using gsi with {"defer_build": false, "num_replica":replicas}
create index wh_id on default.tpcc.warehouse(w_id) using gsi with {"defer_build": false, "num_replica":replicas}
select keyspace_id, state from system:indexes
select keyspace_id, state from system:indexes where state != 'online'
| true |
c315105a4e9a4f6a5aec002e454c1fbeac08ece4 | SQL | clyan/some-mini-project | /大二实训/ebuy.sql | UTF-8 | 27,724 | 2.984375 | 3 | [
"MIT"
] | permissive | /*
Navicat MySQL Data Transfer
Source Server : ebuy
Source Server Version : 50520
Source Host : localhost:3306
Source Database : ebuy
Target Server Type : MYSQL
Target Server Version : 50520
File Encoding : 65001
Date: 2019-02-13 00:14:46
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`a_name` varchar(30) DEFAULT NULL,
`a_pass` varchar(30) DEFAULT NULL,
`a_header` varchar(30) DEFAULT NULL,
`a_phone` char(15) DEFAULT NULL,
`a_email` varchar(40) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of admin
-- ----------------------------
INSERT INTO `admin` VALUES ('liuzc518', 'liuzc518', 'images\\face\\Image25.gif', '8208290', 'liuzc518@163.com');
INSERT INTO `admin` VALUES ('tangzy', 'nihao', 'images\\face\\Image25.gif', '123232', 'tangzy111@sohu.com');
INSERT INTO `admin` VALUES ('admin', '123456', null, null, null);
-- ----------------------------
-- Table structure for customer
-- ----------------------------
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
`c_name` varchar(30) NOT NULL,
`c_pass` varchar(30) NOT NULL,
`c_header` varchar(225) NOT NULL,
`c_phone` varchar(15) NOT NULL,
`c_question` varchar(30) NOT NULL,
`c_answer` varchar(30) NOT NULL,
`c_address` varchar(50) DEFAULT NULL,
`c_email` varchar(50) NOT NULL,
PRIMARY KEY (`c_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of customer
-- ----------------------------
INSERT INTO `customer` VALUES ('13142189031', '99', 'resources/img/header.jpg\r\n', '18890052317', '您的生日是?', '991119', '999', '99');
INSERT INTO `customer` VALUES ('18890052317', '123456', 'resources/img/u=144388917,3393541021&fm=26&gp=0.jpg\r\n', '18890052317', '您的生日是?', '991119', '湖南商务职业技术学院', '1570555124@qq.com');
INSERT INTO `customer` VALUES ('admin', '123456', 'resources/img/4e488bad48fe43fc8afa36f02e41ec6c.jpg\r\n', '18890052317', '您的生日是?', '2019-2-9', '湖南商务职业技术学院', '18890052317');
INSERT INTO `customer` VALUES ('ebuytest', 'ebuytest', 'images\\face\\Image1.gif', '07338208290', '你最喜欢的人是?', '刘津', '湖南株洲', 'ebuy@163.com');
INSERT INTO `customer` VALUES ('liujin0414', '990414', 'images\\face\\Image23.gif', '07336188290', '你最喜欢的人是?', '老爸', '湖南株洲', 'liujin@163.com');
INSERT INTO `customer` VALUES ('liuzc518', 'liuzc518', 'images\\face\\Image1.gif', '8208290', '你最喜欢的人是?', '刘津', '湖南株洲', 'liuzc518@163.com');
INSERT INTO `customer` VALUES ('null', '', 'images\\face\\Image1.gif', '18890052317', '', '', '湖南商务职业技术学院', '2429335889@qq.com');
INSERT INTO `customer` VALUES ('tangzy', 'nihao', 'images\\face\\Image37.gif', '8888888', '你最喜欢的人是?', '爸爸', '湖南株洲', 'tangzy@sohu.com');
INSERT INTO `customer` VALUES ('wuhaibo', 'wuhaibo', 'images\\face\\Image26.gif', '13246579845', '你最喜欢的一部电影是?', '真实的谎言', '湖南湘潭', 'wu2bo@sina.com');
INSERT INTO `customer` VALUES ('模式', '991119', 'resources/img/header.jpg\r\n', '18890052317', '您的生日是?', '991119', '湖南商务职业技术学院', '1570555124@qq.com');
-- ----------------------------
-- Table structure for demo
-- ----------------------------
DROP TABLE IF EXISTS `demo`;
CREATE TABLE `demo` (
`name` varchar(30) DEFAULT NULL,
`pass` varchar(30) DEFAULT NULL,
`mail` varchar(30) DEFAULT NULL,
`phone` char(15) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of demo
-- ----------------------------
INSERT INTO `demo` VALUES ('demo', 'demo', 'demo@163.com', '8888888');
INSERT INTO `demo` VALUES ('liuzc', 'liuzc', 'liuzc@163.com', '8208290');
-- ----------------------------
-- Table structure for idea
-- ----------------------------
DROP TABLE IF EXISTS `idea`;
CREATE TABLE `idea` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`c_name` varchar(30) NOT NULL,
`c_header` varchar(225) NOT NULL,
`new_message` varchar(255) NOT NULL,
`re_message` varchar(255) DEFAULT NULL,
`new_time` char(20) NOT NULL,
`re_time` char(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=659 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of idea
-- ----------------------------
INSERT INTO `idea` VALUES ('326', 'tangzy', 'images\\face\\Image37.gif', '快来买啊', '好啊', '7:40 3-28-2008', '7:43 3-28-2008');
INSERT INTO `idea` VALUES ('447', 'tangzy', 'images\\face\\Image5.gif', '海尔商品很好', '感谢支持', '7:14 3-28-2008', '7:43 3-28-2008');
INSERT INTO `idea` VALUES ('644', 'liuzc', 'images\\face\\Image19.gif', '服务很好', '谢谢!', '10:15 3-27-2008', '7:43 3-28-2008');
INSERT INTO `idea` VALUES ('654', '18890052317', 'resources/img/u=144388917,3393541021&fm=26&gp=0.jpg\r\n', '其实没什么道理', '感谢支持', '08:00 05-57-2019', '2019-01-06 20:00:25');
INSERT INTO `idea` VALUES ('656', '18890052317', 'resources/img/u=144388917,3393541021&fm=26&gp=0.jpg\r\n', '商品太垃圾了,都不用付钱,就支付成功', '即日起,免费送', '08:08 06-02-2019', '2019-01-06 20:02:42');
INSERT INTO `idea` VALUES ('657', 'admin', 'resources/img/4e488bad48fe43fc8afa36f02e41ec6c.jpg\r\n', '管理员表示很好', null, '08:42 06-08-2019', null);
INSERT INTO `idea` VALUES ('658', 'admin', 'resources/img/4e488bad48fe43fc8afa36f02e41ec6c.jpg\r\n', '好', null, '10:34 07-28-2019', null);
-- ----------------------------
-- Table structure for main_type
-- ----------------------------
DROP TABLE IF EXISTS `main_type`;
CREATE TABLE `main_type` (
`t_id` int(11) NOT NULL AUTO_INCREMENT,
`t_type` varchar(30) NOT NULL DEFAULT '',
PRIMARY KEY (`t_id`)
) ENGINE=InnoDB AUTO_INCREMENT=374 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of main_type
-- ----------------------------
INSERT INTO `main_type` VALUES ('290', '电脑专区');
INSERT INTO `main_type` VALUES ('341', '洗衣机系列');
INSERT INTO `main_type` VALUES ('368', '厨卫系列');
INSERT INTO `main_type` VALUES ('370', '电视机系列');
INSERT INTO `main_type` VALUES ('373', '水果系列');
-- ----------------------------
-- Table structure for notice
-- ----------------------------
DROP TABLE IF EXISTS `notice`;
CREATE TABLE `notice` (
`n_id` int(10) NOT NULL AUTO_INCREMENT,
`n_message` varchar(1000) NOT NULL,
`n_admin` varchar(30) NOT NULL,
`n_header` varchar(50) DEFAULT NULL,
`n_time` char(225) DEFAULT NULL,
PRIMARY KEY (`n_id`)
) ENGINE=InnoDB AUTO_INCREMENT=888 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of notice
-- ----------------------------
INSERT INTO `notice` VALUES ('181', '迎新年,数码产品特惠!~', 'tangzy', 'images\\face\\Image28.gif', '8-17-2008');
INSERT INTO `notice` VALUES ('489', '各种家电超低价销售!!!', 'tangzy', 'images\\face\\Image28.gif', '3-17-2008');
INSERT INTO `notice` VALUES ('528', '祝各位会员牛年大吉,牛气冲天!', 'tangzy', 'images\\face\\Image28.gif', '1-17-2009');
INSERT INTO `notice` VALUES ('884', '圣诞团队活动,优惠多多...', 'tangzy', 'images\\face\\Image28.gif', '12-16-2008');
INSERT INTO `notice` VALUES ('887', '冬季上新', 'admin', null, '2019-01-06 20:03:07');
-- ----------------------------
-- Table structure for orderdetails
-- ----------------------------
DROP TABLE IF EXISTS `orderdetails`;
CREATE TABLE `orderdetails` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` varchar(225) NOT NULL,
`p_id` int(10) NOT NULL,
`p_price` float NOT NULL,
`p_number` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=113 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of orderdetails
-- ----------------------------
INSERT INTO `orderdetails` VALUES ('1', '0117483494', '0', '4928', '1');
INSERT INTO `orderdetails` VALUES ('2', '0117483494', '0', '2390', '1');
INSERT INTO `orderdetails` VALUES ('3', '0117483494', '0', '1985', '1');
INSERT INTO `orderdetails` VALUES ('4', '0117483494', '0', '3058', '1');
INSERT INTO `orderdetails` VALUES ('5', '0117483494', '0', '1142', '1');
INSERT INTO `orderdetails` VALUES ('6', '9996374742', '0', '5998', '2');
INSERT INTO `orderdetails` VALUES ('7', '9996374742', '0', '5478', '1');
INSERT INTO `orderdetails` VALUES ('8', '9996374742', '0', '1890', '1');
INSERT INTO `orderdetails` VALUES ('9', '7083902532', '0', '7000', '10');
INSERT INTO `orderdetails` VALUES ('10', '7350963892', '0', '4899', '1');
INSERT INTO `orderdetails` VALUES ('11', '7350963892', '0', '2728', '2');
INSERT INTO `orderdetails` VALUES ('12', '7350963892', '0', '4928', '1');
INSERT INTO `orderdetails` VALUES ('13', 'O20190103112451', '1', '5998', '1');
INSERT INTO `orderdetails` VALUES ('33', 'O20190105225731', '23', '1142', '1');
INSERT INTO `orderdetails` VALUES ('65', 'O20190106142800', '23', '1142', '1');
INSERT INTO `orderdetails` VALUES ('66', 'O20190106174512', '22', '8999', '1');
INSERT INTO `orderdetails` VALUES ('67', 'O20190106174930', '26', '5478', '2');
INSERT INTO `orderdetails` VALUES ('76', 'O20190106175226', '23', '1142', '1');
INSERT INTO `orderdetails` VALUES ('78', 'O20190106175226', '20', '13500', '1');
INSERT INTO `orderdetails` VALUES ('80', 'O20190106185716', '23', '1142', '1');
INSERT INTO `orderdetails` VALUES ('82', 'O20190106204018', '24', '1086', '1');
INSERT INTO `orderdetails` VALUES ('88', 'O20190106211112', '24', '1086', '1');
INSERT INTO `orderdetails` VALUES ('96', 'O20190106212541', '28', '20', '1');
INSERT INTO `orderdetails` VALUES ('97', 'O20190107090840', '23', '1142', '1');
INSERT INTO `orderdetails` VALUES ('98', 'O20190107090915', '24', '1086', '1');
INSERT INTO `orderdetails` VALUES ('108', 'O20190107093204', '28', '20', '1');
INSERT INTO `orderdetails` VALUES ('109', 'O20190107093204', '3', '8998', '1');
INSERT INTO `orderdetails` VALUES ('110', 'O20190106191028', '18', '2728', '1');
INSERT INTO `orderdetails` VALUES ('112', 'O190211200547', '24', '1086', '1');
-- ----------------------------
-- Table structure for orders
-- ----------------------------
DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders` (
`order_id` varchar(225) NOT NULL,
`order_payment` varchar(100) DEFAULT NULL,
`order_address` varchar(200) NOT NULL,
`order_email` varchar(50) NOT NULL,
`order_user` varchar(30) NOT NULL,
`order_time` varchar(30) NOT NULL,
`order_sum` float(8,0) NOT NULL,
`type` int(11) NOT NULL,
PRIMARY KEY (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of orders
-- ----------------------------
INSERT INTO `orders` VALUES ('0117483494', '银行付款', '湖南株洲', 'tangzy@sohu.com', 'tangzy', '3-20-2005', '13503', '1');
INSERT INTO `orders` VALUES ('7083902532', '在线支付', '湖南株洲', 'tangzy@.com', 'tangzy', '3-28-2005', '70000', '1');
INSERT INTO `orders` VALUES ('7350963892', '银行支付', '湖南铁道职业技术学院信息工程系', 'liuzc518@163.com', 'liujin0414', '1-20-2009', '15283', '1');
INSERT INTO `orders` VALUES ('9996374742', '银行支付', '湖南株洲', 'ebuy@163.com', 'ebuytest', '1-20-2009', '19364', '2');
INSERT INTO `orders` VALUES ('O190211200547', null, '湖南商务职业技术学院', '1570555124@qq.com', '18890052317', '2019-02-11 20:05:47', '1086', '-1');
INSERT INTO `orders` VALUES ('O20190103112451', '在线支付', '湖南商务职业技术学院', '湖南商务职业技术学院', '18890052317', '2019-01-03 11:24:51', '17994', '0');
INSERT INTO `orders` VALUES ('O20190105225731', '在线支付', '湖南商务职业技术学院', '1570555124@qq.com', '模式', '2019-01-05 22:57:31', '1142', '0');
INSERT INTO `orders` VALUES ('O20190106142800', '在线支付', '湖南商务职业技术学院', '1570555124@qq.com', '18890052317', '2019-01-06 14:28:00', '1142', '0');
INSERT INTO `orders` VALUES ('O20190106174512', '在线支付', '湖南商务职业技术学院', '1570555124@qq.com', '18890052317', '2019-01-06 17:45:12', '8999', '0');
INSERT INTO `orders` VALUES ('O20190106174930', '在线支付', '湖南商务职业技术学院', '1570555124@qq.com', '18890052317', '2019-01-06 17:49:30', '10956', '0');
INSERT INTO `orders` VALUES ('O20190106175226', '在线支付', '湖南商务职业技术学院', '1570555124@qq.com', '18890052317', '2019-01-06 17:52:26', '14642', '0');
INSERT INTO `orders` VALUES ('O20190106185716', '在线支付', '湖南商务职业技术学院', '1570555124@qq.com', '18890052317', '2019-01-06 18:57:16', '1142', '0');
INSERT INTO `orders` VALUES ('O20190106191028', '在线支付', '湖南商务职业技术学院', '1570555124@qq.com', '18890052317', '2019-01-06 19:10:28', '2728', '0');
INSERT INTO `orders` VALUES ('O20190106204018', '在线支付', '湖南商务职业技术学院', '18890052317', 'admin', '2019-01-06 20:40:18', '1086', '0');
INSERT INTO `orders` VALUES ('O20190106211112', '在线支付', '湖南商务职业技术学院', '18890052317', 'admin', '2019-01-06 21:11:12', '4900', '0');
INSERT INTO `orders` VALUES ('O20190106212541', '在线支付', '湖南商务职业技术学院', '18890052317', 'admin', '2019-01-06 21:25:41', '20', '0');
INSERT INTO `orders` VALUES ('O20190107090840', '在线支付', '湖南商务职业技术学院', '18890052317', 'admin', '2019-01-07 09:08:40', '1142', '0');
INSERT INTO `orders` VALUES ('O20190107090915', '在线支付', '湖南商务职业技术学院', '18890052317', 'admin', '2019-01-07 09:09:15', '1086', '0');
INSERT INTO `orders` VALUES ('O20190107093204', '在线支付', '湖南商务职业技术学院', '1570555124@qq.com', '模式', '2019-01-07 09:32:04', '9018', '0');
-- ----------------------------
-- Table structure for payment
-- ----------------------------
DROP TABLE IF EXISTS `payment`;
CREATE TABLE `payment` (
`pay_id` int(11) NOT NULL AUTO_INCREMENT,
`pay_payment` varchar(50) NOT NULL,
`pay_msg` varchar(255) DEFAULT NULL,
PRIMARY KEY (`pay_id`)
) ENGINE=InnoDB AUTO_INCREMENT=453 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of payment
-- ----------------------------
INSERT INTO `payment` VALUES ('91', '在线支付', 'www.easybuyonline.com\r\n');
INSERT INTO `payment` VALUES ('439', '银行支付', '请记住帐号:1324659831221656');
INSERT INTO `payment` VALUES ('441', '在线支付', '123');
INSERT INTO `payment` VALUES ('442', '银联支付', '465+4');
INSERT INTO `payment` VALUES ('443', '在线支付', '最后两台');
INSERT INTO `payment` VALUES ('444', '在线支付', '12');
INSERT INTO `payment` VALUES ('445', '在线支付', '');
INSERT INTO `payment` VALUES ('446', '银联支付', '3213');
INSERT INTO `payment` VALUES ('447', '在线支付', '');
INSERT INTO `payment` VALUES ('448', '在线支付', '好吃的apple');
INSERT INTO `payment` VALUES ('449', '在线支付', 'nice啊');
INSERT INTO `payment` VALUES ('450', '在线支付', '风格');
INSERT INTO `payment` VALUES ('451', '在线支付', '好的');
INSERT INTO `payment` VALUES ('452', '在线支付', '');
-- ----------------------------
-- Table structure for product
-- ----------------------------
DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
`p_id` int(11) NOT NULL AUTO_INCREMENT,
`p_type` varchar(30) NOT NULL,
`p_name` varchar(40) NOT NULL,
`p_price` float NOT NULL,
`p_quantity` int(11) NOT NULL,
`p_image` varchar(100) DEFAULT NULL,
`p_description` varchar(2000) NOT NULL,
`p_time` varchar(20) DEFAULT NULL,
PRIMARY KEY (`p_id`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of product
-- ----------------------------
INSERT INTO `product` VALUES ('2', '电脑专区', '海尔H3000-G002 ', '7899', '20', 'images\\computer\\7.jpg', '人性化设计:静音设计,让您拥有安静的工作环境;多功能设计,多媒体、上网、游戏、工作等,从视觉和听觉上获得更佳的享受;人性化设计的前置高速USB2.0和音效接口,方便易用前置常用接口,让你无需为外设转接而烦恼,让你的生活与工作更轻松、更灵活、更方便;单键记忆恢复功能,系统崩溃无烦恼,让系统运行更稳定、数据更安全。', '2019-01-06 20:19:11');
INSERT INTO `product` VALUES ('3', '电脑专区', '海尔W12-T225', '8998', '19', 'images\\computer\\8.jpg', '产品分类:笔记本电脑 \r\n产品型号:W12-T22512080BaWN \r\n屏幕大小:12.1寸宽屏液晶 \r\nCPU类型:酷睿双核T2250 \r\n硬盘容量:80G ', '3-17-2005');
INSERT INTO `product` VALUES ('4', '电脑专区', '海尔W36-T22', '8598', '20', 'images\\computer\\9.jpg', '产品分类:笔记本电脑 \r\n产品型号:W36-T22512080BaWG \r\n屏幕大小:13.3寸宽屏 \r\nCPU类型:酷睿双核T2250 \r\n硬盘容量:80G ', '3-18-2005');
INSERT INTO `product` VALUES ('5', '电脑专区', '海尔H32笔记本电脑', '7298', '20', 'images\\computer\\10.jpg', '润清独显,极速魅力 \r\n极速双核动力,整体性能提高68%(较上代平台) \r\n独立显卡X300 \r\n高清200万像素摄像头 \r\n不凡配色,时尚造型 \r\n造型独特的立体声音响 \r\n低噪低功耗硬盘,贴心保护数据安全 \r\n动感触控板,独立方向键 \r\n超大散热空间加智能线性风扇 ', '3-16-2005');
INSERT INTO `product` VALUES ('6', '电脑专区', '海尔W18笔记本电脑 ', '6798', '20', 'images\\computer\\11.jpg', '12.1英寸润清宽屏 惊艳亮丽画质 \r\n双核强动力 系统整体性能跃升68% \r\n隐藏式转轴设计,开合自如 \r\n易读指示灯设计,主要部件运行状态一目了然 \r\n易拉式网卡插口,使用方便 \r\n金属质感触控板,采用防磨损设计 \r\n内置一体式四合一读卡器,防尘美观 \r\n特设无线网络开关,一键切换 ', '3-16-2005');
INSERT INTO `product` VALUES ('7', '电脑专区', '海尔H8台式电脑', '29999', '20', 'images\\computer\\12.jpg', 'CPU类型:英特尔 QX6700 四核处理器 \r\n硬盘容量:250 \r\n内存:2G ', '3-16-2005');
INSERT INTO `product` VALUES ('8', '电脑专区', '海尔H30笔记本电脑', '5998', '17', 'images\\computer\\13.jpg', '奔腾芯+独显 \r\n经典游戏机型 \r\nATI超极独立显卡 \r\n高清200万像素摄像头 \r\nMTBF4万小时认证测试 \r\n大键程键盘,长期使用不疲劳 \r\n磨砂耐磨表面,不怕硬物划伤 \r\n易用性触控板,操控得心应手 \r\n专业铰链式转轴,阻尼设计工艺 ', '3-16-2005');
INSERT INTO `product` VALUES ('9', '电脑专区', 'NEC笔记本电脑', '5999', '20', 'images\\computer\\14.jpg', '可选颜色:银灰色 \r\nCPU:AMD 3100+\r\n内存:256M DDRII\r\n硬盘:80G\r\n屏幕:15.4寸炫丽屏', '3-16-2005');
INSERT INTO `product` VALUES ('10', '厨卫系列', '爱德SC电热水煲', '118', '19', 'images\\other\\13.jpg', '产品型号:SC135B \r\n材质:食品级塑料 \r\n容量:1.0 \r\n功率:1350 ', '3-18-2005');
INSERT INTO `product` VALUES ('11', '厨卫系列', '爱德LD豆浆机', '220', '20', 'images\\other\\14.jpg', '可选颜色:黄色 \r\n全自动煮豆浆,具有保温功能\r\n可免泡豆(一杯干豆100克)', '3-16-2005');
INSERT INTO `product` VALUES ('12', '厨卫系列', '爱德ZZ18A榨汁机', '135', '19', 'images\\other\\15.jpg', '产品型号:ZZ18A \r\n最大功率(w) :220 \r\n容量:750ml \r\n材质:金属滤网', '3-16-2005');
INSERT INTO `product` VALUES ('13', '厨卫系列', '电烤箱', '240', '20', 'images\\other\\16.jpg', '可选颜色:银灰色 \r\n可调式温控器,温度可自由调节\r\n60分钟内自由调节时间长短\r\n带烧烤盘,烧烤架\r\n烧烤,烘培功能\r\n耐热玻璃门\r\n容易清洗\r\n可拆卸式清洁盘\r\n加热方式独特,可选择上管加热、下管加热、上下管同时', '3-16-2005');
INSERT INTO `product` VALUES ('14', '厨卫系列', '电压力锅', '440', '20', 'images\\other\\17.jpg', '智能型电气锅(全塑盖不锈钢) ●容量5L,功率900W\r\n●10重安全保护装置,使用更放心\r\n●煮、煲、炖、焖,烹饪功能更齐全\r\n●磨砂不锈钢外壳,时尚大方\r\n●电脑型按键菜单烹饪功能,更直观,方便,高档\r\n●超厚黑晶不粘内胆,导热更好,清洗方便\r\n●自动加压保压,无需人工干预\r\n●工作过程不冒热气,热效率极高,非常省电\r\n●24小时预约定时功能,使用更省心\r\n●具有防烫功能', '3-16-2005');
INSERT INTO `product` VALUES ('15', '厨卫系列', '万和ZLD46-5消毒柜', '699', '20', 'images\\other\\18.jpg', '★先进的数码控制,充分发挥数字控制更快速、更精确的优势,消毒更彻底。\r\n\r\n★大屏幕VFD动态显示屏,工作状态清清楚楚。\r\n\r\n★强力臭氧与高效紫外线二种杀菌方式,消毒效果达国标星级要求。\r\n\r\n★PTC循环热风烘干,保证消毒室内处于干燥无菌状态。\r\n\r\n★高密度聚氨脂整体发泡,行业独有,保温效果好,节能省电。\r\n\r\n★全不锈钢内胆及层架,永保消毒室的纯净品质。\r\n\r\n★具有过热、超载、风机故障等多重安全保护装置,使用无忧。\r\n\r\n产品参数:\r\n 系列名称:数码屏显系列消毒柜', '3-16-2005');
INSERT INTO `product` VALUES ('16', '厨卫系列', '电火锅', '139', '19', 'images\\other\\19.jpg', '可选颜色:银灰色 \r\nA120T3 \r\n豪华电热不粘火锅 \r\n\r\n容量:2.5L,功率1300W\r\n分体式底部发热,热效率更高\r\n体积小,容量大\r\n无级调温模式\r\n装有超温保护装置,安全可靠\r\n造型美观新颖,高雅大方\r\n分体结构,清洗方便\r\n', '3-16-2005');
INSERT INTO `product` VALUES ('17', '厨卫系列', '万和超薄电热水器', '1520', '20', 'images\\other\\20.jpg', '产品参数: \r\n 系列名称:H型超薄系列\r\n 产品型号:DSZF50-H\r\n 外型尺寸(mm):855*376*260\r\n 额定功率(W):1500\r\n 容积(L):50\r\n 水温调节范围:30℃-75℃', '3-16-2005');
INSERT INTO `product` VALUES ('18', '厨卫系列', '海尔XQG52', '2728', '2', 'images\\washing\\19.jpg', '极限设计 减薄不减量 \r\n自选挡功能:不同洗涤情况,可以设置不同洗涤档位,通过优化洗涤程序,缩短洗衣时间,减少用水量 \r\n40公分超薄,5.2公斤大容量。极限超薄设计,符合家居简约格调,为你的居所节省更多写意空间,整体嵌入设计为生活省出更多空间 \r\n各种面料智能洗涤,强大功能软件优化各项洗涤参数,全面料洗涤程序, 为现代家庭提供更多选择 ', '3-21-2005');
INSERT INTO `product` VALUES ('19', '电视机系列', '创维TFT32L16SW', '5999', '20', 'images\\TV\\1.jpg', '可选颜色:浅绿色 \r\n六基色图像处理技术\r\nV12数字引擎\r\nBlue wave无线蓝波\r\n超稳USB流媒体技术\r\n画中画、双视窗\r\n高亮度600cd/m2\r\n超高动态对比度3000:1\r\n超快响应时间6ms\r\n超宽可视角度178°\r\n物理分辨率1366x768\r\n超高支持分辨率1920x1200\r\nHDMI高清晰多媒体端口 ', '3-18-2005');
INSERT INTO `product` VALUES ('20', '电视机系列', 'LG42LC2RR', '13500', '19', 'images\\TV\\6.jpg', '暂无说明', '3-17-2005');
INSERT INTO `product` VALUES ('21', '电视机系列', 'LG50PC1R', '21900', '20', 'images\\TV\\7.jpg', '产品分类:等离子 \r\n产品型号:50PC1R \r\n显示器尺寸:50英寸 \r\n屏幕比例:16:9 \r\n扫描方式:逐行', '3-17-2005');
INSERT INTO `product` VALUES ('22', '电视机系列', '夏新LC-37M1', '8999', '19', 'images\\TV\\8.jpg', '产品分类:液晶 \r\n产品型号:LC-37M1 \r\n显示器尺寸:37寸 \r\n屏幕比例:16:9 \r\n分辨率:1366*768 ', '3-17-2005');
INSERT INTO `product` VALUES ('23', '洗衣机系列', '海尔X小小神童', '1142', '4', 'images\\washing\\6.jpg', '内衣外衣分开洗 小件衣物及时洗 \r\n透明上盖,洗涤过程一目了然 \r\n不怕水,永不生锈 \r\n如同手搓衣物,带来手洗效果 \r\n手搓式技术,波轮与内桶反向旋转,产生的水流形状就如同手搓衣物 \r\n进口材料,经久耐用 \r\n两遍洗程序,全面瓦解污渍,提高洗净度 \r\n特设羊毛洗程序,可以洗涤毛制品或内衣 \r\n音乐提醒功能,增加洗衣乐趣 \r\n ', '3-19-2005');
INSERT INTO `product` VALUES ('24', '洗衣机系列', '海尔XQB50', '1086', '17', 'images\\washing\\8.jpg', '进口材料 经济耐用 \r\n性价比高,经济实惠 \r\n不怕水,防生锈 \r\n十分钟速洗,节水节能 \r\n智能控制技术:满足多种衣物洗涤要求,能自动感知衣料及衣物重量,智能编程,自动为您要洗的衣物选择洗衣时间、用水量及用电量等 \r\n数码管显示,显示剩余时间和预约时间 \r\n排水电机静音设计,全过程享受安静 \r\n十分钟速洗是指少量轻污衣物可以在十分钟内完成洗涤、漂洗、脱水全过程,最大限度的加快洗衣速度,提高效率 \r\n预约功能,方便实用 ', '3-19-2005');
INSERT INTO `product` VALUES ('25', '洗衣机系列', '海尔XQB50-18', '1725', '7', 'images\\washing\\9.jpg', '海尔手搓式洗衣机 洗得净又磨损低 \r\n透明上盖,洗涤过程一目了然 \r\n不怕水,防生锈 \r\n如同手搓衣物,带来手洗效果 \r\n手搓式技术,波轮与内桶反向旋转,产生的水流形状就如同手搓衣物 \r\n盆型大波轮专利结构,大波轮对水的带动力更强,同时凹进的盆型,减少衣物和波轮直接接触,降低了磨损率 \r\n智能控制,可根据衣物的重量及质量自动选择一种合适的程序 \r\n“自编程”洗衣机,用户可根据需要自行设定漂、脱次数,浸泡、洗涤、脱水时间 \r\n预约功能,方便实用 ', '3-19-2005');
INSERT INTO `product` VALUES ('26', '洗衣机系列', '海尔XQSB55', '5478', '0', 'images\\washing\\10.jpg', '暂无说明', '3-21-2005');
-- ----------------------------
-- Table structure for sub_type
-- ----------------------------
DROP TABLE IF EXISTS `sub_type`;
CREATE TABLE `sub_type` (
`s_id` int(11) NOT NULL AUTO_INCREMENT,
`s_supertype` int(11) NOT NULL,
`s_name` varchar(30) NOT NULL,
PRIMARY KEY (`s_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sub_type
-- ----------------------------
INSERT INTO `sub_type` VALUES ('1', '187', '海尔');
INSERT INTO `sub_type` VALUES ('2', '187', '松下');
INSERT INTO `sub_type` VALUES ('3', '187', '长虹');
INSERT INTO `sub_type` VALUES ('4', '187', '康佳');
INSERT INTO `sub_type` VALUES ('5', '187', '海信');
INSERT INTO `sub_type` VALUES ('6', '368', '好太太');
INSERT INTO `sub_type` VALUES ('7', '368', '爱妻');
INSERT INTO `sub_type` VALUES ('8', '368', '欧派');
INSERT INTO `sub_type` VALUES ('9', '368', '海尔');
-- ----------------------------
-- Table structure for sysdiagrams
-- ----------------------------
DROP TABLE IF EXISTS `sysdiagrams`;
CREATE TABLE `sysdiagrams` (
`name` varchar(128) DEFAULT NULL,
`principal_id` int(11) DEFAULT NULL,
`diagram_id` int(11) DEFAULT NULL,
`version` int(11) DEFAULT NULL,
`definition` longblob
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sysdiagrams
-- ----------------------------
| true |
d900160187ebf6d05ccef1e39866c1321b12396c | SQL | mundodron/arduino-bot-aurelio | /Querys/~eb8C0A.sql | UTF-8 | 495 | 2.625 | 3 | [] | no_license | select * from customer_id_acct_map where external_id = '899998500563'
select cmf.cust_state, cmf.bill_state from cmf where account_no = 8551415
select rowid, a.* from cmf a where account_no = 8551415
select SB.PARENT_ACCOUNT_NO, vl.*
from service_billing sb, equip_class_code_values vl
where sb.parent_account_no = 8551415
and VL.EQUIP_CLASS_CODE = SB.EQUIP_CLASS_CODE
and VL.LANGUAGE_CODE = 2
select * from local_address
select * from service_address_assoc
| true |
cb4bfaf57a0965d3bdd3ff8fea21a3abd4ddb998 | SQL | YurySS/oracle_dbd_plsql_basic | /2. blocks/1. block_types.sql | UTF-8 | 1,034 | 3.03125 | 3 | [] | no_license | /*
Курс: PL/SQL.Basic
Автор: Кивилев Д.С. (https://t.me/oracle_dbd, https://oracle-dbd.ru, https://www.youtube.com/c/OracleDBD)
Лекция 2. Блоки
Описание скрипта: примеры трех типов PL/SQL-блоков
*/
---- Пример 1. Неименованный блок
declare
v_str varchar2(20 char) := 'Hello world!';
begin
dbms_output.put_line(v_str);
end;
/
---- Пример 2. Именнованный блок на уровне схемы
create or replace procedure hello_world
is
v_str varchar2(20 char) := 'Hello world!';
begin
dbms_output.put_line(v_str);
end;
/
-- вызов процедуры
begin
hello_world();
end;
/
---- Пример 3. Именнованный внутри другого блока
declare
-- процедура внутри анонимного блока
procedure hello_world_inner
is
v_str varchar2(20 char) := 'Hello world!';
begin
dbms_output.put_line(v_str);
end;
begin
hello_world_inner();
end;
/
| true |
2dbe74183094d8128f70cc0f65911f2714a7c8b9 | SQL | Gonomic/Genealogy-backend | /GetPossibleFathersBasedOnAge.sql | UTF-8 | 602 | 3.890625 | 4 | [
"MIT"
] | permissive | DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `getPossibleFathersBasedOnAge`(IN `PersonAgeIn` DATE)
SQL SECURITY INVOKER
COMMENT 'To get the possible fathers of a person based on the persons bir'
BEGIN
SELECT DISTINCT
P.PersonID as PossibleFatherID,
concat(P.PersonGivvenName, ' ', P.PersonFamilyName) as PossibleFather
FROM persons P
WHERE P.PersonIsMale = true
AND YEAR(P.PersonDateOfBirth) < (YEAR(PersonAgeIn) - 15)
AND YEAR(P.PersonDateOfBirth) > (YEAR(PersonAgeIn) - 50)
ORDER BY P.PersonDateOfBirth;
END$$
DELIMITER ;
| true |
cea71908948d3b505485d6755cedc89f49e2b054 | SQL | CommerceRack/backend-static | /ebay/sql/database00.sql | UTF-8 | 2,753 | 3.203125 | 3 | [
"MIT"
] | permissive | DROP TABLE IF EXISTS `ebay_categories`;
CREATE TABLE `ebay_categories` (
`id` int(10) unsigned NOT NULL default '0',
`parent_id` int(10) unsigned NOT NULL default '0',
`level` tinyint(3) unsigned NOT NULL default '0',
`name` varchar(64) NOT NULL default '',
`leaf` tinyint(3) unsigned NOT NULL default '0',
`item_specifics_enabled` tinyint(3) unsigned NOT NULL default '0',
`catalog_enabled` tinyint(3) unsigned NOT NULL default '0',
`product_search_page_available` tinyint(3) unsigned NOT NULL default '0',
`site` tinyint(4) NOT NULL default '0',
UNIQUE KEY `id` (`id`),
KEY `parent_id` (`parent_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ebay_category_custom_specifics`;
CREATE TABLE `ebay_category_custom_specifics` (
`parent_id` int(10) unsigned NOT NULL default '0',
UNIQUE KEY `parent_id` (`parent_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ebay_category_2_cs`;
CREATE TABLE `ebay_category_2_cs` (
`category_id` int(10) unsigned NOT NULL default '0',
`attribute_set_id` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`category_id`, `attribute_set_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ebay_attribute_sets`;
CREATE TABLE `ebay_attribute_sets` (
`id` int(10) unsigned NOT NULL default '0',
`version` varchar(10) NOT NULL default '',
`name` varchar(64) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ebay_category_2_product_finder`;
CREATE TABLE `ebay_category_2_product_finder` (
`category_id` int(10) unsigned NOT NULL default '0',
`product_finder_id` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`category_id`, `product_finder_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ebay_product_finders`;
CREATE TABLE `ebay_product_finders` (
`id` int(10) unsigned NOT NULL default '0',
`buy_side` tinyint(3) unsigned NOT NULL default '0',
`data_present` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ebay_attribute_set_2_attribute`;
CREATE TABLE `ebay_attribute_set_2_attribute` (
`attribute_set_id` int(10) unsigned NOT NULL default '0',
`attribute_id` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`attribute_set_id`, `attribute_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `ebay_attributes`;
CREATE TABLE `ebay_attributes` (
`id` int(10) unsigned NOT NULL default '0',
`name` varchar(64) NOT NULL default '',
`display_sequence` int(10) unsigned NOT NULL default '0',
`visible` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
| true |
f05fdd425d8a3c9ee8b15eb97484f722a005c48b | SQL | taylor97data/LeetCode-SQL-Summary | /join/simple_join/1112. 每位学生的最高成绩.sql | UTF-8 | 185 | 3.171875 | 3 | [] | no_license | SELECT student_id,min(course_id) as course_id,grade
FROM enrollments
WHERE (student_id,grade)
in(SELECT student_id,max(grade)
FROM enrollments
GROUP BY student_id)
GROUP BY student_id
| true |
cb3dcc57b45c4636b5ca08c51b771a0d11d424e4 | SQL | JaneChengYiChen/SQLQuerySet | /view_BonusRateWithRelations.sql | UTF-8 | 9,107 | 3.484375 | 3 | [] | no_license | --sql server --
--view_BonusRateWithRelations
CREATE VIEW v_LS_mentoring_relation_ratios AS
WITH mentoring_line AS (
SELECT
man_code,
man_name,
man_tcode,
gd_code,
gd_name,
gd_tcode,
LV,
CASE WHEN LV = 1 THEN
POWER(cast(0.5 AS float),
init_split)
ELSE
POWER(cast(0.5 AS float),
gd_split_sum + init_split - gd_split)
END square,
N'單純輔導線' line_name,
NULL binding_man_code,
NULL binding_man_tcode,
0 DEPTH
FROM (
SELECT
*,
SUM(gd_split) OVER (PARTITION BY man_code ORDER BY LV) gd_split_sum
FROM (
SELECT
mt.Man_Code man_code,
md_man. [Name] man_name,
md_man.TCode man_tcode,
mt.GDCode gd_code,
md.name gd_name,
md.TCode gd_tcode,
mt.LV,
CASE WHEN tp.man_code IS NOT NULL THEN
1
ELSE
0
END init_split,
CASE WHEN tp_gd.man_code IS NOT NULL THEN
1
ELSE
0
END gd_split
FROM
pks_ManTree mt
LEFT JOIN v_LS_turning_points tp ON mt.Man_Code = tp.man_code
LEFT JOIN v_LS_turning_points tp_gd ON mt.GDCode = tp_gd.man_code
LEFT JOIN pks_MAN_Data md_man ON mt.Man_Code = md_man.Code
LEFT JOIN pks_MAN_Data md ON mt.GDCode = md.Code
WHERE
mt.SType = 1 -- 輔導線
) mentoring_line) mentoring_line_rate
),
cross_line AS (
SELECT
man_code,
man_name,
man_tcode,
gd_code,
gd_name,
gd_tcode,
LV,
CASE WHEN LV = 1 THEN
( CASE WHEN is_recommended = 0 THEN
POWER(cast(0.5 AS float),
init_split + man_depth + DEPTH - 1)
ELSE
POWER(cast(0.5 AS float),
( CASE WHEN is_recommended = 1
AND man_depth > 1 THEN
[DEPTH] + man_depth - 1
ELSE
[DEPTH]
END))
END)
ELSE
( CASE WHEN is_recommended = 0 THEN
POWER(cast(0.5 AS float),
[DEPTH] + man_depth + gd_split_sum - gd_split - is_not_turning_points)
ELSE
POWER(cast(0.5 AS float),
gd_split_sum - gd_split + ( CASE WHEN is_recommended = 1
AND man_depth > 1 THEN
[DEPTH] + man_depth - 1
ELSE
[DEPTH]
END))
END)
END square,
N'跨區/育成綜合輔導線' line_name,
binding_man_code,
binding_man_tcode,
DEPTH
FROM (
SELECT
*,
SUM(gd_split) OVER (PARTITION BY man_code,
binding_man_code,
[DEPTH] ORDER BY LV) gd_split_sum
FROM (
SELECT
a.*,
CASE WHEN tp.man_code IS NOT NULL THEN
1
ELSE
0
END init_split,
CASE WHEN tp_gd.man_code IS NOT NULL THEN
1
ELSE
0
END gd_split
FROM
v_LS_mentoring_cross_relations a
LEFT JOIN v_LS_turning_points tp ON a.man_code = tp.man_code
LEFT JOIN v_LS_turning_points tp_gd ON a.gd_code = tp_gd.man_code) cross_line) cross_line_rate
),
unionData AS (
SELECT
man_code
, man_name
, man_tcode
, vmr.fy_rate man_fy_rate
, vmr.sy_rate man_sy_rate
, vmr.continued_rate man_continued_rate
, vmr.year_end_rate man_year_end_rate
, vmr.service_rate man_service_rate
, gd_name
, gd_code
, gd_tcode
, vmr_gd.fy_rate gd_fy_rate
, vmr_gd.sy_rate gd_sy_rate
, vmr_gd.continued_rate gd_continued_rate
, vmr_gd.year_end_rate gd_year_end_rate
, vmr_gd.service_rate gd_service_rate
, LV
, square
, line_name
, isnull(binding_man_code, 0 ) binding_man_code
, isnull(binding_man_tcode, 0 ) binding_man_tcode
, vmr_binding.fy_rate binding_fy_rate
, vmr_binding.sy_rate binding_sy_rate
, vmr_binding.continued_rate binding_continued_rate
, vmr_binding.year_end_rate binding_year_end_rate
, vmr_binding.service_rate binding_service_rate
, DEPTH
FROM (
SELECT
*
FROM
mentoring_line
UNION ALL
SELECT
*
FROM
cross_line) a
left join v_commission_rates vmr on a.man_tcode = vmr.tcode
left join v_commission_rates vmr_gd on a.gd_tcode = vmr_gd.tcode
left join v_commission_rates vmr_binding on a.binding_man_tcode = vmr_binding.tcode
)
SELECT
a.man_code
, a.man_name
, a.man_tcode
, a.gd_code
, a.gd_name
, a.gd_tcode
, a.binding_man_code
, a.binding_man_tcode
, a.LV
, a.square
, a.line_name
, a.[DEPTH]
, -- FIRST YEAR RATE
CASE WHEN a.binding_man_code = 0
THEN
(
CASE WHEN a.LV = 1 THEN
(a.gd_fy_rate - a.man_fy_rate) / 100
ELSE
(a.gd_fy_rate - b.gd_fy_rate) /100
END)
ELSE
(
CASE WHEN a.LV = 1 THEN
(a.gd_fy_rate - a.binding_fy_rate) /100
ELSE
(a.gd_fy_rate - b.gd_fy_rate) /100
END)
END gd_diff_fy_rate
, -- SECOND YEAR RATE
CASE WHEN a.binding_man_code = 0
THEN
(
CASE WHEN a.LV = 1 THEN
(a.gd_sy_rate - a.man_sy_rate) / 100
ELSE
(a.gd_sy_rate - b.gd_sy_rate) /100
END)
ELSE
(
CASE WHEN a.LV = 1 THEN
(a.gd_sy_rate - a.binding_sy_rate) /100
ELSE
(a.gd_sy_rate - b.gd_sy_rate) /100
END)
END gd_diff_sy_rate
, -- CONTINUED RATE
CASE WHEN a.binding_man_code = 0
THEN
(
CASE WHEN a.LV = 1 THEN
(a.gd_continued_rate- a.man_continued_rate) / 100
ELSE
(a.gd_continued_rate - b.gd_continued_rate) /100
END)
ELSE
(
CASE WHEN a.LV = 1 THEN
(a.gd_continued_rate - a.binding_continued_rate) /100
ELSE
(a.gd_continued_rate - b.gd_continued_rate) /100
END)
END gd_diff_continued_rate
, -- YEAR END BONUS
CASE WHEN a.binding_man_code = 0
THEN
(
CASE WHEN a.LV = 1 THEN
(a.gd_year_end_rate- a.man_year_end_rate) / 100
ELSE
(a.gd_year_end_rate - b.gd_year_end_rate) /100
END)
ELSE
(
CASE WHEN a.LV = 1 THEN
(a.gd_year_end_rate - a.binding_year_end_rate) /100
ELSE
(a.gd_year_end_rate - b.gd_year_end_rate) /100
END)
END gd_diff_year_end_rate
, -- service_rate
CASE WHEN a.binding_man_code = 0
THEN
(
CASE WHEN a.LV = 1 THEN
(a.gd_service_rate- a.man_service_rate) / 100
ELSE
(a.gd_service_rate - b.gd_service_rate) /100
END)
ELSE
(
CASE WHEN a.LV = 1 THEN
(a.gd_service_rate - a.binding_service_rate) /100
ELSE
(a.gd_service_rate - b.gd_service_rate) /100
END)
END gd_diff_service_rate
FROM
unionData a
left join unionData b on a.man_code = b.man_code
and a.[DEPTH] = b.DEPTH
and a.binding_man_code = b.binding_man_code
and a.LV = b.LV+1 ; | true |
bf05ef015c155c9a1359ae4a8613518d2a5b3c74 | SQL | ameet2r/ParkingApplication | /parking.sql | UTF-8 | 2,015 | 4 | 4 | [] | no_license | -- Karanbir Toor and Ameet Toor
-- Create ParkingLot table and generate values.
DROP TABLE ParkingLot;
CREATE TABLE ParkingLot
(
lotName VARCHAR(100),
UNIQUE(lotName),
location VARCHAR(100),
capacity INT,
floors INT,
PRIMARY KEY(lotName)
);
INSERT INTO ParkingLot
VALUES('TestOne', 'Seattle', '100', '2'),
('TTwo', 'Tacoma', '5', '1');
-- Create ParkingSpace and generate values.
DROP TABLE ParkingSpace;
CREATE TABLE ParkingSpace
(
spaceNumber INT,
UNIQUE(spaceNumber),
monthlyRate DECIMAL(10,2) CHECK (monthlyRate >= 0),
lotName VARCHAR(100) REFERENCES ParkingLot(lotName),
taken BOOL,
PRIMARY KEY(spaceNumber)
);
INSERT INTO ParkingSpace
VALUES (1, 12.01, 'TestOne', FALSE),
(3, 1.00, 'TTwo', FALSE),
(2, 0, 'TTwo', FALSE),
(4, 0, 'TTwo', FALSE),
(5, 0, 'TTwo', FALSE),
(6, 0, 'TTwo', FALSE);
-- Create StaffSpace and generate values.
DROP TABLE StaffSpace;
CREATE TABLE StaffSpace
(
staffNumber INT REFERENCES Staff(staffNumber),
spaceNumber INT REFERENCES ParkingSpace(spaceNumber),
PRIMARY KEY(staffNumber, spaceNumber)
);
INSERT INTO StaffSpace
VALUES (123, 1),
(321, 3);
-- Create Staff and generate values.
DROP TABLE Staff;
CREATE TABLE Staff
(
staffNumber INT,
UNIQUE(staffNumber),
staffName VARCHAR(100),
telephoneExt VARCHAR(30), -- This is because we may lose leading 0's if it is an int.
vehicleLicenseNumber VARCHAR(100),
PRIMARY KEY(staffNumber)
);
INSERT INTO Staff
VALUES (123, 'karan', '2221118888', '123icense'),
(321, 'Ameet', '1112223333', '321lincense');
-- Create SpaceBooking and generate values.
DROP TABLE SpaceBooking;
CREATE TABLE SpaceBooking
(
bookingId INT,
UNIQUE(bookingId),
spaceNumber INT REFERENCES ParkingSpace(spaceNumber),
staffNumber INT REFERENCES Staff(staffNumber),
visitorLicense VARCHAR(30),
dateOfVisit DATE CHECK (dateOfVisit >= CURDATE),
PRIMARY KEY(bookingId)
);
INSERT INTO SpaceBooking
VALUES (3, 1, 123, '123visitorLic', '02-03-18'),
(2, 3, 321, '321visitorLic', '03-03-17');
| true |
8fb851e479f29ddb63bfa84f6b18e55fcc077f5b | SQL | ArmandoNCM/SanMartinMS | /Implementation/Database/DDL Scripts/DatabaseConstraints.sql | UTF-8 | 536 | 3.265625 | 3 | [] | no_license | ALTER TABLE DISPATCH
ADD CONSTRAINT FK_DISPATCH
FOREIGN KEY (OWNER)
REFERENCES CLIENT (NIT);
ALTER TABLE INVOICE
ADD CONSTRAINT FK_INVOICE
FOREIGN KEY (CLIENT)
REFERENCES CLIENT (NIT);
ALTER TABLE ITEM_PRICE
ADD CONSTRAINT FK_ITEM_PRICE
FOREIGN KEY (ITEM)
REFERENCES ITEM (ITEM_CODE);
ALTER TABLE ORDER_DETAIL
ADD CONSTRAINT FK_ORDER_TO_INVOICE
FOREIGN KEY (INVOICE)
REFERENCES INVOICE (SERIAL_NUMBER);
ALTER TABLE ORDER_DETAIL
ADD CONSTRAINT FK_ORDER_TO_ITEM
FOREIGN KEY (DETAIL_ITEM)
REFERENCES ITEM (ITEM_CODE);
| true |
aef6a0d637682682ecbd582ba6f2166d923fbacb | SQL | sinerger/HR_Application | /HR_Application_DB/Stored Procedures/Base/Comments/UpdateComment.sql | UTF-8 | 338 | 3 | 3 | [] | no_license | CREATE PROCEDURE [HRAppDB].[UpdateComment]
@ID int,
@EmployeeID int,
@Information nvarchar (255),
@Date nvarchar (255)
AS
Update [HRAppDB].[Comments]
SET [HRAppDB].[Comments].EmployeeID = @EmployeeID,
[HRAppDB].[Comments].Information = @Information,
[HRAppDB].[Comments].[Date] = @Date
Where [HRAppDB].[Comments].ID = @ID
| true |
3f914f54aaf67c019701cdbd38b0b81bed78f878 | SQL | edigonzales-archiv/landuseplans_extract_light | /src/main/resources/queries.sql | UTF-8 | 12,150 | 3.671875 | 4 | [
"MIT"
] | permissive | /*
WITH parcel AS (
SELECT
flaechenmass AS area,
geometrie AS geometry
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
egrid = 'CH970687433258'
)
SELECT
foo.t_id,
'NoiseSensitivityLevels' AS theme,
'Lärmempfindlichkeitsstufen (in Nutzungszonen)' AS subtheme,
substring(foo.typ_kt FROM 1 FOR 4) AS typecode,
'inForce' AS lawstatuscode,
foo.typ_bezeichnung AS information,
ST_Area(foo.geom) AS areashare,
area AS parcelarea
FROM
(
SELECT
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
ST_Union(geom) AS geom,
area
FROM
(
SELECT
ueberlagerndeFestlegung.t_id,
ueberlagerndeFestlegung.typ_kt,
ueberlagerndeFestlegung.typ_code_kommunal,
ueberlagerndeFestlegung.typ_bezeichnung,
(ST_Dump(ST_CollectionExtract(ST_Intersection(parcel.geometry, ueberlagerndeFestlegung.geometrie), 3))).geom,
area
FROM
parcel
INNER JOIN arp_npl_pub.nutzungsplanung_ueberlagernd_flaeche AS ueberlagerndeFestlegung
ON ST_Intersects(parcel.geometry, ueberlagerndeFestlegung.geometrie)
) AS bar
GROUP BY
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
area
) AS foo
WHERE
substring(foo.typ_kt FROM 1 FOR 4) IN ('N680','N681','N682','N683','N684','N685','N686')
WHERE
ST_Length(foo.geom) > 0.5
ORDER BY
foo.typ_kt
;
*/
/*
WITH parcel AS (
SELECT
flaechenmass AS area,
geometrie AS geometry
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
egrid = 'CH970687433258'
)
SELECT
foo.t_id,
'LandUsePlans' AS theme,
'Erschliessung (Punktobjekte)' AS subtheme,
substring(foo.typ_kt FROM 1 FOR 4) AS typecode,
'inForce' AS lawstatuscode,
foo.typ_bezeichnung AS information,
nrofpoints,
area AS parcelarea,
geometrytype(foo.geom)
FROM
(
SELECT
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
geom,
count(geom) AS nrofpoints,
area
FROM
(
SELECT
erschliessungPunktobjekt.t_id,
erschliessungPunktobjekt.typ_kt,
erschliessungPunktobjekt.typ_code_kommunal,
erschliessungPunktobjekt.typ_bezeichnung,
ST_Intersection(parcel.geometry, erschliessungPunktobjekt.geometrie) AS geom,
area
FROM
parcel
INNER JOIN arp_npl_pub.nutzungsplanung_erschliessung_punktobjekt AS erschliessungPunktobjekt
ON ST_Intersects(parcel.geometry, erschliessungPunktobjekt.geometrie)
) AS bar
GROUP BY
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
bar.geom,
area
) AS foo
ORDER BY
foo.typ_kt
;
*/
/*
WITH parcel AS (
SELECT
flaechenmass AS area,
geometrie AS geometry
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
egrid = 'CH908806533280'
)
SELECT
foo.t_id,
'LandUsePlans' AS theme,
'Erschliessung (Linienobjekt)' AS subtheme,
substring(foo.typ_kt FROM 1 FOR 4) AS typecode,
'inForce' AS lawstatuscode,
foo.typ_bezeichnung AS information,
ST_Length(foo.geom) AS lengthshare,
area AS parcelarea,
geometrytype(foo.geom)
FROM
(
SELECT
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
ST_Union(geom) AS geom,
area
FROM
(
SELECT
erschliessungLinienobjekt.t_id,
erschliessungLinienobjekt.typ_kt,
erschliessungLinienobjekt.typ_code_kommunal,
erschliessungLinienobjekt.typ_bezeichnung,
(ST_Dump(ST_CollectionExtract(ST_Intersection(parcel.geometry, erschliessungLinienobjekt.geometrie), 2))).geom,
area
FROM
parcel
INNER JOIN arp_npl_pub.nutzungsplanung_erschliessung_linienobjekt AS erschliessungLinienobjekt
ON ST_Intersects(parcel.geometry, erschliessungLinienobjekt.geometrie)
) AS bar
GROUP BY
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
area
) AS foo
WHERE
ST_Length(foo.geom) > 0.5
ORDER BY
foo.typ_kt
;
*/
/*
WITH parcel AS (
SELECT
flaechenmass AS area,
geometrie AS geometry
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
egrid = 'CH233287066989'
)
SELECT
foo.t_id,
'LandUsePlans' AS theme,
'Erschliessung (Flächenobjekte)' AS subtheme,
substring(foo.typ_kt FROM 1 FOR 4) AS typecode,
'inForce' AS lawstatuscode,
foo.typ_bezeichnung AS information,
ST_Area(foo.geom) AS areashare,
area
FROM
(
SELECT
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
ST_Union(geom) AS geom,
area
FROM
(
SELECT
erschliessungFlaechenobjekt.t_id,
erschliessungFlaechenobjekt.typ_kt,
erschliessungFlaechenobjekt.typ_code_kommunal,
erschliessungFlaechenobjekt.typ_bezeichnung,
(ST_Dump(ST_CollectionExtract(ST_Intersection(parcel.geometry, erschliessungFlaechenobjekt.geometrie), 3))).geom,
area
FROM
parcel
INNER JOIN arp_npl_pub.nutzungsplanung_erschliessung_flaechenobjekt AS erschliessungFlaechenobjekt
ON ST_Intersects(parcel.geometry, erschliessungFlaechenobjekt.geometrie)
) AS bar
GROUP BY
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
area
) AS foo
WHERE
ST_Area(foo.geom) > 0.5
ORDER BY
foo.typ_kt
;
*/
/*
WITH parcel AS (
SELECT
flaechenmass AS area,
geometrie AS geometry
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
egrid = 'CH328910320651'
)
SELECT
foo.t_id,
'LandUsePlans' AS theme,
'Objektbezogene Festlegung' AS subtheme,
substring(foo.typ_kt FROM 1 FOR 4) AS typecode,
'inForce' AS lawstatuscode,
foo.typ_bezeichnung AS information,
nrofpoints,
area AS parcelarea,
geometrytype(foo.geom)
FROM
(
SELECT
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
geom,
count(geom) AS nrofpoints,
area
FROM
(
SELECT
objektbezogeneFestlegung.t_id,
objektbezogeneFestlegung.typ_kt,
objektbezogeneFestlegung.typ_code_kommunal,
objektbezogeneFestlegung.typ_bezeichnung,
ST_Intersection(parcel.geometry, objektbezogeneFestlegung.geometrie) AS geom,
area
FROM
parcel
INNER JOIN arp_npl_pub.nutzungsplanung_ueberlagernd_punkt AS objektbezogeneFestlegung
ON ST_Intersects(parcel.geometry, objektbezogeneFestlegung.geometrie)
) AS bar
GROUP BY
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
bar.geom,
area
) AS foo
ORDER BY
foo.typ_kt
;
*/
/*
WITH parcel AS (
SELECT
flaechenmass AS area,
geometrie AS geometry
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
egrid = 'CH908806773208'
)
SELECT
foo.t_id,
'LandUsePlans' AS theme,
'Linienbezogene Festlegung' AS subtheme,
substring(foo.typ_kt FROM 1 FOR 4) AS typecode,
'inForce' AS lawstatuscode,
foo.typ_bezeichnung AS information,
ST_Length(foo.geom) AS lengthshare,
area AS parcelarea,
geometrytype(foo.geom)
FROM
(
SELECT
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
ST_Union(geom) AS geom,
area
FROM
(
SELECT
linienbezogeneFestlegung.t_id,
linienbezogeneFestlegung.typ_kt,
linienbezogeneFestlegung.typ_code_kommunal,
linienbezogeneFestlegung.typ_bezeichnung,
(ST_Dump(ST_CollectionExtract(ST_Intersection(parcel.geometry, linienbezogeneFestlegung.geometrie), 2))).geom,
area
FROM
parcel
INNER JOIN arp_npl_pub.nutzungsplanung_ueberlagernd_linie AS linienbezogeneFestlegung
ON ST_Intersects(parcel.geometry, linienbezogeneFestlegung.geometrie)
) AS bar
GROUP BY
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
area
) AS foo
WHERE
ST_Length(foo.geom) > 0.5
ORDER BY
foo.typ_kt
;
*/
/*
WITH parcel AS (
SELECT
flaechenmass AS area,
geometrie AS geometry
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
egrid = 'CH669932068034'
)
SELECT
foo.t_id,
'LandUsePlans' AS theme,
'Überlagernde Festlegung' AS subtheme,
substring(foo.typ_kt FROM 1 FOR 4) AS typecode,
'inForce' AS lawstatuscode,
foo.typ_bezeichnung AS information,
ST_Area(foo.geom) AS areashare,
area AS parcelarea
FROM
(
SELECT
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
ST_Union(geom) AS geom,
area
FROM
(
SELECT
ueberlagerndeFestlegung.t_id,
ueberlagerndeFestlegung.typ_kt,
ueberlagerndeFestlegung.typ_code_kommunal,
ueberlagerndeFestlegung.typ_bezeichnung,
(ST_Dump(ST_CollectionExtract(ST_Intersection(parcel.geometry, ueberlagerndeFestlegung.geometrie), 3))).geom,
area
FROM
parcel
INNER JOIN arp_npl_pub.nutzungsplanung_ueberlagernd_flaeche AS ueberlagerndeFestlegung
ON ST_Intersects(parcel.geometry, ueberlagerndeFestlegung.geometrie)
) AS bar
GROUP BY
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
area
) AS foo
WHERE
substring(foo.typ_kt FROM 1 FOR 4) NOT IN ('N680','N681','N682','N683','N684','N685','N686')
AND
ST_Area(foo.geom) > 0.5
ORDER BY
foo.typ_kt
;
*/
/*
WITH parcel AS (
SELECT
flaechenmass AS area,
geometrie AS geometry
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
egrid = 'CH987632068201'
)
SELECT
foo.t_id,
'LandUsePlans' AS theme,
'Grundnutzung' AS subtheme,
substring(foo.typ_kt FROM 1 FOR 4) AS typecode,
'inForce' AS lawstatuscode,
foo.typ_bezeichnung AS information,
ST_Area(foo.geom) AS areashare,
area
FROM
(
SELECT
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
ST_Union(geom) AS geom,
area
FROM
(
SELECT
grundnutzung.t_id,
grundnutzung.typ_kt,
grundnutzung.typ_code_kommunal,
grundnutzung.typ_bezeichnung,
(ST_Dump(ST_CollectionExtract(ST_Intersection(parcel.geometry, grundnutzung.geometrie), 3))).geom,
area
FROM
parcel
INNER JOIN arp_npl_pub.nutzungsplanung_grundnutzung AS grundnutzung
ON ST_Intersects(parcel.geometry, grundnutzung.geometrie)
) AS bar
GROUP BY
bar.t_id,
bar.typ_kt,
bar.typ_code_kommunal,
bar.typ_bezeichnung,
area
) AS foo
WHERE
ST_Area(foo.geom) > 0.5
ORDER BY
foo.typ_kt
;
*/
--16503
/*
WITH docs AS
(
SELECT
json_array_elements(dok_id::json) AS obj,
dok_id::json
FROM
arp_npl_pub.nutzungsplanung_grundnutzung
WHERE
t_id = 15130
UNION ALL
SELECT
json_array_elements(dok_id::json) AS obj,
dok_id::json
FROM
arp_npl_pub.nutzungsplanung_ueberlagernd_flaeche
WHERE
t_id = 15130
UNION ALL
SELECT
json_array_elements(dok_id::json) AS obj,
dok_id::json
FROM
arp_npl_pub.nutzungsplanung_ueberlagernd_linie
WHERE
t_id = 15130
UNION ALL
SELECT
json_array_elements(dok_id::json) AS obj,
dok_id::json
FROM
arp_npl_pub.nutzungsplanung_ueberlagernd_punkt
WHERE
t_id = 15130
UNION ALL
SELECT
json_array_elements(dok_id::json) AS obj,
dok_id::json
FROM
arp_npl_pub.nutzungsplanung_erschliessung_flaechenobjekt
WHERE
t_id = 15130
UNION ALL
SELECT
json_array_elements(dok_id::json) AS obj,
dok_id::json
FROM
arp_npl_pub.nutzungsplanung_erschliessung_linienobjekt
WHERE
t_id = 15130
UNION ALL
SELECT
json_array_elements(dok_id::json) AS obj,
dok_id::json
FROM
arp_npl_pub.nutzungsplanung_erschliessung_punktobjekt
WHERE
t_id = 15130
)
SELECT
obj->>'titel' AS title,
obj->>'offiziellertitel' AS officialtitle,
obj->>'abkuerzung' AS abbreviation,
obj->>'offiziellenr' AS officialnumber,
CAST(obj->>'gemeinde' AS integer) AS municipality,
obj->>'publiziertab' AS publishedat,
'inForce' AS lawstatuscode,
obj->>'textimweb_absolut' AS textatweb,
'LegalProvision' AS documenttype
FROM
docs
;
*/
--CH987632068201
/*
SELECT
t_id,
nummer AS number,
CASE
WHEN egrid IS NULL THEN 'CH-DUMMY'
ELSE egrid
END AS egrid,
nbident AS identdn,
'valid' AS validitytype,
'RealEstate' AS realestatetype
FROM
agi_mopublic_pub.mopublic_grundstueck
WHERE
art = 0
AND
ST_Intersects(ST_SetSRID(ST_MakePoint(:easting, :northing), 2056), geometrie)
;
*/
| true |
c83f56f5a2668e186ce2666b4c0bf1b20817a5e9 | SQL | bomethis/leetcode | /swap_salary.sql | UTF-8 | 108 | 2.71875 | 3 | [] | no_license | UPDATE salary
SET sex = Case
When sex = 'm' Then 'f'
When sex = 'f' then 'm'
End
Where sex ='f' or sex ='m'
| true |
db0c6a7198b1924f325bb07ca9709583d30af5f3 | SQL | SolarHalo/iiiviviko | /createtable.sql | UTF-8 | 4,525 | 3.09375 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : iiivivi
Source Server Version : 50148
Source Host : hdm-059.hichina.com:3306
Source Database : hdm0590365_db
Target Server Type : MYSQL
Target Server Version : 50148
File Encoding : 65001
Date: 2012-12-14 11:32:06
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `category`
-- ----------------------------
DROP TABLE IF EXISTS `category`;
CREATE TABLE `category` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`desc` varchar(255) DEFAULT NULL,
`rank` int(11) DEFAULT NULL,
`link` varchar(255) DEFAULT NULL,
`img` varchar(255) DEFAULT NULL,
`pid` int(8) DEFAULT NULL,
`menu` int(1) unsigned zerofill DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
-- ----------------------------
-- Records of category
-- ----------------------------
-- ----------------------------
-- Table structure for `pages`
-- ----------------------------
DROP TABLE IF EXISTS `pages`;
CREATE TABLE `pages` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`pid` int(8) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`imgbig` varchar(255) DEFAULT NULL,
`imgsmall` varchar(255) DEFAULT NULL,
`createtime` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
-- ----------------------------
-- Records of pages
-- ----------------------------
-- ----------------------------
-- Table structure for `storeaddress`
-- ----------------------------
DROP TABLE IF EXISTS `storeaddress`;
CREATE TABLE `storeaddress` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`area` varchar(255) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
-- ----------------------------
-- Records of storeaddress
-- ----------------------------
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (1, 'COLLECTION', NULL, 1, NULL, NULL, NULL, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (2, 'LOOKBOOK', NULL, 2, NULL, NULL, NULL, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (3, 'DESIGN BY III VIVINIKO', NULL, 3, NULL, NULL, NULL, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (4, 'EXHIBITION', NULL, 4, '/imagelist.php', NULL, NULL, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (5, 'ACTIVITY', NULL, 5, '/activity.php', NULL, NULL, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (6, 'STORE', NULL, 6, NULL, NULL, NULL, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (7, 'ABOUT US', NULL, 7, '/aboutus.php', NULL, NULL, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (8, 'WORK', NULL, 8, '/work.php', NULL, NULL, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (9, '2012AW', NULL, 9, '/contentlist.php', NULL, 1, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (10, '2012AW', NULL, 10, '/contentlist.php', NULL, 2, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (11, '2012SS', NULL, 11, '/contentlist.php', NULL, 2, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (12, '2011AW', NULL, 12, '/contentlist.php', NULL, 2, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (13, '2011SS', NULL, 13, '/contentlist.php', NULL, 2, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (14, 'III VIVINIKO LETTER', NULL, 14, '/contentlist.php', NULL, 3, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (15, 'ACC', NULL, 15, '/imagelist.php', NULL, 3, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (16, 'STORE IMAGE', NULL, 16, '/contentlist.php', NULL, 6, 1);
INSERT INTO `category` (`id`, `name`, `desc`, `rank`, `link`, `img`, `pid`, `menu`) VALUES (17, 'STORE LOCATION', NULL, 17, '/storeslocation.php', NULL, 6, 1);
| true |
0cb4bd150d6c0ffdfa8d0c3f6a6defe4fa17595c | SQL | luchomarfil/tallerJava | /t/src/ar/edu/unlp/hermes2/resources/hermes.schema.sql | UTF-8 | 1,435 | 3.25 | 3 | [] | no_license | PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE "Hermes.Ninios" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"nombre" TEXT NOT NULL,
"apellido" TEXT NULL
);
CREATE TABLE "Hermes.Contextos" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"nombre" TEXT NOT NULL,
"descripcion" TEXT
);
CREATE TABLE "Hermes.Categorias" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"nombre" TEXT NOT NULL
);
CREATE TABLE "Hermes.Categorias.Contextos" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"idContexto" INTEGER NOT NULL,
"idCategoria" INTEGER NOT NULL
);
CREATE TABLE "Hermes.Etiquetas" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"nombre" TEXT NOT NULL,
"descripcion" TEXT DEFAULT ('Sin descripción'),
"idTerapeuta" INTEGER NOT NULL DEFAULT (0)
);
CREATE TABLE "Hermes.Notificaciones" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"idCategoria" INTEGER,
"idContexto" INTEGER,
"idNinio" INTEGER,
"idMensaje" TEXT,
"fecha" TEXT,
"fechaEnviado" TEXT,
"fechaRecibido" TEXT
);
CREATE TABLE "Hermes.Mensajes" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"nombre" TEXT,
"descripcion" TEXT,
"imagen" TEXT
);
CREATE TABLE "Hermes.Notificaciones.Etiquetas" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"idNotificacion" INTEGER NOT NULL,
"idEtiqueta" INTEGER NOT NULL
);
COMMIT;
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.