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
9e303d377eedfa8373fcf92462a29b77d5c9bb49
SQL
EthanLMartin/Bookish
/Scripts/BookishSchema.sql
UTF-8
523
3.265625
3
[]
no_license
DROP DATABASE IF EXISTS bookish; CREATE DATABASE bookish; USE bookish; CREATE TABLE Books ( ISBN CHAR(13) NOT NULL PRIMARY KEY, title VARCHAR(80), author VARCHAR(255) ); CREATE TABLE BookCopies ( barcode INT IDENTITY(1, 1) PRIMARY KEY, ISBN CHAR(13) NOT NULL FOREIGN KEY REFERENCES Books(ISBN), borrowed BIT NOT NULL ); CREATE TABLE Loans ( barcode INT FOREIGN KEY REFERENCES BookCopies(barcode), userId VARCHAR(30) NOT NULL, dueDate DATE, completed BIT NOT NULL ); USE master;
true
776190fe44d0c89cd4feeeca7008466842299035
SQL
veyisTurgut/cmpe321-p1-sqlQueries
/q8.sql
UTF-8
1,369
4.1875
4
[]
no_license
SELECT T.team_id, T.short_name, T.full_name, ROUND(sumx,3) /*display up to three precision*/ as total_driven FROM (SELECT team, SUM(clim*total_laps*1.0/1000)/*convert length of the circut to km's*/ as sumx FROM Drivers, Tracks WHERE country_of_birth != 'England' /* drivers who are not born in England */ AND lap_recorder = driver_id /* considering only the drivers of the team who hold a lap record in any track */ GROUP BY team HAVING sumx >= 500 /* only the teams that have driven at least 500 KMs in total */ ORDER BY sumx/*in ascending order with respect to driven total*/) D INNER JOIN Teams T ON D.team = T.team_id /* join the D table which we retrieved from subquery and Teams table*/ /*General idea: First create a table D such that D has the teams that driven at least 500KMs and their total driven lengths. While constructing D we do not use Teams table, instead we infer teams' name from drivers by grouping them with respect to their teams and summing up their driven totals. After we get D, we join D with Teams table so that we can reach other details of these teams. Finally we round total driven to 3 preciison so that we can be consistent with outputs.*/
true
491659587863a2d56e1b59adbcf577e321de694b
SQL
AntonyGlim/gb_10_Database_Basic_course
/db/lesson1/Lesson1Dump20190602/geodata_languages.sql
UTF-8
3,217
2.984375
3
[]
no_license
-- MySQL dump 10.13 Distrib 5.7.26, for Linux (x86_64) -- -- Host: 192.168.0.41 Database: geodata -- ------------------------------------------------------ -- Server version 8.0.13 /*!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 `languages` -- DROP TABLE IF EXISTS `languages`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `languages` ( `idlanguages` int(10) unsigned NOT NULL AUTO_INCREMENT, `languagescol` varchar(32) NOT NULL, PRIMARY KEY (`idlanguages`) ) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `languages` -- LOCK TABLES `languages` WRITE; /*!40000 ALTER TABLE `languages` DISABLE KEYS */; INSERT INTO `languages` VALUES (1,'Азербайджанский'),(2,'Албанский'),(3,'Английский'),(4,'Армянский'),(5,'Белорусский'),(6,'Болгарский'),(7,'Боснийски'),(8,'Венгерский'),(9,'Греческий'),(10,'Грузинский'),(11,'Датский'),(12,'Ирландский'),(13,'Исландский'),(14,'Испанский'),(15,'Итальянский'),(16,'Казахский'),(17,'Каталанский'),(18,'Латинский'),(19,'Латышский'),(20,'Литовский'),(21,'Люксембургский'),(22,'Македонский'),(23,'Мальтийский'),(24,'Молдавский'),(25,'Мэнский'),(26,'Немецкий'),(27,'Нидерландский'),(28,'Норвежский'),(29,'Польский'),(30,'Португальский'),(31,'Ретороманский'),(32,'Румынский'),(33,'Русский'),(34,'Сербский'),(35,'Словацкий'),(36,'Словенский'),(37,'Турецкий'),(38,'Украинский'),(39,'Фарерский'),(40,'Финский'),(41,'Французский'),(42,'Хорватский'),(43,'Черногорский'),(44,'Чешский'),(45,'Шведский'),(46,'Эстонский'); /*!40000 ALTER TABLE `languages` 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 2019-06-02 9:40:54
true
8ee80e9edb25227888299977790d53b513e78e86
SQL
tiagoviniciuslopes/ES1-trab1
/documentacao/ScriptInicial.sql
UTF-8
10,167
3.140625
3
[]
no_license
-- MySQL Script generated by MySQL Workbench -- Wed May 8 00:01:07 2019 -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- -- Schema mydb -- ----------------------------------------------------- -- ----------------------------------------------------- -- Schema mydb -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ; USE `mydb` ; -- ----------------------------------------------------- -- Table `mydb`.`Estado` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Estado` ( `idEstado` INT NOT NULL AUTO_INCREMENT, `nome` VARCHAR(45) NOT NULL, PRIMARY KEY (`idEstado`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Cidade` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Cidade` ( `idCidade` INT NOT NULL AUTO_INCREMENT, `nome` VARCHAR(45) NOT NULL, `Estado_idEstado` INT NOT NULL, PRIMARY KEY (`idCidade`), INDEX `fk_Cidade_Estado_idx` (`Estado_idEstado` ASC), CONSTRAINT `fk_Cidade_Estado` FOREIGN KEY (`Estado_idEstado`) REFERENCES `mydb`.`Estado` (`idEstado`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Rua` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Rua` ( `idRua` INT NOT NULL AUTO_INCREMENT, `nome` VARCHAR(45) NOT NULL, PRIMARY KEY (`idRua`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Bairro` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Bairro` ( `idBairro` INT NOT NULL AUTO_INCREMENT, `nome` VARCHAR(45) NOT NULL, PRIMARY KEY (`idBairro`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Endereco` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Endereco` ( `idEndereco` INT NOT NULL, `cep` VARCHAR(45) NOT NULL, `Cidade_idCidade` INT NOT NULL, `Bairro_idBairro` INT NOT NULL, `Rua_idRua` INT NOT NULL, PRIMARY KEY (`idEndereco`), INDEX `fk_Endereco_Cidade1_idx` (`Cidade_idCidade` ASC), INDEX `fk_Endereco_Bairro1_idx` (`Bairro_idBairro` ASC), INDEX `fk_Endereco_Rua1_idx` (`Rua_idRua` ASC), CONSTRAINT `fk_Endereco_Cidade1` FOREIGN KEY (`Cidade_idCidade`) REFERENCES `mydb`.`Cidade` (`idCidade`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Endereco_Bairro1` FOREIGN KEY (`Bairro_idBairro`) REFERENCES `mydb`.`Bairro` (`idBairro`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Endereco_Rua1` FOREIGN KEY (`Rua_idRua`) REFERENCES `mydb`.`Rua` (`idRua`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`TipoUsuario` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`TipoUsuario` ( `idTipoUsuario` INT NOT NULL AUTO_INCREMENT, `tipo` VARCHAR(45) NOT NULL, PRIMARY KEY (`idTipoUsuario`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Pessoa` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Pessoa` ( `idPessoa` INT NOT NULL AUTO_INCREMENT, `nome` VARCHAR(45) NOT NULL, `cpf` VARCHAR(45) NOT NULL, `rg` VARCHAR(45) NOT NULL, `senha` VARCHAR(45) NOT NULL, `numero` VARCHAR(45) NOT NULL, `complemento` TEXT NULL, `Endereco_idEndereco` INT NOT NULL, `TipoUsuario_idTipoUsuario` INT NOT NULL, PRIMARY KEY (`idPessoa`), INDEX `fk_Cliente_Endereco1_idx` (`Endereco_idEndereco` ASC), INDEX `fk_Pessoa_TipoUsuario1_idx` (`TipoUsuario_idTipoUsuario` ASC), CONSTRAINT `fk_Cliente_Endereco1` FOREIGN KEY (`Endereco_idEndereco`) REFERENCES `mydb`.`Endereco` (`idEndereco`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Pessoa_TipoUsuario1` FOREIGN KEY (`TipoUsuario_idTipoUsuario`) REFERENCES `mydb`.`TipoUsuario` (`idTipoUsuario`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Telefone` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Telefone` ( `idTelefone` INT NOT NULL AUTO_INCREMENT, `numero` VARCHAR(45) NOT NULL, `Pessoa_idPessoa` INT NOT NULL, PRIMARY KEY (`idTelefone`), INDEX `fk_Telefone_Cliente1_idx` (`Pessoa_idPessoa` ASC), CONSTRAINT `fk_Telefone_Cliente1` FOREIGN KEY (`Pessoa_idPessoa`) REFERENCES `mydb`.`Pessoa` (`idPessoa`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Email` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Email` ( `idEmail` INT NOT NULL AUTO_INCREMENT, `email` VARCHAR(45) NOT NULL, `Pessoa_idPessoa` INT NOT NULL, PRIMARY KEY (`idEmail`), INDEX `fk_Email_Cliente1_idx` (`Pessoa_idPessoa` ASC), CONSTRAINT `fk_Email_Cliente1` FOREIGN KEY (`Pessoa_idPessoa`) REFERENCES `mydb`.`Pessoa` (`idPessoa`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Veiculo` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Veiculo` ( `idVeiculo` INT NOT NULL AUTO_INCREMENT, `placa` VARCHAR(45) NOT NULL, `modelo` VARCHAR(45) NOT NULL, `numeroChassi` VARCHAR(45) NOT NULL, `marca` VARCHAR(45) NOT NULL, `cor` VARCHAR(45) NULL, `Pessoa_idPessoa` INT NOT NULL, PRIMARY KEY (`idVeiculo`), INDEX `fk_Veiculo_Cliente1_idx` (`Pessoa_idPessoa` ASC), CONSTRAINT `fk_Veiculo_Cliente1` FOREIGN KEY (`Pessoa_idPessoa`) REFERENCES `mydb`.`Pessoa` (`idPessoa`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Etapa` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Etapa` ( `idEtapa` INT NOT NULL AUTO_INCREMENT, `etapa` VARCHAR(45) NOT NULL, PRIMARY KEY (`idEtapa`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`OrdemServico` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`OrdemServico` ( `idOrdemServico` INT NOT NULL AUTO_INCREMENT, `data` DATETIME NOT NULL, `Etapa_idEtapa` INT NOT NULL, `Veiculo_idVeiculo` INT NOT NULL, PRIMARY KEY (`idOrdemServico`), INDEX `fk_OrdemServico_Etapa1_idx` (`Etapa_idEtapa` ASC), INDEX `fk_OrdemServico_Veiculo1_idx` (`Veiculo_idVeiculo` ASC), CONSTRAINT `fk_OrdemServico_Etapa1` FOREIGN KEY (`Etapa_idEtapa`) REFERENCES `mydb`.`Etapa` (`idEtapa`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_OrdemServico_Veiculo1` FOREIGN KEY (`Veiculo_idVeiculo`) REFERENCES `mydb`.`Veiculo` (`idVeiculo`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Servico` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Servico` ( `idServico` INT NOT NULL, `nome` VARCHAR(45) NOT NULL, `preco` FLOAT NOT NULL, `horas` FLOAT NOT NULL, PRIMARY KEY (`idServico`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`Peca` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Peca` ( `idPeca` INT NOT NULL AUTO_INCREMENT, `nome` VARCHAR(45) NOT NULL, `preco` FLOAT NOT NULL, `marca` VARCHAR(45) NOT NULL, PRIMARY KEY (`idPeca`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`ServicoOrdemServico` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`ServicoOrdemServico` ( `Servico_idServico` INT NOT NULL, `OrdemServico_idOrdemServico` INT NOT NULL, PRIMARY KEY (`Servico_idServico`, `OrdemServico_idOrdemServico`), INDEX `fk_Servico_has_OrdemServico_OrdemServico1_idx` (`OrdemServico_idOrdemServico` ASC), INDEX `fk_Servico_has_OrdemServico_Servico1_idx` (`Servico_idServico` ASC), CONSTRAINT `fk_Servico_has_OrdemServico_Servico1` FOREIGN KEY (`Servico_idServico`) REFERENCES `mydb`.`Servico` (`idServico`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Servico_has_OrdemServico_OrdemServico1` FOREIGN KEY (`OrdemServico_idOrdemServico`) REFERENCES `mydb`.`OrdemServico` (`idOrdemServico`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`PecaOrdemServico` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`PecaOrdemServico` ( `Peca_idPeca` INT NOT NULL, `OrdemServico_idOrdemServico` INT NOT NULL, PRIMARY KEY (`Peca_idPeca`, `OrdemServico_idOrdemServico`), INDEX `fk_Peca_has_OrdemServico_OrdemServico1_idx` (`OrdemServico_idOrdemServico` ASC), INDEX `fk_Peca_has_OrdemServico_Peca1_idx` (`Peca_idPeca` ASC), CONSTRAINT `fk_Peca_has_OrdemServico_Peca1` FOREIGN KEY (`Peca_idPeca`) REFERENCES `mydb`.`Peca` (`idPeca`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Peca_has_OrdemServico_OrdemServico1` FOREIGN KEY (`OrdemServico_idOrdemServico`) REFERENCES `mydb`.`OrdemServico` (`idOrdemServico`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
true
75b88f0ffcb8495f328b797da5447ae01962194b
SQL
streamline-wkp/gcd-web-services
/mysql/database.sql
UTF-8
501
2.890625
3
[ "Apache-2.0" ]
permissive
CREATE DATABASE `GCD_TEST` /*!40100 DEFAULT CHARACTER SET utf8 */; CREATE TABLE `GCD_TEST`.`GCD_SOURCE` ( `ID` INT NOT NULL AUTO_INCREMENT, `NUMBER_1` INT NOT NULL, `NUMBER_2` INT NOT NULL, `ADDED_DATE` DATETIME NOT NULL, PRIMARY KEY (`ID`), UNIQUE INDEX `ID_GCD_SOURCE` (`ID` ASC)); CREATE TABLE `GCD_TEST`.`GCD_RESULT` ( `ID` INT NOT NULL AUTO_INCREMENT, `GCD` INT NOT NULL, `COMPUTED_DATE` DATETIME NOT NULL, PRIMARY KEY (`ID`), UNIQUE INDEX `ID_GCD_RESULT` (`ID` ASC));
true
ea1eac88c7abd1f7617713bac61973774167bce6
SQL
fullarray/MySQL
/handcode/query1.sql
UTF-8
977
3.4375
3
[]
no_license
create database student; use student; create table student_signups( student_id INT(11) AUTO_INCREMENT PRIMARY KEY, student_name VARCHAR(50), student_age INT(11) ); create table course( course_id INT AUTO_INCREMENT PRIMARY KEY, course_name VARCHAR(50), enroll_id INT(11), FOREIGN KEY(enroll_id) REFERENCES enrollment (enrollment_id) ON DELETE cascade ON UPDATE cascade ); create table coursetype( coursetype_id INT AUTO_INCREMENT PRIMARY KEY, course_type VARCHAR(50), enroll_id INT(11), FOREIGN KEY(enroll_id) REFERENCES enrollment (enrollment_id) ON DELETE cascade ON UPDATE cascade ); create table enrollement( enrollment_id INT(11) AUTO_INCREMENT PRIMARY KEY, semester_name VARCHAR(50) ); create table specialized( specialized_id INT(11) AUTO_INCREMENT PRIMARY KEY, person_name VARCHAR(50) ); create table status( status_id INT(11) AUTO_INCREMENT PRIMARY KEY, person_name VARCHAR(50) );
true
f2b42e264cce4a8f92e7e98590fc75d936c8fe41
SQL
dwatson78/database
/updatescripts/from_36x/views/ipsitem.sql
UTF-8
2,298
3.515625
4
[]
no_license
SELECT dropIfExists('VIEW', 'ipsitem', 'public', true); CREATE OR REPLACE VIEW ipsitem AS SELECT ipsitem_id, ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount FROM ipsiteminfo JOIN item ON (ipsitem_item_id=item_id) WHERE ((ipsitem_discntprcnt=0.00) AND (ipsitem_fixedamtdiscount=0.00)) UNION SELECT ipsitem_id, ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, noNeg(CAST((item_listprice - (item_listprice * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount) AS NUMERIC(16,4))) AS ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount FROM ipsiteminfo JOIN item ON (ipsitem_item_id=item_id) WHERE ((ipsitem_discntprcnt<>0.00) OR (ipsitem_fixedamtdiscount<>0.00)); REVOKE ALL ON TABLE ipsitem FROM PUBLIC; GRANT ALL ON TABLE ipsitem TO GROUP xtrole; --Rules CREATE OR REPLACE RULE "_INSERT" AS ON INSERT TO ipsitem DO INSTEAD INSERT INTO ipsiteminfo ( ipsitem_id, ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount) VALUES ( new.ipsitem_id, new.ipsitem_ipshead_id, new.ipsitem_item_id, new.ipsitem_qtybreak, new.ipsitem_price, new.ipsitem_qty_uom_id, new.ipsitem_price_uom_id, new.ipsitem_discntprcnt, new.ipsitem_fixedamtdiscount ); CREATE OR REPLACE RULE "_UPDATE" AS ON UPDATE TO ipsitem DO INSTEAD UPDATE ipsiteminfo SET ipsitem_ipshead_id=new.ipsitem_ipshead_id, ipsitem_qtybreak=new.ipsitem_qtybreak, ipsitem_price=new.ipsitem_price, ipsitem_qty_uom_id=new.ipsitem_qty_uom_id, ipsitem_price_uom_id=new.ipsitem_price_uom_id, ipsitem_discntprcnt=new.ipsitem_discntprcnt, ipsitem_fixedamtdiscount=new.ipsitem_fixedamtdiscount WHERE (ipsitem_id=old.ipsitem_id); CREATE OR REPLACE RULE "_DELETE" AS ON DELETE TO ipsitem DO INSTEAD DELETE FROM ipsiteminfo WHERE (ipsitem_id=old.ipsitem_id);
true
7394766d10a1250131bc11e29ff016bd7fbe27ec
SQL
babak-kobari/hmtr
/sql/hm_exp_head.sql
UTF-8
1,881
2.9375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 3.3.3 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jan 28, 2013 at 01:35 AM -- Server version: 5.1.50 -- PHP Version: 5.3.14 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: `hmt` -- -- -------------------------------------------------------- -- -- Table structure for table `hm_exp_head` -- DROP TABLE IF EXISTS `hm_exp_head`; CREATE TABLE IF NOT EXISTS `hm_exp_head` ( `exp_id` int(11) NOT NULL AUTO_INCREMENT, `exp_user_id` int(11) NOT NULL, `exp_title` varchar(200) NOT NULL, `exp_country` int(11) NOT NULL, `exp_city` varchar(20) NOT NULL, `exp_mount` varchar(15) NOT NULL, `exp_days` int(2) NOT NULL, `exp_adults` int(2) NOT NULL, `exp_childs` int(2) NOT NULL, `exp_overall_rate` int(1) NOT NULL DEFAULT '0', `exp_travel_type` int(11) NOT NULL, `exp_travel_objective` int(11) NOT NULL, `exp_total_cost` int(11) DEFAULT '0', `exp_user_rating` decimal(10,0) DEFAULT '0', `exp_total_rated` int(11) DEFAULT '0', `exp_total_helpful` int(11) DEFAULT '0', `exp_status` varchar(11) DEFAULT 'WIP', PRIMARY KEY (`exp_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `hm_exp_head` -- INSERT INTO `hm_exp_head` (`exp_id`, `exp_user_id`, `exp_title`, `exp_country`, `exp_city`, `exp_mount`, `exp_days`, `exp_adults`, `exp_childs`, `exp_overall_rate`, `exp_travel_type`, `exp_travel_objective`, `exp_total_cost`, `exp_user_rating`, `exp_total_rated`, `exp_total_helpful`, `exp_status`) VALUES (1, 1, 'Exciting relaxation in exotic environment', 8, 'Dubai', 'Jan', 6, 2, 0, 0, 1, 6, 2500, '0', 0, 0, 'WIP');
true
01b2c33e1d68e9d104cdfc34ce5731b2bd190de0
SQL
fredyw/leetcode
/src/main/sql/Problem175.sql
UTF-8
162
3.21875
3
[ "MIT" ]
permissive
-- https://leetcode.com/problems/combine-two-tables/ select p.FirstName, p.LastName, a.City, a.State from Person p left join Address a on p.PersonId = a.PersonId;
true
7206dbd9b53d0b1c3a87146da1286ee042d5d4bb
SQL
csyoong28/spring
/transaction_fromWeb/programmatic-transaction-example/src/main/resources/createOrderItemTable.sql
UTF-8
147
2.59375
3
[]
no_license
CREATE TABLE ORDER_ITEM( ID BIGINT PRIMARY KEY AUTO_INCREMENT, ITEM VARCHAR(255) NOT NULL, QTY INT(255) NOT NULL check (QTY > 0 and QTY <= 100), );
true
fbeb5a7601d220a02974f07befb498ad7c173680
SQL
imgrbs/PromptKai_Software_Process_I
/Database SQL/promptkai.sql
UTF-8
5,628
3.21875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.8.3 -- https://www.phpmyadmin.net/ -- -- Host: db -- Generation Time: Nov 20, 2018 at 04:20 PM -- Server version: 10.2.18-MariaDB-1:10.2.18+maria~bionic -- PHP Version: 7.2.8 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: `promptkai` -- -- -------------------------------------------------------- -- -- Table structure for table `orders` -- CREATE TABLE `orders` ( `order_id` int(11) NOT NULL, `order_date` date NOT NULL, `amount` int(4) NOT NULL, `total` float NOT NULL, `location` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `orders` -- INSERT INTO `orders` (`order_id`, `order_date`, `amount`, `total`, `location`) VALUES (1, '2018-11-14', 2, 360, ''), (2, '2018-11-20', 1, 150, ''), (3, '2018-11-20', 1, 150, ''), (4, '2018-11-20', 1, 150, ''), (5, '2018-11-20', 1, 150, ''), (6, '2018-11-20', 1, 150, ''), (7, '2018-11-20', 1, 150, ''), (8, '2018-11-20', 1, 150, ''), (9, '2018-11-20', 1, 150, 'asdasdsad'), (10, '2018-11-20', 1, 150, 'asdasdasddas'), (11, '2018-11-20', 1, 150, 'sadsad'); -- -------------------------------------------------------- -- -- Table structure for table `order_details` -- CREATE TABLE `order_details` ( `order_detail_id` int(11) NOT NULL, `product_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `payment_id` int(11) NOT NULL, `amount` int(11) NOT NULL, `sub_total_price` float NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `order_details` -- INSERT INTO `order_details` (`order_detail_id`, `product_id`, `order_id`, `payment_id`, `amount`, `sub_total_price`) VALUES (1, 1, 11, 9, 1, 150); -- -------------------------------------------------------- -- -- Table structure for table `payments` -- CREATE TABLE `payments` ( `payment_id` int(11) NOT NULL, `payment_method` varchar(30) NOT NULL, `paid_date` date NOT NULL, `user_id` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `payments` -- INSERT INTO `payments` (`payment_id`, `payment_method`, `paid_date`, `user_id`) VALUES (2, 'Credit Card', '2018-11-20', '1076104752563889'), (3, 'Credit Card', '2018-11-20', '1076104752563889'), (4, 'Credit Card', '2018-11-20', '1076104752563889'), (5, 'Credit Card', '2018-11-20', '1076104752563889'), (6, 'Credit Card', '2018-11-20', '1076104752563889'), (7, 'Credit Card', '2018-11-20', '1076104752563889'), (8, 'Credit Card', '2018-11-20', '1076104752563889'), (9, 'Credit Card', '2018-11-20', '1076104752563889'); -- -------------------------------------------------------- -- -- Table structure for table `products` -- CREATE TABLE `products` ( `id` int(11) NOT NULL, `product_name` varchar(45) DEFAULT NULL, `product_detail` varchar(255) NOT NULL, `product_price` double NOT NULL, `product_type` varchar(50) NOT NULL, `img_path` varchar(150) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `products` -- INSERT INTO `products` (`id`, `product_name`, `product_detail`, `product_price`, `product_type`, `img_path`) VALUES (1, 'กระเป๋าใส่เหรียญ', 'กระเป๋าใส่เหรียญ ดีไซน์เก๋ๆ ขนาดสามารถใส่บัตรได้ มีซิปเพื่อความปลอดภัย วัสดุทนทาน ทำความสะอาดง่าย', 150, 'bag', 'assets/img/bag.png'), (2, 'แว่นสายตาแฟชั่น', 'แว่นสายตาแฟชั่น สวยๆ เหมาะสำหรับคนชิคๆ', 199, 'accessory', 'assets/img/glasses.png'); -- -- Indexes for dumped tables -- -- -- Indexes for table `orders` -- ALTER TABLE `orders` ADD PRIMARY KEY (`order_id`); -- -- Indexes for table `order_details` -- ALTER TABLE `order_details` ADD PRIMARY KEY (`order_detail_id`), ADD KEY `order_id` (`order_id`), ADD KEY `payment_id` (`payment_id`), ADD KEY `product_id` (`product_id`); -- -- Indexes for table `payments` -- ALTER TABLE `payments` ADD PRIMARY KEY (`payment_id`); -- -- Indexes for table `products` -- ALTER TABLE `products` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `orders` -- ALTER TABLE `orders` MODIFY `order_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12; -- -- AUTO_INCREMENT for table `order_details` -- ALTER TABLE `order_details` MODIFY `order_detail_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `payments` -- ALTER TABLE `payments` MODIFY `payment_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; -- -- Constraints for dumped tables -- -- -- Constraints for table `order_details` -- ALTER TABLE `order_details` ADD CONSTRAINT `order_details_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`order_id`), ADD CONSTRAINT `order_details_ibfk_2` FOREIGN KEY (`payment_id`) REFERENCES `payments` (`payment_id`), ADD CONSTRAINT `order_details_ibfk_3` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`); 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
dffa20385bc0d6bd8e1217903385bf67f1aff054
SQL
Harmo80/CreationFormulaire
/form_bd.sql
UTF-8
2,588
3.5625
4
[]
no_license
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; CREATE TABLE IF NOT EXISTS `form` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `HASH` varchar(255) NOT NULL, `NOM` varchar(255) NOT NULL, `TITRE` varchar(255) NOT NULL, `INC_FORM_VALIDATE` varchar(255) NOT NULL, `INC_MAIL` varchar(255) NOT NULL, `INC_PASS` varchar(255) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; -- ID : clé primaire. -- NOM : nom du formulaire pour l'attr name du <form>. -- TITRE : titre affiché dans le formulaire. -- INC_FORM_VALIDATE : "db" ou "email" choix de l'utilisateur pour les résultats du formulaire. -- INC_MAIL : email de l'utilisateur pour les envois de résultat et / ou pour la connexion ultérieure. -- INC_PASS : password de l'utilisateur pour la connexion ultérieure. CREATE TABLE IF NOT EXISTS `form_item` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `ID_FORM` int(11) NOT NULL, `NOM` varchar(255) NOT NULL, `TITRE` varchar(255) NOT NULL, `TYPE` varchar(255) NOT NULL, `NOTE` varchar(255) NOT NULL, `REQUIRED` varchar(3) NOT NULL DEFAULT 'NON', `ERROR` varchar(255) NOT NULL, `VALUE` longtext NOT NULL, `DEP_NOM` varchar(255) NOT NULL, `DEP_VALUE` varchar(255) NOT NULL, `POSITION` int(11) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; -- ID : clé primaire. -- ID_FORM : id du form dans lequel est le champ -- NOM : nom du champ pour l'attr name du <input> -- TITRE : titre affichédu champ -- TYPE : type de champ (text, textarea, password, select, ...) -- NOTE : note à l'attention de l'utilisateur (indice, précision) -- REQUIRED : OUI ou NON si le champ est requis ou optionnel -- ERROR : erreur affiché "ce champ est obligatoire" ou rien -- VALUE : options séparés par des virgules pour les select, checkbox, radio... ou value par défaut. -- DEP_NOM : champ auquel il est dépendant -- DEP_VALUE : valeur du champ auquel il est dépendant -- POSITION : position du champ dans le formulaire CREATE TABLE IF NOT EXISTS `form_result` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `ID_FORM` int(11) NOT NULL, `DATE_POST` datetime NOT NULL, `INC_PARAM` longtext NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; -- ID : clé primaire. -- ID_FORM : id du form pour lequel est le result -- INC_DATE : date du result -- INC_PARAM : résultat sous la forme -- {#NOM_CHAMP#} value value value -- value value value {!END#NOM_CHAMP#} -- {##NOM_CHAMP2##} value {!END#NOM_CHAMP#} -- {#NOM_CHAMP3#} value {!END#NOM_CHAMP#} -- A parser en PHP pour affichage et analyse des résultats.
true
164d3f30cef316bad77593d8be4d81e18dab4236
SQL
QuartetBaguette/PR-Duels
/duels_counter.sql
UTF-8
5,611
2.671875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Apr 13, 2021 at 03:26 PM -- 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: `duels_counter` -- -- -------------------------------------------------------- -- -- Table structure for table `gamemodes` -- CREATE TABLE `gamemodes` ( `mode_id` int(11) NOT NULL, `mode_name` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `gamemodes` -- INSERT INTO `gamemodes` (`mode_id`, `mode_name`) VALUES (1, 'CTF_'), (2, 'CP_'), (3, 'KOTH_'), (4, 'PAYLOAD_'); -- -------------------------------------------------------- -- -- Table structure for table `maps` -- CREATE TABLE `maps` ( `map_id` int(11) NOT NULL, `gamemode` int(11) NOT NULL, `map_name` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `maps` -- INSERT INTO `maps` (`map_id`, `gamemode`, `map_name`) VALUES (1, 2, '5Gorge'), (2, 2, 'Badlands'), (3, 2, 'Coldfront'), (4, 2, 'Dustbowl'), (5, 2, 'Egypt'), (6, 2, 'Fastlane'), (7, 2, 'Foundry'), (8, 2, 'Freight_final1'), (9, 2, 'Gorge'), (10, 2, 'Granary'), (11, 2, 'Gravel pit'), (12, 2, 'Gullywash_final1'), (13, 2, 'Junction_final'), (14, 2, 'Mercenarypark'), (15, 2, 'Metalworks'), (16, 2, 'Mossrock'), (17, 2, 'Mountainlab'), (18, 2, 'Powerhouse'), (19, 2, 'Process_final'), (20, 2, 'Snakewater_final1'), (21, 2, 'Snowplow'), (22, 2, 'Standin_final'), (23, 2, 'Steel'), (24, 2, 'Sunshine'), (25, 2, 'Vanguard'), (26, 2, 'Well'), (27, 2, 'Yukon_final'), (28, 1, '2Fort'), (29, 1, 'Doublecross'), (30, 1, 'Landfall'), (31, 1, 'Sawmill'), (32, 1, 'Snowfall_final'), (33, 1, 'Turbine'), (34, 1, 'Well'), (35, 3, 'Badlands'), (36, 3, 'Brazil'), (37, 3, 'Harvest_final'), (38, 3, 'Highpass'), (39, 3, 'King'), (40, 3, 'Lakeside_final'), (41, 3, 'Lazarus'), (42, 3, 'Nucleus'), (43, 3, 'Sawmill'), (44, 3, 'Suijin'), (45, 3, 'Viaduct'), (60, 4, 'Badwater'), (61, 4, 'Barnblitz'), (62, 4, 'Borneo'), (63, 4, 'Enclosure_final'), (64, 4, 'Frontier_final'), (65, 4, 'Goldrush'), (66, 4, 'Hoodoo_final'), (67, 4, 'Pier'), (68, 4, 'Snowycoast'), (69, 4, 'Swiftwater_final1'), (70, 4, 'Thundermountain'), (71, 4, 'Upward'); -- -------------------------------------------------------- -- -- Table structure for table `match_history` -- CREATE TABLE `match_history` ( `match_id` int(11) NOT NULL, `match_map` int(11) NOT NULL, `DK_patrick` int(11) NOT NULL, `DK_ruben` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `points` -- CREATE TABLE `points` ( `player_id` int(11) NOT NULL, `name` varchar(50) NOT NULL, `points` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `points` -- INSERT INTO `points` (`player_id`, `name`, `points`) VALUES (1, 'Patrick', 2), (2, 'Ruben', 21); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `userID` int(11) NOT NULL, `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `users` -- INSERT INTO `users` (`userID`, `username`, `password`) VALUES (1, 'Ruby', 'Hans!69'), (2, 'Patty', 'Garfield'); -- -- Indexes for dumped tables -- -- -- Indexes for table `gamemodes` -- ALTER TABLE `gamemodes` ADD PRIMARY KEY (`mode_id`); -- -- Indexes for table `maps` -- ALTER TABLE `maps` ADD PRIMARY KEY (`map_id`), ADD KEY `gamemode` (`gamemode`); -- -- Indexes for table `match_history` -- ALTER TABLE `match_history` ADD PRIMARY KEY (`match_id`), ADD KEY `maps` (`match_map`); -- -- Indexes for table `points` -- ALTER TABLE `points` ADD PRIMARY KEY (`player_id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`userID`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `gamemodes` -- ALTER TABLE `gamemodes` MODIFY `mode_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `maps` -- ALTER TABLE `maps` MODIFY `map_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=72; -- -- AUTO_INCREMENT for table `match_history` -- ALTER TABLE `match_history` MODIFY `match_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `points` -- ALTER TABLE `points` MODIFY `player_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `userID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- Constraints for dumped tables -- -- -- Constraints for table `maps` -- ALTER TABLE `maps` ADD CONSTRAINT `gamemode` FOREIGN KEY (`gamemode`) REFERENCES `gamemodes` (`mode_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `match_history` -- ALTER TABLE `match_history` ADD CONSTRAINT `maps` FOREIGN KEY (`match_map`) REFERENCES `maps` (`map_id`) ON DELETE CASCADE ON UPDATE CASCADE; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
9b57c59d8ee3fbf06b3b32815bf0fd7118a44e82
SQL
davidkzeng/pi-trading-lib
/python/pi_trading_lib/data/db/1_initialize.sql
UTF-8
563
3.6875
4
[]
no_license
CREATE TABLE contract ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, market_id INTEGER NOT NULL, begin_date TEXT NOT NULL, last_update_date TEXT NOT NULL, end_date TEXT, FOREIGN KEY(market_id) REFERENCES market(id) ); CREATE TABLE market ( id INTEGER PRIMARY KEY, name TEXT NOT NULL ); CREATE TABLE daily_history ( contract_id INTEGER, date TEXT NOT NULL, value REAL NOT NULL, value_type INTEGER NOT NULL, FOREIGN KEY(contract_id) REFERENCES contract(id), PRIMARY KEY(contract_id, date, value_type) );
true
a38e98e43f4a575b46dc8ea3f74fabc391edbe15
SQL
AllWKA/NotificationsFullStack
/BaseDeDatos/db_notifications_inventia_devicetokens.sql
UTF-8
2,501
2.96875
3
[]
no_license
-- MySQL dump 10.13 Distrib 8.0.15, for Win64 (x86_64) -- -- Host: localhost Database: db_notifications_inventia -- ------------------------------------------------------ -- Server version 8.0.15 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; SET NAMES utf8 ; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `devicetokens` -- DROP TABLE IF EXISTS `devicetokens`; /*!40101 SET @saved_cs_client = @@character_set_client */; SET character_set_client = utf8mb4 ; CREATE TABLE `devicetokens` ( `userID` int(10) NOT NULL, `applicationID` int(10) NOT NULL, `deviceToken` varchar(500) NOT NULL, `active` tinyint(4) NOT NULL DEFAULT '1', `so` enum('android','ios','web') NOT NULL, `createdAt` datetime DEFAULT NULL, `updatedAt` datetime DEFAULT NULL, PRIMARY KEY (`userID`,`applicationID`,`deviceToken`), KEY `FK_AplicacionID_idx` (`applicationID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `devicetokens` -- LOCK TABLES `devicetokens` WRITE; /*!40000 ALTER TABLE `devicetokens` DISABLE KEYS */; INSERT INTO `devicetokens` VALUES (12,1,'cBCeHrzyXVM:APA91bHL187MLbgvAGHZsSsHZkJizDv4Wja9RiYLDzVKNUKVUl37JCLuhkQwGo-Pgy-biEOeLTu3MKTCFqohbg6f34rPTVP8AHw8r-p2ifc5XOTPE4RjISbPh5Q4P6HuUTbG5ZrC_3Ay',1,'android',NULL,'2019-04-26 12:32:16'),(17,1,'fbTlox-e91I:APA91bHQ63zuRN8BMmoFggHAQa8XVIyVOt7VDcwZZ8YiDBIXEMSZP-0rmBLx1VBRKjXrE0i0Wt3_GaY77F2sjhVSoRdPlWT2BjmKneCzm94dQLb2WLh8BVuf6sstGnx72eic_oaxoHtF',1,'android',NULL,NULL),(18,1,'cBCeHrzyXVM:APA91bHL187MLbgvAGHZsSsHZkJizDv4Wja9RiYLDzVKNUKVUl37JCLuhkQwGo-Pgy-biEOeLTu3MKTCFqohbg6f34rPTVP8AHw8r-p2ifc5XOTPE4RjISbPh5Q4P6HuUTbG5ZrC_3Ay',1,'android',NULL,'2019-04-26 12:32:16'),(19,1,'q',1,'android',NULL,'2019-04-26 12:32:16'),(20,1,'sdf',1,'android',NULL,'2019-04-26 12:32:16'),(21,1,'sdffsdfff',1,'android',NULL,'2019-04-26 12:32:16'); /*!40000 ALTER TABLE `devicetokens` 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 2019-04-26 15:09:19
true
45bbef54cc03a43ae0fc1eafd4081e5973ef4a1f
SQL
Fukada9905/pythagora
/sql/queries/tran/pyt_p_302000_update.sql
UTF-8
2,284
3.875
4
[]
no_license
DROP PROCEDURE IF EXISTS pyt_p_302000_update; delimiter // CREATE PROCEDURE pyt_p_302000_update( IN p_work_id int , IN p_update_row text , IN p_user_id varchar(20) ) BEGIN DECLARE _user_name varchar(20); -- EXIT HANDLE DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; RESIGNAL; END; -- トランザクション開始 START TRANSACTION; CREATE TEMPORARY TABLE tmp_insert( work_detail_id int , Comment varchar(255) ); IF p_update_row IS NOT NULL THEN SET @s = CONCAT('INSERT INTO tmp_insert VALUES ',IFNULL(p_update_row,'(null,null)')); PREPARE stmt from @s; EXECUTE stmt; DEALLOCATE PREPARE stmt; END IF; IF EXISTS(SELECT * FROM tmp_insert) THEN UPDATE pyt_t_location_stocks AS LS INNER JOIN( SELECT WH.NNSICD , WH.JGSCD , WD.SRRNO , WD.RTNO , WD.KANRIK , WD.SYUKAK , WD.KOUJOK , WH.SNTCD , WD.SHCD , WH.PYTStocktakingDate , WD.work_detail_id FROM pyt_w_302000_head AS WH INNER JOIN pyt_w_302000_details AS WD ON WH.work_id = WD.work_id AND WH.user_id = WD.user_id WHERE WH.work_id = p_work_id AND WH.user_id = p_user_id ) AS WK ON LS.NNSICD = WK.NNSICD AND LS.JGSCD = WK.JGSCD AND LS.SRRNO = WK.SRRNO AND LS.RTNO = WK.RTNO AND LS.KANRIK = WK.KANRIK AND LS.SYUKAK = WK.SYUKAK AND LS.KOUJOK = WK.KOUJOK AND LS.SNTCD = WK.SNTCD AND LS.SHCD = WK.SHCD AND LS.PYTStocktakingDate = WK.PYTStocktakingDate INNER JOIN tmp_insert AS TP ON WK.work_detail_id = TP.work_detail_id SET LS.ReviewComment = TP.Comment; END IF; UPDATE pyt_t_location_stocks AS LS INNER JOIN pyt_w_302000_head AS WK ON LS.NNSICD = WK.NNSICD AND LS.JGSCD = WK.JGSCD AND LS.SNTCD = WK.SNTCD AND LS.PYTStocktakingDate = WK.PYTStocktakingDate SET LS.ReviewerID = p_user_id , LS.ReviewDatetime = current_timestamp() , LS.Status = 2 WHERE WK.work_id = p_work_id AND WK.user_id = p_user_id; COMMIT; END// delimiter ;
true
75e0a33b350b28a5ce19c315a407258744ce4fed
SQL
tmanuszak/CMU-Intro-to-DBMS
/HW1/q6_dubbed_smash.sql
UTF-8
258
3.609375
4
[]
no_license
with dubs as ( select title_id, count(*) as num_dubs from akas group by title_id order by num_dubs desc limit 10 ) select titles.primary_title, dubs.num_dubs from dubs join titles on titles.title_id == dubs.title_id order by dubs.num_dubs desc;
true
63f227e5d19bcc9f0a808448211442d7ab1ee3af
SQL
prathyushavoleti/assignment1
/sql assignment.sql
UTF-8
2,035
4.09375
4
[]
no_license
create table categories( id int not null primary key identity(1,1), category_name varchar(64), tax decimal ) insert into categories values('category5',25000) select *from categories create table product( id int not null primary key identity(1,1), product_name varchar(64), open_stock decimal , cur_stock decimal, sal_price decimal, category int not null foreign key references categories(id) ) insert into product values('product5',340.00,240.00,10000,5) select *from product create table customers( id int not null primary key identity(1,1), customer_name varchar(32), mobile varchar(15), open_bal decimal not null default '0', is_active Bit default '1' ) insert into customers values('harika',14361,32000,0) select*from customers create table saleshead( sale_inv_no int not null primary key identity(1,1), sale_date date not null, customer int not null foreign key references customers(id), card_type char ) insert into saleshead values('2020-06-23',5,'C') select*from saleshead create table salesdetail( sale_inv_no int not null foreign key references saleshead(sale_inv_no), product_id int not null foreign key references product(id), qty decimal not null, rate decimal not null ) insert into salesdetail values(6,5,12,19000) select*from salesdetail select product_name,category_name,cur_stock from product as p, categories as c where p.id=c.id --query to select product name,category name and current stock-- select * from customers where is_active= 1--query2 select customer,customer_name,open_bal from customers as c,saleshead as s where c.id=s.customer--query3 select sum(qty) as sum1 from salesdetail as sd,saleshead as s where sale_date='2020-06-23' and s.sale_inv_no=sd.sale_inv_no---query4 select product_name from Product p inner join SalesDetail sd on p.id=sd.product_id where sd.qty=(select max(qty) from SalesDetail) select product_name from Product p inner join SalesDetail sd on p.id=sd.product_id where sd.qty=(select min(qty) from SalesDetail)
true
8db1d98dafd1fab8d548b0085f53eadf697025e8
SQL
MeganCrane1/DatabaseManagement
/Lab5.sql
UTF-8
2,212
4.8125
5
[]
no_license
-- Megan Crane -- Lab 5 SQL Queries -- 2/20/14 -- I worked on this lab with Graham Harrison if some of our queries look similar and looked as stackoverflow charts for references -- 1. Get the cities of agents booking an order for customer "Basics" using joins. select agents.city from orders, agents, customers where agents.aid = orders.aid and customers.cid = orders.cid and customers.name = 'Basics' -- 2. Get the pids of products ordered through any agent who makes at least one order for a customer in Kyoto select distinct Loopthrough2nd.pid from Orders Loopthrough1st, orders Loopthrough2nd, Customers where Loopthrough1st.cid = customers.cid and Loopthrough1st.aid = Loopthrough2nd.aid and customers.city = 'Kyoto' -- 3. Get the names of customers who have never placed an order with a subquery select name from customers where cid not in (select cid from orders) -- 4. Get the names of customers who have never placed an order, use an outer join. select name from customers c FULL OUTER JOIN orders o ON c.cid = o.cid where o.cid is NULL -- 5. Get the names of customers who placed at least one order through an agent in their city, and the agents names select distinct customers.name as CUSTOMERName, agents.name as AGENTSName from customers, orders, agents, products where customers.cid = orders.cid and agents.aid = orders.aid and products.pid = orders.pid and customers.city = agents.city -- 6. Get the names of customers and agents in the same city, along with the name of the city, regardless of whether or not the customer has ever placed an order with that agent select customers.name as CUSTOMERName, agents.name as AGENTSName, customers.city as CUSTOMERCity, agents.city as AGENTSCity from customers, agents where customers.city = agents.city -- 7. Get the name and city of customers who live in the city where the least number of products are made select c2.name, c2.city, sum(quantity) as sumquantity from products, customers c1, orders, customers c2 where c1.cid = orders.cid and products.pid = orders.pid and c1.city = products.city and c1.city = c2.city group by c2.city, c2.name order by sumquantity desc limit 2
true
55a5d1fa90ee97e3fddf0af447d8ea25813f9785
SQL
mcg931501/RPMS
/includes/COT/rpms.sql
UTF-8
6,473
3.21875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.0.1 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Aug 26, 2019 at 07:16 AM -- Server version: 10.3.16-MariaDB -- PHP Version: 7.3.7 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: `rpms` -- -- -------------------------------------------------------- -- -- Table structure for table `mtindicator_items_tbl` -- CREATE TABLE `mtindicator_items_tbl` ( `indicator_items_id` int(20) NOT NULL, `indicator_id` int(20) NOT NULL, `indicator_name` longtext NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `mtindicator_tbl` -- CREATE TABLE `mtindicator_tbl` ( `indicator_id` int(11) NOT NULL, `indicator_no` int(20) NOT NULL, `indicator_name` char(250) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `mtindicator_tbl` -- INSERT INTO `mtindicator_tbl` (`indicator_id`, `indicator_no`, `indicator_name`) VALUES (1, 1, 'Apply knowledge of content within and across curriculum teaching areas.'), (2, 2, 'Apply a range of teaching strategies to develop critical and creative thinking, as well as other higher-order thinking skills'), (3, 3, 'Manage classroom structure to engage learners, individually or in groups, in meaningful exploration, discovery and hands-on activities within a range of physical learning environments'), (4, 4, 'Manage learner behavior constructively by applying positive and non-violent discipline to ensure learning-focused environments'), (6, 5, 'Plan, manage and implement developmentally sequenced teaching and learning processes to meet curriculum requirements and varied teaching contexts'); -- -------------------------------------------------------- -- -- Table structure for table `tblesatguide` -- CREATE TABLE `tblesatguide` ( `eguide_id` int(11) NOT NULL, `eguide_text1` text NOT NULL, `eguide_text2` text NOT NULL, `userid` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tblesatguide` -- INSERT INTO `tblesatguide` (`eguide_id`, `eguide_text1`, `eguide_text2`, `userid`) VALUES (25, 'sdfdsf', 'sdfdf', 0), (26, 'sdsdsd', 'sdsd', 0), (27, 'tst', 'test', 0); -- -------------------------------------------------------- -- -- Table structure for table `tindicator_items_tbl` -- CREATE TABLE `tindicator_items_tbl` ( `indicator_items_id` int(20) NOT NULL, `indicator_id` int(20) NOT NULL, `indicator_name` longtext NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `tindicator_tbl` -- CREATE TABLE `tindicator_tbl` ( `indicator_id` int(20) NOT NULL, `indicator_no` char(20) NOT NULL, `indicator_name` varchar(300) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tindicator_tbl` -- INSERT INTO `tindicator_tbl` (`indicator_id`, `indicator_no`, `indicator_name`) VALUES (14, '1', 'Apply knowledge of content within and across curriculum teaching areas'), (15, '2', 'Use a range of teaching strategies that enhance learner achievement in literacy and numeracy skills'), (16, '3', 'Apply a range of teaching strategies to develop critical and creative thinking, as well as other higher-order thinking skills'), (17, '4', 'Manage classroom structure to engage learners, individually or in groups, in meaningful exploration, discovery and hands-on activities within a range of physical learning environments'), (18, '5', 'Manage learner behavior constructively by applying positive and non-violent discipline to ensure learning-focused environments\r\n'), (20, '6', 'Use differentiated, developmentally appropriate learning experiences to address learners’ gender, needs, strengths, interests and experiences\r\n'), (21, '7', 'Plan, manage and implement developmentally sequenced teaching and learning processes to meet curriculum requirements and varied teaching contexts'), (22, '8', 'Select, develop, organize, and use appropriate teaching and learning resources, including ICT, to address learning goals\r\n'), (23, '9', 'Design, select, organize, and use diagnostic, formative and summative assessment strategies consistent with curriculum requirements\r\n'); -- -- Indexes for dumped tables -- -- -- Indexes for table `mtindicator_items_tbl` -- ALTER TABLE `mtindicator_items_tbl` ADD PRIMARY KEY (`indicator_items_id`), ADD UNIQUE KEY `indicator_id` (`indicator_id`); -- -- Indexes for table `mtindicator_tbl` -- ALTER TABLE `mtindicator_tbl` ADD PRIMARY KEY (`indicator_id`), ADD KEY `indicator_no` (`indicator_no`); -- -- Indexes for table `tblesatguide` -- ALTER TABLE `tblesatguide` ADD PRIMARY KEY (`eguide_id`); -- -- Indexes for table `tindicator_items_tbl` -- ALTER TABLE `tindicator_items_tbl` ADD PRIMARY KEY (`indicator_items_id`), ADD UNIQUE KEY `indicator_id` (`indicator_id`); -- -- Indexes for table `tindicator_tbl` -- ALTER TABLE `tindicator_tbl` ADD PRIMARY KEY (`indicator_id`), ADD KEY `indicator_name` (`indicator_name`), ADD KEY `indicator_no` (`indicator_no`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `mtindicator_items_tbl` -- ALTER TABLE `mtindicator_items_tbl` MODIFY `indicator_items_id` int(20) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `mtindicator_tbl` -- ALTER TABLE `mtindicator_tbl` MODIFY `indicator_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; -- -- AUTO_INCREMENT for table `tblesatguide` -- ALTER TABLE `tblesatguide` MODIFY `eguide_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28; -- -- AUTO_INCREMENT for table `tindicator_items_tbl` -- ALTER TABLE `tindicator_items_tbl` MODIFY `indicator_items_id` int(20) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tindicator_tbl` -- ALTER TABLE `tindicator_tbl` MODIFY `indicator_id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24; 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
281130c3d131cb1066d77b6f5604b2750dd08627
SQL
alenhung/ybc-laravel
/sql/laravel_2017-11-16.sql
UTF-8
11,539
3.140625
3
[]
no_license
# ************************************************************ # Sequel Pro SQL dump # Version 4541 # # http://www.sequelpro.com/ # https://github.com/sequelpro/sequelpro # # Host: 127.0.0.1 (MySQL 5.6.31) # Database: laravel # Generation Time: 2017-11-15 16:52:51 +0000 # ************************************************************ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; # Dump of table migrations # ------------------------------------------------------------ DROP TABLE IF EXISTS `migrations`; CREATE TABLE `migrations` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `batch` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; LOCK TABLES `migrations` WRITE; /*!40000 ALTER TABLE `migrations` DISABLE KEYS */; INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (9,'2014_10_12_000000_create_users_table',1), (10,'2014_10_12_100000_create_password_resets_table',1), (11,'2017_11_05_175106_laratrust_setup_tables',1), (12,'2017_11_09_184045_create_works_table',1); /*!40000 ALTER TABLE `migrations` ENABLE KEYS */; UNLOCK TABLES; # Dump of table password_resets # ------------------------------------------------------------ DROP TABLE IF EXISTS `password_resets`; CREATE TABLE `password_resets` ( `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, KEY `password_resets_email_index` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; # Dump of table permission_role # ------------------------------------------------------------ DROP TABLE IF EXISTS `permission_role`; CREATE TABLE `permission_role` ( `permission_id` int(10) unsigned NOT NULL, `role_id` int(10) unsigned NOT NULL, PRIMARY KEY (`permission_id`,`role_id`), KEY `permission_role_role_id_foreign` (`role_id`), CONSTRAINT `permission_role_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `permission_role_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; LOCK TABLES `permission_role` WRITE; /*!40000 ALTER TABLE `permission_role` DISABLE KEYS */; INSERT INTO `permission_role` (`permission_id`, `role_id`) VALUES (1,1), (2,1), (3,1), (4,1), (5,1), (6,1), (7,1), (8,1), (9,1), (10,1), (1,2), (2,2), (3,2), (4,2), (9,2), (10,2), (9,3), (10,3), (9,4), (10,4), (9,5), (10,5), (9,6), (10,6), (9,7), (10,7); /*!40000 ALTER TABLE `permission_role` ENABLE KEYS */; UNLOCK TABLES; # Dump of table permission_user # ------------------------------------------------------------ DROP TABLE IF EXISTS `permission_user`; CREATE TABLE `permission_user` ( `permission_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `user_type` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`user_id`,`permission_id`,`user_type`), KEY `permission_user_permission_id_foreign` (`permission_id`), CONSTRAINT `permission_user_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; # Dump of table permissions # ------------------------------------------------------------ DROP TABLE IF EXISTS `permissions`; CREATE TABLE `permissions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `display_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `description` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `permissions_name_unique` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; LOCK TABLES `permissions` WRITE; /*!40000 ALTER TABLE `permissions` DISABLE KEYS */; INSERT INTO `permissions` (`id`, `name`, `display_name`, `description`, `created_at`, `updated_at`) VALUES (1,'create-users','Create Users','Create Users','2017-11-09 21:54:32','2017-11-09 21:54:32'), (2,'read-users','Read Users','Read Users','2017-11-09 21:54:32','2017-11-09 21:54:32'), (3,'update-users','Update Users','Update Users','2017-11-09 21:54:32','2017-11-09 21:54:32'), (4,'delete-users','Delete Users','Delete Users','2017-11-09 21:54:32','2017-11-09 21:54:32'), (5,'create-acl','Create Acl','Create Acl','2017-11-09 21:54:32','2017-11-09 21:54:32'), (6,'read-acl','Read Acl','Read Acl','2017-11-09 21:54:32','2017-11-09 21:54:32'), (7,'update-acl','Update Acl','Update Acl','2017-11-09 21:54:32','2017-11-09 21:54:32'), (8,'delete-acl','Delete Acl','Delete Acl','2017-11-09 21:54:32','2017-11-09 21:54:32'), (9,'read-profile','Read Profile','Read Profile','2017-11-09 21:54:32','2017-11-09 21:54:32'), (10,'update-profile','Update Profile','Update Profile','2017-11-09 21:54:32','2017-11-09 21:54:32'); /*!40000 ALTER TABLE `permissions` ENABLE KEYS */; UNLOCK TABLES; # Dump of table role_user # ------------------------------------------------------------ DROP TABLE IF EXISTS `role_user`; CREATE TABLE `role_user` ( `role_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `user_type` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`user_id`,`role_id`,`user_type`), KEY `role_user_role_id_foreign` (`role_id`), CONSTRAINT `role_user_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; LOCK TABLES `role_user` WRITE; /*!40000 ALTER TABLE `role_user` DISABLE KEYS */; INSERT INTO `role_user` (`role_id`, `user_id`, `user_type`) VALUES (1,1,'App\\User'), (2,2,'App\\User'), (3,3,'App\\User'), (4,4,'App\\User'), (5,5,'App\\User'), (6,6,'App\\User'), (7,7,'App\\User'); /*!40000 ALTER TABLE `role_user` ENABLE KEYS */; UNLOCK TABLES; # Dump of table roles # ------------------------------------------------------------ DROP TABLE IF EXISTS `roles`; CREATE TABLE `roles` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `display_name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `description` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `roles_name_unique` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; LOCK TABLES `roles` WRITE; /*!40000 ALTER TABLE `roles` DISABLE KEYS */; INSERT INTO `roles` (`id`, `name`, `display_name`, `description`, `created_at`, `updated_at`) VALUES (1,'superadministrator','Superadministrator','Superadministrator','2017-11-09 21:54:32','2017-11-09 21:54:32'), (2,'administrator','Administrator','Administrator','2017-11-09 21:54:32','2017-11-09 21:54:32'), (3,'editor','Editor','Editor','2017-11-09 21:54:32','2017-11-09 21:54:32'), (4,'author','Author','Author','2017-11-09 21:54:32','2017-11-09 21:54:32'), (5,'contributor','Contributor','Contributor','2017-11-09 21:54:32','2017-11-09 21:54:32'), (6,'supporter','Supporter','Supporter','2017-11-09 21:54:33','2017-11-09 21:54:33'), (7,'subscriber','Subscriber','Subscriber','2017-11-09 21:54:33','2017-11-09 21:54:33'); /*!40000 ALTER TABLE `roles` ENABLE KEYS */; UNLOCK TABLES; # Dump of table users # ------------------------------------------------------------ DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `users_email_unique` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` (`id`, `name`, `email`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES (1,'Alen Huang','superadministrator@app.com','$2y$10$N/EHmUmMKT7lnWCjVxpvBuyHZdLLsClzk9.Ea9qz.ip4t0KPWU.Gu','0lwGyKKCfOS8dPP6mLDJIbRvKQdNWTxsMQUJrm2jx6dyghBY5sc3zG8u0ge6','2017-11-09 21:54:32','2017-11-09 21:56:36'), (2,'Administrator','administrator@app.com','$2y$10$Vr.etJloa0ZPfaO5JJVnF.KOglyd0E77NKN699zq8/Z67AiWRrKZm',NULL,'2017-11-09 21:54:32','2017-11-09 21:54:32'), (3,'Editor','editor@app.com','$2y$10$czDETt1b8QyAWGTNPP7WrOsxOFkw/xl.ofT4XT4kt68DWgCVF7a7G',NULL,'2017-11-09 21:54:32','2017-11-09 21:54:32'), (4,'Author','author@app.com','$2y$10$vK9SKvNKrcTEf9K9fCxcJu6oPyTL0YSTrXJoq73rXGoK0F4wkJkTm',NULL,'2017-11-09 21:54:32','2017-11-09 21:54:32'), (5,'Contributor','contributor@app.com','$2y$10$8HjOnL4WZyoxdG6JyRYx9uJoG9rkJJIZTnpNMaT2f1lOtO8lQCR7.',NULL,'2017-11-09 21:54:33','2017-11-09 21:54:33'), (6,'Supporter','supporter@app.com','$2y$10$Xj0JoyKCWRuVn5CjEsdSjOwadW9aZOWBRDPWUIHtJb6qnf2bPZQC.',NULL,'2017-11-09 21:54:33','2017-11-09 21:54:33'), (7,'Alen Huang','subscriber@app.com','$2y$10$wbqXtt./aCpFZa9aodx.9e/YIh2ddqQqr1gv1y.IsnUJZ1GDpzoNy',NULL,'2017-11-09 21:54:33','2017-11-09 21:55:28'); /*!40000 ALTER TABLE `users` ENABLE KEYS */; UNLOCK TABLES; # Dump of table works # ------------------------------------------------------------ DROP TABLE IF EXISTS `works`; CREATE TABLE `works` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `slogan` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL, `description` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `location` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `service_location` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `land_plan` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `land_size` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `households` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `unit_area` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `public_ratio` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `tall` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `completion_date` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `confirmed` tinyint(1) NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
b3081092da1a53033155d5453d447f782dbd6038
SQL
pdvmoto/binsql
/cdbusers.sql
UTF-8
144
2.890625
3
[]
no_license
-- show users for cdb/pdb column username format a15 column con_id format 999 select username, con_id, common from cdb_users order by 1;
true
75185469275a5ca44837eb651947ddf7c7770b05
SQL
Sergey778/cts
/src/db-scripts/postgresql/create-table/course.sql
UTF-8
433
3.53125
4
[]
no_license
DROP TABLE IF EXISTS course; DROP SEQUENCE IF EXISTS course_seq; CREATE SEQUENCE course_seq START WITH 1; CREATE TABLE course ( course_id BIGINT NOT NULL DEFAULT nextval('course_seq'), course_name TEXT NOT NULL, course_description TEXT NOT NULL, course_creator_id BIGINT NOT NULL, CONSTRAINT course_pk PRIMARY KEY (course_id), CONSTRAINT course_user_fk FOREIGN KEY (course_creator_id) REFERENCES "user"(user_id) );
true
e962910d27258615bac88a5d67ddd564621e01c2
SQL
vicente-santacoloma/usb-lvbp-fantasy
/src/Bases de Datos/roster_equipo_manager.sql
UTF-8
1,191
2.875
3
[ "MIT" ]
permissive
/* Navicat MySQL Data Transfer Source Server : brainsoftbd Source Server Version : 50156 Source Host : localhost:3306 Source Database : brainsof_bd Target Server Type : MYSQL Target Server Version : 50156 File Encoding : 65001 Date: 2011-11-17 14:46:05 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `roster_equipo_manager` -- ---------------------------- DROP TABLE IF EXISTS `roster_equipo_manager`; CREATE TABLE `roster_equipo_manager` ( `id_ref_nombre_equipo` varchar(20) NOT NULL, `id_ref_nombre_equipo_lvbp` varchar(25) NOT NULL, `precio_compra` double NOT NULL, PRIMARY KEY (`id_ref_nombre_equipo`,`id_ref_nombre_equipo_lvbp`), KEY `rostereqlvbp` (`id_ref_nombre_equipo_lvbp`), CONSTRAINT `rostereqlvbp` FOREIGN KEY (`id_ref_nombre_equipo_lvbp`) REFERENCES `roster_pitcher` (`id_ref_nombre_equipo_lvbp`), CONSTRAINT `rostermanager` FOREIGN KEY (`id_ref_nombre_equipo`) REFERENCES `equipo_manager` (`id_nombre_equipo`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- ---------------------------- -- Records of roster_equipo_manager -- ----------------------------
true
8b9d12dbe420114b2331d8848e18fae5471cc332
SQL
darkTheknight/PSImedicalserver
/database/IlYy99NiBs.sql
UTF-8
5,126
3.15625
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.8.5 -- https://www.phpmyadmin.net/ -- -- Host: localhost -- Generation Time: May 11, 2020 at 02:49 PM -- Server version: 8.0.13-4 -- PHP Version: 7.2.24-0ubuntu0.18.04.4 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: `IlYy99NiBs` -- -- -------------------------------------------------------- -- -- Table structure for table `data_packages` -- CREATE TABLE `data_packages` ( `id` int(11) NOT NULL, `name` text COLLATE utf8_unicode_ci NOT NULL, `data` float NOT NULL, `valid_period` float NOT NULL, `price` float NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `data_packages` -- INSERT INTO `data_packages` (`id`, `name`, `data`, `valid_period`, `price`) VALUES (1, 'D29', 200, 2, 29), (2, 'D49', 400, 7, 49), (3, 'D99', 1000, 21, 99), (4, 'D199', 2000, 30, 199), (5, 'D349', 4000, 30, 349), (6, 'D499', 6000, 30, 499), (7, 'D649', 8500, 30, 649); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `user_id` int(11) NOT NULL, `email` text COLLATE utf8_unicode_ci NOT NULL, `first_name` text COLLATE utf8_unicode_ci NOT NULL, `last_name` text COLLATE utf8_unicode_ci NOT NULL, `password_salt` text COLLATE utf8_unicode_ci NOT NULL, `password_hash` text COLLATE utf8_unicode_ci NOT NULL, `created` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `users` -- INSERT INTO `users` (`user_id`, `email`, `first_name`, `last_name`, `password_salt`, `password_hash`, `created`) VALUES (1, 'test@gmail.com', 'Test', 'User 1', '75b6e8243d6774daaea278f67fc2e9b7', 'e107271df14eeda28efe529996408353dbf381962a7405feda7424b185dc5102', '2020-05-11 11:50:15'); -- -------------------------------------------------------- -- -- Table structure for table `user_data_package` -- CREATE TABLE `user_data_package` ( `id` int(11) NOT NULL, `package_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `package_name` text COLLATE utf8_unicode_ci NOT NULL, `data_used` float NOT NULL DEFAULT '0', `activated_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- Table structure for table `user_voice_package` -- CREATE TABLE `user_voice_package` ( `id` int(11) NOT NULL, `package_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `package_name` text COLLATE utf8_unicode_ci NOT NULL, `minutes_used` int(11) NOT NULL DEFAULT '0', `activated_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- Table structure for table `voice_packages` -- CREATE TABLE `voice_packages` ( `id` int(11) NOT NULL, `name` text COLLATE utf8_unicode_ci NOT NULL, `minutes` float NOT NULL, `valid_period` int(11) NOT NULL, `price` float NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `voice_packages` -- INSERT INTO `voice_packages` (`id`, `name`, `minutes`, `valid_period`, `price`) VALUES (1, 'V20', 30, 7, 20), (2, 'V60', 100, 7, 60), (3, 'V100', 200, 14, 100), (4, 'V200', 400, 30, 200); -- -- Indexes for dumped tables -- -- -- Indexes for table `data_packages` -- ALTER TABLE `data_packages` ADD PRIMARY KEY (`id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`user_id`); -- -- Indexes for table `user_data_package` -- ALTER TABLE `user_data_package` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `user_id` (`user_id`); -- -- Indexes for table `user_voice_package` -- ALTER TABLE `user_voice_package` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `user_id` (`user_id`); -- -- Indexes for table `voice_packages` -- ALTER TABLE `voice_packages` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `data_packages` -- ALTER TABLE `data_packages` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `user_data_package` -- ALTER TABLE `user_data_package` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `user_voice_package` -- ALTER TABLE `user_voice_package` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `voice_packages` -- ALTER TABLE `voice_packages` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
8accb25bedd97883f33da9b9b04210689f072917
SQL
TomasG07/CursoSQL
/Consultas Multitabla/Ejercicio 69.sql
UTF-8
210
3.59375
4
[]
no_license
Select a.first_name, a.last_name, sum(b.amount) as "Total amound" from sakila.staff a inner join sakila.payment b on a.staff_id=b.staff_id and b.payment_date Like '2005-08%' group by a.first_name,a.last_name
true
fe8a64898e699529bf93663d617fff5c2909feb4
SQL
EExuke/CProjectDevelop
/7_bookMangeSys/图书管理系统/mrbm.sql
UTF-8
14,526
2.59375
3
[]
no_license
-- MySQL dump 10.10 -- -- Host: localhost Database: db_mrbm -- ------------------------------------------------------ -- Server version 5.0.20a-nt /*!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 `tb_base_book_kind` -- DROP TABLE IF EXISTS `tb_base_book_kind`; CREATE TABLE `tb_base_book_kind` ( `bookkind` varchar(25) NOT NULL, PRIMARY KEY USING BTREE (`bookkind`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=1; -- -- Dumping data for table `tb_base_book_kind` -- /*!40000 ALTER TABLE `tb_base_book_kind` DISABLE KEYS */; LOCK TABLES `tb_base_book_kind` WRITE; INSERT INTO `tb_base_book_kind` VALUES ('心里学'),('文学'),('管理学'),('计算机'); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_base_book_kind` ENABLE KEYS */; -- -- Table structure for table `tb_base_desk_info` -- DROP TABLE IF EXISTS `tb_base_desk_info`; CREATE TABLE `tb_base_desk_info` ( `deskname` varchar(25) NOT NULL, PRIMARY KEY (`deskname`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_base_desk_info` -- /*!40000 ALTER TABLE `tb_base_desk_info` DISABLE KEYS */; LOCK TABLES `tb_base_desk_info` WRITE; INSERT INTO `tb_base_desk_info` VALUES ('1号柜台'),('2号柜台'),('3号柜台'),('超级柜台'); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_base_desk_info` ENABLE KEYS */; -- -- Table structure for table `tb_base_store_info` -- DROP TABLE IF EXISTS `tb_base_store_info`; CREATE TABLE `tb_base_store_info` ( `storename` varchar(25) NOT NULL, PRIMARY KEY USING BTREE (`storename`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_base_store_info` -- /*!40000 ALTER TABLE `tb_base_store_info` DISABLE KEYS */; LOCK TABLES `tb_base_store_info` WRITE; INSERT INTO `tb_base_store_info` VALUES ('东1仓库'),('北1仓库'),('南1仓库'),('南2仓库'),('店内'),('西1仓库'); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_base_store_info` ENABLE KEYS */; -- -- Table structure for table `tb_book_adjust` -- DROP TABLE IF EXISTS `tb_book_adjust`; CREATE TABLE `tb_book_adjust` ( `adjustcode` int(25) NOT NULL auto_increment, `operator` varchar(25) NOT NULL, `take` varchar(25) NOT NULL, `store` varchar(25) NOT NULL, `barcode` varchar(25) NOT NULL, `provider` varchar(25) NOT NULL, `count` int(11) NOT NULL, `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`adjustcode`), KEY `FK_tb_book_adjust_1` (`barcode`), KEY `FK_tb_book_adjust_2` (`operator`), KEY `FK_tb_book_adjust_3` (`provider`), KEY `FK_tb_book_adjust_4` (`store`), CONSTRAINT `FK_tb_book_adjust_1` FOREIGN KEY (`barcode`) REFERENCES `tb_book_info` (`barcode`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_adjust_2` FOREIGN KEY (`operator`) REFERENCES `tb_operators` (`name`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_adjust_3` FOREIGN KEY (`provider`) REFERENCES `tb_provider_info` (`provider`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_adjust_4` FOREIGN KEY (`store`) REFERENCES `tb_base_store_info` (`storename`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_book_adjust` -- /*!40000 ALTER TABLE `tb_book_adjust` DISABLE KEYS */; LOCK TABLES `tb_book_adjust` WRITE; INSERT INTO `tb_book_adjust` VALUES (18,'mrsoft','北1仓库','店内','IBN987-6543-21','XXX出版商',10,'2013-02-03 23:25:33'); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_book_adjust` ENABLE KEYS */; -- -- Table structure for table `tb_book_info` -- DROP TABLE IF EXISTS `tb_book_info`; CREATE TABLE `tb_book_info` ( `barcode` varchar(25) NOT NULL, `bookname` varchar(25) NOT NULL, `mncode` varchar(25) NOT NULL, `authorname` varchar(25) NOT NULL, `bookconcern` varchar(25) NOT NULL, `price` double NOT NULL, `memo` varchar(25) NOT NULL default '无', `kind` varchar(25) NOT NULL, PRIMARY KEY (`barcode`), KEY `FK_tb_book_info_1` (`kind`), CONSTRAINT `FK_tb_book_info_1` FOREIGN KEY (`kind`) REFERENCES `tb_base_book_kind` (`bookkind`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_book_info` -- /*!40000 ALTER TABLE `tb_book_info` DISABLE KEYS */; LOCK TABLES `tb_book_info` WRITE; INSERT INTO `tb_book_info` VALUES ('IBN987-6543-21','WINAPI控件指南','123','松鼠','mr',33.33,'无','计算机'); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_book_info` ENABLE KEYS */; -- -- Table structure for table `tb_book_input` -- DROP TABLE IF EXISTS `tb_book_input`; CREATE TABLE `tb_book_input` ( `inputcode` int(25) unsigned NOT NULL auto_increment, `operator` varchar(25) NOT NULL, `provider` varchar(25) NOT NULL, `barcode` varchar(25) NOT NULL, `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `store` varchar(25) NOT NULL, `count` int(25) unsigned NOT NULL, `pay` double NOT NULL, PRIMARY KEY USING BTREE (`inputcode`,`provider`,`store`), KEY `FK_tb_book_input_3` (`provider`), KEY `FK_tb_book_input_2` (`barcode`), KEY `FK_tb_book_input_1` (`store`), KEY `FK_tb_book_input_4` (`operator`), CONSTRAINT `FK_tb_book_input_1` FOREIGN KEY (`store`) REFERENCES `tb_base_store_info` (`storename`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_input_2` FOREIGN KEY (`barcode`) REFERENCES `tb_book_info` (`barcode`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_input_3` FOREIGN KEY (`provider`) REFERENCES `tb_provider_info` (`provider`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_input_4` FOREIGN KEY (`operator`) REFERENCES `tb_operators` (`name`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='InnoDB free: 3072 kB; '; -- -- Dumping data for table `tb_book_input` -- /*!40000 ALTER TABLE `tb_book_input` DISABLE KEYS */; LOCK TABLES `tb_book_input` WRITE; INSERT INTO `tb_book_input` VALUES (5,'mrsoft','XXX出版商','IBN987-6543-21','2013-02-04 07:18:14','东1仓库',24,1066.56),(6,'mrsoft','XXX出版商','IBN987-6543-21','2013-02-03 23:05:39','北1仓库',14,466.62),(7,'mrsoft','XXX出版商','IBN987-6543-21','2013-02-03 23:05:49','北1仓库',14,466.62); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_book_input` ENABLE KEYS */; -- -- Table structure for table `tb_book_input_back` -- DROP TABLE IF EXISTS `tb_book_input_back`; CREATE TABLE `tb_book_input_back` ( `backcode` int(25) NOT NULL auto_increment, `operator` varchar(25) NOT NULL, `provider` varchar(25) NOT NULL, `barcode` varchar(25) NOT NULL, `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `store` varchar(25) NOT NULL, `count` int(25) NOT NULL, `pay` double NOT NULL, PRIMARY KEY (`backcode`), KEY `FK_tb_book_input_back_1` (`barcode`), KEY `FK_tb_book_input_back_2` (`store`), KEY `FK_tb_book_input_back_3` (`provider`), KEY `FK_tb_book_input_back_4` (`operator`), CONSTRAINT `FK_tb_book_input_back_1` FOREIGN KEY (`barcode`) REFERENCES `tb_book_info` (`barcode`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_input_back_2` FOREIGN KEY (`store`) REFERENCES `tb_base_store_info` (`storename`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_input_back_3` FOREIGN KEY (`provider`) REFERENCES `tb_provider_info` (`provider`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_input_back_4` FOREIGN KEY (`operator`) REFERENCES `tb_operators` (`name`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_book_input_back` -- /*!40000 ALTER TABLE `tb_book_input_back` DISABLE KEYS */; LOCK TABLES `tb_book_input_back` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `tb_book_input_back` ENABLE KEYS */; -- -- Table structure for table `tb_book_sale` -- DROP TABLE IF EXISTS `tb_book_sale`; CREATE TABLE `tb_book_sale` ( `salecode` int(25) unsigned NOT NULL auto_increment, `operator` varchar(25) NOT NULL, `barcode` varchar(25) NOT NULL, `desk` varchar(25) NOT NULL, `customer` varchar(25) NOT NULL default '无记名', `count` int(25) unsigned NOT NULL, `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `pay` double NOT NULL, PRIMARY KEY (`salecode`), KEY `FK_tb_book_sale_1` (`desk`), KEY `FK_tb_book_sale_2` (`barcode`), KEY `FK_tb_book_sale_3` (`operator`), CONSTRAINT `FK_tb_book_sale_1` FOREIGN KEY (`desk`) REFERENCES `tb_base_desk_info` (`deskname`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_sale_2` FOREIGN KEY (`barcode`) REFERENCES `tb_book_info` (`barcode`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_sale_3` FOREIGN KEY (`operator`) REFERENCES `tb_operators` (`name`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_book_sale` -- /*!40000 ALTER TABLE `tb_book_sale` DISABLE KEYS */; LOCK TABLES `tb_book_sale` WRITE; INSERT INTO `tb_book_sale` VALUES (8,'mrsoft','IBN987-6543-21','1号柜台','无记名',3,'2013-02-03 23:31:38',99.99); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_book_sale` ENABLE KEYS */; -- -- Table structure for table `tb_book_sale_back` -- DROP TABLE IF EXISTS `tb_book_sale_back`; CREATE TABLE `tb_book_sale_back` ( `backcode` int(25) NOT NULL auto_increment, `operator` varchar(25) NOT NULL, `barcode` varchar(25) NOT NULL, `desk` varchar(25) NOT NULL, `customer` varchar(25) NOT NULL default '无记名', `count` int(25) NOT NULL, `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `pay` double NOT NULL, PRIMARY KEY (`backcode`), KEY `FK_tb_book_sale_back_1` (`barcode`), KEY `FK_tb_book_sale_back_2` (`desk`), KEY `FK_tb_book_sale_back_3` (`operator`), CONSTRAINT `FK_tb_book_sale_back_1` FOREIGN KEY (`barcode`) REFERENCES `tb_book_info` (`barcode`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_sale_back_2` FOREIGN KEY (`desk`) REFERENCES `tb_base_desk_info` (`deskname`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_tb_book_sale_back_3` FOREIGN KEY (`operator`) REFERENCES `tb_operators` (`name`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='InnoDB free: 3072 kB; (`desk`) REFER `db_mrbm/tb_base_desk_i'; -- -- Dumping data for table `tb_book_sale_back` -- /*!40000 ALTER TABLE `tb_book_sale_back` DISABLE KEYS */; LOCK TABLES `tb_book_sale_back` WRITE; INSERT INTO `tb_book_sale_back` VALUES (3,'mrsoft','IBN987-6543-21','1号柜台','无记名',3,'2013-02-03 23:34:33',99.99); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_book_sale_back` ENABLE KEYS */; -- -- Table structure for table `tb_operators` -- DROP TABLE IF EXISTS `tb_operators`; CREATE TABLE `tb_operators` ( `name` varchar(25) NOT NULL, `password` varchar(25) character set utf8 collate utf8_bin NOT NULL default '111', `level` int(10) NOT NULL default '1', PRIMARY KEY (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=1; -- -- Dumping data for table `tb_operators` -- /*!40000 ALTER TABLE `tb_operators` DISABLE KEYS */; LOCK TABLES `tb_operators` WRITE; INSERT INTO `tb_operators` VALUES ('employee','123',1),('mrsoft','111',2); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_operators` ENABLE KEYS */; -- -- Table structure for table `tb_provider_info` -- DROP TABLE IF EXISTS `tb_provider_info`; CREATE TABLE `tb_provider_info` ( `provider` varchar(25) NOT NULL, `corporation` varchar(25) NOT NULL, `principal` varchar(25) NOT NULL, `phone` varchar(25) NOT NULL, `addr` varchar(25) NOT NULL, `web` varchar(25) NOT NULL, `e_mail` varchar(25) NOT NULL, PRIMARY KEY (`provider`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_provider_info` -- /*!40000 ALTER TABLE `tb_provider_info` DISABLE KEYS */; LOCK TABLES `tb_provider_info` WRITE; INSERT INTO `tb_provider_info` VALUES ('XXX出版商','老赵','老李','1234567890','长春市高新开发区','http//www........','lx@mrbccd.com'); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_provider_info` ENABLE KEYS */; -- -- Table structure for table `tb_stock_info` -- DROP TABLE IF EXISTS `tb_stock_info`; CREATE TABLE `tb_stock_info` ( `barcode` varchar(25) NOT NULL, `store` varchar(25) NOT NULL, `stock` int(25) unsigned NOT NULL default '0', KEY `FK_db_stock_info_1` (`barcode`), KEY `FK_db_stock_info_2` (`store`), CONSTRAINT `FK_db_stock_info_1` FOREIGN KEY (`barcode`) REFERENCES `tb_book_info` (`barcode`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `FK_db_stock_info_2` FOREIGN KEY (`store`) REFERENCES `tb_base_store_info` (`storename`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_stock_info` -- /*!40000 ALTER TABLE `tb_stock_info` DISABLE KEYS */; LOCK TABLES `tb_stock_info` WRITE; INSERT INTO `tb_stock_info` VALUES ('IBN987-6543-21','北1仓库',18),('IBN987-6543-21','南1仓库',0),('IBN987-6543-21','南2仓库',0),('IBN987-6543-21','店内',10),('IBN987-6543-21','西1仓库',0),('IBN987-6543-21','东1仓库',24); UNLOCK TABLES; /*!40000 ALTER TABLE `tb_stock_info` ENABLE KEYS */; /*!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 */;
true
1841b1d1dc3acc86367e06f54e5f11c2b25fd793
SQL
eduardohrmsnt/Reagentes
/reagentes.sql
UTF-8
2,217
3.09375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.0.1 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Tempo de geração: 28-Set-2019 às 23:43 -- Versão do servidor: 10.4.6-MariaDB -- versão do PHP: 7.1.31 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 */; -- -- Banco de dados: `controle de reagentes` -- -- -------------------------------------------------------- -- -- Estrutura da tabela `reagentes` -- CREATE TABLE `reagentes` ( `ID` int(11) NOT NULL, `idreagente` varchar(11) NOT NULL, `nome` varchar(60) CHARACTER SET utf8 NOT NULL, `marca` varchar(30) CHARACTER SET utf8 NOT NULL, `dtentrada` varchar(10) CHARACTER SET utf8 NOT NULL, `dtvalidade` varchar(10) NOT NULL, `quantidade` int(11) NOT NULL, `qtdeminima` int(11) NOT NULL, `medida` varchar(2) NOT NULL, `inerte` varchar(5) NOT NULL, `dtsaida` varchar(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Extraindo dados da tabela `reagentes` -- INSERT INTO `reagentes` (`ID`, `idreagente`, `nome`, `marca`, `dtentrada`, `dtvalidade`, `quantidade`, `qtdeminima`, `medida`, `inerte`, `dtsaida`) VALUES (12, 'E12903', 'ACIDO SULFURICO2', 'TOP', '28/09/2019', '31/10/2019', 10, 5, '1', 'False', ' / /'), (14, 'E12940', 'ACIDO SULFURICO4', 'TOP', '28/09/2019', '31/10/2019', 10, 5, '3', 'False', ' / /'), (17, 'E12903', 'ACIDO SULFURICO2', 'TOP', '28/09/2019', '23/10/2019', 10, 10, '4', 'False', ' / /'); -- -- Índices para tabelas despejadas -- -- -- Índices para tabela `reagentes` -- ALTER TABLE `reagentes` ADD PRIMARY KEY (`ID`); -- -- AUTO_INCREMENT de tabelas despejadas -- -- -- AUTO_INCREMENT de tabela `reagentes` -- ALTER TABLE `reagentes` MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19; 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
4313dee2f01f0ac014e07890a990fcf23d68ae2d
SQL
joseluiz123/locadora_alucars
/scripts/script_dim_data.sql
UTF-8
2,452
3.71875
4
[]
no_license
---script dim_tempo versão:20210930 ---prof. anderson nascimento create table dim_data ( sk_data integer not null, nk_data date not null, desc_data_completa varchar(60) not null, nr_ano integer not null, nm_trimestre varchar(20) not null, nr_ano_trimestre varchar(20) not null, nr_mes integer not null, nm_mes varchar(20) not null, ano_mes varchar(20) not null, nr_semana integer not null, ano_semana varchar(20) not null, nr_dia integer not null, nr_dia_ano integer not null, nm_dia_semana varchar(20) not null, flag_final_semana char(3) not null, flag_feriado char(3) not null, nm_feriado varchar(60) not null, etl_dt_inicio timestamp not null, etl_dt_fim timestamp not null, constraint sk_data_pk primary key (sk_data) ); insert into dim_data select to_number(to_char(datum,'yyyymmdd'), '99999999') as sk_tempo, datum as nk_data, to_char(datum,'dd/mm/yyyy') as data_completa_formatada, extract (year from datum) as nr_ano, 'T' || to_char(datum, 'q') as nm_trimestre, to_char(datum, '"T"q/yyyy') as nr_ano_trimenstre, extract(month from datum) as nr_mes, to_char(datum, 'tmMonth') as nm_mes, to_char(datum, 'yyyy/mm') as nr_ano_nr_mes, extract(week from datum) as nr_semana, to_char(datum, 'iyyy/iw') as nr_ano_nr_semana, extract(day from datum) as nr_dia, extract(doy from datum) as nr_dia_ano, to_char(datum, 'tmDay') as nm_dia_semana, case when extract(isodow from datum) in (6, 7) then 'Sim' else 'Não' end as flag_final_semana, case when to_char(datum, 'mmdd') in ('0101','0421','0501','0907','1012','1102','1115','1120','1225') then 'Sim' else 'Não' end as flag_feriado, case ---incluir aqui os feriados when to_char(datum, 'mmdd') = '0101' then 'Ano Novo' when to_char(datum, 'mmdd') = '0421' then 'Tiradentes' when to_char(datum, 'mmdd') = '0501' then 'Dia do Trabalhador' when to_char(datum, 'mmdd') = '0907' then 'Dia da Pátria' when to_char(datum, 'mmdd') = '1012' then 'Nossa Senhora Aparecida' when to_char(datum, 'mmdd') = '1102' then 'Finados' when to_char(datum, 'mmdd') = '1115' then 'Proclamação da República' when to_char(datum, 'mmdd') = '1120' then 'Dia da Consciência Negra' when to_char(datum, 'mmdd') = '1225' then 'Natal' else 'Não é Feriado' end as nm_feriado, current_timestamp as data_carga, '2199-12-31' from ( ---incluir aqui a data de início do script, criaremos 15 anos de datas select '2019-01-01'::date + sequence.day as datum from generate_series(0,5479) as sequence(day) group by sequence.day ) dq order by 1;
true
56080818fc77558d7aa9bed65cf9a67b2f8a582f
SQL
zjcszzl/SQL_Refresh
/StoredProcedures.sql
UTF-8
3,820
4.15625
4
[]
no_license
-- Creating a Stored Procedure DELIMITER $$ CREATE PROCEDURE get_clients() BEGIN SELECT * FROM clients; END$$ DELIMITER ; CALL get_clients(); DELIMITER $$ CREATE PROCEDURE get_invoices_with_balance() BEGIN SELECT * FROM invoices WHERE invoice_total - payment_total > 0; END$$ DELIMITER ; CALL get_invoices_with_balance(); CALL get_payments(); -- Drop stored procedures DROP PROCEDURE IF EXISTS get_clients; -- Stored Procedures With Parameters DROP PROCEDURE IF EXISTS get_clients_by_state; DELIMITER $$ CREATE PROCEDURE get_clients_by_state( state CHAR(2) ) BEGIN SELECT * FROM Clients c WHERE c.state = state; END $$ DELIMITER ; CALL get_clients_by_state('NY'); DROP PROCEDURE IF EXISTS get_invoices_by_client; DELIMITER $$ CREATE PROCEDURE get_invoices_by_client( client_id INT ) BEGIN SELECT * FROM Invoices i WHERE i.client_id = client_id; END $$ DELIMITER ; CALL get_invoices_by_client(1); -- Default Parameters DROP PROCEDURE IF EXISTS get_clients_by_state; DELIMITER $$ CREATE PROCEDURE get_clients_by_state( state CHAR(2) ) BEGIN IF state IS NULL THEN -- SET state = 'CA'; SELECT * FROM clients; ELSE SELECT * FROM Clients c WHERE c.state = state; END IF; END $$ DELIMITER ; CALL get_clients_by_state(NULL); DROP PROCEDURE IF EXISTS get_payments; DELIMITER $$ CREATE PROCEDURE get_payments( client_id INT, payment_method_id TINYINT ) BEGIN SELECT * FROM payments p WHERE p.client_id = IFNULL(client_id, p.client_id) AND p.payment_method = IFNULL(payment_method_id,p.payment_method); END$$ DELIMITER ; CALL get_payments(5,null); -- Parameters Validation: better do it before hitting the database level DROP PROCEDURE IF EXISTS make_payment; DELIMITER $$ CREATE PROCEDURE make_payment( invoice_id INT, payment_amount DECIMAl(9,2), payment_date DATE ) BEGIN IF payment_amount <= 0 THEN SIGNAL SQLSTATE '22003' SET MESSAGE_TEXT = 'Invalid Payment amount'; END IF; UPDATE invoices i SET i.payment_total = payment_amount, i.payment_date = payment_date WHERE i.invoice_id = invoice_id; END$$ DELIMITER ; CALL make_payment(2,100,'2019-01-01'); -- Output parameters DROP PROCEDURE IF EXISTS get_unpaid_invoices; DELIMITER $$ CREATE PROCEDURE get_unpaid_invoices( client_id INT, OUT invoices_count TINYINT, OUT invoices_total DECIMAL(9,2) ) BEGIN SELECT COUNT(*), SUM(invoice_total) INTO invoices_count, invoices_total FROM invoices i WHERE i.client_id = client_id AND payment_total = 0; END$$ DELIMITER ; SET @invoices_count = 0; -- session variables SET @invoices_total = 0; CALL get_unpaid_invoices(5,@invoices_count,@invoices_total); SELECT @invoices_count,@invoices_total; DROP PROCEDURE IF EXISTS get_risk_factor; DELIMITER $$ CREATE PROCEDURE get_risk_factor( ) BEGIN DECLARE risk_factor DECIMAL(9,2) DEFAULT 0; DECLARE invoices_total DECIMAL(9,2); -- local variables DECLARE invoices_count INT; SELECT count(*), SUM(invoice_total) INTO invoices_count, invoices_total FROM invoices; SET risk_factor = invoices_total / invoices_count * 5; SELECT risk_factor; END$$ DELIMITER ; CALL get_risk_factor(); -- Functions DROP FUNCTION IF EXISTS get_risk_client; DELIMITER $$ CREATE FUNCTION get_risk_client( client_id INT ) RETURNS INTEGER -- DETERMINISTIC READS SQL DATA -- MODIFIES SQL DATA BEGIN DECLARE risk_factor DECIMAL(9,2) DEFAULT 0; DECLARE invoices_total DECIMAL(9,2); -- local variables DECLARE invoices_count INT; SELECT count(*), SUM(invoice_total) INTO invoices_count, invoices_total FROM invoices i WHERE i.client_id = client_id; SET risk_factor = invoices_total / invoices_count * 5; return IFNULL(risk_factor,0); END$$ DELIMITER ; SELECT client_id, name, get_risk_client(client_id) AS Risk_Factor FROM clients;
true
90ba07f275342fa5e4c1b9229548d7f8b9dc7250
SQL
seantanjs/project-2
/table.sql
UTF-8
435
3.03125
3
[]
no_license
CREATE TABLE IF NOT EXISTS users ( id SERIAL PRIMARY KEY, username TEXT, password TEXT, target_amount DECIMAL(10,2), time_horizon INTEGER, start_date DATE, end_date DATE ); CREATE TABLE IF NOT EXISTS finances ( id SERIAL PRIMARY KEY, transaction_date DATE, monthly_income_amount DECIMAL (10,2), monthly_expenses_amount DECIMAL (10,2), monthly_investment_amount DECIMAL (10,2), monthly_saving_amount DECIMAL (10,2), user_id INTEGER );
true
38fb8ea7cbcb81561cedd8f175dfb5a85d8973a8
SQL
crazcalm/friends
/test.sql
UTF-8
425
3.234375
3
[ "MIT" ]
permissive
DROP TABLE IF EXISTS country; CREATE TABLE country ( `uid` integer primary key autoincrement, `name` varchar(260) not null, `abbr_name` varchar(10) null ); DROP TABLE IF EXISTS person; CREATE TABLE person ( `uid` integer primary key autoincrement, `name` varchar(64) not null, `created` date default CURRENT_DATE, `country` integer not null, FOREIGN KEY (`country`) REFERENCES country(uid) );
true
67f602d81c529f2be0fec6c4141c9aec30324ece
SQL
andysitu/algo-problems
/leetcode/200/175_combine_two_tables.sql
UTF-8
165
3.328125
3
[]
no_license
# Write your MySQL query statement below SELECT p.FirstName, p.LastName, adr.City, adr.State from Person as p LEFT JOIN Address as adr ON p.PersonId = adr.PersonId;
true
06829c28d5d053f1d2a8e170b5bbb244cf23efd1
SQL
mfaisalshahid/DataSQL
/queries-quality-and-percentage.sql
UTF-8
408
3.296875
3
[]
no_license
SELECT query_name , ROUND(AVG(rating*100 / position), 0)/100 AS quality , ROUND(AVG(case when rating < 3 then 1 else 0 end )*100, 2) as poor_query_percentage FROM Queries GROUP BY query_nam SELECT query_name, ROUND(AVG(rating / position), 2) AS quality, ROUND(AVG(rating < 3) * 100, 2) AS poor_query_percentage FROM Queries GROUP BY query_name
true
41b1495ec379b33cc97eaa115ac8641b85d8b4d6
SQL
alrawi90/today-is-your-birthday-
/database/birthday.sql
UTF-8
3,368
3.25
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.6.5.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Sep 21, 2017 at 12:37 PM -- Server version: 10.1.21-MariaDB -- PHP Version: 5.6.30 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `birthday` -- -- -------------------------------------------------------- -- -- Table structure for table `customers` -- CREATE TABLE `customers` ( `id` int(11) NOT NULL, `Full_Name` varchar(60) NOT NULL, `Mobile_Number` varchar(14) NOT NULL, `Prefered_Language` tinyint(2) NOT NULL, `Date_of_Birth` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `customers` -- INSERT INTO `customers` (`id`, `Full_Name`, `Mobile_Number`, `Prefered_Language`, `Date_of_Birth`) VALUES (1, 'Ali Alrawi', '+9647828624095', 1, '1985-01-20'), (2, 'Ali Mohsen', '+9647712294680', 2, '2017-09-21'); -- -------------------------------------------------------- -- -- Table structure for table `languages` -- CREATE TABLE `languages` ( `id` tinyint(4) NOT NULL, `Language` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `languages` -- INSERT INTO `languages` (`id`, `Language`) VALUES (1, 'English'), (2, 'Arabic'); -- -------------------------------------------------------- -- -- Table structure for table `logs` -- CREATE TABLE `logs` ( `id` bigint(20) NOT NULL, `date` datetime NOT NULL, `Mobile_Number` varchar(14) NOT NULL, `SMS_Content` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `logs` -- INSERT INTO `logs` (`id`, `date`, `Mobile_Number`, `SMS_Content`) VALUES (0, '2017-09-21 13:04:57', '+964771229', '??? ????? ????'), (0, '2017-09-21 13:10:59', '+964771229', 'عيد ميلاد سعيد'); -- -------------------------------------------------------- -- -- Table structure for table `sms` -- CREATE TABLE `sms` ( `id` int(11) NOT NULL, `Language_id` tinyint(2) NOT NULL, `content` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `sms` -- INSERT INTO `sms` (`id`, `Language_id`, `content`) VALUES (1, 1, 'Happy Birthday!'), (2, 2, 'عيد ميلاد سعيد'); -- -- Indexes for dumped tables -- -- -- Indexes for table `customers` -- ALTER TABLE `customers` ADD PRIMARY KEY (`id`); -- -- Indexes for table `languages` -- ALTER TABLE `languages` ADD PRIMARY KEY (`id`); -- -- Indexes for table `sms` -- ALTER TABLE `sms` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `customers` -- ALTER TABLE `customers` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `languages` -- ALTER TABLE `languages` MODIFY `id` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `sms` -- ALTER TABLE `sms` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; /*!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
7858717163aa5852f57f7ed44424a73e803a9f47
SQL
guillez/ramas
/sql/ddl/60_FK/fk_mgi_institucion_arau_instituciones.sql
ISO-8859-2
719
3.046875
3
[]
no_license
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- SIU-Kolla 4 - Mdulo de Gestin de Encuestas -- Versin 4.3 -- Tabla: mgi_institucion -- FK: fk_mgi_institucion_arau_instituciones -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- DROP INDEX ifk_mgi_institucion_arau_instituciones; CREATE INDEX ifk_mgi_institucion_arau_instituciones ON mgi_institucion (institucion_araucano); -- ALTER TABLE mgi_institucion DROP CONSTRAINT fk_mgi_institucion_arau_instituciones; ALTER TABLE mgi_institucion ADD CONSTRAINT fk_mgi_institucion_arau_instituciones FOREIGN KEY (institucion_araucano) REFERENCES arau_instituciones (institucion_araucano) deferrable;
true
39f353b618e82818e24bbc0623d6396ff9ad6d96
SQL
BarJei/pupspc-stms
/db_pupspc_stms.sql
UTF-8
11,374
3.1875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.4.15.5 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Oct 04, 2016 at 07:55 PM -- Server version: 5.6.30 -- PHP Version: 5.6.21 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `db_pupspc_stms` -- -- -------------------------------------------------------- -- -- Table structure for table `tbl_courses` -- CREATE TABLE IF NOT EXISTS `tbl_courses` ( `id` tinyint(2) NOT NULL, `value` varchar(10) NOT NULL, `label` varchar(99) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbl_courses` -- INSERT INTO `tbl_courses` (`id`, `value`, `label`) VALUES (1, 'BSIT', 'Bachelor of Science in Information Technology'), (2, 'BSA', 'Bachelor of Science in Accountancy'), (3, 'BSBA-MM', 'Bachelor of Science in Business Administration Major in Marketing Management'), (4, 'BSBA-HRDM', 'Bachelor of Science in Business Administration Major in Human Resource Development Management'), (5, 'BSBA-EM', 'Bachelor of Science in Business Administration Major in Entrepreneurial Management'), (6, 'BSED-M', 'Bachelor of Science in Education Major in Math'), (7, 'BSED-E', 'Bachelor of Science in Education Major in English'); -- -------------------------------------------------------- -- -- Table structure for table `tbl_staffs` -- CREATE TABLE IF NOT EXISTS `tbl_staffs` ( `id` int(10) NOT NULL, `userType` tinyint(2) NOT NULL DEFAULT '0' COMMENT '1 = admin, 2 = guard', `email` varchar(50) NOT NULL, `username` varchar(50) NOT NULL, `password` varchar(255) NOT NULL, `firstName` varchar(50) NOT NULL, `lastName` varchar(50) NOT NULL, `birthdate` date DEFAULT NULL, `dateCreated` datetime NOT NULL, `dateUpdated` datetime DEFAULT NULL, `isDeleted` tinyint(2) NOT NULL DEFAULT '0' ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbl_staffs` -- INSERT INTO `tbl_staffs` (`id`, `userType`, `email`, `username`, `password`, `firstName`, `lastName`, `birthdate`, `dateCreated`, `dateUpdated`, `isDeleted`) VALUES (1, 1, 'admin@smartwave.ph', 'admin', '$2a$08$7S0XokFyZcxKMDYj5yVtmOqAJqrILfNtfBcA0nv5g1/Mo0HrmNsX2', 'BarJei', 'Loba', '1995-05-29', '2016-04-17 13:36:54', NULL, 0), (18, 1, 'anthony@gmail.com', 'tonton', '$2a$08$rolJjlcWmEjWIWI1Oi2OgOp9/7ZNrukXwHNduGdt1itpfVeR6npTu', 'Anthony', 'Manuel', NULL, '2016-09-08 08:13:49', NULL, 0), (21, 2, 'barjei@smartwave.ph', 'guard', '$2a$08$7S0XokFyZcxKMDYj5yVtmOqAJqrILfNtfBcA0nv5g1/Mo0HrmNsX2', 'Jeirene Richmond', 'Barbo', NULL, '2016-09-10 18:56:28', NULL, 0), (22, 1, 'asdf@asdf', 'asdfadf', '$2a$08$PYtA8I280IqPSODyI621QOUdPj4yIJsE81bMgI3DU6um/ezCnLX12', 'Asdfasdf', 'Adsfas', NULL, '2016-09-16 00:55:12', NULL, 0), (23, 2, 'asdfasdf@asdf', 'asdfasdf', '$2a$08$J06GguANo7RZCt3dEx0do.Q3SkHrgCe9OrqSduI9Oe0r4lFN4T5PC', 'Asdf', 'Asdf', NULL, '2016-09-16 00:55:33', NULL, 0); -- -------------------------------------------------------- -- -- Table structure for table `tbl_students` -- CREATE TABLE IF NOT EXISTS `tbl_students` ( `id` int(5) NOT NULL, `email` varchar(50) NOT NULL, `username` varchar(50) NOT NULL, `password` varchar(255) NOT NULL, `firstName` varchar(50) NOT NULL, `middleName` varchar(20) NOT NULL, `lastName` varchar(50) NOT NULL, `birthdate` date NOT NULL, `studNo` varchar(20) NOT NULL, `yearLevel` tinyint(2) NOT NULL, `course` varchar(20) NOT NULL, `rfid` int(40) NOT NULL, `userType` tinyint(2) NOT NULL DEFAULT '10' COMMENT '10 = student, 1 = L.M.G., 2 = S.A.', `isOnline` tinyint(2) NOT NULL DEFAULT '0', `isAtLab` tinyint(2) NOT NULL DEFAULT '0', `isValidated` tinyint(2) NOT NULL DEFAULT '0', `dateCreated` datetime NOT NULL, `dateUpdated` datetime DEFAULT NULL, `isDeleted` tinyint(2) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbl_students` -- INSERT INTO `tbl_students` (`id`, `email`, `username`, `password`, `firstName`, `middleName`, `lastName`, `birthdate`, `studNo`, `yearLevel`, `course`, `rfid`, `userType`, `isOnline`, `isAtLab`, `isValidated`, `dateCreated`, `dateUpdated`, `isDeleted`) VALUES (1, '', '', '', 'Jeirene Richmond', 'Loba', 'Barbo', '0000-00-00', '2011-00150-sp-0', 4, 'BSIT', 1282427186, 10, 0, 1, 0, '2016-09-15 00:37:44', NULL, 0), (3, '', '', '', 'Jierose', 'Camara', 'Escaño', '0000-00-00', '2012-00067-sp-0', 4, 'BSIT', 1384568114, 10, 1, 0, 0, '2016-09-15 00:39:21', NULL, 0), (4, '', '', '', 'Labo', '', 'Ratory', '0000-00-00', '2011-00123-sp-0', 3, 'BSIT', 2147483647, 1, 0, 1, 0, '2016-09-15 01:03:04', NULL, 0), (10, '', '', '', 'Assistant', '', 'Student', '0000-00-00', '2011-00232-sp-0', 2, 'BSA', 1016651653, 2, 1, 0, 0, '2016-09-15 02:21:16', NULL, 0); -- -------------------------------------------------------- -- -- Table structure for table `tbl_studTypes` -- CREATE TABLE IF NOT EXISTS `tbl_studTypes` ( `id` tinyint(4) NOT NULL, `value` tinyint(2) NOT NULL, `label` varchar(30) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbl_studTypes` -- INSERT INTO `tbl_studTypes` (`id`, `value`, `label`) VALUES (1, 10, 'N/A'), (2, 1, 'Laboratory Maintenance Group'), (3, 2, 'Student Assistant'); -- -------------------------------------------------------- -- -- Table structure for table `tbl_timelogs` -- CREATE TABLE IF NOT EXISTS `tbl_timelogs` ( `id` int(10) NOT NULL, `rfid` int(20) NOT NULL, `logTime` datetime NOT NULL, `logOut` datetime DEFAULT NULL, `logDate` date NOT NULL, `logHours` time DEFAULT NULL ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbl_timelogs` -- INSERT INTO `tbl_timelogs` (`id`, `rfid`, `logTime`, `logOut`, `logDate`, `logHours`) VALUES (1, 1282427186, '2016-09-15 03:43:30', '2016-09-15 04:17:38', '2016-09-15', NULL), (2, 2147483647, '2016-09-15 03:44:34', NULL, '2016-09-15', NULL), (3, 0, '2016-09-15 03:44:41', NULL, '2016-09-15', NULL), (4, 0, '2016-09-15 03:47:25', NULL, '2016-09-15', NULL), (5, 0, '2016-09-15 03:47:54', NULL, '2016-09-15', NULL), (6, 1282427186, '2016-09-15 03:49:22', '2016-09-15 04:17:38', '2016-09-15', NULL), (7, 1282427186, '2016-09-15 03:51:50', '2016-09-15 04:17:38', '2016-09-15', NULL), (8, 1282427186, '2016-09-15 03:54:35', '2016-09-15 04:17:38', '2016-09-15', NULL), (9, 1282427186, '2016-09-15 03:58:14', '2016-09-15 04:17:38', '2016-09-15', NULL), (10, 1282427186, '2016-09-15 03:59:05', '2016-09-15 04:17:38', '2016-09-15', NULL), (11, 1282427186, '2016-09-15 03:59:27', '2016-09-15 04:17:38', '2016-09-15', NULL), (12, 1282427186, '2016-09-15 04:00:43', '2016-09-15 04:17:38', '2016-09-15', NULL), (13, 1282427186, '2016-09-15 04:01:26', '2016-09-15 04:17:38', '2016-09-15', NULL), (14, 1282427186, '2016-09-15 04:01:26', '2016-09-15 04:17:38', '2016-09-15', NULL), (15, 1282427186, '2016-09-15 04:02:31', '2016-09-15 04:17:38', '2016-09-15', NULL), (16, 1282427186, '2016-09-15 04:03:18', '2016-09-15 04:17:38', '2016-09-15', NULL), (17, 1282427186, '2016-09-15 04:05:00', '2016-09-15 04:17:38', '2016-09-15', NULL), (18, 1282427186, '2016-09-15 04:09:48', '2016-09-15 04:17:38', '2016-09-15', NULL), (19, 1282427186, '2016-09-15 04:11:11', '2016-09-15 04:17:38', '2016-09-15', NULL), (20, 1282427186, '2016-09-15 04:13:32', '2016-09-15 04:17:38', '2016-09-15', NULL), (21, 1282427186, '2016-09-15 04:15:30', '2016-09-15 04:17:38', '2016-09-15', NULL), (22, 1282427186, '2016-09-15 04:16:46', '2016-09-15 04:17:38', '2016-09-15', NULL), (23, 1282427186, '2016-09-15 04:24:35', NULL, '2016-09-15', NULL), (24, 1384568114, '2016-09-26 14:05:22', NULL, '2016-09-26', NULL), (25, 1016651653, '2016-09-26 14:05:45', NULL, '2016-09-26', NULL); -- -------------------------------------------------------- -- -- Table structure for table `tbl_timelogs_lab` -- CREATE TABLE IF NOT EXISTS `tbl_timelogs_lab` ( `id` int(10) NOT NULL, `rfid` int(20) NOT NULL, `logTime` datetime NOT NULL, `logOut` datetime DEFAULT NULL, `logDate` date NOT NULL, `logHours` time DEFAULT NULL ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbl_timelogs_lab` -- INSERT INTO `tbl_timelogs_lab` (`id`, `rfid`, `logTime`, `logOut`, `logDate`, `logHours`) VALUES (1, 1282427186, '2016-10-05 01:55:11', NULL, '2016-10-05', NULL), (2, 2147483647, '2016-10-05 01:56:53', '2016-10-05 01:57:12', '2016-10-05', NULL), (3, 2147483647, '2016-10-05 01:57:05', '2016-10-05 01:57:12', '2016-10-05', NULL), (4, 2147483647, '2016-10-05 01:57:14', NULL, '2016-10-05', NULL); -- -------------------------------------------------------- -- -- Table structure for table `tbl_yearLevels` -- CREATE TABLE IF NOT EXISTS `tbl_yearLevels` ( `id` tinyint(2) NOT NULL, `value` tinyint(2) NOT NULL, `label` varchar(20) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbl_yearLevels` -- INSERT INTO `tbl_yearLevels` (`id`, `value`, `label`) VALUES (1, 1, '1st year'), (2, 2, '2nd year'), (3, 3, '3rd year'), (4, 4, '4th year'); -- -- Indexes for dumped tables -- -- -- Indexes for table `tbl_courses` -- ALTER TABLE `tbl_courses` ADD PRIMARY KEY (`id`); -- -- Indexes for table `tbl_staffs` -- ALTER TABLE `tbl_staffs` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `email` (`email`); -- -- Indexes for table `tbl_students` -- ALTER TABLE `tbl_students` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `rfid` (`rfid`), ADD UNIQUE KEY `studNo` (`studNo`); -- -- Indexes for table `tbl_studTypes` -- ALTER TABLE `tbl_studTypes` ADD PRIMARY KEY (`id`); -- -- Indexes for table `tbl_timelogs` -- ALTER TABLE `tbl_timelogs` ADD PRIMARY KEY (`id`); -- -- Indexes for table `tbl_timelogs_lab` -- ALTER TABLE `tbl_timelogs_lab` ADD PRIMARY KEY (`id`); -- -- Indexes for table `tbl_yearLevels` -- ALTER TABLE `tbl_yearLevels` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tbl_courses` -- ALTER TABLE `tbl_courses` MODIFY `id` tinyint(2) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `tbl_staffs` -- ALTER TABLE `tbl_staffs` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=25; -- -- AUTO_INCREMENT for table `tbl_students` -- ALTER TABLE `tbl_students` MODIFY `id` int(5) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=11; -- -- AUTO_INCREMENT for table `tbl_studTypes` -- ALTER TABLE `tbl_studTypes` MODIFY `id` tinyint(4) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `tbl_timelogs` -- ALTER TABLE `tbl_timelogs` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=26; -- -- AUTO_INCREMENT for table `tbl_timelogs_lab` -- ALTER TABLE `tbl_timelogs_lab` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `tbl_yearLevels` -- ALTER TABLE `tbl_yearLevels` MODIFY `id` tinyint(2) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5; /*!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
cf78f67b3616a1d708e1d7b6dc97314c7c6fd6d9
SQL
NguyenDucHai1999/Baitapgiuaky
/Middle/Kiemtragiuaky-main/Middletearm/nguyenduchai.sql
UTF-8
3,618
3.125
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.2 -- https://www.phpmyadmin.net/ -- -- Máy chủ: 127.0.0.1 -- Thời gian đã tạo: Th8 23, 2021 lúc 01:25 PM -- Phiên bản máy phục vụ: 10.4.14-MariaDB -- Phiên bản PHP: 7.2.33 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 */; -- -- Cơ sở dữ liệu: `dhtl` -- -- -------------------------------------------------------- -- -- Cấu trúc bảng cho bảng `tbl_admin` -- CREATE TABLE `tbl_admin` ( `id` int(10) UNSIGNED NOT NULL, `username` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `password` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Đang đổ dữ liệu cho bảng `tbl_admin` -- INSERT INTO `tbl_admin` (`id`, `username`, `email`, `password`) VALUES (1, 'admin', 'admin@gmail.com', 'admin'); -- -------------------------------------------------------- -- -- Cấu trúc bảng cho bảng `tbl_giangvien` -- CREATE TABLE `tbl_giangvien` ( `id` int(10) UNSIGNED NOT NULL, `parent_id` int(10) UNSIGNED NOT NULL, `hovaten` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `sdt` int(11) NOT NULL, `bomon` varchar(50) NOT NULL, `chucvu` varchar(50) NOT NULL, `mota` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Đang đổ dữ liệu cho bảng `tbl_giangvien` -- INSERT INTO `tbl_giangvien` (`id`, `parent_id`, `hovaten`, `email`, `sdt`, `bomon`, `chucvu`, `mota`) VALUES (1, 1, 'Bùi Xuân Huấn', 'huanhoahong@gmail.com', 1345, 'Công nghệ Web', 'Trưởng khoa', 'Lorem Ipsum the content of desnawdawdwadawdawd'); -- -------------------------------------------------------- -- -- Cấu trúc bảng cho bảng `tbl_khoa` -- CREATE TABLE `tbl_khoa` ( `id` int(10) UNSIGNED NOT NULL, `tenkhoa` varchar(50) NOT NULL, `maytruc` varchar(50) NOT NULL, `diachi` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Đang đổ dữ liệu cho bảng `tbl_khoa` -- INSERT INTO `tbl_khoa` (`id`, `tenkhoa`, `maytruc`, `diachi`) VALUES (1, 'CNTT', '0148484', '175 Tây Sơn'); -- -- Chỉ mục cho các bảng đã đổ -- -- -- Chỉ mục cho bảng `tbl_admin` -- ALTER TABLE `tbl_admin` ADD PRIMARY KEY (`id`); -- -- Chỉ mục cho bảng `tbl_giangvien` -- ALTER TABLE `tbl_giangvien` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `parent_id` (`parent_id`); -- -- Chỉ mục cho bảng `tbl_khoa` -- ALTER TABLE `tbl_khoa` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT cho các bảng đã đổ -- -- -- AUTO_INCREMENT cho bảng `tbl_admin` -- ALTER TABLE `tbl_admin` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT cho bảng `tbl_giangvien` -- ALTER TABLE `tbl_giangvien` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT cho bảng `tbl_khoa` -- ALTER TABLE `tbl_khoa` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- Các ràng buộc cho các bảng đã đổ -- -- -- Các ràng buộc cho bảng `tbl_giangvien` -- ALTER TABLE `tbl_giangvien` ADD CONSTRAINT `tbl_giangvien_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `tbl_khoa` (`id`); 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
004e5057f5968d7e030ad6c4b3652052ba9fa946
SQL
axelsheva/experience
/SQL-Tuning/ifi.uzh.ch/vn/ThucHanhCoSoDuLieu/N0155351/VuDinhDieu_20090459_L0155351.sql
UTF-8
991
4.15625
4
[]
no_license
/* Cau 1 */ select ProductNumber, ListPrice, Name from Production.Product as p1, Sales.SalesOrderDetail as s1 where p1.ProductID in (select top 10 ProductID from Sales.SalesOrderDetail where p1.ProductID = s1.ProductID group by ProductID order by (p1.ListPrice) DESC) /* Cau 2 */ select year(OrderDate), FirstName, MiddleName, LastName, EmailPromotion, SaleOrderID, TotalDue from Person.Person as p1, Sales.SalesOrderHeader as s1 where year(s1.OrderDate) = 2003 and s1.BusinessEntityID = p1.BusinessEntityID and s1.TotalDue >= 100000 /* Cau 3 */ Select COUNT(*) From Production.Product p, Production.ProductSubcategory s, Production.ProductCategory c, Sales.SalesOrderHeader h,Sales.SalesOrderDetail d, Person.Address a Where c.Name = 'Clothing' and p.ProductSubcategoryID = s.ProductSubcategoryID and s.ProductCategoryID = c.ProductCategoryID and d.ProductID = p.ProductID and h.SalesOrderID = d.SalesOrderDetailID and h.ShipToAddressID = a.AddressID and a.City = 'London'
true
8ee2ac8680296ba00185a6a73095f7869977dd32
SQL
tanuwaplk/postgres-netology
/доп.sql
UTF-8
6,980
4.1875
4
[]
no_license
В данной таблице хранят информацию по изменению "статуса" для каждого типа поля (field ). То есть, есть поле pin, на 21.07.2017 было изменено значение, соответственно новое (new_value ) стало '' (пустая строка) и старое (old_value), записалось как '300-L'. Далее 26.07.2017 изменили значение с '' (пустая строка) на '10-AA'. И так по разным полям в разные даты были какие-то изменения значений. Задача: составить запрос таким образом, что бы в новой результирующей таблице был календарь изменения значений для каждого поля. Всего три столбца: дата, поле, текущий статус. То есть для каждого поля будет отображение каждого дня с отображением текущего статуса. К примеру, для поля pin на 21.07.2017 статус будет '' (пустая строка), на 22.07.2017 - '' (пустая строка). и т.д. до 26.07.2017, где статус станет '10-AA' Решение должно быть универсальным для любого SQL, не только под PostgreSQL ;) create table test ( date_event timestamp, field varchar(50), old_value varchar(50), new_value varchar(50) ) insert into test (date_event, field, old_value, new_value) values ('2017-08-05', 'val', 'ABC', '800'), ('2017-07-26', 'pin', '', '10-AA'), ('2017-07-21', 'pin', '300-L', ''), ('2017-07-26', 'con', 'CC800', 'null'), ('2017-08-11', 'pin', 'EKH', 'ABC-500'), ('2017-08-16', 'val', '990055', '100') select * from test order by date(date_event) select gs::date as change_date, fields.field as field_name, case when ( select new_value from test t where t.field = fields.field and t.date_event = gs::date) is not null then ( select new_value from test t where t.field = fields.field and t.date_event = gs::date) else ( select new_value from test t where t.field = fields.field and t.date_event < gs::date order by date_event desc limit 1) end as field_value from generate_series((select min(date(date_event)) from test), (select max(date(date_event)) from test), interval '1 day') as gs, (select distinct field from test) as fields order by field_name, change_date --8 146 223 select distinct field, gs, first_value(new_value) over (partition by value_partition) from (select t2.*, t3.new_value, sum(case when t3.new_value is null then 0 else 1 end) over (order by t2.field, t2.gs) as value_partition from (select field, generate_series((select min(date_event)::date from test), (select max(date_event)::date from test), interval '1 day')::date as gs from test) as t2 left join test t3 on t2.field = t3.field and t2.gs = t3.date_event::date) t4 order by field, gs --92 709 explain analyze with recursive r(a, b, c) as ( select temp_t.i, temp_t.field, t.new_value from (select min(date(t.date_event)) as i, f.field from test t, (select distinct field from test) as f group by f.field) as temp_t left join test t on temp_t.i = t.date_event and temp_t.field = t.field union all select a + 1, b, case when t.new_value is null then c else t.new_value end from r left join test t on t.date_event = a + 1 and b = t.field where a < (select max(date(date_event)) from test) ) SELECT * FROM r order by b, a --2616 explain analyze with recursive r as ( --стартовая часть рекурсии select min(t.date_event) as c_date ,max(t.date_event) as max_date from test t union -- рекурсивная часть select r.c_date+ INTERVAL '1 day' as c_date ,r.max_date from r where r.c_date < r.max_date ), t as (select t.field , t.new_value , t.date_event , case when lead(t.date_event) over (partition by t.field order by t.date_event) is null then max(t.date_event) over () else lead(t.date_event) over (partition by t.field order by t.date_event)- INTERVAL '1 day' end as next_date , min (t.date_event) over () as min_date , max(t.date_event) over () as max_date from ( select t1.date_event ,t1.field ,t1.new_value ,t1.old_value from test t1 union all select distinct min (t2.date_event) over () as date_event --первые стартовые даты ,t2.field ,null as new_value ,null as old_value from test t2) t ) select r.c_date, t.field , t.new_value from r join t on r.c_date between t.date_event and t.next_date order by t.field,r.c_date Есть таблица. В таблице есть юзеры, которые заходят на разные страницы page. задача: выделить из таблицы тех юзеров, которые заходили подряд на страницы 1, 2, 3. именно в таком порядке. Сначала зашел несколько раз (или один раз) на 1 стр, потом 2, потом 3. Юзеры, которые заходили в других последовательностях, к примеру 2 2 2 1 3 2 нам не подходят. drop table a create table a ( user_id int, page int, time int ) insert into a (user_id, page, time) values (1,2,201), (1,1,202), (1,3,203), (2,1,201), (2,2,205), (2,3,206), (3,1,205), (3,2,203), (3,3,208), (4,1,203), (4,1,204), (4,2,205), (4,3,208), (5,1,203), (5,1,204), (5,3,205), (5,2,208), (5,3,209) explain analyze with info as ( select user_id, array_agg( page order by min_time) as page_visits from ( select user_id, page, min(time) as min_time from a group by user_id, page ) s group by user_id) select user_id from info where page_visits = ( select array_agg(t.page) from (select distinct page from a order by page) t) -- 66 with a as (select user_id, page, case when page = row_number() over(partition by user_id order by min(time)) then 1 else 0 end as is_true from a group by user_id, page order by user_id) select user_id from a group by user_id having sum(is_true)=3 explain analyze select t.user_id from ( select distinct user_id, page, time from a order by time, user_id) t group by t.user_id having array_agg(t.page) = any( select array_agg(t.page) from (select distinct page from a order by page) t) -- 61 explain analyze select t.user_id from ( select distinct user_id, page, time from a order by time, user_id) t group by t.user_id having array_agg(t.page) = any( select array_agg(t.gs) from (select generate_series((select min(page) from a), (select max(page) from a)) gs) t) -- 61
true
f1d20d35b13e432bd8c60b1df1abdeae787c7f66
SQL
AlphaSourceCode/PHP-PaChong
/pachong .sql
UTF-8
1,344
2.609375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.1.14 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: 2021-09-02 10:07:47 -- 服务器版本: 5.6.17 -- PHP Version: 5.5.12 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: `pachong` -- -- -------------------------------------------------------- -- -- 表的结构 `datas` -- CREATE TABLE IF NOT EXISTS `datas` ( `id` int(20) NOT NULL AUTO_INCREMENT, `title` varchar(600) DEFAULT NULL, `link` varchar(900) DEFAULT NULL, `date` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- 表的结构 `list` -- CREATE TABLE IF NOT EXISTS `list` ( `id` int(20) NOT NULL AUTO_INCREMENT, `link` varchar(900) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 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
0fee4e5f251a9ee0bda236f768693f2ce559ccfa
SQL
lycantropos/seek-well
/test_scripts/views/v_mtt_useful_games.sql
UTF-8
1,366
3.90625
4
[ "MIT" ]
permissive
CREATE OR REPLACE VIEW v_mtt_useful_games AS ( WITH games_without_bots AS ( SELECT f_name, 'without bots'::TEXT AS f_metric_name, SUM(f_games) AS f_games, SUM(f_rake) AS f_rake FROM mv_mtt_games_by_pools WHERE f_bots_count = 0 GROUP BY f_name ), games_without_players AS ( SELECT f_name, 'without players'::TEXT AS f_metric_name, SUM(f_games) AS f_games, SUM(f_rake) AS f_rake FROM mv_mtt_games_by_pools WHERE f_players_count = 0 GROUP BY f_name ), games_with_players_and_bots AS ( SELECT f_name, 'with players and bots'::TEXT AS f_metric_name, SUM(f_games) AS f_games, SUM(f_rake) AS f_rake FROM mv_mtt_games_by_pools WHERE f_players_count > 0 AND f_bots_count > 0 GROUP BY f_name ) SELECT f_name, f_metric_name, f_games, f_rake FROM games_with_players_and_bots FULL JOIN games_without_bots USING (f_name, f_metric_name, f_games, f_rake) FULL JOIN games_without_players USING (f_name, f_metric_name, f_games, f_rake) );
true
23e4795263067089af7e609fbb914d3c772b0c49
SQL
VictorWestLarsen/SkoleOpgaver
/Database Øvelser/Ex26/Øvelse 5/EmployeesCreate.sql
UTF-8
226
2.921875
3
[]
no_license
CREATE TABLE Employees( Name NvarChar(100) NULL, Address NvarChar(100) NULL, Zipcode INT NULL, Department NvarChar(50) NULL, TelephoneNo NvarChar(50) NOT NULL, -- CONSTRAINT EMPLOYEES_PK PRIMARY KEY(TelephoneNo) )
true
66ce552f6e53191a1a080c8f98bb567976f6af00
SQL
wheatandcat/dotstamp_server
/db/migrations/20170307230520_log_questions.sql
UTF-8
640
3.296875
3
[ "MIT" ]
permissive
-- +goose Up -- SQL in section 'Up' is executed when this migration is applied CREATE TABLE IF NOT EXISTS `log_questions` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `user_id` BIGINT NOT NULL COMMENT 'ユーザID', `email` VARCHAR(100) NOT NULL COMMENT 'メールアドレス', `body` TEXT COMMENT '本文', `created_at` DATETIME NULL COMMENT '作成日時', `updated_at` DATETIME NULL COMMENT '更新日時', `deleted_at` DATETIME NULL COMMENT '削除日時', PRIMARY KEY (`id`) ) ENGINE = InnoDB; -- +goose Down -- SQL section 'Down' is executed when this migration is rolled back DROP TABLE `log_questions`;
true
f231caf6ca5d037ba766498f7b786c3d29a48994
SQL
SauzeauYannis/BDD-Projet
/4_Coherence/contraintes_categories.sql
UTF-8
3,525
3.859375
4
[]
no_license
-- Dans notre base, lorsque l'on veut créer des données spécifiques à une catégorie de document -- (par exemple : ajouter un nombre de page à un livre) il faut ajouter les données dans la table -- qui porte le nom de la catégorie du document avec pour clef primaire une clef étrangère qui -- référence le document (par exemple : ajouter dans la table 'Book' la clef primaire '0' et le -- nombre de page '200' où '0' est la clef primaire d'un document qui a pour catégorie_id la -- clef étrangère qui référence la catégorie 'Livre' dans la table 'Document_category'). -- Création des contraintes CREATE OR REPLACE TRIGGER trigger_book_category BEFORE INSERT OR UPDATE ON Book FOR EACH ROW DECLARE category VARCHAR2(64); BEGIN SELECT category_name INTO category FROM Document D, Document_category DC WHERE :NEW.document_id = D.document_id AND D.document_category_id = DC.document_category_id; IF category != 'Livre' THEN RAISE_APPLICATION_ERROR(-20001, 'Mauvaise clef primaire : Vous devez référencer un document de la catégorie "Livre"'); ELSE NULL; END IF; END; / CREATE OR REPLACE TRIGGER trigger_cd_category BEFORE INSERT OR UPDATE ON CD FOR EACH ROW DECLARE category VARCHAR2(64); BEGIN SELECT category_name INTO category FROM Document D, Document_category DC WHERE :NEW.document_id = D.document_id AND D.document_category_id = DC.document_category_id; IF category != 'CD' THEN RAISE_APPLICATION_ERROR(-20002, 'Mauvaise clef primaire : Vous devez référencer un document de la catégorie "CD"'); ELSE NULL; END IF; END; / CREATE OR REPLACE TRIGGER trigger_dvd_category BEFORE INSERT OR UPDATE ON DVD FOR EACH ROW DECLARE category VARCHAR2(64); BEGIN SELECT category_name INTO category FROM Document D, Document_category DC WHERE :NEW.document_id = D.document_id AND D.document_category_id = DC.document_category_id; IF category != 'DVD' THEN RAISE_APPLICATION_ERROR(-20003, 'Mauvaise clef primaire : Vous devez référencer un document de la catégorie "DVD"'); ELSE NULL; END IF; END; / CREATE OR REPLACE TRIGGER trigger_video_category BEFORE INSERT OR UPDATE ON VIDEO FOR EACH ROW DECLARE category VARCHAR2(64); BEGIN SELECT category_name INTO category FROM Document D, Document_category DC WHERE :NEW.document_id = D.document_id AND D.document_category_id = DC.document_category_id; IF category != 'Video' THEN RAISE_APPLICATION_ERROR(-20004, 'Mauvaise clef primaire : Vous devez référencer un document de la catégorie "Video"'); ELSE NULL; END IF; END; / -- Désactivation des contraintes ALTER TRIGGER trigger_book_category DISABLE; ALTER TRIGGER trigger_cd_category DISABLE; ALTER TRIGGER trigger_dvd_category DISABLE; ALTER TRIGGER trigger_video_category DISABLE; -- Activation des contraintes ALTER TRIGGER trigger_book_category ENABLE; ALTER TRIGGER trigger_cd_category ENABLE; ALTER TRIGGER trigger_dvd_category ENABLE; ALTER TRIGGER trigger_video_category ENABLE; -- Suppression des contraintes DROP TRIGGER trigger_book_category; DROP TRIGGER trigger_cd_category; DROP TRIGGER trigger_dvd_category; DROP TRIGGER trigger_video_category;
true
0fbf7793c268bb2332de87cb523f077a4a98981b
SQL
msldiarra/geovel
/geovel-da/src/main/resources/db/migration/V2__geovel_data_init.sql
UTF-8
1,636
3.375
3
[]
no_license
-- Create owners INSERT INTO Owner (Name) VALUES ('Mamadou Lamine DIARRA'), ('Ange PETE'), ('Toupac Transport'); -- Create contact type INSERT INTO ContactType (Type) VALUES ('Manager'), ('Assistant'), ('Driver'); -- Contact info INSERT INTO ContactInfo (PhoneNumber) VALUES ('+22373034603'), ('+22373034603'), ('+22373034603'); -- Create contacts drivers and owners INSERT INTO Contact (FirstName, LastName, ContactInfoId, ContactTypeId) VALUES ('Mamadou', 'Diarra', 1, 3), ('Issa', 'Synayogo', 2, 1), ('Samba', 'Sidibe', 3, 1); -- Create Cars INSERT INTO Car (Name, Reference, OwnerId) VALUES ('Car 1', 'A000000', 2), --Ange ('Car 2', 'A000001', 2), --Ange ('Car 3', 'A000002', 3), --Issa ('Car 4', 'A000003', 3); --Issa -- Car driver contact INSERT INTO CarDriverContact (CarId, ContactId) VALUES (1, 1), (2, 1), (3, 1), (4, 1); INSERT INTO Login (Login, Password, Enabled) VALUES ('toupac','dnaqr7AnyCW9mrq3iyNAcOcCdS9iW3UuVeVbSOYH41g=','1'); INSERT INTO Login (Login, Password, Enabled) VALUES ('admin','dnaqr7AnyCW9mrq3iyNAcOcCdS9iW3UuVeVbSOYH41g=','1'); INSERT INTO ContactLogin VALUES (2,1); INSERT INTO ContactLogin VALUES (3,2); -- Create zone INSERT INTO Zone (Name) VALUES ('Paris'); INSERT INTO Location (Latitude, Longitude) VALUES (17.570692, -3.996166), (16.570692, -3.996166); INSERT INTO CarLocation (LocationId, CarId, Time) VALUES (1, 3, '2015-06-28''T''15:35:09.000Z'), (1, 3, '2016-07-23''T''15:35:09.000Z'); INSERT INTO Bounds (ZoneId, NorthEastId, SouthwestId) VALUES (1 , 1, 2); -- Zone Paris, NorthEast 1, SouthWest 2 INSERT INTO OwnerContact VALUES (3, 2);
true
dfb610d915b31d3d02feda8e60ce2dd7613f6618
SQL
desc0n/timepoint
/assets/sql/migration2.sql
UTF-8
558
3.109375
3
[ "BSD-3-Clause" ]
permissive
-- -- Структура таблицы `content__contacts` -- CREATE TABLE IF NOT EXISTS `content__contacts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` enum('address','phone','email') NOT NULL, `value` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; -- -- Дамп данных таблицы `content__contacts` -- INSERT INTO `content__contacts` (`id`, `type`, `value`) VALUES (1, 'address', 'г. Владивосток, ул. Посьетская, 14'), (2, 'phone', '8 800 235 35 72');
true
782200b2a0a80aa5c10fd9758f1fa0f82149ce65
SQL
ruviniruvi/Advanced-Database-Project-1
/Advanced Database Project 1/CSC 424 Project 1/table_students.sql
UTF-8
545
3.0625
3
[]
no_license
CREATE TABLE Students( student_id int NOT NULL, student_SSN varchar (11) NOT NULL, student_first_name varchar(50) NOT NULL, student_last_name varchar(50) NOT NULL, student_GPA float NOT NULL, student_graduation_date varchar (25) NOT NULL, student_phone_number varchar (10) NOT NULL, student_email varchar(50) NOT NULL, student_date_of_birth date NOT NULL, student_age int NOT NULL, student_status varchar(50) NOT NULL, department_id int NOT NULL, primary key(student_id), foreign key (department_id) references Departments(department_id) );
true
85fa583268bb0a52db69c66aa95907ea6b3db495
SQL
LSFLK/Copper
/copper-server/service_images/groupoffice-6.3.66/groupoffice-6.3.66-php-70/modules/postfixadmin/install/install.sql
UTF-8
2,706
3.09375
3
[ "GPL-1.0-or-later", "LGPL-2.0-or-later", "LGPL-3.0-only", "LicenseRef-scancode-proprietary-license", "GPL-3.0-only", "AGPL-3.0-only", "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "LGPL-2.0-only", "AGPL-3.0-or-later", "Apache-2.0" ]
permissive
-- phpMyAdmin SQL Dump -- version 2.6.0-pl2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generatie Tijd: 20 Aug 2008 om 15:59 -- Server versie: 5.0.32 -- PHP Versie: 5.2.0-8+etch11 -- -- Database: `servermanager` -- -- -------------------------------------------------------- -- -- Tabel structuur voor tabel `pa_aliases` -- DROP TABLE IF EXISTS `pa_aliases`; CREATE TABLE IF NOT EXISTS `pa_aliases` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain_id` int(11) NOT NULL, `address` varchar(190) default NULL, `goto` text, `ctime` int(11) NOT NULL default '0', `mtime` int(11) NOT NULL default '0', `active` enum('0','1') NOT NULL default '1', PRIMARY KEY (`id`), KEY `address` (`address`), KEY `domain_id` (`domain_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Postfix Admin - Virtual Aliases'; -- -------------------------------------------------------- -- -- Tabel structuur voor tabel `pa_domains` -- DROP TABLE IF EXISTS `pa_domains`; CREATE TABLE IF NOT EXISTS `pa_domains` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `domain` varchar(190) default NULL, `description` varchar(255) default NULL, `max_aliases` int(10) NOT NULL default '0', `max_mailboxes` int(10) NOT NULL default '0', `total_quota` bigint(20) NOT NULL default '0', `default_quota` bigint(20) NOT NULL default '0', `transport` VARCHAR( 255 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'virtual', `backupmx` tinyint(1) NOT NULL default '0', `ctime` int(11) NOT NULL default '0', `mtime` int(11) NOT NULL default '0', `active` BOOLEAN NOT NULL DEFAULT '1', `acl_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `domain` (`domain`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Postfix Admin - Virtual Domains'; -- -------------------------------------------------------- -- -- Tabel structuur voor tabel `pa_mailboxes` -- DROP TABLE IF EXISTS `pa_mailboxes`; CREATE TABLE IF NOT EXISTS `pa_mailboxes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain_id` int(11) NOT NULL, `go_installation_id` varchar(50) default NULL, `username` varchar(190) NOT NULL DEFAULT '', `password` varchar(255) NOT NULL DEFAULT '', `name` varchar(255) NOT NULL DEFAULT '', `maildir` varchar(255) default NULL, `homedir` VARCHAR(255) default NULL, `quota` bigint(20) NOT NULL default '0', `ctime` int(11) NOT NULL, `mtime` int(11) NOT NULL, `active` BOOLEAN NOT NULL DEFAULT '1', `usage` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `username` (`username`), KEY `go_installation_id` (`go_installation_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Postfix Admin - Virtual Mailboxes';
true
4defffe4446bf64cf8b2b95d2d5d89ace44a480c
SQL
Sureshkrishh/SQL-Hands-on
/Hands-on-1/Hands-on-1.sql
UTF-8
1,782
3.140625
3
[ "MIT" ]
permissive
-- # ASSIGNMENT-1 # -- --CREATE DATABASE DEMO; --USE DEMO; ---------------------------------- CREATE TABLE EMP (EID CHAR(5), NAME VARCHAR(20), ADDR VARCHAR(40), CITY VARCHAR(20), DOB DATE, PHONE CHAR(14), EMAIL VARCHAR(30)); ---------------------------------- INSERT INTO EMP VALUES('E0001', 'Krishna', 'no.13 vathalkalam street, govidanagaram', 'Theni', '11-09-1997', '8939152272', 'sarakrishna.k@gmail.com'); INSERT INTO EMP VALUES ('E0002', 'Saraswathi', 'no.56/85 Kasigurusami street, maliputhur', 'Sriviliputhur', '04-14-1978', '9092875718', 'saraswathi.k@yahoo.com'); INSERT INTO EMP VALUES ('E0003', 'Dhivyabharathi', 'no.12/32 vanniyar street, kotivakkam', 'Chennai', '04-11-1991', '9626265468', 'dhivyyk@gmail.com'); INSERT INTO EMP VALUES ('E0004', 'Kariyamal', 'no.26 Indian bank street, varusanadu', 'Theni', '10-21-1968', '9626106254', 'kariyamalk.k@gmail.com'); INSERT INTO EMP VALUES ('E0005', 'Sreeja', 'no.56 police colony, anna nagar', 'Chennai', '11-08-1998', '8956234512', 'sreeja1998@yahoo.com'); INSERT INTO EMP VALUES ('E0006', 'Emimal', 'no.5/11 church road , sathchiyapuram', 'Sivakasi', '12-06-1998', '9428835774', 'yashminjemima@gmail.com'); INSERT INTO EMP VALUES ('E0007', 'Vignesh', 'no.68/75 ponni street, chrompet', 'Chennai', '12-06-1996', '8629637415', 'vikichintu56@gmail.com'); INSERT INTO EMP VALUES ('E0008', 'Shyam sundar', 'no.420 kannagi street, kknagar', 'Chennai', '08-08-1998', '9684251730', 'shyamprathap@yahoo.com'); INSERT INTO EMP VALUES ('E0009', 'Abilash', 'no.13/42, 2nd street, Govindanagaram', 'Theni', '05-02-1997', '8945462750', 'abilashabhii@gmail.com'); INSERT INTO EMP VALUES ('E0010', 'Harsith', 'no.56 police colony, anna nagar', 'Chennai', '07-21-2001', '9444456103', 'harshith@gmail.com'); ---------------------------------- SELECT * FROM EMP;
true
03321cad591116f06eaa56ddb01d2c6d5ca7479e
SQL
suetarazi/book-app
/schema.sql
UTF-8
1,236
3.0625
3
[]
no_license
DROP TABLE IF EXISTS books; CREATE TABLE books( id SERIAL PRIMARY KEY, title VARCHAR(255), author VARCHAR(255), isbn VARCHAR(255), image_url TEXT, description TEXT, bookshelf VARCHAR(255) ); INSERT INTO books (title, author, isbn, image_url, description, bookshelf) VALUES ('Eat, Pray, Love', 'Elizabeth Gilbert', '9782253126300', 'https://www.googleadservices.com/pagead/aclk?sa=L&ai=DChcSEwino8reqvLnAhUT1GQKHQZvDboYABACGgJwag&ohost=www.google.com&cid=CAESQOD20q6Vzq-WUTrDMv9JyaNytx0ftHXgyVKkVAl2Yn6xwEnxE6l8W91SzScaArSkgSL3fCQMbu_HWbshuo97ixY&sig=AOD64_01WX2Kl_s6IKswJaG49pkCCh66kQ&ctype=5&q=&ved=2ahUKEwiQ5r3eqvLnAhWHCjQIHUj5CL0Q8w56BQgcEKMB&adurl=', 'An awesome book about travel and life', 007); INSERT INTO books (title, author, isbn, image_url, description, bookshelf) VALUES ('The Four Agreements', 'don Miguel Ruiz', '9781878424310', 'https://www.googleadservices.com/pagead/aclk?sa=L&ai=DChcSEwiBq-6fq_LnAhWJ12QKHXAQAOoYABADGgJwag&ohost=www.google.com&cid=CAESQOD2iW3a7uf1SlByK6-5XoToM91ByB7h1CwNcfYGCpdFH46wSHkKF0Q0tCEDJalXblcWTDSk_nErr4vox2aweE8&sig=AOD64_1sOh1lXbHEy47k2GVUKEyJvT1l9Q&ctype=5&q=&ved=2ahUKEwj-keKfq_LnAhWBFjQIHaO_BqEQ9aACegQIGBBT&adurl=', 'A book full of infinite wisdom. One to read over and over', 008);
true
41d904898e15572a1796f3cc911ace524ed18100
SQL
mikestevenson86/SQL-Repository
/Mike S Queries/Archives/00 Archive 2017/01 January 2017/Clients - CQC Pro.sql
UTF-8
562
3.46875
3
[]
no_license
SELECT a.Id, Services_Taken_Long__c FROM Salesforce..Account a --inner join [database].CitationMain.dbo.citation_CompanyTable2 ct ON a.CitWeb_ID__c = ct.uid inner join [database].Shorthorn.dbo.cit_sh_clients cl ON a.Shorthorn_Id__c = cl.clientId inner join [database].Shorthorn.dbo.cit_sh_busType bt ON cl.busType = bt.busTypeId inner join [database].Shorthorn.dbo.cit_sh_businessSectors bs ON bt.businessSectorId = bs.Id WHERE a.Citation_Client__c = 'true' and Services_Taken_Long__c = 'Employment Law & HR / Health & Safety' and bs.title in ('Care','Dentists')
true
cd834c20ab3b8a99a3d62868ae9a3708db36b624
SQL
sherriff93/rt-ecommerce-site
/sql/create_database.sql
UTF-8
3,485
3.25
3
[]
no_license
connect 'jdbc:derby:C:\Users\Chris\Documents\webtech\databases\mydb;create=true'; create table users( uid INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), email VARCHAR(35) NOT NULL, password VARCHAR(35) NOT NULL, forename VARCHAR(35) NOT NULL, surname VARCHAR(35) NOT NULL, dob DATE NOT NULL, mobile VARCHAR(15), homephone VARCHAR(15), PRIMARY KEY (uid) ); create table address( aid INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), uid INT NOT NULL, line1 VARCHAR(35) NOT NULL, line2 VARCHAR(35) DEFAULT '', city VARCHAR(35) NOT NULL, county VARCHAR(35) NOT NULL, postcode VARCHAR(8) NOT NULL, PRIMARY KEY (aid), FOREIGN KEY (uid) REFERENCES users(uid) ); create table product( pid INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), name VARCHAR(100) NOT NULL, type VARCHAR(35), description VARCHAR(1000) DEFAULT 'There is no description for this item', image VARCHAR(1000) DEFAULT 'no_image.png', price FLOAT NOT NULL, PRIMARY KEY (pid) ); insert into product (name, type, description, image, price) values ('Beginner Juggling Balls','balls','Standard, light, multicoloured balls for beginners.', 'balls.png',5.99); insert into product (name, type, description, price) values ('Light-up Juggling Balls','balls','Glowing balls!',19.99); insert into product (name, type, description, price) values ('Fire Clubs','clubs','Show off your fire skills with these hot-off-the-market fire clubs! For over 18s only.',29.99); insert into product (name, type, description, price) values ('Throwing Knives','knives','Not for the faint hearted! Over 18s only.',14.99); insert into product (name, type, description, price) values ('Throwing frisbees','frisbees','Great for those looking to move on from juggling balls',9.99); insert into product (name, type, price) values ('Multicoloured Sock Poi','sock_poi',18.99); insert into product (name, type, price) values ('Light-up Poi','glow_poi',17.99); insert into product (name, type, price) values ('Fire Poi','fire_poi',26.99); insert into product (name, type, price) values ('Basic Staff','staffs',9.99); insert into product (name, type, price) values ('Fibre-glass Staff','staffs',14.99); insert into product (name, type, price) values ('Metal Staff','staffs',17.99); insert into product (name, type, price) values ('Light-up Staff','glow_staffs',19.99); insert into product (name, type, price) values ('Fire Staff','fire_staffs',19.99); insert into product (name, type, price) values ('Neon Diabolo','diabolos',14.99); insert into product (name, type, price) values ('Multicoloured Diabolo','diabolos',12.99); insert into product (name, type, price) values ('Mini Diabolo','diabolos',7.99); insert into product (name, type, price) values ('Basic Sticks','sticks',6.99); insert into product (name, type, price) values ('Carbon Fibre sticks','sticks',14.99); insert into product (name, type, price) values ('Basic Juggling DVD','dvds',9.99); insert into product (name, type, price) values ('Be a Diabolo Pro! DVD','dvds',9.99); insert into product (name, type, price) values ('Cirque du Sunny DVD','dvds',14.99); create table orders( uid INT NOT NULL, aid INT NOT NULL, pid INT NOT NULL, date DATE NOT NULL, payment_type varchar(35) NOT NULL, FOREIGN KEY (uid) REFERENCES users(uid), FOREIGN KEY (aid) REFERENCES address(aid), FOREIGN KEY (pid) REFERENCES product(pid) );
true
10b6d43b8ae4bce1ce12dfa78c8c0f4d1d8929ea
SQL
Bartek708/Game
/game.sql
UTF-8
6,777
3.375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.8.3 -- https://www.phpmyadmin.net/ -- -- Host: localhost:3306 -- Generation Time: Mar 07, 2019 at 02:13 PM -- Server version: 5.7.24-log -- PHP Version: 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 */; -- -- Database: `game` -- -- -------------------------------------------------------- -- -- Table structure for table `abilities` -- CREATE TABLE `abilities` ( `id` int(11) NOT NULL, `ability` varchar(25) NOT NULL, `description` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `abilities` -- INSERT INTO `abilities` (`id`, `ability`, `description`) VALUES (1, 'Ice Block', 'Encases you in a block of ice, protecting you from all attacks and damage for 10 sec, but during that time you cannot attack, move, or cast spells.\r\nCauses Hypothermia, preventing you from recasting Ice Block for 30 sec.'), (2, 'Blink', 'Teleports you forward 20 yds or until reaching an obstacle, and frees you from all stuns and bonds.'), (3, 'Frostbolt', 'Launches a bolt of frost at the enemy, causing (51.1% of Spell power) Frost damage and slowing movement speed by 50% for 8 sec.'), (4, 'Feign Death', 'Feign death, tricking enemies into ignoring you. Lasts up to 6 min.'), (5, 'Counter Shot', 'Interrupts spellcasting, preventing any spell in that school from being cast for 3 sec.'), (6, 'Kill Command', 'Give the command to kill, causing your pet to savagely deal (225%-450% of RAP) Physical damage to its target. 25 yard range.'), (7, 'Hearthstone', 'Returns you to <Hearthstone Location>. Speak to an Innkeeper in a different place to change your home location. (30 Min Cooldown)'), (8, 'Divine Shield', 'Protects you from all damage and spells for 8 sec. Cannot be used if you have Forbearance. Causes Forbearance for 30 sec.'), (9, 'Moonfire', 'A quick beam of lunar light burns the enemy for (110% of spell power) Arcane damage and then an additional (400% of spell power) Arcane damage over 16 sec. Usable while in Bear Form.'), (10, 'Fear', 'Strikes fear in the enemy, disorienting for 20 sec. Damage may cancel the effect. Limit 1.'), (11, 'Charge', 'Charge to an enemy, reducing its movement speed by 50% for 6 sec.'); -- -------------------------------------------------------- -- -- Table structure for table `chars` -- CREATE TABLE `chars` ( `id` int(11) NOT NULL, `name` varchar(25) NOT NULL, `level` int(11) NOT NULL, `userID` int(11) NOT NULL, `classID` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `chars` -- INSERT INTO `chars` (`id`, `name`, `level`, `userID`, `classID`) VALUES (1, 'Barkiller', 98, 1, 1), (2, 'craigtheslayer', 100, 2, 3), (3, 'bait', 15, 2, 2), (4, 'pullraidbossBubbleHS', 88, 2, 3), (5, 'blaster', 35, 1, 3), (6, 'Silentkilla', 35, 4, 6); -- -------------------------------------------------------- -- -- Table structure for table `classabilities` -- CREATE TABLE `classabilities` ( `id` int(11) NOT NULL, `abilityID` int(11) NOT NULL, `classID` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `classabilities` -- INSERT INTO `classabilities` (`id`, `abilityID`, `classID`) VALUES (1, 1, 1), (2, 2, 1), (3, 3, 1), (4, 4, 2), (5, 5, 2), (6, 6, 2), (7, 7, 3), (8, 8, 3), (9, 9, 6), (10, 10, 5), (11, 11, 4); -- -------------------------------------------------------- -- -- Table structure for table `classset` -- CREATE TABLE `classset` ( `id` int(11) NOT NULL, `className` varchar(15) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `classset` -- INSERT INTO `classset` (`id`, `className`) VALUES (6, 'druid'), (2, 'hunter'), (1, 'mage'), (3, 'paladin'), (5, 'warlock'), (4, 'warrior'); -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `id` int(11) NOT NULL, `username` varchar(25) NOT NULL, `password` varchar(25) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id`, `username`, `password`) VALUES (1, 'warlord1337', 'balubammuma'), (2, 'muskatel', 'muskatello25'), (3, 'bartek799', 'testo'), (4, 'emberwalker', 'amazingpasswordxxx'); -- -- Indexes for dumped tables -- -- -- Indexes for table `abilities` -- ALTER TABLE `abilities` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `ability` (`ability`); -- -- Indexes for table `chars` -- ALTER TABLE `chars` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `name` (`name`), ADD KEY `userID` (`userID`), ADD KEY `classID` (`classID`); -- -- Indexes for table `classabilities` -- ALTER TABLE `classabilities` ADD PRIMARY KEY (`id`), ADD KEY `classID` (`classID`), ADD KEY `abilityID` (`abilityID`); -- -- Indexes for table `classset` -- ALTER TABLE `classset` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `className` (`className`), ADD KEY `id` (`id`); -- -- Indexes for table `user` -- ALTER TABLE `user` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `abilities` -- ALTER TABLE `abilities` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12; -- -- AUTO_INCREMENT for table `chars` -- ALTER TABLE `chars` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14; -- -- AUTO_INCREMENT for table `classabilities` -- ALTER TABLE `classabilities` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12; -- -- AUTO_INCREMENT for table `classset` -- ALTER TABLE `classset` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `user` -- ALTER TABLE `user` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- Constraints for dumped tables -- -- -- Constraints for table `chars` -- ALTER TABLE `chars` ADD CONSTRAINT `chars_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `user` (`id`), ADD CONSTRAINT `class_rule` FOREIGN KEY (`classID`) REFERENCES `classset` (`id`); -- -- Constraints for table `classabilities` -- ALTER TABLE `classabilities` ADD CONSTRAINT `classabilities_ibfk_1` FOREIGN KEY (`classID`) REFERENCES `classset` (`id`), ADD CONSTRAINT `classabilities_ibfk_2` FOREIGN KEY (`abilityID`) REFERENCES `abilities` (`id`); 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
8654689688118cc6268a2566e55d633095dba00f
SQL
alexmbennett2/mimic-iv-aline-study
/sql/icd.sql
UTF-8
2,645
3.625
4
[]
no_license
-- Extract data which is based on ICD-9 codes WITH dx AS ( SELECT hadm_id, TRIM(icd9_code) AS icd_code FROM `physionet-data.mimiciii_clinical.diagnoses_icd` ) , icd9 AS ( select hadm_id , max(case when icd_code in ( '03642','07422','09320','09321','09322','09323','09324','09884' ,'11281','11504','11514','11594' ,'3911', '4210', '4211', '4219' ,'42490','42491','42499' ) then 1 else 0 end) as endocarditis -- chf , max(case when icd_code in ( '39891','40201','40291','40491','40413' ,'40493','4280','4281','42820','42821' ,'42822','42823','42830','42831','42832' ,'42833','42840','42841','42842','42843' ,'4289','428','4282','4283','4284' ) then 1 else 0 end) as chf -- atrial fibrilliation or atrial flutter , max(case when icd_code like '4273%' then 1 else 0 end) as afib -- renal , max(case when icd_code like '585%' then 1 else 0 end) as renal -- liver , max(case when icd_code like '571%' then 1 else 0 end) as liver -- copd , max(case when icd_code in ( '4660','490','4910','4911','49120' ,'49121','4918','4919','4920','4928' ,'494','4940','4941','496') then 1 else 0 end) as copd -- coronary artery disease , max(case when icd_code like '414%' then 1 else 0 end) as cad -- stroke , max(case when icd_code like '430%' or icd_code like '431%' or icd_code like '432%' or icd_code like '433%' or icd_code like '434%' then 1 else 0 end) as stroke -- malignancy, includes remissions , max(case when icd_code between '140' and '239' then 1 else 0 end) as malignancy -- resp failure , max(case when icd_code like '518%' then 1 else 0 end) as respfail -- ARDS , max(case when icd_code = '51882' or icd_code = '5185' then 1 else 0 end) as ards -- pneumonia , max(case when icd_code between '486' and '48881' or icd_code between '480' and '48099' or icd_code between '482' and '48299' or icd_code between '506' and '5078' then 1 else 0 end) as pneumonia from dx group by hadm_id ) SELECT co.hadm_id -- merge icd-9 and icd-10 codes , COALESCE(icd9.endocarditis, 0) AS endocarditis , COALESCE(icd9.chf, 0) AS chf , COALESCE(icd9.afib, 0) AS afib , COALESCE(icd9.renal, 0) AS renal , COALESCE(icd9.liver, 0) AS liver , COALESCE(icd9.copd, 0) AS copd , COALESCE(icd9.cad, 0) AS cad , COALESCE(icd9.stroke, 0) AS stroke , COALESCE(icd9.malignancy, 0) AS malignancy , COALESCE(icd9.respfail, 0) AS respfail , COALESCE(icd9.ards, 0) AS ards , COALESCE(icd9.pneumonia, 0) AS pneumonia FROM aline.cohort co LEFT JOIN icd9 ON co.hadm_id = icd9.hadm_id
true
6c0bee926d6d23c148b0502311cb00b1aa0b7621
SQL
mattgwwalker/singt
/singt/server/database.sql
UTF-8
1,673
4.09375
4
[]
no_license
/* Enable Foreign Keys. This needs to be executed for each databse connection as it feaults to disabled. */ PRAGMA foreign_keys = ON; /* Create the Participants table. */ CREATE TABLE Participants ( id INTEGER PRIMARY KEY, participantName TEXT NOT NULL ); /* Create the BackingTracks table. */ CREATE TABLE BackingTracks ( id INTEGER PRIMARY KEY, trackName TEXT NOT NULL ); /* Create the Takes table. A Take is based on either a backing track, or another take, or one of each. Takes maybe aborted part way through, in which case they are not considered complete. */ CREATE TABLE Takes ( id INTEGER PRIMARY KEY, backingTrackId INTEGER, takeId INTEGER REFERENCES Takes(id), takeNumber INTEGER NOT NULL, complete BOOLEAN NOT NULL DEFAULT 0, FOREIGN KEY(backingTrackId) REFERENCES BackingTracks(id), --FOREIGN KEY(takeId) REFERENCES Takes(id), CHECK (backingTrackId IS NOT NULL OR takeId IS NOT NULL) -- at least one of them must be set ); /* Create the Recordings table. Participants create recordings that are associated with a given take. */ CREATE TABLE Recordings ( id INTEGER PRIMARY KEY, participantId INTEGER NOT NULL, takeId INTEGER NOT NULL, FOREIGN KEY(participantId) REFERENCES Participants(id), FOREIGN KEY(takeId) REFERENCES Takes(id) ); /* Test data INSERT INTO Participants (participantName) VALUES ("Matthew"); INSERT INTO Participants (participantName) VALUES ("Virginie"); INSERT INTO BackingTracks (trackName) VALUES ("Happy Birthday"); INSERT INTO BackingTracks (trackName) VALUES ("Don't Cry for me Argentina"); */
true
41c9c1a854b1945c8cd74b2dbe3d369c19394c35
SQL
josepitteloud/VESPA
/Vespa Projects/325 - TA Propensity Model Restructure/new code/001_Datamart accounts and stability flags/001_churn_history_datamart.sql
UTF-8
1,071
2.984375
3
[]
no_license
/* purpose: to develop code for TA, stripping SQL code out from spss supernode - churn_history, file 2014-03-12_TA Model Development - ETL v3.0.str */ create or replace variable @Reference integer; set @Reference=201308 ; create or replace variable @Sample_1_EndString varchar(4) ; set @Sample_1_EndString='27' ; select account_number ,effective_from_dt ,effective_to_dt ,status_code into #table_churn_history1 from yarlagaddar.View_CUST_CHURN_HIST ; create or replace variable @likestring varchar(4) ; set @likestring='%' || @Sample_1_EndString ; -- select select * into #table_churn_history2 from #table_churn_history1 where account_number like @likestring -- insert the variable ; select *,@Reference as Reference into #table_churn_history3 from #table_churn_history2 ; select * into #table_churn_history4 from #table_churn_history3 hist3 inner join SourceDates sd on hist3.Reference=sd.Reference ; select * into #table_churn_history_output from #table_churn_history4 effective_from_dt <= Snapshot_Date and effective_from_dt >[2_Years_Prior]
true
2ef9091e05f0cd2394afa2f9191130a823b9d976
SQL
silence-do-good/stress-test-Postgres-and-MySQL
/dump/high/day11/select1629.sql
UTF-8
177
2.609375
3
[]
no_license
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o WHERE timestamp>'2017-11-10T16:29:00Z' AND timestamp<'2017-11-11T16:29:00Z' AND temperature>=6 AND temperature<=11
true
6e0b78a7d04518826d35ec4724bbc02a7ac13c72
SQL
reemaamhaz/RESTful-service
/update-customer.sql
UTF-8
964
3.453125
3
[]
no_license
CREATE DEFINER=`root`@`localhost` PROCEDURE `add_editCustomer`( IN _id INT, IN _email varchar(255), IN _first_name varchar(30), IN _last_name varchar(50), IN _ip varchar(15), IN _latitude float(10,6), IN _longitude float(10,6), IN _created_at datetime, IN _updated_at datetime ) BEGIN IF _id = 0 THEN INSERT INTO customers(email, first_name, last_name, ip, latitude, longitude, created_at, updated_at) VALUES (_email, _first_name, _last_name, _ip, _latitude, _longitude, _created_at, _updated_at); SET _id = LAST_INSERT_ID(); ELSE UPDATE Customer SET email = _email, first_name = _first_name, last_name = _last_name, ip = _ip, latitude = _latitude, longitude = _longitude, created_at = _created_at, updated_at = _updated_at WHERE id = _id; END IF; SELECT _id AS 'id'; END
true
fca44b3eeecd6d49867f44955a1fffcdd1584ace
SQL
Sai-Swarna/medical-erp
/src/main/resources/static/changes.sql
UTF-8
1,182
3.3125
3
[ "MIT" ]
permissive
ALTER TABLE `wards` ADD COLUMN `active` BIT(1) NOT NULL DEFAULT b'1' AFTER `covid_ward`; ALTER TABLE `wards_history` ADD COLUMN `active` BIT(1) NOT NULL DEFAULT b'1' AFTER `covid_ward`; ALTER TABLE `wards` DROP INDEX `facility_id_name_ward_number_floor_building_name`; ALTER TABLE `facilities` ADD COLUMN `region` TINYINT NOT NULL DEFAULT '1' AFTER `ulb_zone_name`; CREATE TABLE `areas` ( `area_id` INT NOT NULL AUTO_INCREMENT, `area` VARCHAR(50) NOT NULL, `region` VARCHAR(50) NOT NULL DEFAULT '1', PRIMARY KEY (`area_id`) ) COLLATE='latin1_swedish_ci' ; ALTER TABLE `patients` ADD COLUMN `locality` VARCHAR(50) NULL DEFAULT NULL AFTER `address`, ADD COLUMN `pincode` VARCHAR(50) NULL DEFAULT NULL AFTER `locality`; ------------ Changes to accept DOB instead of age (22-04-2020)---------- ALTER TABLE `patients` ADD COLUMN `dob` DATE NOT NULL DEFAULT '0000-00-00' AFTER `gender`; ALTER TABLE `patients` ADD UNIQUE INDEX `name_age_contact_number` (`name`, `age`, `contact_number`); ALTER TABLE `patients` ADD COLUMN `month` INT(11) NULL DEFAULT '0' AFTER `age`; ALTER TABLE `patients` CHANGE COLUMN `dob` `dob` VARCHAR(10) NOT NULL AFTER `gender`;
true
83b22837d9afe263b0440d32669f12f2618e5cfe
SQL
RayPeiqingHe/SQLServerObjects
/QuantTrading/Tables/corporate_action.sql
UTF-8
865
3.484375
3
[]
no_license
CREATE TABLE IF NOT EXISTS corporate_action ( id int NOT NULL AUTO_INCREMENT, data_vendor_id int NOT NULL, symbol_id int NOT NULL, corporate_action_date datetime NOT NULL, -- created_date datetime NOT NULL CONSTRAINT df_corporate_action_created_date DEFAULT NOW(), created_date datetime NOT NULL DEFAULT NOW(), -- last_updated_date datetime NOT NULL CONSTRAINT df_corporate_action_last_updated_date DEFAULT NOW(), last_updated_date datetime NOT NULL DEFAULT NOW(), corporate_action_type VARCHAR(20) NOT NULL, prior_amount decimal(19,4) NULL, ex_amount decimal(19,4) NULL, constraint pk_corporate_action PRIMARY KEY (id), constraint fk_corporate_action_data_vendor_id foreign KEY (data_vendor_id) references data_vendor(id), constraint fk_corporate_action_symbol_id foreign KEY (symbol_id) references symbol(id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
true
a5968129856200fd65bbf486b358dbe1882cc5a8
SQL
OlafMd/MedCon1.0
/mm-docconnect-dataimporter/DataImporter/DataImporter/DBMethods/Case/Atomic/Retrieval/SQL/cls_Get_GPOS_where_Management_Fee_is_Waived_for_PatientID.sql
UTF-8
2,821
3.15625
3
[]
no_license
Select hec_bil_potentialcodes.BillingCode, hec_crt_insurancetobrokercontract_participatingpatients.Patient_RefID, hec_ctr_insurancetobrokercontracts_coveredpotentialbillcodes.InsuranceToBrokerContract_RefID From hec_crt_insurancetobrokercontracts Inner Join hec_ctr_insurancetobrokercontracts_coveredpotentialbillcodes On hec_crt_insurancetobrokercontracts.HEC_CRT_InsuranceToBrokerContractID = hec_ctr_insurancetobrokercontracts_coveredpotentialbillcodes.InsuranceToBrokerContract_RefID And hec_ctr_insurancetobrokercontracts_coveredpotentialbillcodes.Tenant_RefID = @TenantID And hec_ctr_insurancetobrokercontracts_coveredpotentialbillcodes.IsDeleted = 0 Inner Join hec_ctr_i2bc_coveredpotentialbillcodes_2_universalproperty On hec_ctr_i2bc_coveredpotentialbillcodes_2_universalproperty.CoveredPotentialBillCode_RefID = hec_ctr_insurancetobrokercontracts_coveredpotentialbillcodes.HEC_CTR_InsuranceToBrokerContracts_CoveredPotentialBillCodeID And hec_ctr_i2bc_coveredpotentialbillcodes_2_universalproperty.Tenant_RefID = @TenantID And hec_ctr_i2bc_coveredpotentialbillcodes_2_universalproperty.IsDeleted = 0 And hec_ctr_i2bc_coveredpotentialbillcodes_2_universalproperty.Value_Boolean = 1 Inner Join hec_ctr_i2bc_coveredpotentialbillcodes_universalproperties On hec_ctr_i2bc_coveredpotentialbillcodes_2_universalproperty.CoveredPotentialBillCode_UniversalProperty_RefID = hec_ctr_i2bc_coveredpotentialbillcodes_universalproperties.HEC_CTR_I2BC_CoveredPotentialBillCodes_UniversalPropertyID And hec_ctr_i2bc_coveredpotentialbillcodes_universalproperties.Tenant_RefID = @TenantID And hec_ctr_i2bc_coveredpotentialbillcodes_universalproperties.IsDeleted = 0 And hec_ctr_i2bc_coveredpotentialbillcodes_universalproperties.PropertyName = 'Waive with order' Inner Join hec_bil_potentialcodes On hec_ctr_insurancetobrokercontracts_coveredpotentialbillcodes.PotentialBillCode_RefID = hec_bil_potentialcodes.HEC_BIL_PotentialCodeID And hec_bil_potentialcodes.Tenant_RefID = @TenantID And hec_bil_potentialcodes.IsDeleted = 0 Inner Join hec_crt_insurancetobrokercontract_participatingpatients On hec_crt_insurancetobrokercontract_participatingpatients.InsuranceToBrokerContract_RefID = hec_ctr_insurancetobrokercontracts_coveredpotentialbillcodes.InsuranceToBrokerContract_RefID And hec_crt_insurancetobrokercontract_participatingpatients.Patient_RefID = @PatientID And hec_crt_insurancetobrokercontract_participatingpatients.Tenant_RefID = @TenantID And hec_crt_insurancetobrokercontract_participatingpatients.IsDeleted = 0 Where hec_crt_insurancetobrokercontracts.Tenant_RefID = @TenantID And hec_crt_insurancetobrokercontracts.IsDeleted = 0
true
79ec06cf77976dd8c15f2d9819b846a7f48665fb
SQL
HKevinH/JadeCore-Fix-Scripst
/sql/fix_sql/1856_misc.sql
UTF-8
4,209
2.75
3
[]
no_license
UPDATE `creature_template` SET `lootid`=73349 WHERE `entry` IN (73349, 733494, 733495, 733496); DELETE FROM `creature_loot_template` WHERE `entry`=73349; INSERT INTO `creature_loot_template` (`entry`, `item`, `ChanceOrQuestChance`, `lootmode`, `groupid`, `mincountOrRef`, `maxcount`) VALUES (73349, 81414, 10, 1, 0, 1, 1), -- food (73349, 81410, 10, 1, 0, 1, 1), -- food (73349, 74844, 10, 1, 0, 1, 1), -- food (73349, 74848, 10, 1, 0, 1, 1), -- food (73349, 87391, 1, 1, 0, 1, 1), -- Сундучок с сокровищами (73349, 88567, 3, 1, 0, 1, 1), -- Сейф из призрачного железа (73349, 72988, 10, 1, 0, 1, 5), -- Ветрошерстяная ткань (73349, 89112, 5, 1, 0, 1, 3), -- Частица гармонии (73349, 1, 20, 1, 0, -702300, 1), -- normal (73349, 2, 10, 1, 0, -702301, 1); -- green UPDATE `creature_template` SET `lootid`=73342 WHERE `entry` IN (73342, 733424, 733425, 733426); DELETE FROM `creature_loot_template` WHERE `entry`=73342; INSERT INTO `creature_loot_template` (`entry`, `item`, `ChanceOrQuestChance`, `lootmode`, `groupid`, `mincountOrRef`, `maxcount`) VALUES (73342, 81414, 10, 1, 0, 1, 1), -- food (73342, 81410, 10, 1, 0, 1, 1), -- food (73342, 74844, 10, 1, 0, 1, 1), -- food (73342, 74848, 10, 1, 0, 1, 1), -- food (73342, 87391, 1, 1, 0, 1, 1), -- Сундучок с сокровищами (73342, 88567, 3, 1, 0, 1, 1), -- Сейф из призрачного железа (73342, 72988, 10, 1, 0, 1, 5), -- Ветрошерстяная ткань (73342, 89112, 5, 1, 0, 1, 3), -- Частица гармонии (73342, 1, 20, 1, 0, -702300, 1), -- normal (73342, 2, 10, 1, 0, -702301, 1); -- green UPDATE `creature_template` SET `lootid`=73191 WHERE `entry` IN (73191, 731914, 731915, 731916); DELETE FROM `creature_loot_template` WHERE `entry`=73191; INSERT INTO `creature_loot_template` (`entry`, `item`, `ChanceOrQuestChance`, `lootmode`, `groupid`, `mincountOrRef`, `maxcount`) VALUES (73191, 81414, 10, 1, 0, 1, 1), -- food (73191, 81410, 10, 1, 0, 1, 1), -- food (73191, 74844, 10, 1, 0, 1, 1), -- food (73191, 74848, 10, 1, 0, 1, 1), -- food (73191, 87391, 1, 1, 0, 1, 1), -- Сундучок с сокровищами (73191, 88567, 3, 1, 0, 1, 1), -- Сейф из призрачного железа (73191, 72988, 10, 1, 0, 1, 5), -- Ветрошерстяная ткань (73191, 89112, 5, 1, 0, 1, 3), -- Частица гармонии (73191, 1, 20, 1, 0, -702300, 1), -- normal (73191, 2, 10, 1, 0, -702301, 1); -- green UPDATE `creature_template` SET `lootid`=72655 WHERE `entry` IN (72655, 726554, 726555, 726556); DELETE FROM `creature_loot_template` WHERE `entry`=72655; INSERT INTO `creature_loot_template` (`entry`, `item`, `ChanceOrQuestChance`, `lootmode`, `groupid`, `mincountOrRef`, `maxcount`) VALUES (72655, 81414, 10, 1, 0, 1, 1), -- food (72655, 81410, 10, 1, 0, 1, 1), -- food (72655, 74844, 10, 1, 0, 1, 1), -- food (72655, 74848, 10, 1, 0, 1, 1), -- food (72655, 87391, 1, 1, 0, 1, 1), -- Сундучок с сокровищами (72655, 88567, 3, 1, 0, 1, 1), -- Сейф из призрачного железа (72655, 72988, 10, 1, 0, 1, 5), -- Ветрошерстяная ткань (72655, 89112, 5, 1, 0, 1, 3), -- Частица гармонии (72655, 1, 20, 1, 0, -702300, 1), -- normal (72655, 2, 10, 1, 0, -702301, 1); -- green UPDATE `creature_template` SET `lootid`=72658 WHERE `entry` IN (72658, 726584, 726585, 726586); DELETE FROM `creature_loot_template` WHERE `entry`=72658; INSERT INTO `creature_loot_template` (`entry`, `item`, `ChanceOrQuestChance`, `lootmode`, `groupid`, `mincountOrRef`, `maxcount`) VALUES (72658, 81414, 10, 1, 0, 1, 1), -- food (72658, 81410, 10, 1, 0, 1, 1), -- food (72658, 74844, 10, 1, 0, 1, 1), -- food (72658, 74848, 10, 1, 0, 1, 1), -- food (72658, 87391, 1, 1, 0, 1, 1), -- Сундучок с сокровищами (72658, 88567, 3, 1, 0, 1, 1), -- Сейф из призрачного железа (72658, 72988, 10, 1, 0, 1, 5), -- Ветрошерстяная ткань (72658, 89112, 5, 1, 0, 1, 3), -- Частица гармонии (72658, 1, 20, 1, 0, -702300, 1), -- normal (72658, 2, 10, 1, 0, -702301, 1); -- green
true
abb70ba45ca6b8c6c4fa286a435430302ed3feba
SQL
cseidman/transaction_processor
/sql/transact.sql
UTF-8
785
3.421875
3
[]
no_license
drop table if exists client_account ; create table client_account ( client_id integer primary key, available float, total float, held float, locked boolean ); create index ix_account_client_id on client_account(client_id) ; drop table if exists dispute ; create table dispute ( client_id integer, event_id integer, amount float, -- disputed amount status text -- 'resolved', 'disputed', 'chargedback' ); create index ix_dispute on dispute(client_id, event_id) ; drop table if exists trade_event ; create table trade_event ( event_id integer primary key , client_id integer, event_type text, amount float null ); create index ix_client_id on trade_event(client_id) ; create index ix_event_type_id on trade_event(event_type) ;
true
b9d2118cd026f23223999fc69f8a014ac17e567b
SQL
DBScourse/TheMeeseekss
/queries/add_to_last_playlist.sql
UTF-8
360
3.609375
4
[]
no_license
INSERT INTO PlaylistToTracks_tbl(playlist_id, track_id) SELECT playlist_id, {track_id} FROM Playlists_tbl AS pt JOIN Users_tbl AS ut ON pt.user_id = ut.user_id WHERE user_name = {username} AND playlist_timestamp = ( SELECT MAX(playlist_timestamp) FROM Playlists_tbl AS pt2 JOIN Users_tbl AS ut2 ON pt2.user_id = ut2.user_id WHERE user_name = {username} )
true
71d6f111144f2f77cc17ee4b06dc6f3bcad6f80a
SQL
pdeguing/empire-and-foundation
/setup.sql
UTF-8
632
3.4375
3
[]
no_license
create table users ( id serial primary key, uuid varchar(64) not null unique, name varchar(255), email varchar(255) not null unique, password varchar(255) not null, created_at timestamp not null ); create table planets ( id serial primary key, uuid varchar(64) not null unique, metal_stock bigint not null, metal_mine integer not null, user_id integer references users(id), created_at timestamp not null, last_metal_update timestamp not null ); CREATE TABLE sessions ( token TEXT PRIMARY KEY, data BYTEA NOT NULL, expiry TIMESTAMPTZ NOT NULL ); CREATE INDEX sessions_expiry_idx ON sessions (expiry);
true
b759fba5e1442e39137d48a9bb846cccf2ff74e2
SQL
fender101/SQLHomework
/SQL_HW_01.sql
UTF-8
9,316
4.40625
4
[]
no_license
-- SQL Homework use sakila; -- 1a. Display the first and last names of all actors from the table actor. select first_name, last_name from actor; -- 1b. Display the first and last name of each actor in a single column in upper case letters. Name the column Actor Name. SELECT CONCAT(first_name, ' ', last_name) AS 'Actor Name' FROM actor; -- --2a. You need to find the ID number, first name, and last name of an actor, of whom you know only the first name, "Joe." -- What is one query would you use to obtain this information? select actor_id, first_name, last_name from actor Where first_name = "Joe"; -- --2b. Find all actors whose last name contain the letters GEN: select actor_id, first_name, last_name from actor Where last_name like "%GEN%"; -- --2c. Find all actors whose last names contain the letters LI. This time, order the rows by last name and first name, in that order: select first_name, last_name from actor Where last_name like "%LI%" order by last_name, first_name; -- --2d. Using IN, display the country_id and country columns of the following countries: Afghanistan, Bangladesh, and China: Select * from country where country in ( "Afghanistan", "Bangladesh", "China" ); -- --3a. You want to keep a description of each actor. You don't think you will be performing queries on a description, -- -- so create a column in the table actor named description and use the data type BLOB (Make sure to research the type BLOB, -- -- as the difference between it and VARCHAR are significant). alter table actor add description BLOB; -- --3b. Very quickly you realize that entering descriptions for each actor is too much effort. Delete the description column. alter table actor drop description; -- --4a. List the last names of actors, as well as how many actors have that last name. select last_name, count(last_name) from actor group by last_name; -- --4b. List last names of actors and the number of actors who have that last name, but only for names that are -- -- shared by at least two actors select last_name, count(last_name) from actor group by last_name Having count(last_name) >= 2; -- --4c. The actor HARPO WILLIAMS was accidentally entered in the actor table as GROUCHO WILLIAMS. -- -- Write a query to fix the record. update actor set first_name = 'HARPO' where first_name = 'GROUCHO' and last_name = 'WILLIAMS'; -- --4d. Perhaps we were too hasty in changing GROUCHO to HARPO. It turns out that GROUCHO was the correct name after all! -- -- In a single query, if the first name of the actor is currently HARPO, change it to GROUCHO. update actor set first_name = 'GROUCHO' where first_name = 'HARPO'; -- --5a. You cannot locate the schema of the address table. Which query would you use to re-create it? -- --Hint: https://dev.mysql.com/doc/refman/5.7/en/show-create-table.html Create table address ( address_id smallint(5) Auto_increment, address1 Varchar(50) not null, address2 Varchar(50), district varchar(20) not null, city_id varchar(5), postal_code varchar(10), phone varchar(20) not null, location geometry not null, last_update timestamp, primary key (address_id) ); -- --6a. Use JOIN to display the first and last names, as well as the address, of each staff member. Use the tables staff and address: select first_name, last_name, address, address2, district, city_id, postal_code from address addr join staff staff on (staff.address_id = addr.address_id); -- --6b. Use JOIN to display the total amount rung up by each staff member in August of 2005. Use tables staff and payment select first_name, last_name, sum(amount) from payment pmt join staff staff on (staff.staff_id = pmt.staff_id) where payment_date between "2005-08-01" and "2005-08-31" group by first_name, last_name; -- --6c. List each film and the number of actors who are listed for that film. Use tables film_actor and film. Use inner join. select title, count(actor_id) from film film join film_actor actor on (film.film_id = actor.film_id) group by title; -- --6d. How many copies of the film Hunchback Impossible exist in the inventory system? select title, count(inventory_id) from film film join inventory inv on (film.film_id = inv.film_id) where title = "Hunchback Impossible" group by title; -- --6e. Using the tables payment and customer and the JOIN command, list the total paid by each customer. -- -- List the customers alphabetically by last name: select first_name "First Name", last_name "Last Name", sum(amount) "Total Paid" from customer cust join payment pmt on (cust.customer_id = pmt.customer_id) group by first_name, last_name order by last_name; -- --7a. The music of Queen and Kris Kristofferson have seen an unlikely resurgence. As an unintended consequence, -- -- films starting with the letters K and Q have also soared in popularity. Use subqueries to display the titles -- -- of movies starting with the letters K and Q whose language is English. select title from film flm join language lang on (flm.language_id = lang.language_id) Where title like "K%" or title like "Q%" and flm.language_id in ( select lang.language_id where lang.name in ("English")) order by title; -- --7b. Use subqueries to display all actors who appear in the film Alone Trip. select act.actor_id, act.first_name, act.last_name from actor act join film_actor flma on (act.actor_id = flma.actor_id) Where flma.actor_id in ( Select flma.actor_id from film_actor flma join film flm on (flm.film_id = flma.film_id) where flm.film_id in ( select film_id from film flm where flm.title = "Alone Trip")) Group by act.actor_id, act.first_name, act.last_name; -- --7c. You want to run an email marketing campaign in Canada, for which you will need the names and email addresses of all -- -- Canadian customers. Use joins to retrieve this information. select cst.first_name, cst.last_name, cst.email from customer cst inner join address addr on (cst.address_id = addr.address_id) inner join city cty on (addr.city_id = cty.city_id) inner join country cnt on (cty.country_id = cnt.country_id) where cnt.country = "Canada"; -- --7d. Sales have been lagging among young families, and you wish to target all family movies for a promotion. -- -- Identify all movies categorized as family films. select title from film flm inner join film_category flmc on (flm.film_id = flmc.film_id) inner join category cat on (flmc.category_id = cat.category_id) where cat.name = "Family"; -- --7e. Display the most frequently rented movies in descending order. select flm.title, count(rnt.rental_id) "Rental Count" from film flm inner join inventory inv on (flm.film_id = inv.film_id) inner join rental rnt on (rnt.inventory_id = inv.inventory_id) group by title order by count(rnt.rental_id) desc limit 10; -- --7f. Write a query to display how much business, in dollars, each store brought in. select str.store_id, sum(pmt.amount) Sales from store str inner join staff stf on (str.store_id = stf.store_id) inner join payment pmt on (stf.staff_id = pmt.staff_id) Group by str.store_id; -- --7g. Write a query to display for each store its store ID, city, and country. select str.store_id, cty.city, cnt.country from store str inner join address adr on (str.address_id = adr.address_id) inner join city cty on (cty.city_id = adr.city_id) inner join country cnt on (cnt.country_id = cty.country_id) Group by str.store_id, cty.city_id, cnt.country; -- --7h. List the top five genres in gross revenue in descending order. -- -- (Hint: you may need to use the following tables: category, film_category, inventory, payment, and rental.) select cat.name "Category", sum(pmt.amount) "Sales" from category cat inner join film_category fcat on (fcat.category_id = cat.category_id) inner join inventory inv on (inv.film_id = fcat.film_id) inner join rental rnt on (rnt.inventory_id = inv.inventory_id) inner join payment pmt on (pmt.rental_id = rnt.rental_id) group by cat.name order by sum(pmt.amount) desc limit 5; -- --8a. In your new role as an executive, you would like to have an easy way of viewing the Top five genres by gross revenue. -- -- Use the solution from the problem above to create a view. If you haven't solved 7h, you can substitute -- -- another query to create a view. create view sales_report as select cat.name "Category", sum(pmt.amount) "Sales" from category cat inner join film_category fcat on (fcat.category_id = cat.category_id) inner join inventory inv on (inv.film_id = fcat.film_id) inner join rental rnt on (rnt.inventory_id = inv.inventory_id) inner join payment pmt on (pmt.rental_id = rnt.rental_id) group by cat.name order by sum(pmt.amount) desc limit 5; -- --8b. How would you display the view that you created in 8a? select * from sales_report; -- --8c. You find that you no longer need the view top_five_genres. Write a query to delete it. drop view sales_report;
true
342f07d47dad401d0f3b0abd48abb7f3f54ce41d
SQL
aditya1819/dbmsproject
/dbinit.sql
UTF-8
1,067
3.765625
4
[]
no_license
drop database project; create database project; use project; create table customer ( cust_id int auto_increment primary key, c_name varchar(50), c_contact varchar(15) ); create table products ( p_id int primary key auto_increment, p_name varchar(30) not null unique, cost int unsigned not null, cost_p int unsigned not null, avl_qn int unsigned not null ); create table users ( u_id int primary key auto_increment , u_name varchar(30) not null, u_pass varchar(200) not null, admin_status boolean not null ); create table t_hist( id int auto_increment primary key, c_id int, emp_id int, total varchar(20), total_p varchar(20), ddtt timestamp default current_timestamp, foreign key(c_id) references customer(cust_id), foreign key(emp_id) references users(u_id) ); create table record ( id int, p_id int, cost int, cost_p int, qunt int, ddmm timestamp default current_timestamp, foreign key(p_id) references products(p_id), foreign key(id) references t_hist(id) );
true
64d0177022fd701221ffd63ece29b08aad7e6803
SQL
Minchuloh/SpringGroupware
/groupware/src/main/resources/DDL/edi_sett.sql
UTF-8
297
2.59375
3
[]
no_license
CREATE TABLE EDI_SETT( EDI_CODE VARCHAR2(20), EDI_SEQ NUMBER(6,0), SETT_EMP_CODE VARCHAR2(10), EDI_SETT_STATUS VARCHAR(1), EDI_COMMENTS VARCHAR2(100), INP_DATE DATE DEFAULT SYSDATE, UPDATE_DATE DATE, CONSTRAINT PK_EDI_SETT PRIMARY KEY (EDI_CODE, EDI_SEQ, SETT_EMP_CODE) );
true
24dc72c30e29db8f61b7c4cb567a9deacf5952e9
SQL
carollaurini/compliance
/banco_sql/query_expirados_contra.sql
UTF-8
1,699
3.421875
3
[]
no_license
CREATE ALGORITHM = UNDEFINED DEFINER = `armory`@`%` SQL SECURITY DEFINER VIEW `compliance`.`cantrapartes_expiradas` AS SELECT `compliance`.`autorizacao_contraparte`.`chave_autorizacao` AS `chave_autorizacao`, `compliance`.`autorizacao_contraparte`.`contraparte` AS `contraparte`, `compliance`.`autorizacao_contraparte`.`data_vencimento_autorizacao` AS `data_vencimento_autorizacao`, `submax`.`data_ultima_autorizacao` AS `data_ultima_autorizacao`, `compliance`.`autorizacao_contraparte`.`nome_usuario` AS `nome_usuario`, `compliance`.`autorizacao_contraparte`.`status` AS `status`, (CASE WHEN ((`compliance`.`autorizacao_contraparte`.`status` = 1) AND (CURTIME() > `compliance`.`autorizacao_contraparte`.`data_vencimento_autorizacao`)) THEN 'Expirado' ELSE 'Reprovado' END) AS `resultado` FROM (`compliance`.`autorizacao_contraparte` JOIN (SELECT MAX(`compliance`.`autorizacao_contraparte`.`data_autorizacao`) AS `data_ultima_autorizacao`, `compliance`.`autorizacao_contraparte`.`contraparte` AS `contraparte_2` FROM `compliance`.`autorizacao_contraparte` GROUP BY `compliance`.`autorizacao_contraparte`.`contraparte`) `submax` ON (((`compliance`.`autorizacao_contraparte`.`data_autorizacao` = `submax`.`data_ultima_autorizacao`) AND (`compliance`.`autorizacao_contraparte`.`contraparte` = `submax`.`contraparte_2`)))) HAVING (`resultado` = 'Expirado') ORDER BY `compliance`.`autorizacao_contraparte`.`data_vencimento_autorizacao`
true
f81080c5fb3f927c3364fef6354e89670cb21f6e
SQL
cosmin-ticu/homework_DE1SQL
/Term/Scripts/5-Views.sql
UTF-8
4,909
4.09375
4
[]
no_license
USE univrankings; -- Always call the final stored procedure to make sure you are working with the most up-to-date data CALL get_cosminranking_comp(); -- ------------------------------------------------------------------- -- self-updating VIEWS (data marts) - but these are slow because they rebuild the table from scratch -- ------------------------------------------------------------------- -- What are the top 50 universities worldwide according to the computed cosmin grade? DROP VIEW IF EXISTS Top_50_Worldwide; CREATE VIEW `Top_50_Worldwide` AS SELECT university_name, country, year, cosmin_grade FROM cosminranking_comp ORDER BY - cosmin_grade LIMIT 50; SELECT * FROM Top_50_Worldwide; -- run the view -- How many universities per country and what is the country's average cosmin grade? -- naturally the countries that only have a few universities might be at a large advantage -- thus, some arbitrary "weights" are added DROP VIEW IF EXISTS Grade_Per_Country; CREATE VIEW `Grade_Per_Country` AS SELECT COUNT(university_name) AS num_univs, country, CASE WHEN COUNT(university_name) <= 4 THEN (AVG(cosmin_grade) - 5.0) WHEN COUNT(university_name) <= 6 THEN (AVG(cosmin_grade) - 2.0) ELSE AVG(cosmin_grade) END AS computed_avg_cosmin_grade FROM cosminranking_comp GROUP BY country ORDER BY - computed_avg_cosmin_grade; SELECT * FROM Grade_Per_Country; -- run the view -- How many universities does this dataset contain for each economic level (country-wide values)? DROP VIEW IF EXISTS grades_econ_levels; CREATE VIEW `grades_econ_levels` AS SELECT AVG(cosmin_grade) AS average_grade, CASE WHEN gdp_capita <= 10000 THEN 'Poor country' WHEN gdp_capita <= 25000 THEN 'Developing country' WHEN gdp_capita <= 35000 THEN 'Lower middle income country' WHEN gdp_capita <= 50000 THEN 'Middle income country' WHEN gdp_capita <= 65000 THEN 'Upper income country' ELSE 'Top income country' END AS econ_rating FROM cosminranking_comp GROUP BY econ_rating ORDER BY - AVG(cosmin_grade); SELECT * FROM grades_econ_levels; -- run the view -- Example depth question: -- "I am interested in studying at top (50/100) universities for internationality, -- I want to know their world rank (cosmin_grade), air quality matters for me, -- and I would like to live in a country where women have a say in parliament." DROP VIEW IF EXISTS air_international_women; CREATE VIEW air_international_women AS SELECT university_name, country, times_international_grade, times_percent_intstudents, cosmin_grade, CASE WHEN air_pollution = NULL THEN 'unknown air pollution level' WHEN air_pollution <= 8 THEN 'low air pollution' WHEN air_pollution <= 15 THEN 'medium air pollution' WHEN air_pollution <= 50 THEN 'high air pollution' ELSE 'very high air pollution' END AS air_pollution_rating, CASE WHEN gov_women = NULL THEN 'unknown ratio of women in parliament' WHEN gov_women <= 15 THEN 'low ratio of women in parliament' WHEN gov_women <= 25 THEN 'lower medium ratio of women in parliament' WHEN gov_women <= 35 THEN 'upper medium ratio of women in parliament' ELSE 'high ratio of women in parliament' END AS women_in_parliament FROM cosminranking_comp ORDER BY - times_international_grade LIMIT 100; SELECT * FROM air_international_women; -- run the view -- Example depth question: -- "I am interested in studying at top (50/100) universities for employment opportunities, -- but I am also interested in entrepreneurship and patenting my work. I want to -- know their world rank (cosmin_grade) and to know whether the country as a whole -- having a good employment market for young people." DROP VIEW IF EXISTS employment_patent_grade; CREATE VIEW employment_patent_grade AS SELECT university_name, cwur_employ_rank AS employment_rank, cwur_patents_rank AS patents_rank, country, CASE WHEN youth_unemploy = NULL THEN 'unknown youth unemployment rate' WHEN youth_unemploy <= 10 THEN 'low youth unemployment' WHEN youth_unemploy <= 15 THEN 'medium youth unemployment' WHEN youth_unemploy <= 20 THEN 'upper medium youth unemployment' WHEN youth_unemploy <= 35 THEN 'high youth unemployment' ELSE 'very high youth unemployment' END AS youth_unemployment FROM cosminranking_comp ORDER BY cwur_employ_rank LIMIT 100; SELECT * FROM employment_patent_grade; -- run the view
true
4aa697d9fc2b25cfb18e122351232d4ba9b3bdac
SQL
dave/dontstayin
/Bobs/Sql/Update Scripts/0294 - Add TwitterHeadline to Article.sql
UTF-8
452
3.234375
3
[]
no_license
IF NOT EXISTS( SELECT * FROM sys.tables [table] INNER JOIN sys.columns [column] ON [table].object_id = [column].object_id WHERE [table].name = 'Article' AND [column].name = 'TwitterHeadline' ) BEGIN ALTER TABLE dbo.Article ADD TwitterHeadline varchar(140) NULL EXECUTE sp_addextendedproperty N'MS_Description', N'Headline of the article for sending to Twitter', N'SCHEMA', N'dbo', N'TABLE', N'Article', N'COLUMN', N'TwitterHeadline' END
true
9261d9fc70c52e72599712752eccd1486e3c89e2
SQL
abhirakshit/Nirvana
/database_queries/enrollView.sql
UTF-8
5,111
3.484375
3
[]
no_license
CREATE VIEW enrollview AS SELECT stu_pay_con_staff.name, stu_pay_con_staff."followUp", stu_pay_con_staff."phoneNumber", stu_pay_con_staff.student_id AS id, stu_pay_con_staff."createdAt", stu_pay_con_staff."updatedAt", stu_pay_con_staff."enquiryStatus", stu_pay_con_staff."enquiryDate", stu_pay_con_staff.services, stu_pay_con_staff."totalFee", stu_pay_con_staff."totalPaid", (stu_pay_con_staff."totalFee" - stu_pay_con_staff."totalPaid") AS "totalDue", stu_pay_con_staff.countries, stu_pay_con_staff."assignedTo", loc.locations FROM (( SELECT stu_pay_con.name, stu_pay_con."followUp", stu_pay_con."phoneNumber", stu_pay_con.student_id, stu_pay_con."createdAt", stu_pay_con."updatedAt", stu_pay_con."enquiryStatus", stu_pay_con."enquiryDate", stu_pay_con.services, stu_pay_con."totalFee", stu_pay_con."totalPaid", stu_pay_con.countries, stf."assignedTo" FROM (( SELECT stu_pay.name, stu_pay."followUp", stu_pay."phoneNumber", stu_pay.student_id, stu_pay."createdAt", stu_pay."updatedAt", stu_pay."enquiryStatus", stu_pay."enquiryDate", stu_pay.services, stu_pay."totalFee", stu_pay."totalPaid", stu_con.countries FROM (( SELECT stu.name, stu."followUp", stu."phoneNumber", stu.student_id, stu."createdAt", stu."updatedAt", stu."enquiryStatus", stu."enquiryDate", paym.services, COALESCE(paym."TotalPaid", (0)::double precision) AS "totalPaid", COALESCE(paym."totalFee", (0)::double precision) AS "totalFee" FROM (( SELECT ((s."firstName" || ' '::text) || COALESCE(s."lastName", 'LNU'::text)) AS name, s."enquiryDate", s."followUp", s."phoneNumber", s.id AS student_id, s."createdAt", s."updatedAt", es.name AS "enquiryStatus" FROM student s, enquirystatus es, location_students__student_locations stuloc WHERE (((s."enquiryStatus" = es.id) AND (es.name = 'Enrolled'::text)) AND (stuloc.student_locations = s.id))) stu LEFT JOIN ( SELECT enr_ser.student, string_agg(enr_ser.serv, ', '::text) AS services, sum(enr_ser."totalFee") AS "totalFee", sum(COALESCE(pmt.amount, (0)::double precision)) AS "TotalPaid" FROM (( SELECT e."totalFee", e.student, s.name AS serv, e.id AS enroll_id FROM enroll e, service s WHERE (e.service = s.id)) enr_ser LEFT JOIN payment pmt ON ((enr_ser.enroll_id = pmt.enroll))) GROUP BY enr_ser.student) paym ON ((paym.student = stu.student_id)))) stu_pay LEFT JOIN ( SELECT string_agg(cc.name, ', '::text) AS countries, sc.student_countries FROM country_students__student_countries sc, country cc WHERE (sc.country_students = cc.id) GROUP BY sc.student_countries) stu_con ON ((stu_con.student_countries = stu_pay.student_id)))) stu_pay_con LEFT JOIN ( SELECT string_agg(((st."firstName" || ' '::text) || st."lastName"), ', '::text) AS "assignedTo", sas.student_staff FROM staff_students__student_staff sas, staff st WHERE (st.id = sas.staff_students) GROUP BY sas.student_staff) stf ON ((stu_pay_con.student_id = stf.student_staff)))) stu_pay_con_staff LEFT JOIN ( SELECT sloc.student_locations, string_agg(sas.name, ', '::text) AS locations FROM location sas, location_students__student_locations sloc WHERE (sloc.location_students = sas.id) GROUP BY sloc.student_locations) loc ON ((stu_pay_con_staff.student_id = loc.student_locations)))
true
b0830cbf51d26a7029436d5410a2a5dc25603921
SQL
Brayangranado/laravel-imw
/laravel8.sql
UTF-8
61,353
3.140625
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.5deb2 -- https://www.phpmyadmin.net/ -- -- Servidor: localhost -- Tiempo de generación: 20-01-2021 a las 14:48:32 -- Versión del servidor: 8.0.22 -- Versión de PHP: 7.4.3 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de datos: `laravel8` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `amigos` -- CREATE TABLE `amigos` ( `id` int UNSIGNED NOT NULL, `nombre` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `apellidos` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `amigos` -- INSERT INTO `amigos` (`id`, `nombre`, `apellidos`, `created_at`, `updated_at`) VALUES (1, 'asdfgasfd', 'asdfasdfasdf', '2018-11-07 10:07:46', '2018-11-07 10:07:46'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `categorias` -- CREATE TABLE `categorias` ( `id` int NOT NULL, `categoria` varchar(200) NOT NULL, `descripcion` text, `user_id` varchar(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `categorias` -- INSERT INTO `categorias` (`id`, `categoria`, `descripcion`, `user_id`) VALUES (1, 'Bebidas alcohol', 'Gaseosas, café, té, cervezas y maltas', NULL), (2, 'Condimentos', 'Salsas dulces y picantes, delicias, comida para untar y aderezos', NULL), (3, 'Repostería', 'Postres, dulces y pan dulce', NULL), (4, 'Lácteos', 'Quesos', NULL), (5, 'Granos/Cereales', 'Pan, galletas, pasta y cereales', NULL), (6, 'Carnes', 'Carnes preparadas', NULL), (7, 'Frutas/Verduras', 'Frutas secas y queso de soja', NULL), (9, 'asdfas', 'asdfasdfadfs', NULL), (11, 'sdgf', 'sdfgsdgf', NULL), (12, 'hgjg', 'jghjh', NULL), (13, 'asdf', 'asdfadsf', NULL), (15, 'Bebidas33', 'Gaseosas, café, té, cervezas y maltas333', NULL), (17, 'si esto funcion', NULL, NULL), (18, 'hasta luego Lucas', NULL, NULL), (19, '', NULL, NULL), (20, 'cohetes y pepinos', NULL, NULL), (21, 'somos los mejores', NULL, NULL); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `clientes` -- CREATE TABLE `clientes` ( `id` int NOT NULL, `codigo` varchar(5) NOT NULL, `empresa` varchar(40) NOT NULL, `contacto` varchar(30) DEFAULT NULL, `cargo_contacto` varchar(30) DEFAULT NULL, `direccion` varchar(60) DEFAULT NULL, `ciudad` varchar(15) DEFAULT NULL, `region` varchar(15) DEFAULT NULL, `cp` varchar(10) DEFAULT NULL, `pais` varchar(15) DEFAULT NULL, `telefono` varchar(24) DEFAULT NULL, `fax` varchar(24) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `clientes` -- INSERT INTO `clientes` (`id`, `codigo`, `empresa`, `contacto`, `cargo_contacto`, `direccion`, `ciudad`, `region`, `cp`, `pais`, `telefono`, `fax`) VALUES (2, 'ANATR', 'Ana Trujillo Emparedados y helados', 'JUANA LA LOCA', 'Propietario', 'Avda. de la Constitución 2222', 'México D.F.', NULL, '05021', 'México', '(5) 555-4729', '(5) 555-3745'), (3, 'ANTON', 'Antonio Moreno Taquería', 'Antonio Moreno', 'Propietario', 'Mataderos 2312', 'México D.F.', NULL, '05023', 'México', '(5) 555-3932', NULL), (4, 'AROUT', 'Around the Horn', 'Thomas Hardy', 'Representante de ventas', '120 Hanover Sq.', 'Londres', NULL, 'WA1 1DP', 'Reino Unido', '(71) 555-7788', '(71) 555-6750'), (5, 'BERGS', 'Berglunds snabbköp', 'Christina Berglund', 'Administrador de pedidos', 'Berguvsvägen 8', 'Luleå', NULL, 'S-958 22', 'Suecia', '0921-12 34 65', '0921-12 34 67'), (6, 'BLAUS', 'Blauer See Delikatessen', 'Hanna Moos', 'Representante de ventas', 'Forsterstr. 57', 'Mannheim', NULL, '68306', 'Alemania', '0621-08460', '0621-08924'), (7, 'BLONP', 'Blondel père et fils', 'Frédérique Citeaux', 'Gerente de marketing', '24, place Kléber', 'Estrasburgo', NULL, '67000', 'Francia', '88.60.15.31', '88.60.15.32'), (8, 'BOLID', 'Bólido Comidas preparadas', 'Martín Sommer', 'Propietario', 'C/ Araquil, 67', 'Madrid', NULL, '28023', 'España', '(91) 555 22 82', '(91) 555 91 99'), (9, 'BONAP', 'Bon app\'', 'Laurence Lebihan', 'Propietario', '12, rue des Bouchers', 'Marsella', NULL, '13008', 'Francia', '91.24.45.40', '91.24.45.41'), (10, 'BOTTM', 'Bottom-Dollar Markets', 'Elizabeth Lincoln', 'Gerente de contabilidad', '23 Tsawassen Blvd.', 'Tsawassen', 'BC', 'T2F 8M4', 'Canadá', '(604) 555-4729', '(604) 555-3745'), (11, 'BSBEV', 'B\'s Beverages', 'Victoria Ashworth', 'Representante de ventas', 'Fauntleroy Circus', 'Londres', NULL, 'EC2 5NT', 'Reino Unido', '(71) 555-1212', NULL), (13, 'CENTC', 'Centro comercial Moctezuma', 'Francisco Chang', 'Gerente de marketing', 'Sierras de Granada 9993', 'México D.F.', NULL, '05022', 'México', '(5) 555-3392', '(5) 555-7293'), (14, 'COMMI', 'Comércio Mineiro', 'Pedro Afonso', 'Asistente de ventas', 'Av. dos Lusíadas, 23', 'São Paulo', 'SP', '05432-043', 'Brasil', '(11) 555-7647', NULL), (15, 'CONSH', 'Consolidated Holdings', 'Elizabeth Brown', 'Representante de ventas', 'Berkeley Gardens\r\n12 Brewery ', 'Londres', NULL, 'WX1 6LT', 'Reino Unido', '(71) 555-2282', '(71) 555-9199'), (18, 'DUMON', 'Du monde entier', 'Janine Labrune', 'Propietario', '67, rue des Cinquante Otages', 'Nantes', NULL, '44000', 'Francia', '40.67.88.88', '40.67.89.89'), (19, 'EASTC', 'Eastern Connection', 'Ann Devon', 'Agente de ventas', '35 King George', 'Londres', NULL, 'WX3 6FW', 'Reino Unido', '(71) 555-0297', '(71) 555-3373'), (20, 'ERNSH', 'Ernst Handel', 'Roland Mendel', 'Gerente de ventas', 'Kirchgasse 6', 'Graz', NULL, '8010', 'Austria', '7675-3425', '7675-3426'), (21, 'FAMIA', 'Familia Arquibaldo', 'Aria Cruz', 'Asistente de marketing', 'Rua Orós, 92', 'Sao Paulo', 'SP', '05442-030', 'Brasil', '(11) 555-9857', NULL), (22, 'FISSA', 'FISSA Fabrica Inter. Salchichas S.A.', 'Diego Roel', 'Gerente de contabilidad', 'C/ Moralzarzal, 86', 'Madrid', NULL, '28034', 'España', '(91) 555 94 44', '(91) 555 55 93'), (23, 'FOLIG', 'Folies gourmandes', 'Martine Rancé', 'Asistente de agente de ventas', '184, chaussée de Tournai', 'Lille', NULL, '59000', 'Francia', '20.16.10.16', '20.16.10.17'), (25, 'FRANK', 'Frankenversand', 'Peter Franken', 'Gerente de marketing', 'Berliner Platz 43', 'München', NULL, '80805', 'Alemania', '089-0877310', '089-0877451'), (26, 'FRANR', 'France restauration', 'Carine Schmitt', 'Gerente de marketing', '54, rue Royale', 'Nantes', NULL, '44000', 'Francia', '40.32.21.21', '40.32.21.20'), (27, 'FRANS', 'Franchi S.p.A.', 'Paolo Accorti', 'Representante de ventas', 'Via Monte Bianco 34', 'Torino', NULL, '10100', 'Italia', '011-4988260', '011-4988261'), (28, 'FURIB', 'Furia Bacalhau e Frutos do Mar', 'Lino Rodriguez ', 'Gerente de ventas', 'Jardim das rosas n. 32', 'Lisboa', NULL, '1675', 'Portugal', '(1) 354-2534', '(1) 354-2535'), (30, 'GODOS', 'Godos Cocina Típica', 'José Pedro Freyre', 'Gerente de ventas', 'C/ Romero, 33', 'Sevilla', NULL, '41101', 'España', '(95) 555 82 82', NULL), (32, 'GREAL', 'Great Lakes Food Market', 'Howard Snyder', 'Gerente de marketing', '2732 Baker Blvd.', 'Eugenia', 'OR', '97403', 'Estados Unidos', '(503) 555-7555', NULL), (34, 'HANAR', 'Hanari Carnes', 'Mario Pontes', 'Gerente de contabilidad', 'Rua do Paço, 67', 'Rio de Janeiro', 'RJ', '05454-876', 'Brasil', '(21) 555-0091', '(21) 555-8765'), (35, 'HILAA', 'HILARIÓN-Abastos', 'Carlos Hernández', 'Representante de ventas', 'Carrera 22 con Ave. Carlos Soublette #8-35', 'San Cristóbal', 'Táchira', '5022', 'Venezuela', '(5) 555-1340', '(5) 555-1948'), (36, 'HUNGC', 'Hungry Coyote Import Store', 'Yoshi Latimer', 'Representante de ventas', 'City Center Plaza\r\n516 Main St.', 'Elgin', 'OR', '97827', 'Estados Unidos', '(503) 555-6874', '(503) 555-2376'), (37, 'HUNGO', 'Hungry Owl All-Night Grocers', 'Patricia McKenna', 'Asistente de ventas', '8 Johnstown Road', 'Cork', 'Co. Cork', NULL, 'Irlanda', '2967 542', '2967 3333'), (38, 'ISLAT', 'Island Trading', 'Helen Bennett', 'Gerente de marketing', 'Garden House\r\nCrowther Way', 'Cowes', 'Isla de Wight', 'PO31 7PJ', 'Reino Unido', '(198) 555-8888', NULL), (40, 'LACOR', 'La corne d\'abondance', 'Daniel Tonini', 'Representante de ventas', '67, avenue de l\'Europe', 'Versalles', NULL, '78000', 'Francia', '30.59.84.10', '30.59.85.11'), (41, 'LAMAI', 'La maison d\'Asie', 'Annette Roulet', 'Gerente de ventas', '1 rue Alsace-Lorraine', 'Toulouse', NULL, '31000', 'Francia', '61.77.61.10', '61.77.61.11'), (42, 'LAUGB', 'Laughing Bacchus Wine Cellars', 'Yoshi Tannamuri', 'Asistente de marketing', '1900 Oak St.', 'Vancouver', 'BC', 'V3F 2K1', 'Canadá', '(604) 555-3392', '(604) 555-7293'), (43, 'LAZYK', 'Lazy K Kountry Store', 'John Steel', 'Gerente de marketing', '12 Orchestra Terrace', 'Walla Walla', 'WA', '99362', 'Estados Unidos', '(509) 555-7969', '(509) 555-6221'), (44, 'LEHMS', 'Lehmanns Marktstand', 'Renate Messner', 'Representante de ventas', 'Magazinweg 7', 'Francfurt', NULL, '60528', 'Alemania', '069-0245984', '069-0245874'), (45, 'LETSS', 'Let\'s Stop N Shop', 'Jaime Yorres', 'Propietario', '87 Polk St.\r\nSuite 5', 'San Francisco', 'CA', '94117', 'Estados Unidos', '(415) 555-5938', NULL), (47, 'LINOD', 'LINO-Delicateses', 'Felipe Izquierdo', 'Propietario', 'Ave. 5 de Mayo Porlamar', 'I. de Margarita', 'Nueva Esparta', '4980', 'Venezuela', '(8) 34-56-12', '(8) 34-93-93'), (48, 'LONEP', 'Lonesome Pine Restaurant', 'Fran Wilson', 'Gerente de ventas', '89 Chiaroscuro Rd.', 'Portland', 'OR', '97219', 'Estados Unidos', '(503) 555-9573', '(503) 555-9646'), (51, 'MEREP', 'Mère Paillarde', 'Jean Fresnière', 'Asistente de marketing', '43 rue St. Laurent', 'Montreal', 'Québec', 'H1J 1C3', 'Canadá', '(514) 555-8054', '(514) 555-8055'), (52, 'MORGK', 'Morgenstern Gesundkost', 'Alexander Feuer', 'Asistente de marketing', 'Heerstr. 22', 'Leipzig', NULL, '04179', 'Alemania', '0342-023176', NULL), (53, 'NORTS', 'North/South', 'Simon Crowther', 'Asistente de ventas', 'South House\r\n300 Queensbridge', 'Londres', NULL, 'SW7 1RZ', 'Reino Unido', '(71) 555-7733', '(71) 555-2530'), (56, 'OTTIK', 'Ottilies Käseladen', 'Henriette Pfalzheim', 'Propietario', 'Mehrheimerstr. 369', 'Köln', NULL, '50739', 'Alemania', '0221-0644327', '0221-0765721'), (57, 'PARIS', 'Paris spécialités', 'Marie Bertrand', 'Propietario', '265, boulevard Charonne', 'París', NULL, '75012', 'Francia', '(1) 42.34.22.66', '(1) 42.34.22.77'), (58, 'PERIC', 'Pericles Comidas clásicas', 'Guillermo Fernández', 'Representante de ventas', 'Calle Dr. Jorge Cash 321', 'México D.F.', NULL, '05033', 'México', '(5) 552-3745', '(5) 545-3745'), (59, 'PICCO', 'Piccolo und mehr', 'Georg Pipps', 'Gerente de ventas', 'Geislweg 14', 'Salzburgo', NULL, '5020', 'Austria', '6562-9722', '6562-9723'), (60, 'PRINI', 'Princesa Isabel Vinhos', 'Isabel de Castro', 'Representante de ventas', 'Estrada da saúde n. 58', 'Lisboa', NULL, '1756', 'Portugal', '(1) 356-5634', NULL), (61, 'QUEDE', 'Que Delícia', 'Bernardo Batista', 'Gerente de contabilidad', 'Rua da Panificadora, 12', 'Rio de Janeiro', 'RJ', '02389-673', 'Brasil', '(21) 555-4252', '(21) 555-4545'), (62, 'QUEEN', 'Queen Cozinha', 'Lúcia Carvalho', 'Asistente de marketing', 'Alameda dos Canàrios, 891', 'Sao Paulo', 'SP', '05487-020', 'Brasil', '(11) 555-1189', NULL), (63, 'QUICK', 'QUICK-Stop', 'Horst Kloss', 'Gerente de contabilidad', 'Taucherstraße 10', 'Cunewalde', NULL, '01307', 'Alemania', '0372-035188', NULL), (66, 'REGGC', 'Reggiani Caseifici', 'Maurizio Moroni', 'Asistente de ventas', 'Strada Provinciale 124', 'Reggio Emilia', NULL, '42100', 'Italia', '0522-556721', '0522-556722'), (67, 'RICAR', 'Ricardo Adocicados', 'Janete Limeira', 'Asistente de agente de ventas', 'Av. Copacabana, 267', 'Rio de Janeiro', 'RJ', '02389-890', 'Brasil', '(21) 555-3412', NULL), (68, 'RICSU', 'Richter Supermarkt', 'Michael Holz', 'Gerente de ventas', 'Grenzacherweg 237', 'Génova', NULL, '1203', 'Suiza', '0897-034214', NULL), (69, 'ROMEY', 'Romero y tomillo', 'Alejandra Camino', 'Gerente de contabilidad', 'Gran Vía, 1', 'Madrid', NULL, '28001', 'España', '(91) 745 6200', '(91) 745 6210'), (70, 'SANTG', 'Santé Gourmet', 'Jonas Bergulfsen', 'Propietario', 'Erling Skakkes gate 78', 'Stavern', NULL, '4110', 'Noruega', '07-98 92 35', '07-98 92 47'), (72, 'SEVES', 'Seven Seas Imports', 'Hari Kumar', 'Gerente de ventas', '90 Wadhurst Rd.', 'Londres', NULL, 'OX15 4NB', 'Reino Unido', '(71) 555-1717', '(71) 555-5646'), (73, 'SIMOB', 'Simons bistro', 'Jytte Petersen', 'Propietario', 'Vinbæltet 34', 'København', NULL, '1734', 'Dinamarca', '31 12 34 56', '31 13 35 57'), (74, 'SPECD', 'Spécialités du monde', 'Dominique Perrier', 'Gerente de marketing', '25, rue Lauriston', 'París', NULL, '75016', 'Francia', '(1) 47.55.60.10', '(1) 47.55.60.20'), (75, 'SPLIR', 'Split Rail Beer & Ale', 'Art Braunschweiger', 'Gerente de ventas', 'P.O. Box 555', 'Lander', 'WY', '82520', 'Estados Unidos', '(307) 555-4680', '(307) 555-6525'), (77, 'THEBI', 'The Big Cheese', 'Liz Nixon', 'Gerente de marketing', '89 Jefferson Way\r\nSuite 2', 'Portland', 'OR', '97201', 'Estados Unidos', '(503) 555-3612', NULL), (79, 'TOMSP', 'Toms Spezialitäten', 'Karin Josephs', 'Gerente de marketing', 'Luisenstr. 48', 'Münster', NULL, '44087', 'Alemania', '0251-031259', '0251-035695'), (80, 'TORTU', 'Tortuga Restaurante', 'Miguel Angel Paolino', 'Propietario', 'Avda. Azteca 123', 'México D.F.', NULL, '05033', 'México', '(5) 555-2933', NULL), (81, 'TRADH', 'Tradição Hipermercados', 'Anabela Domingues', 'Representante de ventas', 'Av. Inês de Castro, 414', 'Sao Paulo', 'SP', '05634-030', 'Brasil', '(11) 555-2167', '(11) 555-2168'), (82, 'TRAIH', 'Trail\'s Head Gourmet Provisioners', 'Helvetius Nagy', 'Asistente de ventas', '722 DaVinci Blvd.', 'Kirkland', 'WA', '98034', 'Estados Unidos', '(206) 555-8257', '(206) 555-2174'), (84, 'VICTE', 'Victuailles en stock', 'Mary Saveley', 'Agente de ventas', '2, rue du Commerce', 'Lion', NULL, '69004', 'Francia', '78.32.54.86', '78.32.54.87'), (85, 'VINET', 'Vins et alcools Chevalier', 'Paul Henriot', 'Gerente de contabilidad', '59 rue de l\'Abbaye', 'Reims', NULL, '51100', 'Francia', '26.47.15.10', '26.47.15.11'), (86, 'WANDK', 'Die Wandernde Kuh', 'Rita Müller', 'Representante de ventas', 'Adenauerallee 900', 'Stuttgart', NULL, '70563', 'Alemania', '0711-020361', '0711-035428'), (87, 'WARTH', 'Wartian Herkku', 'Pirkko Koskitalo', 'Gerente de contabilidad', 'Torikatu 38', 'Oulu', NULL, '90110', 'Finlandia', '981-443655', '981-443655'), (88, 'WELLI', 'Wellington Importadora', 'Paula Parente', 'Gerente de ventas', 'Rua do Mercado, 12', 'Resende', 'SP', '08737-363', 'Brasil', '(14) 555-8122', NULL), (89, 'WHITC', 'White Clover Markets', 'Karl Jablonski', 'Propietario', '305 - 14th Ave. S.\r\nSuite 3B', 'Seattle', 'WA', '98128', 'Estados Unidos', '(206) 555-4112', '(206) 555-4115'), (90, 'WILMK', 'Wilman Kala', 'Matti Karttunen', 'Prop./Asistente marketing', 'Keskuskatu 45', 'Helsinki', NULL, '21240', 'Finlandia', '90-224 8858', '90-224 8858'), (91, 'WOLZA', 'Wolski Zajazd', 'Zbyszek Piestrzeniewicz', 'Propietario', 'ul. Filtrowa 68', 'Warszawa', NULL, '01-012', 'Polonia', '(26) 642-7012', '(26) 642-7012'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `detalles` -- CREATE TABLE `detalles` ( `pedido_id` int NOT NULL, `producto_id` int NOT NULL, `precio_unidad` decimal(19,4) DEFAULT NULL, `cantidad` smallint DEFAULT NULL, `descuento` double(7,2) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `detalles` -- INSERT INTO `detalles` (`pedido_id`, `producto_id`, `precio_unidad`, `cantidad`, `descuento`) VALUES (10265, 17, '31.2000', 30, 0.00), (10265, 70, '12.0000', 20, 0.00), (10277, 28, '36.4000', 20, 0.00), (10277, 62, '39.4000', 12, 0.00), (10280, 24, '3.6000', 12, 0.00), (10280, 55, '19.2000', 20, 0.00), (10280, 75, '6.2000', 30, 0.00), (10295, 56, '30.4000', 4, 0.00), (10307, 62, '39.4000', 10, 0.00), (10307, 68, '10.0000', 3, 0.00), (10312, 28, '36.4000', 4, 0.00), (10312, 43, '36.8000', 24, 0.00), (10312, 53, '26.2000', 20, 0.00), (10312, 75, '6.2000', 10, 0.00), (10313, 36, '15.2000', 12, 0.00), (10339, 4, '17.6000', 10, 0.00), (10339, 17, '31.2000', 70, 0.05), (10339, 62, '39.4000', 28, 0.00), (10345, 8, '32.0000', 70, 0.00), (10345, 19, '7.3000', 80, 0.00), (10345, 42, '11.2000', 9, 0.00), (10368, 21, '8.0000', 5, 0.10), (10368, 28, '36.4000', 13, 0.10), (10368, 57, '15.6000', 25, 0.00), (10368, 64, '26.6000', 35, 0.10), (10379, 41, '7.7000', 8, 0.10), (10379, 63, '35.1000', 16, 0.10), (10379, 65, '16.8000', 20, 0.10), (10388, 45, '7.6000', 15, 0.20), (10388, 52, '5.6000', 20, 0.20), (10388, 53, '26.2000', 40, 0.00), (10392, 69, '28.8000', 50, 0.00), (10407, 11, '16.8000', 30, 0.00), (10407, 69, '28.8000', 15, 0.00), (10407, 71, '17.2000', 15, 0.00), (10414, 19, '7.3000', 18, 0.05), (10414, 33, '2.0000', 50, 0.00), (10422, 26, '24.9000', 2, 0.00), (10462, 13, '4.8000', 1, 0.00), (10462, 23, '7.2000', 21, 0.00), (10471, 7, '24.0000', 30, 0.00), (10471, 56, '30.4000', 20, 0.00), (10478, 10, '24.8000', 20, 0.05), (10487, 19, '7.3000', 5, 0.00), (10487, 26, '24.9000', 30, 0.00), (10487, 54, '5.9000', 24, 0.25), (10502, 45, '9.5000', 21, 0.00), (10502, 53, '32.8000', 6, 0.00), (10502, 67, '14.0000', 30, 0.00), (10515, 9, '97.0000', 16, 0.15), (10515, 16, '17.4500', 50, 0.00), (10515, 27, '43.9000', 120, 0.00), (10515, 33, '2.5000', 16, 0.15), (10515, 60, '34.0000', 84, 0.15), (10516, 18, '62.5000', 25, 0.10), (10516, 41, '9.6500', 80, 0.10), (10516, 42, '14.0000', 20, 0.00), (10541, 24, '4.5000', 35, 0.10), (10541, 38, '263.5000', 4, 0.10), (10541, 65, '21.0500', 36, 0.10), (10541, 71, '21.5000', 9, 0.10), (10552, 69, '36.0000', 18, 0.00), (10552, 75, '7.7500', 30, 0.00), (10553, 11, '21.0000', 15, 0.00), (10553, 16, '17.4500', 14, 0.00), (10553, 22, '21.0000', 24, 0.00), (10553, 31, '12.5000', 30, 0.00), (10553, 35, '18.0000', 6, 0.00), (10556, 72, '34.8000', 24, 0.00), (10563, 36, '19.0000', 25, 0.00), (10563, 52, '7.0000', 70, 0.00), (10583, 29, '123.7900', 10, 0.00), (10583, 60, '34.0000', 24, 0.15), (10583, 69, '36.0000', 10, 0.15), (10588, 18, '62.5000', 40, 0.20), (10588, 42, '14.0000', 100, 0.20), (10595, 35, '18.0000', 30, 0.25), (10595, 61, '28.5000', 120, 0.25), (10595, 69, '36.0000', 65, 0.25), (10615, 55, '24.0000', 5, 0.00), (10620, 24, '4.5000', 5, 0.00), (10620, 52, '7.0000', 5, 0.00), (10663, 40, '18.4000', 30, 0.05), (10663, 42, '14.0000', 30, 0.05), (10663, 51, '53.0000', 20, 0.05), (10669, 36, '19.0000', 30, 0.00), (10673, 16, '17.4500', 3, 0.00), (10673, 42, '14.0000', 6, 0.00), (10673, 43, '46.0000', 6, 0.00), (10676, 10, '31.0000', 2, 0.00), (10676, 19, '9.2000', 7, 0.00), (10676, 44, '19.4500', 21, 0.00), (10683, 52, '7.0000', 9, 0.00), (10686, 17, '39.0000', 30, 0.20), (10686, 26, '31.2300', 15, 0.00), (10691, 1, '18.0000', 30, 0.00), (10691, 29, '123.7900', 40, 0.00), (10691, 43, '46.0000', 40, 0.00), (10691, 44, '19.4500', 24, 0.00), (10691, 62, '49.3000', 48, 0.00), (10727, 17, '39.0000', 20, 0.05), (10727, 56, '38.0000', 10, 0.05), (10727, 59, '55.0000', 10, 0.05), (10737, 13, '6.0000', 4, 0.00), (10737, 41, '9.6500', 12, 0.00), (10738, 16, '17.4500', 3, 0.00), (10752, 1, '18.0000', 8, 0.00), (10752, 69, '36.0000', 3, 0.00), (10781, 54, '7.4500', 3, 0.20), (10781, 56, '38.0000', 20, 0.20), (10781, 74, '10.0000', 35, 0.00), (10787, 2, '19.0000', 15, 0.05), (10787, 29, '123.7900', 20, 0.05), (10798, 62, '49.3000', 2, 0.00), (10798, 72, '34.8000', 10, 0.00), (10805, 34, '14.0000', 10, 0.00), (10805, 38, '263.5000', 10, 0.00), (10810, 13, '6.0000', 7, 0.00), (10810, 25, '14.0000', 5, 0.00), (10810, 70, '15.0000', 5, 0.00), (10832, 13, '6.0000', 3, 0.20), (10832, 25, '14.0000', 10, 0.20), (10832, 44, '19.4500', 16, 0.20), (10832, 64, '33.2500', 3, 0.00), (10858, 7, '30.0000', 5, 0.00), (10858, 27, '43.9000', 10, 0.00), (10858, 70, '15.0000', 4, 0.00), (10865, 38, '263.5000', 60, 0.05), (10865, 39, '18.0000', 80, 0.05), (10912, 11, '21.0000', 40, 0.25), (10912, 29, '123.7900', 60, 0.25), (10915, 17, '39.0000', 10, 0.00), (10915, 33, '2.5000', 30, 0.00), (10915, 54, '7.4500', 10, 0.00), (10919, 16, '17.4500', 24, 0.00), (10919, 25, '14.0000', 24, 0.00), (10919, 40, '18.4000', 20, 0.00), (10949, 6, '25.0000', 12, 0.00), (10949, 10, '31.0000', 30, 0.00), (10949, 17, '39.0000', 6, 0.00), (10949, 62, '49.3000', 60, 0.00), (10967, 19, '9.2000', 12, 0.00), (10967, 49, '20.0000', 40, 0.00), (10971, 29, '123.7900', 14, 0.00), (10982, 7, '30.0000', 20, 0.00), (10982, 43, '46.0000', 9, 0.00), (10985, 16, '17.4500', 36, 0.10), (10985, 18, '62.5000', 8, 0.10), (10985, 32, '32.0000', 35, 0.10), (10989, 6, '25.0000', 40, 0.00), (10989, 11, '21.0000', 15, 0.00), (10989, 41, '9.6500', 4, 0.00), (10990, 21, '10.0000', 65, 0.00), (10990, 34, '14.0000', 60, 0.15), (10990, 55, '24.0000', 65, 0.15), (10990, 61, '28.5000', 66, 0.15), (11005, 1, '18.0000', 2, 0.00), (11005, 59, '55.0000', 10, 0.00), (11009, 24, '4.5000', 12, 0.00), (11009, 36, '19.0000', 18, 0.25), (11009, 60, '34.0000', 9, 0.00), (11010, 7, '30.0000', 20, 0.00), (11010, 24, '4.5000', 10, 0.00), (11013, 23, '9.0000', 10, 0.00), (11013, 42, '14.0000', 4, 0.00), (11013, 45, '9.5000', 20, 0.00), (11013, 68, '12.5000', 2, 0.00), (11014, 41, '9.6500', 28, 0.10), (11015, 30, '25.8900', 15, 0.00), (11015, 77, '13.0000', 18, 0.00), (11020, 10, '31.0000', 24, 0.15), (11032, 36, '19.0000', 35, 0.00), (11032, 38, '263.5000', 25, 0.00), (11032, 59, '55.0000', 30, 0.00), (11042, 44, '19.4500', 15, 0.00), (11042, 61, '28.5000', 4, 0.00), (11053, 18, '62.5000', 35, 0.20), (11053, 32, '32.0000', 20, 0.00), (11053, 64, '33.2500', 25, 0.20), (11059, 13, '6.0000', 30, 0.00), (11059, 17, '39.0000', 12, 0.00), (11059, 60, '34.0000', 35, 0.00), (11060, 60, '34.0000', 4, 0.00), (11060, 77, '13.0000', 10, 0.00), (11070, 1, '18.0000', 40, 0.15), (11070, 2, '19.0000', 20, 0.15), (11070, 16, '17.4500', 30, 0.15), (11070, 31, '12.5000', 20, 0.00), (11073, 11, '21.0000', 10, 0.00), (11073, 24, '4.5000', 20, 0.00); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `empleados` -- CREATE TABLE `empleados` ( `id` int NOT NULL, `apellidos` varchar(20) NOT NULL, `nombre` varchar(10) NOT NULL, `cargo` varchar(30) DEFAULT NULL, `tratamiento` varchar(25) DEFAULT NULL, `fecha_nacimiento` date DEFAULT NULL, `fecha_contratacion` date DEFAULT NULL, `direccion` varchar(60) DEFAULT NULL, `ciudad` varchar(15) DEFAULT NULL, `region` varchar(15) DEFAULT NULL, `cp` varchar(10) DEFAULT NULL, `pais` varchar(15) DEFAULT NULL, `telefono_domicilio` varchar(24) DEFAULT NULL, `extension` varchar(4) DEFAULT NULL, `notas` text, `jefe_id` int DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `empleados` -- INSERT INTO `empleados` (`id`, `apellidos`, `nombre`, `cargo`, `tratamiento`, `fecha_nacimiento`, `fecha_contratacion`, `direccion`, `ciudad`, `region`, `cp`, `pais`, `telefono_domicilio`, `extension`, `notas`, `jefe_id`) VALUES (2, 'Fuller', 'Andrew', 'Vicepresidente comercial', 'Dr.', '1952-02-19', '1992-08-14', '908 W. Capital Way', 'Tacoma', 'WA', '98401', 'EE.UU.', '(206) 555-9482', '3457', 'Andrew completó su licenciatura en Comercio y un doctorado en Marketing Internacional de la Universidad de Dallas. Habla con fluidez en francés e italiano y lee el alemán. Ingresó en la empresa como representante de ventas, fue ascendido a gerente de cuentas y después fue nombrado vicepresidente comercial.\r\nAndrew es miembro de la Mesa redonda de administración de Ventas, la Cámara de comercio de Seattle y de la Asociación de importadores de la Cuenca del Pacífico.', NULL); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `envios` -- CREATE TABLE `envios` ( `id` int NOT NULL, `empresa` varchar(40) NOT NULL, `telefono` varchar(24) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `envios` -- INSERT INTO `envios` (`id`, `empresa`, `telefono`) VALUES (1, 'Speedy Express', '(503) 555-9831'), (2, 'United Package', '(503) 555-3199'), (3, 'Federal Shipping', '(503) 555-9931'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `failed_jobs` -- CREATE TABLE `failed_jobs` ( `id` bigint UNSIGNED NOT NULL, `uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `connection` text COLLATE utf8mb4_unicode_ci NOT NULL, `queue` text COLLATE utf8mb4_unicode_ci NOT NULL, `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `menus` -- CREATE TABLE `menus` ( `id` int UNSIGNED NOT NULL, `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `menus` -- INSERT INTO `menus` (`id`, `name`, `created_at`, `updated_at`) VALUES (1, 'admin', '2018-11-06 13:46:46', '2018-11-06 13:46:46'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `migrations` -- CREATE TABLE `migrations` ( `id` int UNSIGNED NOT NULL, `migration` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `batch` int NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `migrations` -- INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1, '2014_10_12_000000_create_users_table', 1), (2, '2014_10_12_100000_create_password_resets_table', 1), (3, '2016_01_01_000000_add_voyager_user_fields', 1), (4, '2016_01_01_000000_create_data_types_table', 1), (5, '2016_05_19_173453_create_menu_table', 1), (6, '2016_10_21_190000_create_roles_table', 1), (7, '2016_10_21_190000_create_settings_table', 1), (8, '2016_11_30_135954_create_permission_table', 1), (9, '2016_11_30_141208_create_permission_role_table', 1), (10, '2016_12_26_201236_data_types__add__server_side', 1), (11, '2017_01_13_000000_add_route_to_menu_items_table', 1), (12, '2017_01_14_005015_create_translations_table', 1), (13, '2017_01_15_000000_make_table_name_nullable_in_permissions_table', 1), (14, '2017_03_06_000000_add_controller_to_data_types_table', 1), (15, '2017_04_21_000000_add_order_to_data_rows_table', 1), (16, '2017_07_05_210000_add_policyname_to_data_types_table', 1), (17, '2017_08_05_000000_add_group_to_settings_table', 1), (18, '2017_11_26_013050_add_user_role_relationship', 1), (19, '2017_11_26_015000_create_user_roles_table', 1), (20, '2018_03_11_000000_add_user_settings', 1), (21, '2018_03_14_000000_add_details_to_data_types_table', 1), (22, '2018_03_16_000000_make_settings_value_nullable', 1), (23, '2018_11_21_115359_create_permission_tables', 2); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `model_has_permissions` -- CREATE TABLE `model_has_permissions` ( `permission_id` int UNSIGNED NOT NULL, `model_type` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `model_id` bigint UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `model_has_permissions` -- INSERT INTO `model_has_permissions` (`permission_id`, `model_type`, `model_id`) VALUES (1, 'App\\User', 1), (2, 'App\\User', 1); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `model_has_roles` -- CREATE TABLE `model_has_roles` ( `role_id` int UNSIGNED NOT NULL, `model_type` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `model_id` bigint UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `model_has_roles` -- INSERT INTO `model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES (1, 'App\\User', 1); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `password_resets` -- CREATE TABLE `password_resets` ( `email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `token` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `pedidos` -- CREATE TABLE `pedidos` ( `id` int NOT NULL, `cliente_id` int NOT NULL, `empleado_id` int DEFAULT NULL, `fecha_pedido` date DEFAULT NULL, `fecha_entrega` date DEFAULT NULL, `fecha_envio` date DEFAULT NULL, `envio_id` int DEFAULT NULL, `cargo` decimal(19,4) DEFAULT NULL, `destinatario` varchar(40) DEFAULT NULL, `direccion_destinatario` varchar(60) DEFAULT NULL, `ciudad_destinatario` varchar(15) DEFAULT NULL, `region_destinatario` varchar(15) DEFAULT NULL, `cp_destinatario` varchar(10) DEFAULT NULL, `pais_destinatario` varchar(15) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `pedidos` -- INSERT INTO `pedidos` (`id`, `cliente_id`, `empleado_id`, `fecha_pedido`, `fecha_entrega`, `fecha_envio`, `envio_id`, `cargo`, `destinatario`, `direccion_destinatario`, `ciudad_destinatario`, `region_destinatario`, `cp_destinatario`, `pais_destinatario`) VALUES (10265, 7, 2, '2018-10-30', '1996-08-22', '1996-08-12', 1, '55.2800', 'Blondel père et fils', '24, place Kléber', 'Strasbourg', NULL, '67000', 'Francia'), (10277, 52, 2, '1996-08-09', '1996-09-06', '1996-08-13', 3, '125.7700', 'Morgenstern Gesundkost', 'Heerstr. 22', 'Leipzig', NULL, '04179', 'Alemania'), (10280, 5, 2, '1996-08-14', '1996-09-11', '1996-09-12', 1, '8.9800', 'Berglunds snabbköp', 'Berguvsvägen 8', 'Luleå', NULL, 'S-958 22', 'Suecia'), (10295, 85, 2, '1996-09-02', '1996-09-30', '1996-09-10', 2, '1.1500', 'Vins et alcools Chevalier', '59 rue de l\'Abbaye', 'Reims', NULL, '51100', 'Francia'), (10307, 48, 2, '1996-09-17', '1996-10-15', '1996-09-25', 2, '0.5600', 'Lonesome Pine Restaurant', '89 Chiaroscuro Rd.', 'Portland', 'OR', '97219', 'Estados Unidos'), (10312, 86, 2, '1996-09-23', '1996-10-21', '1996-10-03', 2, '40.2600', 'Die Wandernde Kuh', 'Adenauerallee 900', 'Stuttgart', NULL, '70563', 'Alemania'), (10313, 63, 2, '1996-09-24', '1996-10-22', '1996-10-04', 2, '1.9600', 'QUICK-Stop', 'Taucherstraße 10', 'Cunewalde', NULL, '01307', 'Alemania'), (10339, 51, 2, '1996-10-28', '1996-11-25', '1996-11-04', 2, '15.6600', 'Mère Paillarde', '43 rue St. Laurent', 'Montréal', 'Québec', 'H1J 1C3', 'Canadá'), (10345, 63, 2, '1996-11-04', '1996-12-02', '1996-11-11', 2, '249.0600', 'QUICK-Stop', 'Taucherstraße 10', 'Cunewalde', NULL, '01307', 'Alemania'), (10368, 20, 2, '1996-11-29', '1996-12-27', '1996-12-02', 2, '101.9500', 'Ernst Handel', 'Kirchgasse 6', 'Graz', NULL, '8010', 'Austria'), (10379, 61, 2, '1996-12-11', '1997-01-08', '1996-12-13', 1, '45.0300', 'Que Delícia', 'Rua da Panificadora, 12', 'Río de Janeiro', 'RJ', '02389-673', 'Brasil'), (10388, 72, 2, '1996-12-19', '1997-01-16', '1996-12-20', 1, '34.8600', 'Seven Seas Imports', '90 Wadhurst Rd.', 'London', NULL, 'OX15 4NB', 'Reino Unido'), (10392, 59, 2, '1996-12-24', '1997-01-21', '1997-01-01', 3, '122.4600', 'Piccolo und mehr', 'Geislweg 14', 'Salzburg', NULL, '5020', 'Austria'), (10407, 56, 2, '1997-01-07', '1997-02-04', '1997-01-30', 2, '91.4800', 'Ottilies Käseladen', 'Mehrheimerstr. 369', 'Köln', NULL, '50739', 'Alemania'), (10414, 21, 2, '1997-01-14', '1997-02-11', '1997-01-17', 3, '21.4800', 'Familia Arquibaldo', 'Rua Orós, 92', 'São Paulo', 'SP', '05442-030', 'Brasil'), (10422, 27, 2, '1997-01-22', '1997-02-19', '1997-01-31', 1, '3.0200', 'Franchi S.p.A.', 'Via Monte Bianco 34', 'Torino', NULL, '10100', 'Italia'), (10462, 15, 2, '1997-03-03', '1997-03-31', '1997-03-18', 1, '6.1700', 'Consolidated Holdings', 'Berkeley Gardens\r\n12 Brewery ', 'London', NULL, 'WX1 6LT', 'Reino Unido'), (10471, 11, 2, '1997-03-11', '1997-04-08', '1997-03-18', 3, '45.5900', 'B\'s Beverages', 'Fauntleroy Circus', 'London', NULL, 'EC2 5NT', 'Reino Unido'), (10478, 84, 2, '1997-03-18', '1997-04-01', '1997-03-26', 3, '4.8100', 'Victuailles en stock', '2, rue du Commerce', 'Lyon', NULL, '69004', 'Francia'), (10487, 62, 2, '1997-03-26', '1997-04-23', '1997-03-28', 2, '71.0700', 'Queen Cozinha', 'Alameda dos Canàrios, 891', 'São Paulo', 'SP', '05487-020', 'Brasil'), (10502, 58, 2, '1997-04-10', '1997-05-08', '1997-04-29', 1, '69.3200', 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', NULL, '05033', 'México'), (10515, 63, 2, '1997-04-23', '1997-05-07', '1997-05-23', 1, '204.4700', 'QUICK-Stop', 'Taucherstraße 10', 'Cunewalde', NULL, '01307', 'Alemania'), (10516, 37, 2, '1997-04-24', '1997-05-22', '1997-05-01', 3, '62.7800', 'Hungry Owl All-Night Grocers', '8 Johnstown Road', 'Cork', 'Co. Cork', NULL, 'Irlanda'), (10541, 34, 2, '1997-05-19', '1997-06-16', '1997-05-29', 1, '68.6500', 'Hanari Carnes', 'Rua do Paço, 67', 'Río de Janeiro', 'RJ', '05454-876', 'Brasil'), (10552, 35, 2, '1997-05-29', '1997-06-26', '1997-06-05', 1, '83.2200', 'HILARIÓN-Abastos', 'Carrera 22 con Ave. Carlos Soublette #8-35', 'San Cristóbal', 'Táchira', '5022', 'Venezuela'), (10553, 87, 2, '1997-05-30', '1997-06-27', '1997-06-03', 2, '149.4900', 'Wartian Herkku', 'Torikatu 38', 'Oulu', NULL, '90110', 'Finlandia'), (10556, 73, 2, '1997-06-03', '1997-07-15', '1997-06-13', 1, '9.8000', 'Simons bistro', 'Vinbæltet 34', 'København', NULL, '1734', 'Dinamarca'), (10563, 67, 2, '1997-06-10', '1997-07-22', '1997-06-24', 2, '60.4300', 'Ricardo Adocicados', 'Av. Copacabana, 267', 'Río de Janeiro', 'RJ', '02389-890', 'Brasil'), (10583, 87, 2, '1997-06-30', '1997-07-28', '1997-07-04', 2, '7.2800', 'Wartian Herkku', 'Torikatu 38', 'Oulu', NULL, '90110', 'Finlandia'), (10588, 63, 2, '1997-07-03', '1997-07-31', '1997-07-10', 3, '194.6700', 'QUICK-Stop', 'Taucherstraße 10', 'Cunewalde', NULL, '01307', 'Alemania'), (10595, 20, 2, '1997-07-10', '1997-08-07', '1997-07-14', 1, '96.7800', 'Ernst Handel', 'Kirchgasse 6', 'Graz', NULL, '8010', 'Austria'), (10615, 90, 2, '1997-07-30', '1997-08-27', '1997-08-06', 3, '0.7500', 'Wilman Kala', 'Keskuskatu 45', 'Helsinki', NULL, '21240', 'Finlandia'), (10620, 42, 2, '1997-08-05', '1997-09-02', '1997-08-14', 3, '0.9400', 'Laughing Bacchus Wine Cellars', '2319 Elm St.', 'Vancouver', 'BC', 'V3F 2K1', 'Canadá'), (10663, 9, 2, '1997-09-10', '1997-09-24', '1997-10-03', 2, '113.1500', 'Bon app\'', '12, rue des Bouchers', 'Marseille', NULL, '13008', 'Francia'), (10669, 73, 2, '1997-09-15', '1997-10-13', '1997-09-22', 1, '24.3900', 'Simons bistro', 'Vinbæltet 34', 'København', NULL, '1734', 'Dinamarca'), (10673, 90, 2, '1997-09-18', '1997-10-16', '1997-09-19', 1, '22.7600', 'Wilman Kala', 'Keskuskatu 45', 'Helsinki', NULL, '21240', 'Finlandia'), (10676, 80, 2, '1997-09-22', '1997-10-20', '1997-09-29', 2, '2.0100', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', NULL, '05033', 'México'), (10683, 18, 2, '1997-09-26', '1997-10-24', '1997-10-01', 1, '4.4000', 'Du monde entier', '67, rue des Cinquante Otages', 'Nantes', NULL, '44000', 'Francia'), (10686, 59, 2, '1997-09-30', '1997-10-28', '1997-10-08', 1, '96.5000', 'Piccolo und mehr', 'Geislweg 14', 'Salzburg', NULL, '5020', 'Austria'), (10691, 63, 2, '1997-10-03', '1997-11-14', '1997-10-22', 2, '810.0500', 'QUICK-Stop', 'Taucherstraße 10', 'Cunewalde', NULL, '01307', 'Alemania'), (10727, 66, 2, '1997-11-03', '1997-12-01', '1997-12-05', 1, '89.9000', 'Reggiani Caseifici', 'Strada Provinciale 124', 'Reggio Emilia', NULL, '42100', 'Italia'), (10737, 85, 2, '1997-11-11', '1997-12-09', '1997-11-18', 2, '7.7900', 'Vins et alcools Chevalier', '59 rue de l\'Abbaye', 'Reims', NULL, '51100', 'Francia'), (10738, 74, 2, '1997-11-12', '1997-12-10', '1997-11-18', 1, '2.9100', 'Spécialités du monde', '25, rue Lauriston', 'Paris', NULL, '75016', 'Francia'), (10752, 53, 2, '1997-11-24', '1997-12-22', '1997-11-28', 3, '1.3900', 'North/South', 'South House\r\n300 Queensbridge', 'London', NULL, 'SW7 1RZ', 'Reino Unido'), (10781, 87, 2, '1997-12-17', '1998-01-14', '1997-12-19', 3, '73.1600', 'Wartian Herkku', 'Torikatu 38', 'Oulu', NULL, '90110', 'Finlandia'), (10787, 41, 2, '1997-12-19', '1998-01-02', '1997-12-26', 1, '249.9300', 'La maison d\'Asie', '1 rue Alsace-Lorraine', 'Toulouse', NULL, '31000', 'Francia'), (10798, 38, 2, '1997-12-26', '1998-01-23', '1998-01-05', 1, '2.3300', 'Island Trading', 'Garden House\r\nCrowther Way', 'Cowes', 'Isle of Wight', 'PO31 7PJ', 'Reino Unido'), (10805, 77, 2, '1997-12-30', '1998-01-27', '1998-01-09', 3, '237.3400', 'The Big Cheese', '89 Jefferson Way\r\nSuite 2', 'Portland', 'OR', '97201', 'Estados Unidos'), (10810, 42, 2, '1998-01-01', '1998-01-29', '1998-01-07', 3, '4.3300', 'Laughing Bacchus Wine Cellars', '2319 Elm St.', 'Vancouver', 'BC', 'V3F 2K1', 'Canadá'), (10832, 41, 2, '1998-01-14', '1998-02-11', '1998-01-19', 2, '43.2600', 'La maison d\'Asie', '1 rue Alsace-Lorraine', 'Toulouse', NULL, '31000', 'Francia'), (10858, 40, 2, '1998-01-29', '1998-02-26', '1998-02-03', 1, '52.5100', 'La corne d\'abondance', '67, avenue de l\'Europe', 'Versailles', NULL, '78000', 'Francia'), (10865, 63, 2, '1998-02-02', '1998-02-16', '1998-02-12', 1, '348.1400', 'QUICK-Stop', 'Taucherstraße 10', 'Cunewalde', NULL, '01307', 'Alemania'), (10912, 37, 2, '1998-02-26', '1998-03-26', '1998-03-18', 2, '580.9100', 'Hungry Owl All-Night Grocers', '8 Johnstown Road', 'Cork', 'Co. Cork', NULL, 'Irlanda'), (10915, 80, 2, '1998-02-27', '1998-03-27', '1998-03-02', 2, '3.5100', 'Tortuga Restaurante', 'Avda. Azteca 123', 'México D.F.', NULL, '05033', 'México'), (10919, 47, 2, '1998-03-02', '1998-03-30', '1998-03-04', 2, '19.8000', 'LINO-Delicateses', 'Ave. 5 de Mayo Porlamar', 'I. de Margarita', 'Nueva Esparta', '4980', 'Venezuela'), (10949, 10, 2, '1998-03-13', '1998-04-10', '1998-03-17', 3, '74.4400', 'Bottom-Dollar Markets', '23 Tsawassen Blvd.', 'Tsawassen', 'BC', 'T2F 8M4', 'Canadá'), (10967, 79, 2, '1998-03-23', '1998-04-20', '1998-04-02', 2, '62.2200', 'Toms Spezialitäten', 'Luisenstr. 48', 'Münster', NULL, '44087', 'Alemania'), (10971, 26, 2, '1998-03-24', '1998-04-21', '1998-04-02', 2, '121.8200', 'France restauration', '54, rue Royale', 'Nantes', NULL, '44000', 'Francia'), (10982, 10, 2, '1998-03-27', '1998-04-24', '1998-04-08', 1, '14.0100', 'Bottom-Dollar Markets', '23 Tsawassen Blvd.', 'Tsawassen', 'BC', 'T2F 8M4', 'Canadá'), (10985, 37, 2, '1998-03-30', '1998-04-27', '1998-04-02', 1, '91.5100', 'Hungry Owl All-Night Grocers', '8 Johnstown Road', 'Cork', 'Co. Cork', NULL, 'Irlanda'), (10989, 61, 2, '1998-03-31', '1998-04-28', '1998-04-02', 1, '34.7600', 'Que Delícia', 'Rua da Panificadora, 12', 'Río de Janeiro', 'RJ', '02389-673', 'Brasil'), (10990, 20, 2, '1998-04-01', '1998-05-13', '1998-04-07', 3, '117.6100', 'Ernst Handel', 'Kirchgasse 6', 'Graz', NULL, '8010', 'Austria'), (11005, 90, 2, '1998-04-07', '1998-05-05', '1998-04-10', 1, '0.7500', 'Wilman Kala', 'Keskuskatu 45', 'Helsinki', NULL, '21240', 'Finlandia'), (11009, 30, 2, '1998-04-08', '1998-05-06', '1998-04-10', 1, '59.1100', 'Godos Cocina Típica', 'C/ Romero, 33', 'Sevilla', NULL, '41101', 'España'), (11010, 66, 2, '1998-04-09', '1998-05-07', '1998-04-21', 2, '28.7100', 'Reggiani Caseifici', 'Strada Provinciale 124', 'Reggio Emilia', NULL, '42100', 'Italia'), (11013, 69, 2, '1998-04-09', '1998-05-07', '1998-04-10', 1, '32.9900', 'Romero y tomillo', 'Gran Vía, 1', 'Madrid', NULL, '28001', 'España'), (11014, 47, 2, '1998-04-10', '1998-05-08', '1998-04-15', 3, '23.6000', 'LINO-Delicateses', 'Ave. 5 de Mayo Porlamar', 'I. de Margarita', 'Nueva Esparta', '4980', 'Venezuela'), (11015, 70, 2, '1998-04-10', '1998-04-24', '1998-04-20', 2, '4.6200', 'Santé Gourmet', 'Erling Skakkes gate 78', 'Stavern', NULL, '4110', 'Noruega'), (11020, 56, 2, '1998-04-14', '1998-05-12', '1998-04-16', 2, '43.3000', 'Ottilies Käseladen', 'Mehrheimerstr. 369', 'Köln', NULL, '50739', 'Alemania'), (11032, 89, 2, '1998-04-17', '1998-05-15', '1998-04-23', 3, '606.1900', 'White Clover Markets', '1029 - 12th Ave. S.', 'Seattle', 'WA', '98124', 'Estados Unidos'), (11042, 14, 2, '1998-04-22', '1998-05-06', '1998-05-01', 1, '29.9900', 'Comércio Mineiro', 'Av. dos Lusíadas, 23', 'São Paulo', 'SP', '05432-043', 'Brasil'), (11053, 59, 2, '1998-04-27', '1998-05-25', '1998-04-29', 2, '53.0500', 'Piccolo und mehr', 'Geislweg 14', 'Salzburg', NULL, '5020', 'Austria'), (11059, 67, 2, '1998-04-29', '1998-06-10', NULL, 2, '85.8000', 'Ricardo Adocicados', 'Av. Copacabana, 267', 'Río de Janeiro', 'RJ', '02389-890', 'Brasil'), (11060, 27, 2, '1998-04-30', '1998-05-28', '1998-05-04', 2, '10.9800', 'Franchi S.p.A.', 'Via Monte Bianco 34', 'Torino', NULL, '10100', 'Italia'), (11070, 44, 2, '1998-05-05', '1998-06-02', NULL, 1, '136.0000', 'Lehmanns Marktstand', 'Magazinweg 7', 'Frankfurt a.M. ', NULL, '60528', 'Alemania'), (11073, 58, 2, '1998-05-05', '1998-06-02', NULL, 2, '24.9500', 'Pericles Comidas clásicas', 'Calle Dr. Jorge Cash 321', 'México D.F.', NULL, '05033', 'México'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `permissions` -- CREATE TABLE `permissions` ( `id` int UNSIGNED NOT NULL, `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `guard_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `permissions` -- INSERT INTO `permissions` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES (1, 'edit articles', 'web', '2018-11-21 12:14:36', '2018-11-21 12:14:36'), (2, 'delete articles', 'web', '2018-11-21 12:30:42', '2018-11-21 12:30:42'), (3, 'mostrar pedidos', 'web', '2018-11-21 12:44:49', '2018-11-21 12:44:49'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `productos` -- CREATE TABLE `productos` ( `id` int NOT NULL, `producto` varchar(40) NOT NULL, `proveedor_id` int DEFAULT NULL, `categoria_id` int DEFAULT NULL, `cantidad_por_unidad` varchar(20) DEFAULT NULL, `precio_unidad` decimal(19,4) DEFAULT NULL, `unidades_existencia` smallint DEFAULT NULL, `unidades_pedido` smallint DEFAULT NULL, `nivel_nuevo_pedido` int DEFAULT NULL, `suspendido` tinyint(1) DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `productos` -- INSERT INTO `productos` (`id`, `producto`, `proveedor_id`, `categoria_id`, `cantidad_por_unidad`, `precio_unidad`, `unidades_existencia`, `unidades_pedido`, `nivel_nuevo_pedido`, `suspendido`) VALUES (4, 'Papas', 2, 2, '48 - frascos 6 l', '22.0000', 53, 0, 0, 0), (5, 'Mezcla Gumbo del chef Anton', 2, 2, '36 cajas', '21.3500', 0, 0, 0, -1), (6, 'Mermelada de grosellas de la abuela', 3, 2, '12 - frascos 8 l', '25.0000', 120, 0, 25, 0), (7, 'Peras secas orgánicas del tío Bob', 3, 7, '12 - paq. 1 kg', '30.0000', 15, 0, 10, 0), (8, 'Salsa de arándanos Northwoods', 3, 2, '12 - frascos 12 l', '40.0000', 6, 0, 0, 0), (9, 'Buey Mishi Kobe', 4, 6, '18 - paq. 500 g', '97.0000', 29, 0, 0, -1), (14, 'Cuajada de judías', 6, 7, '40 - paq. 100 g', '23.2500', 35, 0, 0, 0), (15, 'Salsa de soja baja en sodio', 6, 2, '24 - bot. 250 ml', '15.5000', 39, 0, 5, 0), (16, 'Postre de merengue Pavlova', 7, 3, '32 - cajas 500 g', '17.4500', 29, 0, 10, 0), (17, 'papas arrugadas', 7, 6, '20 - latas 1 kg', '39.0000', 0, 0, 0, -1), (19, 'Pastas de té de chocolate', 8, 3, '10 cajas x 12 piezas', '9.2000', 25, 0, 5, 0), (20, 'Mermelada de Sir Rodney\'s', 8, 3, '30 cajas regalo', '81.0000', 40, 0, 0, 0), (21, 'Bollos de Sir Rodney\'s', 8, 3, '24 paq. x 4 piezas', '10.0000', 3, 40, 5, 0), (22, 'Pan de centeno crujiente estilo Gustaf\'s', 9, 5, '24 - paq. 500 g', '21.0000', 104, 0, 25, 0), (23, 'Pan fino', 9, 5, '12 - paq. 250 g', '9.0000', 61, 0, 25, 0), (24, 'Refresco Guaraná Fantástica', 10, 1, '12 - latas 355 ml', '4.5000', 20, 0, 0, -1), (25, 'Crema de chocolate y nueces NuNuCa', 11, 3, '20 - vasos 450 g', '14.0000', 76, 0, 30, 0), (26, 'Ositos de goma Gumbär', 11, 3, '100 - bolsas 250 g', '31.2300', 15, 0, 0, 0), (27, 'Chocolate Schoggi', 11, 3, '100 - piezas 100 g', '43.9000', 49, 0, 30, 0), (28, 'Col fermentada Rössle', 12, 7, '25 - latas 825 g', '45.6000', 26, 0, 0, -1), (29, 'Salchicha Thüringer', 12, 6, '50 bolsas x 30 salch', '123.7900', 0, 0, 0, -1), (31, 'Queso gorgonzola Telino', 14, 4, '12 - paq. 100 g', '12.5000', 0, 70, 20, 0), (32, 'Queso Mascarpone Fabioli', 14, 4, '24 - paq. 200 g', '32.0000', 9, 40, 25, 0), (33, 'Queso de cabra', 15, 4, '500 g', '2.5000', 112, 0, 20, 0), (42, 'Tallarines de Singapur', 20, 5, '32 - 1 kg paq.', '14.0000', 26, 0, 0, -1), (43, 'Café de Malasia', 20, 1, '16 - latas 500 g', '46.0000', 17, 10, 25, 0), (49, 'Regaliz', 23, 3, '24 - paq. 50 g', '20.0000', 10, 60, 15, 0), (50, 'Chocolate blanco', 23, 3, '12 - barras 100 g', '16.2500', 65, 0, 30, 0), (51, 'Manzanas secas Manjimup', 24, 7, '50 - paq. 300 g', '53.0000', 20, 0, 10, 0), (53, 'Empanada de carne', 24, 6, '48 porc.', '32.8000', 0, 0, 0, -1), (54, 'Empanada de cerdo', 25, 6, '16 tartas', '7.4500', 21, 0, 10, 0), (55, 'Paté chino', 25, 6, '24 cajas x 2 tartas', '24.0000', 115, 0, 20, 0), (56, 'Gnocchi de la abuela Alicia', 26, 5, '24 - paq. 250 g', '38.0000', 21, 10, 30, 0), (57, 'Raviolis Angelo', 26, 5, '24 - paq. 250 g', '19.5000', 36, 0, 20, 0), (59, 'Raclet de queso Courdavault', 28, 4, 'paq. 5 kg', '55.0000', 79, 0, 0, 0), (60, 'Camembert Pierrot', 28, 4, '15 - paq. 300 g', '34.0000', 19, 0, 0, 0), (63, 'Sandwich de vegetales', 7, 2, '15 - frascos 625 g', '43.9000', 24, 0, 5, 0), (64, 'Bollos de pan de Wimmer', 12, 5, '20 bolsas x 4 porc.', '33.2500', 22, 80, 30, 0), (66, 'Especias picantes de Luisiana', 2, 2, '24 - frascos 8 l', '17.0000', 4, 100, 20, 0), (69, 'Queso Gudbrandsdals', 15, 4, 'paq. 10 kg', '36.0000', 26, 0, 15, 0), (70, 'Cerveza Outback', 7, 1, '24 - bot. 355 ml', '15.0000', 15, 10, 30, 0), (71, 'Crema de queso Fløtemys', 15, 4, '10 - paq. 500 g', '21.5000', 26, 0, 0, 0), (72, 'Queso Mozzarella Giovanni', 14, 4, '24 - paq. 200 g', '34.8000', 14, 0, 0, 0), (75, 'Cerveza Klosterbier Rhönbräu', 12, 1, '24 - bot. 0,5 l', '7.7500', 125, 0, 25, 0), (76, 'Licor Cloudberry', 23, 1, '500 ml', '18.0000', 57, 0, 20, 0), (77, 'Salsa verde original Frankfurter', 12, 2, '12 cajas', '13.0000', 32, 0, 15, 0), (85, 'sake japones', 6, 1, NULL, NULL, NULL, NULL, NULL, 0), (86, 'Coca Cola', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0), (88, 'Coca Cola1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0), (90, 'Coca Cola61', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0), (91, 'Coca Cola631', NULL, NULL, NULL, NULL, 234, NULL, NULL, 0); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `proveedores` -- CREATE TABLE `proveedores` ( `id` int NOT NULL, `empresa` varchar(40) NOT NULL, `contacto` varchar(30) DEFAULT NULL, `cargo_contacto` varchar(30) DEFAULT NULL, `direccion` varchar(60) DEFAULT NULL, `ciudad` varchar(15) DEFAULT NULL, `region` varchar(15) DEFAULT NULL, `cp` varchar(10) DEFAULT NULL, `pais` varchar(15) DEFAULT NULL, `telefono` varchar(24) DEFAULT NULL, `fax` varchar(24) DEFAULT NULL, `web` text ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `proveedores` -- INSERT INTO `proveedores` (`id`, `empresa`, `contacto`, `cargo_contacto`, `direccion`, `ciudad`, `region`, `cp`, `pais`, `telefono`, `fax`, `web`) VALUES (1, 'Exotic Liquids', 'Charlotte Cooper', 'Gerente de compras', '49 Gilbert St.', 'Londres', NULL, 'EC1 4SD', 'Reino Unido', '(171) 555-2222', NULL, NULL), (2, 'New Orleans Cajun Delights', 'Shelley Burke', 'Administrador de pedidos', 'P.O. Box 78934', 'New Orleans', 'LA', '70117', 'Estados Unidos', '(100) 555-4822', NULL, NULL), (3, 'Grandma Kelly\'s Homestead', 'Regina Murphy', 'Representante de ventas', '707 Oxford Rd.', 'Ann Arbor', 'MI', '48104', 'Estados Unidos', '(313) 555-5735', '(313) 555-3349', NULL), (4, 'Tokyo Traders', 'Yoshi Nagase', 'Gerente de marketing', '9-8 Sekimai\r\nMusashino-shi', 'Tokyo', NULL, '100', 'Japón', '(03) 3555-5011', NULL, NULL), (5, 'Cooperativa de Quesos \'Las Cabras\'', 'Antonio del Valle Saavedra ', 'Administrador de exportaciones', 'Calle del Rosal 4', 'Oviedo', 'Asturias', '33007', 'España', '(98) 598 76 54', NULL, NULL), (6, 'Mayumi\'s', 'Mayumi Ohno', 'Representante de marketing', '92 Setsuko\r\nChuo-ku', 'Osaka', NULL, '545', 'Japón', '(06) 431-7877', NULL, NULL), (7, 'Pavlova, Ltd.', 'Ian Devling', 'Gerente de marketing', '74 Rose St.\r\nMoonie Ponds', 'Melbourne', 'Victoria', '3058', 'Australia', '(03) 444-2343', '(03) 444-6588', NULL), (8, 'Specialty Biscuits, Ltd.', 'Peter Wilson', 'Representante de ventas', '29 King\'s Way', 'Manchester', NULL, 'M14 GSD', 'Reino Unido', '(161) 555-4448', NULL, NULL), (9, 'PB Knäckebröd AB', 'Lars Peterson', 'Agente de ventas', 'Kaloadagatan 13', 'Göteborg', NULL, 'S-345 67', 'Suecia', '031-987 65 43', '031-987 65 91', NULL), (10, 'Refrescos Americanas LTDA', 'Carlos Diaz', 'Gerente de marketing', 'Av. das Americanas 12.890', 'São Paulo', NULL, '5442', 'Brasil', '(11) 555 4640', NULL, NULL), (11, 'Heli Süßwaren GmbH & Co. KG', 'Petra Winkler', 'Gerente de ventas', 'Tiergartenstraße 5', 'Berlín', NULL, '10785', 'Alemania', '(010) 9984510', NULL, NULL), (12, 'Plutzer Lebensmittelgroßmärkte AG', 'Martin Bein', 'Ger. marketing internacional', 'Bogenallee 51', 'Frankfurt', NULL, '60439', 'Alemania', '(069) 992755', NULL, NULL), (13, 'Nord-Ost-Fisch Handelsgesellschaft mbH', 'Sven Petersen', 'Coordinador de mercados', 'Frahmredder 112a', 'Cuxhaven', NULL, '27478', 'Alemania', '(04721) 8713', '(04721) 8714', NULL), (14, 'Formaggi Fortini s.r.l.', 'Elio Rossi', 'Representante de ventas', 'Viale Dante, 75', 'Ravenna', NULL, '48100', 'Italia', '(0544) 60323', '(0544) 60603', NULL), (15, 'Norske Meierier', 'Beate Vileid', 'Gerente de marketing', 'Hatlevegen 5', 'Sandvika', NULL, '1320', 'Noruega', '(0)2-953010', NULL, NULL), (16, 'Bigfoot Breweries', 'Cheryl Saylor', 'Repr. de cuentas regional', '3400 - 8th Avenue\r\nSuite 210', 'Bend', 'OR', '97101', 'Estados Unidos', '(503) 555-9931', NULL, NULL), (17, 'Svensk Sjöföda AB', 'Michael Björn', 'Representante de ventas', 'Brovallavägen 231', 'Stockholm', NULL, 'S-123 45', 'Suecia', '08-123 45 67', NULL, NULL), (18, 'Aux joyeux ecclésiastiques', 'Guylène Nodier', 'Gerente de ventas', '203, Rue des Francs-Bourgeois', 'París', NULL, '75004', 'Francia', '(1) 03.83.00.68', '(1) 03.83.00.62', NULL), (19, 'New England Seafood Cannery', 'Robb Merchant', 'Agente de cuentas al por mayor', 'Order Processing Dept.\r\n2100 Paul Revere Blvd.', 'Boston', 'MA', '02134', 'Estados Unidos', '(617) 555-3267', '(617) 555-3389', NULL), (20, 'Leka Trading', 'Chandra Leka', 'Propietario', '471 Serangoon Loop, Suite #402', 'Singapore', NULL, '0512', 'Singapur', '555-8787', NULL, NULL), (21, 'Lyngbysild', 'Niels Petersen', 'Gerente de ventas', 'Lyngbysild\r\nFiskebakken 10', 'Lyngby', NULL, '2800', 'Dinamarca', '43844108', '43844115', NULL), (22, 'Zaanse Snoepfabriek', 'Dirk Luchte', 'Gerente de contabilidad', 'Verkoop\r\nRijnweg 22', 'Zaandam', NULL, '9999 ZZ', 'Holanda', '(12345) 1212', '(12345) 1210', NULL), (23, 'Karkki Oy', 'Anne Heikkonen', 'Gerente de producción', 'Valtakatu 12', 'Lappeenranta', NULL, '53120', 'Finlandia', '(953) 10956', NULL, NULL), (24, 'G\'day, Mate', 'Wendy Mackenzie', 'Representante de ventas', '170 Prince Edward Parade\r\nHunter\'s Hill', 'Sydney', 'NSW', '2042', 'Australia', '(02) 555-5914', '(02) 555-4873', NULL), (25, 'Ma Maison', 'Jean-Guy Lauzon', 'Gerente de marketing', '2960 Rue St. Laurent', 'Montréal', 'Québec', 'H1J 1C3', 'Canadá', '(514) 555-9022', NULL, NULL), (26, 'Pasta Buttini s.r.l.', 'Giovanni Giudici', 'Administrador de pedidos', 'Via dei Gelsomini, 153', 'Salerno', NULL, '84100', 'Italia', '(089) 6547665', '(089) 6547667', NULL), (27, 'Escargots Nouveaux', 'Marie Delamare', 'Gerente de ventas', '22, rue H. Voiron', 'Montceau', NULL, '71300', 'Francia', '85.57.00.07', NULL, NULL), (28, 'Gai pâturage', 'Eliane Noz', 'Representante de ventas', 'Bat. B\r\n3, rue des Alpes', 'Annecy', NULL, '74000', 'Francia', '38.76.98.06', '38.76.98.58', NULL), (29, 'Forêts d\'érables', 'Chantal Goulet', 'Gerente de contabilidad', '148 rue Chasseur', 'Ste-Hyacinthe', 'Québec', 'J2S 7S8', 'Canadá', '(514) 555-2955', '(514) 555-2921', NULL); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `roles` -- CREATE TABLE `roles` ( `id` int UNSIGNED NOT NULL, `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `guard_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `roles` -- INSERT INTO `roles` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES (1, 'writer', 'web', '2018-11-21 12:06:00', '2018-11-21 12:06:00'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `role_has_permissions` -- CREATE TABLE `role_has_permissions` ( `permission_id` int UNSIGNED NOT NULL, `role_id` int UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `role_has_permissions` -- INSERT INTO `role_has_permissions` (`permission_id`, `role_id`) VALUES (1, 1), (3, 1); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `users` -- CREATE TABLE `users` ( `id` int UNSIGNED NOT NULL, `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `email` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `avatar` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT 'users/default.png', `email_verified_at` timestamp NULL DEFAULT NULL, `password` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `remember_token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `settings` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Volcado de datos para la tabla `users` -- INSERT INTO `users` (`id`, `name`, `email`, `avatar`, `email_verified_at`, `password`, `remember_token`, `settings`, `created_at`, `updated_at`) VALUES (1, 'mario', 'nuwanda555@gmail.com', 'users/default.png', NULL, '$2y$10$5XHcqD4tBGXN2uZk5uzCM.vcdsBIDOLtlRBCFPB8eJ5g/Ta7uCVfO', NULL, NULL, '2018-11-06 13:54:08', '2018-11-06 13:54:08'), (2, 'pepe', 'pepe@gmail.com', 'users/default.png', NULL, '$2y$10$5XHcqD4tBGXN2uZk5uzCM.vcdsBIDOLtlRBCFPB8eJ5g/Ta7uCVfO', NULL, NULL, '2018-11-06 13:54:08', '2018-11-06 13:54:08'); -- -- Índices para tablas volcadas -- -- -- Indices de la tabla `amigos` -- ALTER TABLE `amigos` ADD PRIMARY KEY (`id`); -- -- Indices de la tabla `categorias` -- ALTER TABLE `categorias` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `uq_categoria` (`categoria`); -- -- Indices de la tabla `clientes` -- ALTER TABLE `clientes` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `uq_cliente1` (`codigo`), ADD UNIQUE KEY `uq_cliente2` (`empresa`); -- -- Indices de la tabla `detalles` -- ALTER TABLE `detalles` ADD PRIMARY KEY (`pedido_id`,`producto_id`), ADD KEY `fk_producto` (`producto_id`); -- -- Indices de la tabla `empleados` -- ALTER TABLE `empleados` ADD PRIMARY KEY (`id`), ADD KEY `fk_jefe` (`jefe_id`); -- -- Indices de la tabla `envios` -- ALTER TABLE `envios` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `uq_envio` (`empresa`); -- -- Indices de la tabla `failed_jobs` -- ALTER TABLE `failed_jobs` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`); -- -- Indices de la tabla `menus` -- ALTER TABLE `menus` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `menus_name_unique` (`name`); -- -- Indices de la tabla `migrations` -- ALTER TABLE `migrations` ADD PRIMARY KEY (`id`); -- -- Indices de la tabla `model_has_permissions` -- ALTER TABLE `model_has_permissions` ADD PRIMARY KEY (`permission_id`,`model_id`,`model_type`), ADD KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`); -- -- Indices de la tabla `model_has_roles` -- ALTER TABLE `model_has_roles` ADD PRIMARY KEY (`role_id`,`model_id`,`model_type`), ADD KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`); -- -- Indices de la tabla `password_resets` -- ALTER TABLE `password_resets` ADD KEY `password_resets_email_index` (`email`); -- -- Indices de la tabla `pedidos` -- ALTER TABLE `pedidos` ADD PRIMARY KEY (`id`), ADD KEY `fk_cliente` (`cliente_id`), ADD KEY `fk_empleado` (`empleado_id`), ADD KEY `fk_envio` (`envio_id`); -- -- Indices de la tabla `permissions` -- ALTER TABLE `permissions` ADD PRIMARY KEY (`id`); -- -- Indices de la tabla `productos` -- ALTER TABLE `productos` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `uq_producto` (`producto`), ADD KEY `fk_categoria` (`categoria_id`), ADD KEY `fk_proveedor` (`proveedor_id`); -- -- Indices de la tabla `proveedores` -- ALTER TABLE `proveedores` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `uq_proveedor` (`empresa`); -- -- Indices de la tabla `roles` -- ALTER TABLE `roles` ADD PRIMARY KEY (`id`); -- -- Indices de la tabla `role_has_permissions` -- ALTER TABLE `role_has_permissions` ADD PRIMARY KEY (`permission_id`,`role_id`), ADD KEY `role_has_permissions_role_id_foreign` (`role_id`); -- -- Indices de la tabla `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `users_email_unique` (`email`); -- -- AUTO_INCREMENT de las tablas volcadas -- -- -- AUTO_INCREMENT de la tabla `amigos` -- ALTER TABLE `amigos` MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT de la tabla `categorias` -- ALTER TABLE `categorias` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22; -- -- AUTO_INCREMENT de la tabla `clientes` -- ALTER TABLE `clientes` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=92; -- -- AUTO_INCREMENT de la tabla `empleados` -- ALTER TABLE `empleados` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT de la tabla `envios` -- ALTER TABLE `envios` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT de la tabla `failed_jobs` -- ALTER TABLE `failed_jobs` MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT de la tabla `menus` -- ALTER TABLE `menus` MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT de la tabla `migrations` -- ALTER TABLE `migrations` MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24; -- -- AUTO_INCREMENT de la tabla `pedidos` -- ALTER TABLE `pedidos` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11074; -- -- AUTO_INCREMENT de la tabla `permissions` -- ALTER TABLE `permissions` MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT de la tabla `productos` -- ALTER TABLE `productos` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=92; -- -- AUTO_INCREMENT de la tabla `proveedores` -- ALTER TABLE `proveedores` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30; -- -- AUTO_INCREMENT de la tabla `roles` -- ALTER TABLE `roles` MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT de la tabla `users` -- ALTER TABLE `users` MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- Restricciones para tablas volcadas -- -- -- Filtros para la tabla `detalles` -- ALTER TABLE `detalles` ADD CONSTRAINT `fk_pedido` FOREIGN KEY (`pedido_id`) REFERENCES `pedidos` (`id`) ON DELETE CASCADE; -- -- Filtros para la tabla `empleados` -- ALTER TABLE `empleados` ADD CONSTRAINT `fk_jefe` FOREIGN KEY (`jefe_id`) REFERENCES `empleados` (`id`); -- -- Filtros para la tabla `model_has_permissions` -- ALTER TABLE `model_has_permissions` ADD CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE; -- -- Filtros para la tabla `model_has_roles` -- ALTER TABLE `model_has_roles` ADD CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE; -- -- Filtros para la tabla `pedidos` -- ALTER TABLE `pedidos` ADD CONSTRAINT `fk_cliente` FOREIGN KEY (`cliente_id`) REFERENCES `clientes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `fk_empleado` FOREIGN KEY (`empleado_id`) REFERENCES `empleados` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `fk_envio` FOREIGN KEY (`envio_id`) REFERENCES `envios` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Filtros para la tabla `productos` -- ALTER TABLE `productos` ADD CONSTRAINT `fk_categoria` FOREIGN KEY (`categoria_id`) REFERENCES `categorias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `fk_proveedor` FOREIGN KEY (`proveedor_id`) REFERENCES `proveedores` (`id`); -- -- Filtros para la tabla `role_has_permissions` -- ALTER TABLE `role_has_permissions` ADD CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
90525e3ab6048d9d7d32faf65a61614b9720c74f
SQL
Shmyg/unix
/scripts/sql/full_segments.sql
UTF-8
284
3.140625
3
[]
no_license
SELECT a.SEGMENT_NAME, a.SEGMENT_TYPE, a.TABLESPACE_NAME, a.OWNER FROM DBA_SEGMENTS a WHERE a.NEXT_EXTENT >= (SELECT MAX(b.BYTES) FROM DBA_FREE_SPACE b WHERE b.TABLESPACE_NAME = a.TABLESPACE_NAME) OR a.EXTENTS = a.MAX_EXTENTS OR a.EXTENTS = '8192' ;
true
a92442f0d741772453c0999094cc85dd44e2ecb6
SQL
NGrant92/ca-oracle-database
/createTable.sql
UTF-8
27,483
3.59375
4
[]
no_license
CREATE TABLE gg_hero ( name VARCHAR2(15) CONSTRAINT hr_nm_pk PRIMARY KEY, role VARCHAR2(10) NOT NULL CONSTRAINT chk_rl CHECK(role = 'Tank' OR role = 'Offense' OR role = 'Defence' OR role = 'Support'), ability1 VARCHAR2(25) NOT NULL, ability2 VARCHAR2(25) NOT NULL, ability3 VARCHAR2(25) NOT NULL, ability4 VARCHAR2(25), ability_passive VARCHAR2(25), ability_ult1 VARCHAR2(25) NOT NULL, ability_ult2 VARCHAR2(25) ); CREATE TABLE gg_team ( team_name VARCHAR2(25) CONSTRAINT tm_tm_id_pk PRIMARY KEY, t_facebook VARCHAR2(60), t_twitter VARCHAR2(60), t_youtube VARCHAR2(60), t_website VARCHAR2(60) CONSTRAINT tm_tm_web_uk UNIQUE ); CREATE TABLE gg_player ( username VARCHAR2(25) CONSTRAINT plr_usnm_pk PRIMARY KEY, email VARCHAR2(60) NOT NULL, team_id VARCHAR2(25), p_facebook VARCHAR2(60), p_twitter VARCHAR2(60), p_youtube VARCHAR2(60), p_twitch VARCHAR2(60) ); CREATE TABLE gg_team_history ( username VARCHAR2(25), team_name VARCHAR2(25), start_date DATE NOT NULL, end_date DATE NOT NULL, CONSTRAINT tm_hist_st_end_chk CHECK(end_date > start_date), CONSTRAINT tm_hist_tm_nm_usrnm_pk PRIMARY KEY (username, team_name) ); CREATE TABLE gg_player_hero ( username VARCHAR2(25), name VARCHAR2(15), eliminations NUMBER(6,0) NOT NULL, deaths NUMBER(6,0) NOT NULL, damage NUMBER(10,0) NOT NULL, healing NUMBER(10,0) DEFAULT 0, wins NUMBER(5,0) DEFAULT 0, losses NUMBER(5,0) DEFAULT 0, damage_blocked NUMBER(10, 0) DEFAULT 0, CONSTRAINT plr_hr_usnm_nm_pk PRIMARY KEY (username, name) ); CREATE TABLE gg_event ( event_id NUMBER(4,0) CONSTRAINT evnt_id_pk PRIMARY KEY, event_name VARCHAR2(50) NOT NULL, event_date DATE NOT NULL, event_website VARCHAR2(100) NOT NULL, event_type VARCHAR2(6) NOT NULL, venue VARCHAR2(50), county VARCHAR2(50), country VARCHAR2(50), server_region VARCHAR2(4) CONSTRAINT evnt_svr_reg_chk CHECK(server_region = 'US' OR server_region = 'EU' OR server_region = 'Asia'), first_prize VARCHAR2(25) NOT NULL, second_prize VARCHAR2(25) NOT NULL, third_prize VARCHAR2(25) NOT NULL, CONSTRAINT evnt_typ_chk CHECK( (event_type = 'Lan' AND venue IS NOT NULL AND county IS NOT NULL AND country IS NOT NULL AND server_region IS NULL) OR (event_type = 'Online' AND server_region IS NOT NULL AND venue IS NULL AND county IS NULL AND country IS NULL) ) ); CREATE TABLE gg_event_team ( event_id NUMBER(4,0), team_name VARCHAR2(25), CONSTRAINT evnt_tm_pk PRIMARY KEY(event_id, team_name) ); CREATE TABLE gg_map ( name VARCHAR2(30) CONSTRAINT mp_nm_pk PRIMARY KEY, location VARCHAR2(30) NOT NULL, map_type VARCHAR2(15) NOT NULL, objective VARCHAR2(100) NOT NULL, team_size NUMBER(2,0) NOT NULL ); CREATE TABLE gg_event_map ( event_id NUMBER(4,0), map_name VARCHAR2(30), CONSTRAINT evnt_mp_nm_id_pk PRIMARY KEY(event_id, map_name) ); CREATE TABLE gg_rank ( rank_player VARCHAR2(25), rank NUMBER(4,0) NOT NULL CONSTRAINT rnk_chk CHECK(rank < 5001), date_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, is_current NUMBER(1,0) DEFAULT 1 CONSTRAINT rnk_curr_chk CHECK(is_current = 0 OR is_current = 1), CONSTRAINT rnk_plr_dt_pk PRIMARY KEY(rank_player, date_time) ); ALTER TABLE gg_player ADD CONSTRAINT plr_tm_fk FOREIGN KEY (team_id) REFERENCES gg_team(team_name) ON DELETE SET NULL; ALTER TABLE gg_team_history ADD CONSTRAINT tm_hist_usnm_fk FOREIGN KEY (username) REFERENCES gg_player(username) ON DELETE CASCADE; ALTER TABLE gg_team_history ADD CONSTRAINT tm_hist_nm_fk FOREIGN KEY (team_name) REFERENCES gg_team(team_name); ALTER TABLE gg_player_hero ADD CONSTRAINT plr_hr_usnm_fk FOREIGN KEY (username) REFERENCES gg_player(username) ON DELETE CASCADE; ALTER TABLE gg_player_hero ADD CONSTRAINT plr_hr_nm_fk FOREIGN KEY (name) REFERENCES gg_hero(name) ON DELETE CASCADE; ALTER TABLE gg_event_map ADD CONSTRAINT evnt_mp_evnt_id_fk FOREIGN KEY (event_id) REFERENCES gg_event(event_id); ALTER TABLE gg_event_map ADD CONSTRAINT evnt_mp_mp_nm_fk FOREIGN KEY (map_name) REFERENCES gg_map(name); ALTER TABLE gg_event_team ADD CONSTRAINT evnt_tm_evnt_fk FOREIGN KEY(event_id) REFERENCES gg_event(event_id) ON DELETE CASCADE; ALTER TABLE gg_event_team ADD CONSTRAINT evnt_tm_tm_fk FOREIGN KEY(team_name) REFERENCES gg_team(team_name) ON DELETE CASCADE; --VALUES(name, role, ability 1, ability 2, ability 3, ability 4, ability_passive, ability_ult1, ability_ult2) INSERT ALL INTO gg_hero VALUES ('Genji', 'Offense', 'Successive Shuriken', 'Fan of Blades', 'Swift Strike', 'Deflect', 'Cyber-Agility', 'Dragonblade', null) INTO gg_hero VALUES ('McCree', 'Offense', 'Peacekeeper', 'Fan the Hammer', 'Combat Roll', 'Flashbang', null, 'Deadeye', null) INTO gg_hero VALUES ('Pharah', 'Offense', 'Rocket Launcher', 'Hover Jets', 'Jump Jet', 'Concussive Blast', null, 'Barrage', null) INTO gg_hero VALUES ('Reaper', 'Offense', 'Hellfire Shotguns', 'Wraith Form', 'Shadow Step', null, 'The Reaping', 'Death Blossom', null) INTO gg_hero VALUES ('Soldier: 76', 'Offense', 'Heavy Pulse Rifle', 'Helix Rockets', 'Biotic Field', 'Sprint', null, 'Tactical Visor', null) INTO gg_hero VALUES ('Sombra', 'Offense', 'Machine Pistol', 'Hack', 'Stealth', 'Translocator', 'Opportunist', 'EMP', null) INTO gg_hero VALUES ('Tracer', 'Offense', 'Pulse Pistols', 'Blink', 'Recall', null, null, 'Pulse Bomb', null) INTO gg_hero VALUES ('Bastion', 'Defence', 'Recon', 'Self-Repair', 'Reconfigure', null, 'Ironclad', 'Tank', null) INTO gg_hero VALUES ('Hanzo', 'Defence', 'Storm Bow', 'Sonic Arrow', 'Scatter Arrow', null, 'Wall Climb', 'Dragonstrike', null) INTO gg_hero VALUES ('Junkrat', 'Defence', 'Frag Launcher', 'Concussion Mine', 'Steel Trap', null, 'Total Mayhem', 'RIP-Tire', null) INTO gg_hero VALUES ('Mei', 'Defence', 'Frost Stream', 'Icicle Shot', 'Cryo-Freeze', 'Ice Wall', null, 'Blizzard', null) INTO gg_hero VALUES ('Torbjorn', 'Defence', 'Rivet Shot', 'Rivet Burst', 'Turret', 'Armor Pack', 'Scrap Collector', 'Molten Core', null) INTO gg_hero VALUES ('Widowmaker', 'Defence', 'Automatic Rifle', 'Sniper Rifle', 'Grappling Hook', 'Venom Mine', null, 'Infra-Sight', null) INTO gg_hero VALUES ('D.Va', 'Tank', 'Fusion Cannons', 'Defense Matrix', 'Boosters', null, 'Eject', 'Self-Destruct', null) INTO gg_hero VALUES ('Orisa', 'Tank', 'Fusion Driver', 'Halt!', 'Fortify', 'Protective Barrier', 'Energy', 'Supercharger', null) INTO gg_hero VALUES ('Reinhardt', 'Tank', 'Rocket Hammer', 'Barrier Shield', 'Charge', 'Fire Strike', null, 'Earthshatter', null) INTO gg_hero VALUES ('Roadhog', 'Tank', 'Shrapnel Blast', 'Shrapnel Ball', 'Chain Hook', 'Take A Breather', null, 'Whole Hog', null) INTO gg_hero VALUES ('Winston', 'Tank', 'Tesla Cannon', 'Jump Pack', 'Barrier Projector', null, null, 'Primal Rage', null) INTO gg_hero VALUES ('Zarya', 'Tank', 'Energy Beam', 'Explosive Charge', 'Particle Barrier', 'Projected Barrier', 'Energy', 'Graviton Surge', null) INTO gg_hero VALUES ('Ana', 'Support', 'Unscoped', 'Scoped', 'Sleep Dart', 'Biotic Grenade', null, 'Nano Boost', null) INTO gg_hero VALUES ('Lucio', 'Support', 'Sonic Projectile', 'Soundwave', 'Crossfade', 'Amp It Up', 'Wall Ride', 'Sound Barrier', null) INTO gg_hero VALUES ('Mercy', 'Support', 'Healing Beam', 'Damage Boost Beam', 'Caduceus Blaster', 'Guardian Angel', 'Angelic Descent', 'Resurrection', null) INTO gg_hero VALUES ('Symmetra', 'Support', 'Photon Beam', 'Energy Ball', 'Sentry Turret', 'Photon Barrier', null, 'Teleporter', 'Shield Generator') INTO gg_hero VALUES ('Zenyatta', 'Support', 'Orb of Destruction', 'Orb Volley', 'Orb of Harmony', null, null, 'Transcendence', null) SELECT * FROM dual; --(event_id, event_name, date, website, type, venue, county, country, server region, first_prize, second_prize, third_prize) INSERT ALL INTO gg_event VALUES(100, 'OGN Apex Season 3', '04/28/2017', 'http://www.gosugamers.net/overwatch/events/673-ogn-overwatch-apex-season-3', 'Lan', 'E-Stadium', 'Seoul', 'Korea', null, '$85,630', '$34,250', '$10,275') INTO gg_event VALUES(101, 'Overwatch Rumble', '04/18/2017', 'http://rivalcades.com/owrumble.php', 'Online', null, null, null, 'US', '$6,000', '$3,000', '$1,000') INTO gg_event VALUES(102, 'Overwatch Pacific Championship', '04/08/2017', 'http://www.gosugamers.net/overwatch/events/668-overwatch-pacific-championship', 'Online', null, null, null, 'Asia', '$98,400', '$49,200', '$32,800') INTO gg_event VALUES(103, 'Overwatch Premier Series', '04/29/2017', 'http://www.gosugamers.net/overwatch/events/655-overwatch-premier-series-2017-spring-season', 'Lan', 'Yun Space (Baoshan)', 'Shanghai','China', null, '$77,00', '$21,000', '$6,000') SELECT * FROM dual; --VALUES(team_id, facebook, twitter, youtube, website) INSERT ALL INTO gg_team VALUES ('EnVyus', 'https://www.facebook.com/TeamEnVyUs/', 'https://twitter.com/TeamEnVyUs', 'https://www.youtube.com/user/TeamEnVyUs', 'https://gg_teamenvyus.com/pages/overwatch') INTO gg_team VALUES ('NRG', 'https://www.facebook.com/NRGwin/', 'https://twitter.com/NRGgg', 'https://www.youtube.com/c/nrggg', 'http://www.nrg.gg/overwatch') INTO gg_team VALUES ('Rogue', 'https://www.facebook.com/goingroguegg/', 'https://twitter.com/goingroguegg', 'https://www.youtube.com/roguegg', null) INTO gg_team VALUES ('Runaway', null, null, null, null) SELECT * FROM dual; --VALUES(event_id, team_name) INSERT ALL INTO gg_event_team VALUES(100, 'EnVyus') INTO gg_event_team VALUES(100, 'NRG') INTO gg_event_team VALUES(100, 'Rogue') INTO gg_event_team VALUES(100, 'Runaway') INTO gg_event_team VALUES(101, 'EnVyus') INTO gg_event_team VALUES(101, 'NRG') INTO gg_event_team VALUES(101, 'Rogue') INTO gg_event_team VALUES(101, 'Runaway') INTO gg_event_team VALUES(102, 'EnVyus') INTO gg_event_team VALUES(102, 'NRG') INTO gg_event_team VALUES(102, 'Rogue') INTO gg_event_team VALUES(102, 'Runaway') INTO gg_event_team VALUES(103, 'EnVyus') INTO gg_event_team VALUES(103, 'NRG') INTO gg_event_team VALUES(103, 'Rogue') INTO gg_event_team VALUES(103, 'Runaway') SELECT * FROM dual; --VALUES(username, email, team_id, facebook, twitter, youtube, twitch) INSERT ALL INTO gg_player VALUES ('Taimou', 'taimouow@gmail.com', 'EnVyus', 'https://www.facebook.com/OFFICIALtaimou/', 'https://twitter.com/EnVy_Taimou', 'https://www.youtube.com/user/Taimouu', 'https://www.twitch.tv/taimoutv') INTO gg_player VALUES ('HarryHook', 'harryhookow@gmail.com', 'EnVyus', null, 'https://twitter.com/envy_harryhook', null, 'https://www.twitch.tv/harryhook') INTO gg_player VALUES ('cocco', 'coccoow@gmail.com', 'EnVyus', null, 'https://twitter.com/EnVy_Taimou', null, 'https://www.twitch.tv/cocco') INTO gg_player VALUES ('chipshajen', 'chipsow@gmail.com', 'EnVyus', null, 'https://twitter.com/EnVy_chips', null, 'https://www.twitch.tv/chipshajen') INTO gg_player VALUES ('INTERNETHULK', 'hulkow@gmail.com', 'EnVyus', null, 'https://twitter.com/EnVy_HULK', null, 'https://www.twitch.tv/internethulk') INTO gg_player VALUES ('Mickie', 'mickie-ppow@gmail.com', 'EnVyus', 'https://www.facebook.com/MickiePP/', 'https://twitter.com/Mickie_PP', 'https://www.youtube.com/mickiepp', 'https://www.twitch.tv/MickiePP') INTO gg_player VALUES ('aKm', 'akm95@gmail.com', 'Rogue', null, 'https://twitter.com/Rogue_aKm', null, null) INTO gg_player VALUES ('SoOn', 'so0n-ow@gmail.com', 'Rogue', null, 'https://twitter.com/Rogue_SoOn', null, 'https://www.twitcwh.tv/soonsm') INTO gg_player VALUES ('winz', 'i-winz@gmail.com', 'Rogue', null, 'https://twitter.com/Rogue_winz', null, 'https://www.twitcwh.tv/winz_TV') INTO gg_player VALUES ('NiCO', 'nico-ow@gmail.com', 'Rogue', null, 'https://twitter.com/Rogue_NiCOgdh', null, null) INTO gg_player VALUES ('uNKOE', 'unkoe@gmail.com', 'Rogue', null, 'https://twitter.com/Rogue_uNKOE', null, 'https://www.twitch.tv/unkoeee') INTO gg_player VALUES ('KnOxXx', 'knoxxx@gmail.com', 'Rogue', null, 'https://twitter.com/Rogue_KnOxXx', null, 'https://www.twitch.tv/knoxxx69') INTO gg_player VALUES ('iddqd', 'iddqdow@gmail.com', 'NRG', null, 'https://twitter.com/iddqdOW', null, 'https://www.twitch.tv/iddqdOW') INTO gg_player VALUES ('dummy', 'dummyow@gmail.com', 'NRG', 'https://www.facebook.com/Tim-Olson-492164497651805', 'https://twitter.com/dummyolson', 'https://www.youtube.com/channel/UCPe63pqEA2Ij39Xna7ZJc8A', 'https://www.twitch.tv/dummyolson') INTO gg_player VALUES ('numlocked', 'numlockedow@gmail.com', 'NRG', 'https://www.facebook.com/num1ocked', 'https://twitter.com/numlocked', 'https://www.youtube.com/num1ocked', 'https://www.twitch.tv/numlocked') INTO gg_player VALUES ('Harbleu', 'harbleuow@gmail.com', 'NRG', null, 'https://twitter.com/harbleuOW', 'https://www.youtube.com/user/Harbleu', 'https://www.twitch.tv/harbleu') INTO gg_player VALUES ('Ajax', 'ajax1ow@gmail.com', 'NRG', null, 'https://twitter.com/Ajax1OW', null, 'https://www.twitch.tv/ajax1TV') INTO gg_player VALUES ('Seagull', 'aseagullbusiness@gmail.com', 'NRG', null, 'https://twitter.com/a_seagull', 'https://www.youtube.com/channel/UCaFnEJ5tWlK0TO5PWHqr8Hw', 'https://www.twitch.tv/a_seagull') INTO gg_player VALUES ('Hoodie', 'hoodiez@gmail.com', 'Runaway', 'https://twitter.com/NiallGrnt', null, null, null) INTO gg_player VALUES ('Nyaves', 'nyaves93@gmail.com', 'Runaway', null, null, 'https://www.youtube.com/user/z00ney', null) INTO gg_player VALUES ('UnhappyMango', 'mango-93@gmail.com', 'Runaway', null, null, null, null) INTO gg_player VALUES ('tictacz', 'tictacz@gmail.com', 'Runaway', null, null, null, null) INTO gg_player VALUES ('BloodyMonday', 'mr-monday@gmail.com', 'Runaway', null, null, null, null) INTO gg_player VALUES ('Frozen', 'frozen@gmail.com', 'Runaway', null, null, null, null) INTO gg_player VALUES ('Mendokusaii', 'mendojo-ow@gmail.com', null, null, 'https://twitter.com/mendokusaii', 'https://www.youtube.com/channel/UCg9bCZl8859x6QrSfGbdOnw', 'https://www.twitch.tv/mendokusaii') INTO gg_player VALUES ('Kephrii', 'kephkeph@gmail.com', null, null, 'https://twitter.com/Kephrii', 'https://www.youtube.com/user/Kephri1', 'https://www.twitch.tv/kephrii') SELECT * FROM dual; --VALUES(username, team_id, start_date, end_date) INSERT ALL INTO gg_team_history VALUES ('Harbleu', 'Rogue', '01/06/2016', '09/21/2016') INTO gg_team_history VALUES ('Harbleu', 'EnVyus', '02/20/2016', '05/28/2016') INTO gg_team_history VALUES ('iddqd', 'EnVyus', '04/04/2016', '11/16/2016') INTO gg_team_history VALUES ('SoOn', 'NRG', '07/01/2016', '01/14/2017') INTO gg_team_history VALUES ('INTERNETHULK', 'Rogue', '06/22/016', '02/02/2017') INTO gg_team_history VALUES ('Seagull', 'Rogue', '03/20/2016', '07/15/2016') INTO gg_team_history VALUES ('NiCO', 'EnVyus', '05/22/2016', '12/20/2016') INTO gg_team_history VALUES ('HarryHook', 'NRG', '04/11/2016', '01/02/2017') INTO gg_team_history VALUES ('HarryHook', 'Rogue', '02/22/2016', '03/02/2016') SELECT * FROM dual; --VALUES = (username, hero_name, eliminations, deaths, damage, healing, wins, losses, damage_blocked) INSERT ALL INTO gg_player_hero VALUES ('Mendokusaii', 'McCree', 3100, 2200, 1200045, 0, 371, 200, 0) INTO gg_player_hero VALUES ('Frozen', 'Bastion', 2700, 1800, 620045, 0, 300, 200, 0) INTO gg_player_hero VALUES ('Kephrii', 'Widowmaker', 3120, 2100, 1520045, 0, 350, 150, 0) INTO gg_player_hero VALUES ('Taimou', 'McCree', 2800, 950, 1000000, 0, 360, 230, 0) INTO gg_player_hero VALUES ('HarryHook', 'Soldier: 76', 3000, 980, 102000, 5000, 400, 230, 0) INTO gg_player_hero VALUES ('cocco', 'Winston', 2000, 1100, 90000, 0, 300, 200, 40000) INTO gg_player_hero VALUES ('chipshajen', 'Ana', 1200, 800, 42000, 102000, 500, 200, 0) INTO gg_player_hero VALUES ('INTERNETHULK', 'Lucio', 800, 700, 4000, 202000, 450, 100, 0) INTO gg_player_hero VALUES ('Mickie', 'Widowmaker', 2500, 800, 200000, 0, 600, 400, 0) INTO gg_player_hero VALUES ('aKm', 'Soldier: 76', 2650, 750, 950000, 3000, 360, 150, 0) INTO gg_player_hero VALUES ('SoOn', 'Tracer', 2901, 600, 1001000, 0, 375, 300, 0) INTO gg_player_hero VALUES ('winz', 'Bastion', 2200, 820, 80000, 0, 310, 150, 0) INTO gg_player_hero VALUES ('NiCO', 'Sombra', 2025, 500, 50000, 42000, 325, 200, 0) INTO gg_player_hero VALUES ('uNKOE', 'Ana', 1400, 1000, 8000, 108400, 275, 100, 0) INTO gg_player_hero VALUES ('KnOxXx', 'Zarya', 2206, 950, 50000, 0, 340, 275, 86040) INTO gg_player_hero VALUES ('iddqd', 'Tracer', 2855, 1000, 1000000, 0, 450, 220, 0) INTO gg_player_hero VALUES ('dummy', 'Ana', 1105, 800, 8000, 100000, 450, 300, 0) INTO gg_player_hero VALUES ('numlocked', 'Reinhardt', 1500, 1100, 8000, 0, 400, 300, 1640800) INTO gg_player_hero VALUES ('Harbleu', 'Roadhog', 2950, 1200, 1008000, 0, 360, 222, 4500) INTO gg_player_hero VALUES ('Ajax', 'Lucio', 900, 700, 8000, 202000, 450, 340, 0) INTO gg_player_hero VALUES ('Seagull', 'Genji', 3050, 950, 1020000, 0, 500, 230, 0) INTO gg_player_hero VALUES ('Hoodie', 'Roadhog', 1500, 1400, 8000, 0, 360, 330, 2310) INTO gg_player_hero VALUES ('Nyaves', 'Zenyatta', 1000, 900, 4000, 500000, 440, 420, 0) INTO gg_player_hero VALUES ('UnhappyMango', 'Symmetra', 750, 800, 1200, 0, 360, 360, 9400) INTO gg_player_hero VALUES ('tictacz', 'Reaper', 1300, 1100, 9000, 0, 140, 75, 0) INTO gg_player_hero VALUES ('BloodyMonday', 'Torbjorn', 600, 750, 9500, 0, 300, 400, 0) INTO gg_player_hero VALUES ('Mendokusaii', 'Genji', 2900, 2000, 990045, 0, 320, 175, 0) INTO gg_player_hero VALUES ('Frozen', 'Mei', 2200, 2000, 400045, 0, 320, 175, 0) INTO gg_player_hero VALUES ('Kephrii', 'Sombra', 2250, 1100, 420045, 41600, 315, 115, 0) INTO gg_player_hero VALUES ('Taimou', 'Widowmaker', 2850, 1100, 1005000, 0, 360, 180, 0) INTO gg_player_hero VALUES ('HarryHook', 'Pharah', 2546, 500, 800000, 0, 400, 230, 0) INTO gg_player_hero VALUES ('cocco', 'Zarya', 2400, 950, 750000, 0, 300, 215, 42300) INTO gg_player_hero VALUES ('chipshajen', 'Symmetra', 2200, 450, 40000, 0, 250, 230, 8320) INTO gg_player_hero VALUES ('INTERNETHULK','D.Va', 1400, 1100, 9500, 0, 150, 100, 120500) INTO gg_player_hero VALUES ('Mickie', 'D.Va', 1500, 901, 10000, 0, 365, 225, 204310) INTO gg_player_hero VALUES ('aKm', 'Reaper', 2800, 950, 1000500, 0, 420, 300, 0) INTO gg_player_hero VALUES ('SoOn', 'Sombra', 2050, 400, 12000, 5000, 150, 75, 0) INTO gg_player_hero VALUES ('winz', 'Mei', 1800, 1200, 11000, 0, 323, 300, 0) INTO gg_player_hero VALUES ('NiCO', 'Bastion', 2800, 1400, 1000652, 0, 375, 250, 0) INTO gg_player_hero VALUES ('uNKOE', 'Pharah', 2701, 1200, 900000, 0, 400, 230, 0) INTO gg_player_hero VALUES ('KnOxXx', 'Soldier: 76', 3100, 800, 1040752, 6250, 315, 260, 0) INTO gg_player_hero VALUES ('iddqd', 'McCree', 3200, 1000, 1282000, 0, 525, 150, 0) INTO gg_player_hero VALUES ('dummy', 'Orisa', 750, 700, 5000, 0, 362, 275, 64000) INTO gg_player_hero VALUES ('numlocked', 'Winston', 1200, 1000, 7000, 0, 300, 100, 24000) INTO gg_player_hero VALUES ('Harbleu', 'Pharah', 1400, 950, 7500, 0, 220, 100, 0) INTO gg_player_hero VALUES ('Ajax', 'Zenyatta', 600, 200, 1100, 46000, 323, 290, 0) INTO gg_player_hero VALUES ('Seagull', 'Hanzo', 3000, 1300, 1010632, 0, 350, 200, 0) INTO gg_player_hero VALUES ('Hoodie', 'Reinhardt', 1500, 1600, 8000, 0, 200, 230, 1130230) INTO gg_player_hero VALUES ('Nyaves', 'Mercy', 400, 950, 2000, 10450, 200, 88, 0) INTO gg_player_hero VALUES ('UnhappyMango', 'Mercy', 200, 400, 0, 10000, 300, 301, 0) INTO gg_player_hero VALUES ('tictacz', 'Genji', 2800, 2700, 1004200, 0, 320, 60, 0) INTO gg_player_hero VALUES ('BloodyMonday', 'Junkrat', 1300, 1400, 7200, 0, 200, 230, 0) SELECT * FROM dual; --VALUES(map_name, country, map_type, objective, team_size) INSERT ALL INTO gg_map VALUES('Hanamura', 'Japan', 'Capture Point', 'Capture more points on the map than the enemy team.', 6) INTO gg_map VALUES('Temple of Anubis', 'Egypt', 'Capture Point', 'Capture more points on the map than the enemy team.', 6) INTO gg_map VALUES('Volskya Industries', 'Russia', 'Capture Point', 'Capture more points on the map than the enemy team.', 6) INTO gg_map VALUES('Dorado', 'Mexico', 'Escort', 'To deliver a payload further than the enemy team.', 6) INTO gg_map VALUES('Route 66', 'USA', 'Escort', 'To deliver a payload further than the enemy team.', 6) INTO gg_map VALUES('Watchpoint: Gibraltar', 'Gibraltar', 'Escort', 'To deliver a payload further than the enemy team.', 6) INTO gg_map VALUES('Eichenwalde', 'Germany', 'Hybrid', 'To capture a point and also deliver a payload further than the enemy team', 6) INTO gg_map VALUES('Hollywood', 'USA', 'Hybrid', 'To capture a point and also deliver a payload further than the enemy team', 6) INTO gg_map VALUES('Kings Row', 'England', 'Hybrid', 'To capture a point and also deliver a payload further than the enemy team', 6) INTO gg_map VALUES('Numbani', 'Africa', 'Hybrid', 'To capture a point and also deliver a payload further than the enemy team', 6) INTO gg_map VALUES('Ilios', 'Greece', 'Control Point', 'To maintain control of multiple points while fending off the enemy team. Best of 3 or 5 wins', 6) INTO gg_map VALUES('Lijang Tower', 'China', 'Control Point', 'To maintain control of multiple points while fending off the enemy team. Best of 3 or 5 wins', 6) INTO gg_map VALUES('Nepal', 'Nepal', 'Control Point', 'To maintain control of multiple points while fending off the enemy team. Best of 3 or 5 wins', 6) INTO gg_map VALUES('Oasis', 'Iraq', 'Control Point', 'To maintain control of multiple points while fending off the enemy team. Best of 3 or 5 wins', 6) SELECT * FROM dual; --VALUES(event_id, map_name) INSERT ALL INTO gg_event_map VALUES(100, 'Hanamura') INTO gg_event_map VALUES(100, 'Dorado') INTO gg_event_map VALUES(100, 'Hollywood') INTO gg_event_map VALUES(100, 'Eichenwalde') INTO gg_event_map VALUES(100, 'Ilios') INTO gg_event_map VALUES(101, 'Hanamura') INTO gg_event_map VALUES(101, 'Route 66') INTO gg_event_map VALUES(101, 'Kings Row') INTO gg_event_map VALUES(101, 'Numbani') INTO gg_event_map VALUES(101, 'Lijang Tower') INTO gg_event_map VALUES(102, 'Volskya Industries') INTO gg_event_map VALUES(102, 'Watchpoint: Gibraltar') INTO gg_event_map VALUES(102, 'Eichenwalde') INTO gg_event_map VALUES(102, 'Hollywood') INTO gg_event_map VALUES(102, 'Oasis') INTO gg_event_map VALUES(103, 'Temple of Anubis') INTO gg_event_map VALUES(103, 'Route 66') INTO gg_event_map VALUES(103, 'Eichenwalde') INTO gg_event_map VALUES(103, 'Numbani') INTO gg_event_map VALUES(103, 'Lijang Tower') SELECT * FROM dual; --VALUES(rank_id, player_name, rank, timestamp(defaulted)) --initial creation of a player's current rank, updateRank in selectStatements folder INSERT ALL INTO gg_rank(rank_player, rank) VALUES ('Taimou', 4844) INTO gg_rank(rank_player, rank) VALUES ('HarryHook', 4200) INTO gg_rank(rank_player, rank) VALUES ('cocco', 4625) INTO gg_rank(rank_player, rank) VALUES ('chipshajen', 4150) INTO gg_rank(rank_player, rank) VALUES ('INTERNETHULK', 4845) INTO gg_rank(rank_player, rank) VALUES ('Mickie', 4653) INTO gg_rank(rank_player, rank) VALUES ('aKm', 3801) INTO gg_rank(rank_player, rank) VALUES ('SoOn', 4260) INTO gg_rank(rank_player, rank) VALUES ('winz', 3526) INTO gg_rank(rank_player, rank) VALUES ('NiCO', 4444) INTO gg_rank(rank_player, rank) VALUES ('uNKOE', 3240) INTO gg_rank(rank_player, rank) VALUES ('KnOxXx', 3540) INTO gg_rank(rank_player, rank) VALUES ('iddqd', 4756) INTO gg_rank(rank_player, rank) VALUES ('dummy', 4103) INTO gg_rank(rank_player, rank) VALUES ('numlocked', 4301) INTO gg_rank(rank_player, rank) VALUES ('Harbleu', 4605) INTO gg_rank(rank_player, rank) VALUES ('Ajax', 4102) INTO gg_rank(rank_player, rank) VALUES ('Seagull', 4545) INTO gg_rank(rank_player, rank) VALUES ('BloodyMonday', 2760) INTO gg_rank(rank_player, rank) VALUES ('tictacz', 3050) INTO gg_rank(rank_player, rank) VALUES ('UnhappyMango', 1800) INTO gg_rank(rank_player, rank) VALUES ('Nyaves', 2345) INTO gg_rank(rank_player, rank) VALUES ('Hoodie', 2432) SELECT * FROM dual; --historical data --CURRENT_TIMESTAMP + interval '2' second is used only for the initial population due to timestamp being a part of the primary key INSERT ALL INTO gg_rank VALUES ('Taimou', 4899, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('HarryHook', 4333, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('cocco', 4680, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('chipshajen', 4200, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('INTERNETHULK', 4454, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('Mickie', 4601, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('aKm', 3500, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('SoOn', 4100, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('winz', 3468, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('NiCO', 4400, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('uNKOE', 3420, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('KnOxXx', 3700, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('iddqd', 4799, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('dummy', 4115, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('numlocked', 4250, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('Harbleu', 4888, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('Ajax', 4010, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('Seagull', 4444, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('BloodyMonday', 2501, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('tictacz', 3100, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('UnhappyMango', 1700, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('Nyaves', 2370, CURRENT_TIMESTAMP + interval '2' second, 0) INTO gg_rank VALUES ('Hoodie', 2400, CURRENT_TIMESTAMP + interval '2' second, 0) SELECT * FROM dual; --historical data INSERT ALL INTO gg_rank VALUES ('Taimou', 4222, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('HarryHook', 4140, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('cocco', 4888, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('chipshajen', 4220, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('INTERNETHULK', 4640, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('Mickie', 4500, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('aKm', 3575, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('SoOn', 4243, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('winz', 3499, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('NiCO', 4491, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('uNKOE', 3466, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('KnOxXx', 3740, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('iddqd', 4800, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('dummy', 4125, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('numlocked', 4315, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('Harbleu', 4899, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('Ajax', 4011, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('Seagull', 4445, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('BloodyMonday', 2225, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('tictacz', 3115, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('UnhappyMango', 1750, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('Nyaves', 2323, CURRENT_TIMESTAMP + interval '3' second, 0) INTO gg_rank VALUES ('Hoodie', 2305, CURRENT_TIMESTAMP + interval '3' second, 0) SELECT * FROM dual;
true
467375868e8f4707d0aba3b293eeed592f35b6bb
SQL
creynold/machineShop
/schema.sql
UTF-8
373
2.65625
3
[]
no_license
drop table if exists schedule; create table schedule ( id integer primary key autoincrement, username string not null, time string not null ); drop table if exists users; create table users ( id integer primary key autoincrement, username string not null, cell_number integer, cell_provider string, looking boolean not null, is_admin boolean not null );
true
6d9136326a743958806bcc17e42f95cc942b5d5d
SQL
empresas-weloze/weloze-reports
/BiView/Metas de Faturamento/MetaFaturamento_OMT.sql
UTF-8
1,647
4.09375
4
[]
no_license
-- ALTER VIEW [BiView].[MetaFaturamento_OMT] AS SELECT SG.YEAR AS "Ano", SGL.ECORESCATEGORYNAME AS "Item - Categoria", '' AS "Item", SGL.SEGMENTID AS "Cliente - Segmento", AVG(SGL.AMOUNT) / 1000 AS "Meta", CASE WHEN SUM(REAL.[Valor Rec. Líquida]) IS NULL THEN NULL ELSE SUM(REAL.[Valor Rec. Líquida]) / 1000 END AS "Faturado" FROM SALEGOAL SG JOIN SALEGOALLINE SGL ON SGL.SALEGOAL = SG.RECID LEFT JOIN BI_Weloze.BiWeloze.ReceitaLiquida_omt REAL ON YEAR(REAL.Data) = SG.YEAR AND SGL.SEGMENTID = REAL.[Cliente - Segmento] AND SGL.ECORESCATEGORYNAME = REAL.[Linha de Produto OMT] JOIN ECORESCATEGORY ERC ON ERC.NAME = SGL.ECORESCATEGORYNAME JOIN ECORESCATEGORYHIERARCHY ERCH ON ERCH.NAME = 'LINHA DE PRODUTO OMT' GROUP BY SG.YEAR, SGL.ECORESCATEGORYNAME, SGL.SEGMENTID UNION SELECT YEAR(REAL.Data) AS "Ano", REAL.[Linha de Produto OMT] AS "Item - Categoria", REAL.[Item (Un. de Estoque)] AS "Item", REAL.[Cliente - Segmento] AS "Cliente - Segmento", NULL AS "Meta", CASE WHEN SUM(REAL.[Valor Rec. Líquida]) IS NULL THEN NULL ELSE SUM(REAL.[Valor Rec. Líquida]) / 1000 END AS "Faturado" FROM BI_Weloze.BiWeloze.ReceitaLiquida_omt REAL LEFT JOIN SALEGOALLINE SGL ON SGL.SEGMENTID = REAL.[Cliente - Segmento] AND SGL.ECORESCATEGORYNAME = REAL.[Linha de Produto OMT] LEFT JOIN SALEGOAL SG ON YEAR(REAL.Data) = SG.YEAR AND SG.RECID = SGL.SALEGOAL WHERE SG.RECID IS NULL AND YEAR(REAL.Data) = '2017' GROUP BY (REAL.Data), REAL.[Linha de Produto OMT], REAL.[Cliente - Segmento], REAL.[Item (Un. de Estoque)]
true
7d6dee4a61b5d4eefc4df7e1b678941b3c783434
SQL
jaewookwak92/sql
/2021_03_19.sql
UTF-8
4,487
4.625
5
[]
no_license
[실습 grp4] 직원의 입사 년월별로 몇명의 직원이 입사했는지 조회하는 쿼리를 작성하세요. select TO_CHAR(hiredate, 'YYYYMM'), hire_yyyymm, COUNT(*)cnt from emp GROUP BY TO_CHAR(hiredate, 'YYYYMM') ORDER BY TO_CHAR(hiredate, 'YYYYMM'); [실습 grp5] 직원의 입사 년별로 몇명의 직원이 입사했는지 조회하는 쿼리를 작성하세요. select TO_CHAR(hiredate, 'YYYYMM'), hire_yyyy, COUNT(*)cnt from emp GROUP BY TO_CHAR(hiredate, 'YYYY') ORDER BY TO_CHAR(hiredate, 'YYYY'); [실습 grp6] SELECT COUNT(*) FROM dept; SELECT * FROM emp WHERE deptno IN(10,20,30); SELECT deptno FROM emp GROUP BY deptno; SELECT COUNT(*) FROM (SELECT deptno FROM emp GROUP BY deptno); < 데이터 결합 > JOIN - RDBMS는 중복을 최소화 하는 형태의 데이터 베이스 - 다른 테이블과 결합하여 데이터를 조회 --JOIN 데이터를 결합할수있는 방법중에 하나 - EMP 테이블에는 부서코드만 존재, 부서정보를 담은 dept테이블 별도로 생성 - emp테이블과 dept테이블의 연결고리로 조인하여 실제 부서명을 조회한다. JOIN 1. 표준 SQL => ANSI SQL 2. 비표준 SQL - DBMS를 만드는 회사에서 만든 고유의 SQL 문법 ANSI : SQL ORACLE : SQL ARSI - NATURAL JOIN - 조인하고자 하는 테이블의 연결컬럼 명(타입도 동일)이 동일한경우(emp,deptno, dept.deptno) - 연결 컬럼의 값이 동일할때(=) 컬럼이 확장된다. SELECT * FROM emp NATURAL JOIN dept; SELECT ename, dname FROM emp NATURAL JOIN dept; ORACLE join : 1. FROM절에 조인할 테이블을 (,)콤마로 구분하여 나열 2. WHERE : 조인할 테이블의 연결조건을 기술 7369 SMITH, 7902 FORD SELECT * FROM emp, dept WHERE emp.deptno = dept.deptno; -- oracle에서는 join을 이런식으로 한다. SELECT * FROM emp, emp WHERE emp.mgr = emp.empno; -- 동일한거므로 하나는 별칭을 사용해주자 => 아래 참조 SELECT e.empno, e.ename, m.empno, m.ename FROM emp e, emp m WHERE e.mgr = m.empno; -- ANSI SQL : JOIN WITH USING 조인 하려고 하는 테이블의 컬럼명과 타입이 같은 컬럼이 두개 이상인 상황에서 두 컬럼을 모두 조인 조건으로 참여시키지 않고, 개발자가 원하는 특정 컬럼으로만 연결을 시키고 싶을 때 사용 SELECT emp.deptno FROM emp JOIN dept USING(deptno); SELECT * FROM emp, dept WHERE emp.deptno = dept.deptno; JOIN WITH ON : NATURAL JOIN, JOIN WITH USING을 대체할 수 있는 보편적인 문법 조인 컬럼을 개발자가 임의로 지정 SELECT * FROM emp JOIN dept ON (emp.deptno = dept.deptno); 사원 번호, 사원 이름, 해당사원의 상시 사번, 해당사원의 상사 이름 : JOIN WITH ON을 이용하여 쿼리 작성 (단 사원의 번호가 7369에서 7698인 사원들만 조회) SELECT e.empno, e.name, m.empno, m.ename FROM emp e JOIN emp m ON (e.mgr = m.empno) WHERE e.empno BETWEEN 7369 AND 7698; SELECT e.empno, e.name, m.empno, m.ename FROM emp e, emp m WHERE e.empno BETWEEM 8369 AND 7698 AND e.mgr = m.empno; 논리적인 조인 형태 1. SELF JOIN : 조인 테이블이 같은 경우 - 계층구조 2. NONEQUI-JOIN : 조인 조건이 =(equals)가 아닌 조인 SELECT * FROM emp, dept WHERE emp.deptno != dept.deptno; SELECT * FROM salgrade; --salgrade를 이용하여 직원의 급여 등급 구하기 -- empno, ename, sal, 급여등급 -- ansi, oracle SELECT * FROM emp; SELECT empno, ename, sal, SELECT * FROM emp JOIN dept ON (emp.deptno = dept.deptno); SELECT * FROM emp e, salgrade s WHERE e.sal BETWEEN s.local AND s.hisal; 데이터를 확장(결합) 1. 컬럼에 대한 확장 : JOIN 2. 행에 대한 확장 : 집합연산자(UNION ALL, UNION(합집합), MINUS(차집합), INTERSECT(교집합)) emp, dept 테이블을 이용하여 다음과 같이 조회되도록 쿼리를 작성하세요 SELECT empno, ename, emp.deptno, dname FROM emp, dept WHERE emp.deptno = dept.deptno AND emp.deptno IN (10,30); emp, dept 테이블을 이용하여 다음과 같이 조회되도록 쿼리를 작성하세요 (급여가 2500 초과) sal >= 2500 SELECT empno, ename, emp.deptno, dname FROM emp, dept; WHERE emp.deptno = dept.deptno AND emp.deptno IN (10,30); 급여 2500초과, 사번이 7600보다 크고 RESEARCH부서에 속하는 직원 SELECT empno, ename, emp.deptno, dname FROM emp, dept; WHERE emp.deptno = dept.deptno AND sal>2500 AND empno>7600 AND dname = 'RESEARCH';
true
e8d61e5b8687304a6d8215808ef228d38894178c
SQL
j7ng/CLFY_SA
/SA/Indexes/FLD_INFO_OBJINDEX.sql
UTF-8
69
2.5625
3
[]
no_license
CREATE UNIQUE INDEX sa.fld_info_objindex ON sa.table_fld_info(objid);
true
fe23261b334c8012c222bf6bf9f27d2aee403e1d
SQL
YeeeeahRight/rest-api-security
/persistence/src/test/resources/db_init.sql
UTF-8
542
2.75
3
[]
no_license
INSERT INTO certificates (name, description, price, create_date, last_update_date, duration) VALUES ('certificate 1', 'description 1', 1.1, '2020-01-01 01:11:11', '2021-01-01 01:22:11', 1), ('certificate 2', 'description 2', 2.2, '2020-02-02 02:22:22', '2021-02-02 02:33:22', 2), ('certificate 3', 'description 3', 3.3, '2020-03-03 03:33:33', '2021-03-03 03:44:33', 3); INSERT INTO tags (name) VALUES ('tag 1'), ('tag 2'), ('tag 3'); INSERT INTO certificates_tags (certificate_id, tag_id) VALUES (1, 1), (1, 3), (2, 2), (3,3);
true
fb7c28426d93aedd2ab23b6832bc13e436bc5902
SQL
slowcoder-fastsleeper/dune-snippets
/dune/gas/BackRunningBots_DailyGasUsage.sql
UTF-8
1,746
3.140625
3
[ "MIT" ]
permissive
SELECT DATE_TRUNC('day', t.block_time) AS dt, sum(t.gas_used / 12000000) / (60*60*24/14) as daily_gas_used_ratio FROM ethereum.transactions t WHERE t."to" = '\x860bd2dba9Cd475A61E6d1b45e16c365F6D78F66' OR t."to" = '\xb958a8f59ac6145851729f73c7a6968311d8b633' OR t."to" = '\x85c5c26dc2af5546341fc1988b9d178148b4838b' OR t."to" = '\x8018280076d7fa2caa1147e441352e8a89e1ddbe' OR t."to" = '\x693c188e40f760ecf00d2946ef45260b84fbc43e' OR t."to" = '\x0000000000c90bc353314b6911180ed7e06019a9' OR t."to" = '\xce5702e94ad38c061e44a4a049cc29261f992846' OR t."to" = '\x514fd3b8109cfb7cde4b17e4912fd56690c23145' OR t."to" = '\xa57bd00134b2850b2a1c55860c9e9ea100fdd6cf' OR t."to" = '\x8977c88d021882ef712200142062ed636031a3fd' OR t."to" = '\x985149cf58af5d2f50dee363a52ed4e0acc10cf1' OR t."to" = '\xb14a74c43ce0bf8f7912f7f1f8feb90b4b5f466b' OR t."to" = '\xc2a694c5ced27e3d3a5a8bd515a42f2b89665003' OR t."to" = '\x00000000b1786c9698c160d78232c78d6f6474fe' OR t."to" = '\x000000000000deab340f067535869a0e5226e58a' OR t."to" = '\x28f2914ebb7ac98feefa7f6008a76e70bfa7963c' OR t."to" = '\x9799b475dec92bd99bbdd943013325c36157f383' OR t."to" = '\xf6fb09a41fa6c18cebc1e7c6f75a8664d69e4d48' OR t."to" = '\xe9519677e6ec8d2d6bfab92a059529fea6075d37' OR t."to" = '\x000000000000006f6502b7f2bbac8c30a3f67e9a' OR t."to" = '\xf1ad4bfdf8829d55ec0ce7900ef9d122b2610673' OR t."to" = '\x8a3960472b3d63894b68df3f10f58f11828d6fd9' OR t."to" = '\x762ed657b76372f8c08c6f7e0aa4170658c4ca35' OR t."to" = '\x78a55b9b3bbeffb36a43d9905f654d2769dc55e8' OR t."to" = '\xf443253607dbde5bda77c358c9b9f244d819e25c' OR t."to" = '\xe33c8e3a0d14a81f0dd7e174830089e82f65fc85' GROUP BY 1
true
e700cbbe3421fd18ec42ee014db61e335fe8cc32
SQL
artem8449/forth_inter
/2d_step/colons.inc
UTF-8
11,862
2.8125
3
[]
no_license
section .rodata msg: .no_such_word: db "! No such word: ", 0 section .bss word_buf: resq 512 user_dict: resq 65536 section .data here: dq user_dict fd: dq 0 %define STATE_COMPILE 1 %define STATE_INTERPRET 0 state: dq STATE_INTERPRET const "forth-here", here const "forth-last-word", last_word const "forth-is-compiling", state const "forth-input-fd", fd const "forth-stack-start", stack_start ;colon words such utils (I/O working, parser) colon "bye", bye dq xt_lit, 60 TIMES 6 dq xt_lit, 0 dq xt_syscall %define sys_read_no 0 %define sys_write_no 1 colon "sys-read", sys_read TIMES 3 dq xt_to_r dq xt_lit, sys_read_no TIMES 3 dq xt_from_r TIMES 3 dq xt_lit, 0 dq xt_syscall , xt_drop, xt_exit colon "sys-write", sys_write TIMES 3 dq xt_to_r dq xt_lit, sys_write_no TIMES 3 dq xt_from_r TIMES 3 dq xt_lit, 0 dq xt_syscall , xt_drop, xt_exit ;make place to sym and ret adr colon "stack-cell", stack_cell dq xt_lit, 0, xt_sp, xt_exit ; ( fd - char 1) or ( - 0 ) read char from stdin colon "file-read-char", file_read_char dq xt_to_r, xt_stack_cell, xt_from_r, xt_swap, xt_lit, 1, xt_sys_read branch0 .fail dq xt_lit, 1 .fail : dq xt_exit ; ( fd char - ) print char to screan colon "file-write-char", file_write_char dq xt_swap, xt_to_r, xt_to_r dq xt_stack_cell, xt_dup, xt_from_r, xt_swap, xt_save_char dq xt_from_r, xt_swap, xt_lit, 1, xt_sys_write, xt_drop, xt_drop, xt_exit colon "string-length", string_length dq xt_dup .loop: dq xt_dup, xt_fetch_char branch0 .exit dq xt_inc branch .loop .exit: dq xt_swap, xt_sub, xt_exit ; print carriage return sym colon "print-cr", print_cr dq xt_lit, 1, xt_lit, 10, xt_file_write_char, xt_exit ; ( str count - ) print count in str colon "print-string-counted", print_string_counted dq xt_to_r, xt_to_r, xt_lit, 1, xt_from_r, xt_from_r, xt_sys_write, xt_drop, xt_exit ; ( str -- ) count str length and print str colon "print-string", print_string dq xt_dup, xt_string_length, xt_print_string_counted, xt_exit ;check sym to white space (whith tab sym) colon "char-is-space", char_is_space dq xt_to_r dq xt_r_fetch, xt_lit, ' ', xt_equal dq xt_r_fetch, xt_lit, 10, xt_equal, xt_lor dq xt_r_fetch, xt_lit, 13, xt_equal, xt_lor dq xt_r_fetch, xt_lit, 9, xt_equal, xt_lor dq xt_from_r, xt_lit, '\t', xt_equal, xt_lor, xt_exit ; ( addr - ) add 0 terminate to str colon "string-terminate", string_terminate dq xt_lit, 0, xt_swap, xt_save_char, xt_exit ; ( fd buffer - ) word to read word whith check space colon "file-read-word", file_read_word dq xt_dup, xt_to_r, xt_to_r ;miss all unusual space .read_space: dq xt_dup, xt_file_read_char branch0 .eof dq xt_dup, xt_char_is_space branch0 .commit dq xt_drop branch .read_space ;read unspace sym .read: dq xt_dup, xt_file_read_char branch0 .eof dq xt_dup, xt_char_is_space, xt_not branch0 .end ;save now sym and go to next .commit: dq xt_r_fetch, xt_save_char dq xt_from_r, xt_inc, xt_to_r branch .read .end: dq xt_drop ;add 0 terminate to str .eof: dq xt_drop, xt_r_fetch, xt_string_terminate dq xt_from_r, xt_from_r, xt_sub, xt_exit ;save up of stack to mem where saved new word, and go to next token colon ",", comma dq xt_here, xt_fetch, xt_save dq xt_here, xt_fetch, xt_lit, 8, xt_plus dq xt_here, xt_save, xt_exit ;save byte up of stack to mem where saved new word colon "c,", char_comma dq xt_here, xt_fetch, xt_save_char dq xt_here, xt_fetch, xt_inc dq xt_here, xt_save, xt_exit ;double call dup or inc colon "2dup", ddup dq xt_to_r, xt_dup, xt_r_fetch, xt_swap, xt_from_r, xt_exit colon "2inc", dinc dq xt_to_r, xt_inc, xt_from_r, xt_inc, xt_exit ;compare strs and ret 1 (yes) or 0 (no) colon "string-equals", string_equals .start: dq xt_ddup, xt_fetch_char, xt_swap, xt_fetch_char, xt_equal branch0 .no dq xt_dup, xt_fetch_char branch0 .yes dq xt_dinc branch .start .yes: dq xt_drop, xt_drop, xt_lit, 1, xt_exit .no: dq xt_drop, xt_drop, xt_lit, 0, xt_exit ; ( dest source - ) copy str to adr o up of stack colon "string-copy", string_copy .loop: dq xt_ddup, xt_fetch_char, xt_to_r, xt_r_fetch, xt_swap, xt_save_char dq xt_dinc, xt_from_r, xt_not branch0 .loop dq xt_drop, xt_drop, xt_exit ;read colon word in compile state of machine and save them colon ":", colon .restart: dq xt_fd, xt_fetch, xt_lit, word_buf, xt_file_read_word branch0 .restart dq xt_lit, 0, xt_lit, word_buf, xt_forth_create dq xt_lit, STATE_COMPILE, xt_state, xt_save dq xt_lit, i_docol, xt_comma, xt_exit ;exit from compile mod to interpretator colon ";", semicolon, 1 dq xt_lit, STATE_INTERPRET, xt_state, xt_save dq xt_lit, xt_exit, xt_comma, xt_exit ;check char to digit save flag colon "char-is-digit", char_is_digit dq xt_to_r dq xt_r_fetch, xt_lit, '9'+1, xt_less dq xt_lit, '0'-1, xt_r_fetch, xt_less, xt_land dq xt_from_r, xt_drop, xt_exit ;go tp iz_zero if and of up of stack 0 colon "drop0", drop0 dq xt_dup branch0 .is_zero dq xt_exit .is_zero: dq xt_drop, xt_exit ;convert ascii code to digit colon "char-to-digit", char_to_digit dq xt_lit, '0', xt_sub, xt_exit ; ( buf -- num? len ) colon "string-parse-unsigned-number", string_parse_unsigned_number dq xt_dup, xt_to_r dq xt_lit, 0, xt_to_r .loop: dq xt_dup, xt_fetch_char, xt_dup, xt_char_is_digit branch0 .end dq xt_char_to_digit dq xt_lit, 10, xt_from_r, xt_mul, xt_plus, xt_to_r dq xt_inc branch .loop .end: dq xt_drop, xt_from_r, xt_swap, xt_from_r, xt_sub, xt_drop0, xt_exit ;check that num less than 0 colon "neg", neg dq xt_lit, 0, xt_swap, xt_sub, xt_exit ;increment some digit on mem colon "inc", inc dq xt_lit, 1, xt_plus, xt_exit ; ( buf -- num? len ) check type of char num and parse colon "string-parse-number", string_parse_number dq xt_dup, xt_fetch_char, xt_dup, xt_char_is_digit, xt_not branch0 .unsigned dq xt_dup, xt_lit, '-', xt_equal, xt_not branch0 .negative dq xt_dup, xt_lit, '+', xt_equal, xt_not branch0 .positive .negative: dq xt_drop dq xt_inc, xt_string_parse_unsigned_number dq xt_dup branch0 .error dq xt_inc dq xt_swap, xt_neg, xt_swap, xt_exit .positive: dq xt_drop dq xt_inc, xt_string_parse_unsigned_number dq xt_dup branch0 .error dq xt_inc, xt_exit .unsigned: dq xt_drop, xt_string_parse_unsigned_number, xt_exit .error: dq xt_drop, xt_lit, 0, xt_exit ;module to forth interpretator and words to work with dictinory ;add name to word on dictinory colon "forth-dict-word-name", forth_dict_word_name dq xt_lit, 9, xt_plus, xt_exit ;word in dictinory ? if yes ret 1 colon "forth-find-word", forth_find_word dq xt_to_r, xt_last_word, xt_fetch dq xt_state, xt_fetch branch0 .loop dq xt_fetch .loop: dq xt_dup branch0 .not_found dq xt_dup, xt_forth_dict_word_name, xt_r_fetch, xt_string_equals, xt_not branch0 .found dq xt_fetch branch .loop .found: dq xt_lit, 1 .not_found: dq xt_from_r, xt_drop, xt_exit ;read word and pale it xt adress on stack colon "'", forth_tick, 1 dq xt_fd, xt_fetch, xt_lit, word_buf, xt_file_read_word branch0 .eof dq xt_lit, word_buf, xt_forth_find_word branch0 .no_word dq xt_forth_cfa, xt_state branch0 .interp dq xt_lit, xt_lit, xt_comma, xt_comma .interp: dq xt_exit .no_word: dq xt_lit, msg.no_such_word, xt_print_string, xt_print_string, xt_print_cr, xt_exit .eof: dq xt_drop, xt_exit ;add info to word place in dictinory colon "forth-cfa", forth_cfa dq xt_lit, 9, xt_plus dq xt_dup, xt_string_length, xt_plus dq xt_lit, 2, xt_plus, xt_exit ; ( flags name - ) prepare macjine to add new word on dictinory colon "forth-create", forth_create dq xt_here, xt_fetch ; word start dq xt_last_word, xt_fetch, xt_comma ; fill `link` dq xt_last_word, xt_save ; update `last_word` dq xt_lit, 0, xt_char_comma dq xt_dup, xt_here, xt_fetch, xt_swap, xt_string_copy dq xt_string_length, xt_here, xt_fetch, xt_plus, xt_inc, xt_here, xt_save dq xt_char_comma dq xt_exit ;check that we have word after branch or branch0 colon "forth-follows-branch", forth_follows_branch dq xt_here, xt_fetch, xt_lit, 8, xt_sub, xt_fetch dq xt_dup, xt_lit, xt_branch0, xt_equal, xt_swap dq xt_lit, xt_branch, xt_equal, xt_lor, xt_exit ; ( fd -- ) file readet to forth colon "forth-interpret-fd", forth_interpret_fd dq xt_lit, xt_fd, xt_fetch, xt_to_r dq xt_fd, xt_save .loop: dq xt_fd, xt_fetch, xt_lit, word_buf, xt_file_read_word branch0 .eof dq xt_lit, word_buf, xt_forth_interpret branch .loop .eof: dq xt_from_r, xt_fd, xt_save, xt_exit ;chech to go swith interpretator mod colon "forth-xt-is-immediate", forth_xt_is_immediate dq xt_lit, 1, xt_sub, xt_fetch_char, xt_exit ; ( str - ) the interpreter itself accepts tokens from the prasser, selects the mode of operation and saves and executes the words colon "forth-interpret", forth_interpret .start: ; ( inbuf ) dq xt_dup, xt_forth_find_word ; find in dict branch0 .number ; ( inbuf dictaddr? 0/1 ) dq xt_swap, xt_drop, xt_forth_cfa ; ( xt ) ; if not compiling dq xt_state, xt_fetch branch0 .interpreting dq xt_dup, xt_forth_xt_is_immediate, xt_not branch0 .interpreting .compiling: dq xt_comma, xt_exit .interpreting: dq xt_execute, xt_exit .number: ; ( inbuf ) dq xt_dup, xt_string_parse_number ; ( inbuf num? 0/len ) branch0 .no_word ; ( inbuf num ) dq xt_swap, xt_drop dq xt_state, xt_fetch ; if interpreting, that's it branch0 .exit dq xt_forth_follows_branch, xt_not branch0 .is_branch .not_branch: dq xt_lit, xt_lit, xt_comma .is_branch: ; ( num prev_xt ) dq xt_comma, xt_exit .no_word: ; ( inbuf ) dq xt_lit, msg.no_such_word, xt_print_string, xt_print_string, xt_print_cr .exit: dq xt_exit colon "trap", trap dq xt_lit, wh_trap + 9, xt_print_string, xt_print_cr, xt_exit ;set start state to machine forth_init: dq xt_lit, 0, xt_forth_interpret_fd, xt_bye ;add colon words to .S (which nead to prtint stack on screan: print-char, digit-to-char) ;convert digit to char to print colon "digit-to-char", digit_to_char dq xt_lit, 0x30, xt_plus, xt_exit ;send char to print colon "print-char", print_char dq xt_lit, 1, xt_swap, xt_file_write_char, xt_exit ;gets a sequence of values ​​converts them to characters and displays colon "print-uint", print_uint dq xt_to_r dq xt_sp dq xt_from_r, xt_swap dq xt_to_r, xt_to_r .loop: dq xt_r_fetch dq xt_lit, 10, xt_div_rem dq xt_from_r dq xt_lit, 10, xt_div dq xt_dup branch0 .print dq xt_to_r branch .loop .print: dq xt_drop .print_loop: dq xt_sp, xt_r_fetch, xt_less branch0 .exit dq xt_digit_to_char, xt_print_char branch .print_loop .exit: dq xt_from_r, xt_drop, xt_exit ;comand to print stack colon ".S", show_stack_s dq xt_sp dq xt_to_r .loop: dq xt_r_fetch, xt_forth_stack_base, xt_less branch0 .exit dq xt_r_fetch, xt_fetch, xt_print_uint, xt_print_cr dq xt_from_r dq xt_lit, 8, xt_plus dq xt_to_r branch .loop .exit: dq xt_from_r, xt_drop, xt_exit
true
6728c03eef9c7a78d27e37dbfee2580b43104d3f
SQL
caioqazz/Dionisio
/Dionisio/Scripts/SQL_Script_Dionisio.sql
UTF-8
2,627
3.390625
3
[]
no_license
create schema Dionisio ; use Dionisio; create table Dionisio.propriedade ( nome varchar(40) primary key, adm varchar(40), endereço varchar(60) ); create table Dionisio.telefone( nome varchar(40) not null, num varchar(11) primary key, foreign key(nome) references propriedade(nome) on delete cascade on update cascade ); create table Dionisio.emails( nome varchar(40) not null, endereço varchar(25) primary key, foreign key(nome) references propriedade(nome) on delete cascade on update cascade ); create table Dionisio.terroir( região varchar(20) primary key, solo varchar(15), altitude int, umidade int, indice_pluviometrico int, temp float, nome_propriedade varchar(40), foreign key(nome_propriedade) references propriedade(nome) on delete restrict on update cascade ); create table Dionisio.cepa( nome varchar(40) primary key, região varchar(20) ); create table Dionisio.parreiral( id int primary key, qtd_vinhas int, area int, data_plantio date, nome_propriedade varchar(40), nome_cepa varchar(20), foreign key(nome_propriedade) references propriedade(nome) on delete cascade on update cascade, foreign key(nome_cepa) references cepa(nome) on delete set null on update cascade ); create table Dionisio.colheita( id int primary key, data_colheita date, material boolean, -- true para madeira, false para metal i_maturação date, f_maturação date, id_parreiral int, cepa_nome varchar(40), foreign key(id_parreiral) references parreiral(id) on delete set null on update cascade, foreign key(cepa_nome) references cepa(nome) on delete restrict on update cascade ); create table Dionisio.vinho( id int primary key, nome varchar(30), classificação boolean, -- true para varietal, false para assemblage rotulo longblob ); create table Dionisio.safra( id int , ano year, quantidade int, id_vinho int, primary key(id_vinho,ano), unique(id), foreign key(id_vinho) references vinho(id) on delete restrict on update cascade ); create table Dionisio.produção( id_colheita int, id_safra int, primary key(id_colheita, id_safra), foreign key(id_colheita) references colheita(id) on delete restrict on update cascade, foreign key(id_safra) references safra(id) on delete restrict on update cascade ); create table Dionisio.avaliação( nome varchar(25), nota int, id_safra int, primary key (nome,id_safra), foreign key(id_safra) references safra(id) on delete cascade on update cascade );
true
7089e179c7f8eeb77c1d3d1cdfa6372f676be29b
SQL
vmogilev/evnt
/linux/mon/sys/install/event_based_reports.sql
UTF-8
8,804
3.359375
3
[]
no_license
set scan off -- COLL_SNAP -- X -- Collection data by snapshoot -- Displays all data from a single collection snapshoot -- SELECT * FROM COLL_PULL__&SNAPSHOOT_TABLE -- TBSP_GROWTH -- E -- Tablespace growth rate -- Reports tablespace growth rate over a time period -- SELECT /*+ ORDERED */ et_attribute1||DECODE(et_attribute2,NULL,NULL,':'||et_attribute2) "Target" , '<a href="evnt_web_pkg.get_trigger?p_et_id='||et.et_id||'"><font class="TRL">'||et.et_id||'</font></a>' "Trigger" , et_trigger_time "Time" , etd_attribute1 "Tablespace" , TO_NUMBER(etd_attribute3) "Total KB" , TO_NUMBER(etd_attribute4) "Free KB" , TO_NUMBER(etd_attribute2) "PCT" FROM event_triggers et , event_trigger_details etd WHERE et.e_id = (SELECT e_id FROM events WHERE e_code = 'TABSP_USAGE') AND et.s_id = :p_s_id AND etd_attribute1 LIKE(:p_tabsp_name) AND et.et_id = etd.et_id ORDER BY et_trigger_time -- RUNAWAY_PROCS -- E -- Runaway processes report -- Reports historical runaway processes -- SELECT /*+ ORDERED */ et_attribute1||DECODE(et_attribute2,NULL,NULL,':'||et_attribute2) "Target" , '<a href="evnt_web_pkg.get_trigger?p_et_id='||et.et_id||'"><font class="TRL">'||et.et_id||'</font></a>' "Trigger" , et_trigger_time "Time" , etd_status "Threshold" , etd_attribute3 "User" , htf.escape_sc(etd_attribute4) "Module/Action" FROM event_triggers et , event_trigger_details etd WHERE et.e_id IN (SELECT e_id FROM events WHERE e_code LIKE 'RUNAWAY_PROC%') AND et.s_id = :p_s_id AND LTRIM(etd_attribute4) LIKE(:p_module_name) AND et.et_id = etd.et_id ORDER BY et_trigger_time -- LGRSEG_GROWTH -- E -- Large segment growth -- Reports growth history of segments with high number of extents -- SELECT /*+ ORDERED */ et_attribute1||DECODE(et_attribute2,NULL,NULL,':'||et_attribute2) "Target" , '<a href="evnt_web_pkg.get_trigger?p_et_id='||et.et_id||'"><font class="TRL">'||et.et_id||'</font></a>' "Trigger" , et_trigger_time "Time" , etd_status "Threshold" , etd_attribute1 "Owner" , etd_attribute2 "Segment Name" , etd_attribute3 "Segment Type" , etd_attribute4 "Tablespace" , TO_NUMBER(etd_attribute5)/1024 "KBytes" , TO_NUMBER(etd_attribute6) "Extents" , TO_NUMBER(etd_attribute7) "Max Extents" , TO_NUMBER(etd_attribute8)/1024 "Initial KB" , TO_NUMBER(etd_attribute9)/1024 "Next KB" , TO_NUMBER(etd_attribute10) "PCT" FROM event_triggers et , event_trigger_details etd WHERE et.e_id = (SELECT e_id FROM events WHERE e_code = 'HIGH_EXTENTS') AND et.s_id = :p_s_id AND et.et_id = etd.et_id AND etd_attribute2 LIKE (:p_segment_name) ORDER BY et_trigger_time -- FASTEXT_SEGS -- E -- Fast extending segments -- Reports segment extent history -- SELECT /*+ ORDERED */ et_attribute1||DECODE(et_attribute2,NULL,NULL,':'||et_attribute2) "Target" , '<a href="evnt_web_pkg.get_trigger?p_et_id='||et.et_id||'"><font class="TRL">'||et.et_id||'</font></a>' "Trigger" , et_trigger_time "Time" , etd_status "Threshold" , etd_attribute1 "Owner" , etd_attribute2 "Segment Type" , etd_attribute3 "Segment Name" , etd_attribute4 "Tablespace" , TO_NUMBER(etd_attribute5) "Start KB" , TO_NUMBER(etd_attribute6) "End KB" , TO_NUMBER(etd_attribute6) - TO_NUMBER(etd_attribute5) "Diff KB" , TO_NUMBER(etd_attribute7) "Start Ext" , TO_NUMBER(etd_attribute8) "End Ext" , TO_NUMBER(etd_attribute8) - TO_NUMBER(etd_attribute7) "Diff Ext" , TO_NUMBER(etd_attribute9)/1024 "Next KB" , TO_NUMBER(etd_attribute10) "PCT" FROM event_triggers et , event_trigger_details etd WHERE et.e_id = (SELECT e_id FROM events WHERE e_code = 'DB_SEGEX') AND et.s_id = :p_s_id AND et.et_id = etd.et_id AND etd_attribute3 LIKE (:p_segment_name) ORDER BY et_trigger_time -- HIGH_SORTS -- E -- High sort usage -- Reports history of sessions with high sort usage -- SELECT /*+ ORDERED */ et_attribute1||DECODE(et_attribute2,NULL,NULL,':'||et_attribute2) "Target" , '<a href="evnt_web_pkg.get_trigger?p_et_id='||et.et_id||'"><font class="TRL">'||et.et_id||'</font></a>' "Trigger" , et_trigger_time "Time" , etd_status "Threshold" , etd_attribute3 "User" , etd_attribute4 "Logon Time" , etd_attribute5 "Machine" , htf.escape_sc(etd_attribute6) "Prog/Mod/Action" , etd_attribute7 "Status" , etd_attribute8 "Tabsp" , etd_attribute10 "Extents" , etd_attribute11 "Sort KB" FROM event_triggers et , event_trigger_details etd WHERE et.e_id IN (SELECT e_id FROM events WHERE e_code LIKE 'SORT_SIZE') AND et.s_id = :p_s_id AND LTRIM(etd_attribute6) LIKE(:p_module_name) AND et.et_id = etd.et_id ORDER BY et_trigger_time -- APPS11I_SES -- R -- APPS (11i) - Active forms sessions -- Application 11i forms connections with APPS level username -- select chr(39)||s.sid||','||s.serial#||chr(39) "Sid,Serial" , to_char(s.logon_time,'DDth HH24:MI:SS') "LogOn Time" , floor(last_call_et/3600)||':'|| floor(mod(last_call_et,3600)/60)||':'|| mod(mod(last_call_et,3600),60) "Idle" , s.username "O-User" , s.osuser "OS-User" , s.status "Status" , DECODE(lockwait,'','','Y') "Lockwait" , u.user_name "APPS-User" , s.module||' '||s.action "Form Responsibility" from v$session@&DB_LINK_NAME s , v$process@&DB_LINK_NAME p , fnd_logins@&DB_LINK_NAME n , fnd_user@&DB_LINK_NAME u where s.paddr = p.addr and n.pid IS NOT NULL and n.serial# IS NOT NULL and n.login_name IS NOT NULL and n.end_time IS NULL and n.serial# = p.serial# and n.pid = p.pid and n.process_spid = p.spid and n.spid = s.process and n.user_id = u.user_id and trunc(s.logon_time) = trunc(n.start_time) order by u.user_name , s.logon_time -- TABSP_USAGE -- R -- Tablespace Usage -- Reports current tablespace usage -- select '<a href="glob_web_pkg.exec_sql' ||'?p_report=DFILE_USAGE' ||'&p_pag=YES' ||'&p_rep_what='||web_std_pkg.encode_ustr(UPPER('&db_link_name')) ||'&p_rep_with='||web_std_pkg.encode_ustr('&DB_LINK_NAME') ||'&p_bind_names=:p_tabsp_name' ||'&p_bind_values='||b.tablespace_name ||'&p_heading='||web_std_pkg.encode_ustr('Data File Usage (&DB_LINK_NAME)') ||'"><font class="TRL">'||b.tablespace_name||'</font></a>' "TS Name" , kbytes_alloc "Total KB" , kbytes_alloc-nvl(kbytes_free,0) "Used KB" , nvl(kbytes_free,0) "Free KB" , ROUND(((kbytes_alloc-nvl(kbytes_free,0))/kbytes_alloc)*100,2) "PCT Used" , nvl(largest,0) "Largest KB" from (select sum(bytes)/1024 Kbytes_free , max(bytes)/1024 largest , tablespace_name from dba_free_space@&DB_LINK_NAME group by tablespace_name) a , (select sum(bytes)/1024 Kbytes_alloc , tablespace_name from dba_data_files@&DB_LINK_NAME group by tablespace_name) b where a.tablespace_name (+) = b.tablespace_name order by 5 desc,1 -- DFILE_USAGE -- R -- Data File Usage -- Reports current datafile usage -- select /*+ ORDERED */ df.tablespace_name "TS Name" , df.file_name "File Name" , df.bytes/1024 "Total KB" , (df.bytes-nvl(fr.bytes,0))/1024 "Used KB" , nvl(fr.bytes/1024,0) "Free Kb" , ROUND(((df.bytes-nvl(fr.bytes,0))/df.bytes)*100,2) "PCT Used" from (select sum(bytes) bytes , file_id from dba_free_space@&DB_LINK_NAME group by file_id) fr , dba_data_files@&DB_LINK_NAME df where df.file_id = fr.file_id(+) and df.tablespace_name like (:p_tabsp_name) order by 1, df.file_id /* shared parameters */ -- P_MODULE_NAME -- Module Name -- C -- NULL -- P_TABSP_NAME -- Tablespace Name -- C -- NULL -- -- P_SEGMENT_NAME -- Segment Name -- C -- NULL -- P_E_ID -- Event Name -- L SELECT e_id , e_code , NULL FROM events ORDER BY e_code -- -- P_S_ID -- Sid Name -- L SELECT s_id , s_name , NULL FROM sids ORDER BY s_name
true
60bbe03baaebcb0be7c36d7c2bbac91f2476ea15
SQL
mongmx/fiber-cms
/db-schema/postgres/20201230025318-create_users_table.sql
UTF-8
365
2.953125
3
[ "MIT" ]
permissive
-- +migrate Up CREATE TABLE users ( id BIGSERIAL PRIMARY KEY, uuid UUID DEFAULT uuid_generate_v4(), email VARCHAR NOT NULL DEFAULT '' UNIQUE, is_banned BOOLEAN NOT NULL DEFAULT FALSE, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), deleted_at TIMESTAMPTZ NULL ); -- +migrate Down DROP TABLE users;
true
ac27b3b634765ff3422ddb61d9491fdc87f7e7c3
SQL
george-sp/coding_bootcamp-preparatory
/my_sql_tutorial/exercises_2/ex4-participate_any.sql
UTF-8
263
3.25
3
[]
no_license
# Display those students that have participated in an (any) course. SELECT DISTINCT `bootcamp`.`students`.* FROM `bootcamp`.`students` INNER JOIN `bootcamp`.`students_has_courses` ON `bootcamp`.`students`.StID = `bootcamp`.`students_has_courses`.`students_StID`
true
c4d85d4457f6b6d16c8bf4189c181bcca0a9e903
SQL
BranislavLazic/gochan
/sql/preapril2020migration/oldDBMigration_master.sql
UTF-8
11,127
3.671875
4
[ "BSD-2-Clause" ]
permissive
/* Migrates the pre-refactor database of april 2020 to database verion 1 rename all tables to table_old run version 1 population script filter, copy change data A deactivated, unauthorized user with the name "unknown_staff" is created to attribute to unknown staff */ INSERT INTO DBPREFIXsections (id, name, abbreviation, position, hidden) SELECT id, name, abbreviation, list_order, hidden > 0 FROM DBPREFIXsections_old; INSERT INTO DBPREFIXboards ( id, section_id, uri, dir, navbar_position, title, subtitle, description, max_file_size, max_threads, default_style, locked, created_at, anonymous_name, force_anonymous, autosage_after, no_images_after, max_message_length, min_message_length, allow_embeds, redirect_to_thread, require_file, enable_catalog) SELECT id, section, dir, dir, list_order, title, subtitle, description, max_file_size, 1000, default_style, locked, created_on, anonymous, forced_anon, autosage_after, no_images_after, max_message_length, 0, embeds_allowed, redirect_to_thread, require_file, enable_catalog FROM DBPREFIXboards_old; /* ---Migrating posts add oldpostid to thread table, make it unique add oldselfid, oldparentid and oldboardid to posts table add oldselfid and oldboardid to files remove foreign key constraint on thread_id in posts remove foreign key constraint on post_id in files create thread per top post, add id of said old post to oldpostid insert top posts with old parent id being own old id and old board id being board id insert child posts with old parent id being old parent post id and old board id being board id --- UPDATE posts, threads SET posts.thread_id = threads.id WHERE threads.oldpostid = posts.oldparentid AND threads.boardid = posts.oldboardid --- insert into files values where file values exist --- UPDATE posts, files SET files.post_id = posts.id WHERE files.oldpostid = posts.oldselfid AND files.oldboardid = posts.oldboardid --- remove all dummy columns add foreign key constraint on thread_id in posts add foreign key constraint on post_id in files */ ALTER TABLE DBPREFIXthreads ADD oldpostid int; ALTER TABLE DBPREFIXposts ADD oldselfid int; ALTER TABLE DBPREFIXposts ADD oldparentid int; ALTER TABLE DBPREFIXposts ADD oldboardid int; ALTER TABLE DBPREFIXposts {drop fk} posts_thread_id_fk; ALTER TABLE DBPREFIXfiles ADD oldpostid int; ALTER TABLE DBPREFIXfiles ADD oldboardid int; ALTER TABLE DBPREFIXfiles {drop fk} files_post_id_fk; #IF POSTGRES -- Drops not null constraint ALTER TABLE DBPREFIXposts ALTER COLUMN thread_id DROP NOT NULL; ALTER TABLE DBPREFIXfiles ALTER COLUMN post_id DROP NOT NULL; #ENDIF #IF MYSQL -- Drops not null constraint ALTER TABLE DBPREFIXposts MODIFY thread_id {fk to serial}; ALTER TABLE DBPREFIXfiles MODIFY post_id {fk to serial}; #ENDIF INSERT INTO DBPREFIXthreads(board_id, locked, stickied, anchored, last_bump, is_deleted, deleted_at, oldpostid) SELECT boardid, locked, stickied, autosage, bumped, deleted_timestamp > '2000-01-01', deleted_timestamp, id FROM DBPREFIXposts_old WHERE parentid = 0; INSERT INTO DBPREFIXposts(is_top_post, ip, created_on, name, tripcode, is_role_signature, email, subject, message, message_raw, password, deleted_at, is_deleted, oldparentid, oldboardid, oldselfid) SELECT parentid = 0, ip, timestamp, name, tripcode, false, email, subject, message, message_raw, password, deleted_timestamp, deleted_timestamp > '2000-01-01', id, boardid, id from DBPREFIXposts_old WHERE parentid = 0; INSERT INTO DBPREFIXposts(is_top_post, ip, created_on, name, tripcode, is_role_signature, email, subject, message, message_raw, password, deleted_at, is_deleted, oldparentid, oldboardid, oldselfid) SELECT parentid = 0, ip, timestamp, name, tripcode, false, email, subject, message, message_raw, password, deleted_timestamp, deleted_timestamp > '2000-01-01', parentid, boardid, id from DBPREFIXposts_old WHERE parentid <> 0; #IF POSTGRES --Sets correct thread id UPDATE DBPREFIXposts as posts SET thread_id = threads.id FROM DBPREFIXthreads as threads WHERE threads.oldpostid = posts.oldparentid AND threads.board_id = posts.oldboardid; #ENDIF #IF MYSQL --Sets correct thread id UPDATE DBPREFIXposts as posts, DBPREFIXthreads as threads SET posts.thread_id = threads.id WHERE threads.oldpostid = posts.oldparentid AND threads.board_id = posts.oldboardid; #ENDIF INSERT INTO DBPREFIXfiles(file_order, original_filename, filename, checksum, file_size, is_spoilered, width, height, thumbnail_width, thumbnail_height, oldpostid, oldboardid) SELECT 1, filename_original, filename, file_checksum, filesize, false, image_w, image_h, thumb_w, thumb_h, id, boardid FROM DBPREFIXposts_old WHERE filename <> '' AND filename <> 'deleted'; #IF POSTGRES -- Creates files in files table UPDATE DBPREFIXfiles as files SET post_id = posts.id FROM DBPREFIXposts as posts WHERE files.oldpostid = posts.oldselfid AND files.oldboardid = posts.oldboardid; #ENDIF #IF MYSQL -- Creates files in files table UPDATE DBPREFIXfiles as files, DBPREFIXposts as posts SET files.post_id = posts.id WHERE files.oldpostid = posts.oldselfid AND files.oldboardid = posts.oldboardid; #ENDIF ALTER TABLE DBPREFIXthreads DROP COLUMN oldpostid; ALTER TABLE DBPREFIXposts DROP COLUMN oldparentid; ALTER TABLE DBPREFIXposts DROP COLUMN oldboardid; ALTER TABLE DBPREFIXfiles DROP COLUMN oldpostid; ALTER TABLE DBPREFIXfiles DROP COLUMN oldboardid; ALTER TABLE DBPREFIXfiles ADD CONSTRAINT files_post_id_fk FOREIGN KEY (post_id) REFERENCES DBPREFIXposts(id); ALTER TABLE DBPREFIXposts ADD CONSTRAINT posts_thread_id_fk FOREIGN KEY (thread_id) REFERENCES DBPREFIXthreads(id); #IF POSTGRES -- Drops not null constraint ALTER TABLE DBPREFIXposts ALTER COLUMN thread_id SET NOT NULL; ALTER TABLE DBPREFIXfiles ALTER COLUMN post_id SET NOT NULL; #ENDIF #IF MYSQL -- Adds not null constraint ALTER TABLE DBPREFIXposts MODIFY thread_id {fk to serial} NOT NULL; ALTER TABLE DBPREFIXfiles MODIFY post_id {fk to serial} NOT NULL; #ENDIF --Staff INSERT INTO DBPREFIXstaff(id, username, password_checksum, global_rank, added_on, last_login) SELECT id, username, password_checksum, rank, added_on, last_active FROM DBPREFIXstaff_old; --Bans-- --Step 1, normalisation from comma seperated boards to seperate entries per board --Create copy of table structure and drop not null constraint on boards #IF MYSQL CREATE TABLE DBPREFIXbanlist_old_normalized SELECT * FROM DBPREFIXbanlist_old LIMIT 0; ALTER TABLE DBPREFIXbanlist_old_normalized MODIFY boards VARCHAR(255); #ENDIF #IF POSTGRES CREATE TABLE DBPREFIXbanlist_old_normalized (like DBPREFIXbanlist_old including all); ALTER TABLE DBPREFIXbanlist_old_normalized ALTER COLUMN boards DROP NOT NULL; #ENDIF --needed because id sequence is otherwise shared between this and the old table ALTER TABLE DBPREFIXbanlist_old_normalized DROP COLUMN id; ALTER TABLE DBPREFIXbanlist_old_normalized ADD COLUMN old_id int; /* Joins every ban on every entry in the numbers list (lists 1 to 1000 ints), then filters to only return results where numbers.num <= #elementsInCommaList Cuts out element in list using the num as index */ INSERT INTO DBPREFIXbanlist_old_normalized(old_id, allow_read, ip, name, name_is_regex, filename, file_checksum, staff, timestamp, expires, permaban, reason, type, staff_note, appeal_at, can_appeal, boards) (SELECT bans.id, bans.allow_read, bans.ip, bans.name, bans.name_is_regex, bans.filename, bans.file_checksum, bans.staff, bans.timestamp, bans.expires, bans.permaban, bans.reason, bans.type, bans.staff_note, bans.appeal_at, bans.can_appeal, #IF MYSQL TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(bans.boards, ',', nums.num), ',', -1)) #ENDIF #IF POSTGRES TRIM(SPLIT_PART(bans.boards, ',', nums.num)) #ENDIF FROM DBPREFIXnumbersequel_temp AS nums INNER JOIN DBPREFIXbanlist_old AS bans ON TRUE WHERE CHAR_LENGTH(bans.boards)-CHAR_LENGTH(REPLACE(bans.boards, ',', '')) >= nums.num-1); --replace * with null UPDATE DBPREFIXbanlist_old_normalized SET boards = null WHERE boards = '*'; ALTER TABLE DBPREFIXbanlist_old_normalized ADD COLUMN board_id int; ALTER TABLE DBPREFIXbanlist_old_normalized ADD COLUMN staff_id int; --Fix board id #IF POSTGRES UPDATE DBPREFIXbanlist_old_normalized as bans SET board_id = boards.id FROM DBPREFIXboards as boards WHERE bans.boards = boards.dir; #ENDIF #IF MYSQL UPDATE DBPREFIXbanlist_old_normalized as bans, DBPREFIXboards as boards SET bans.board_id = boards.id WHERE bans.boards = boards.dir; #ENDIF --Fix staff_id #IF POSTGRES UPDATE DBPREFIXbanlist_old_normalized as bans SET staff_id = staff.id FROM DBPREFIXstaff as staff WHERE bans.staff = staff.username; #ENDIF #IF MYSQL UPDATE DBPREFIXbanlist_old_normalized as bans, DBPREFIXstaff as staff SET bans.staff_id = staff.id WHERE bans.staff = staff.username; #ENDIF --Step 2, copy them all to the live ban board per ban type /* ban types: 1 = thread ban 2 = image ban 3 = full ban if image <> "" or null create image ban */ --Add an old_id column to each table for later foreign key linking for appeals, remove at the end ALTER TABLE DBPREFIXip_ban ADD COLUMN old_id int; --ip bans INSERT INTO DBPREFIXip_ban(old_id, staff_id, board_id, is_thread_ban, is_active, ip, issued_at, expires_at, permanent, staff_note, message, can_appeal, appeal_at, copy_post_text) ( SELECT old_id, staff_id, board_id, TRUE, TRUE, ip, timestamp, expires, permaban, staff_note, reason, can_appeal, appeal_at, '' FROM DBPREFIXbanlist_old_normalized WHERE type = 1 ); INSERT INTO DBPREFIXip_ban(old_id, staff_id, board_id, is_thread_ban, is_active, ip, issued_at, expires_at, permanent, staff_note, message, can_appeal, appeal_at, copy_post_text) ( SELECT old_id, staff_id, board_id, FALSE, TRUE, ip, timestamp, expires, permaban, staff_note, reason, can_appeal, appeal_at, '' FROM DBPREFIXbanlist_old_normalized WHERE type = 3 ); --appeals INSERT INTO DBPREFIXip_ban_appeals(ip_ban_id, appeal_text, staff_response, is_denied)( SELECT ban.id, appeal.message, appeal.staff_response, appeal.denied FROM DBPREFIXappeals_old as appeal JOIN DBPREFIXip_ban as ban ON ban.old_id = appeal.id ); ALTER TABLE DBPREFIXip_ban DROP COLUMN old_id; --file ban INSERT INTO DBPREFIXfile_ban(board_id, staff_id, staff_note, issued_at, checksum)( SELECT board_id, staff_id, staff_note, timestamp, file_checksum FROM DBPREFIXbanlist_old_normalized WHERE file_checksum <> '' ); --filename ban INSERT INTO DBPREFIXfilename_ban(board_id, staff_id, staff_note, issued_at, filename, is_regex)( SELECT board_id, staff_id, staff_note, timestamp, filename, name_is_regex FROM DBPREFIXbanlist_old_normalized WHERE filename <> '' ); --username ban INSERT INTO DBPREFIXusername_ban(board_id, staff_id, staff_note, issued_at, username, is_regex)( SELECT board_id, staff_id, staff_note, timestamp, name, name_is_regex FROM DBPREFIXbanlist_old_normalized WHERE name <> '' ); --reports INSERT INTO DBPREFIXreports(post_id, ip, reason, is_cleared)( SELECT post.id, report.id, report.reason, report.cleared FROM DBPREFIXreports_old as report JOIN DBPREFIXposts as post on post.oldselfid = report.postid );
true
93a3c9b2a8c4ade7d4541b7ab191f9c90e9d6ec1
SQL
HLeek40/SQL-Homework
/MYSQL Homework HLEEK.sql
UTF-8
8,812
4.40625
4
[]
no_license
-- Sakila already exists since I am on PC, therefore I just need to use databse to do homework-- USE Sakila; -- Display the first and last names of all actors from the table actor-- SELECT first_name, last_name from actor; -- Display the first and last name of each actor in a single column in upper case letters. Name the column Actor Name-- SELECT UPPER(CONCAT(first_name, " ", last_name)) AS Actor_Name FROM actor; -- 2a. You need to find the ID number, first name, and last name of an actor, of whom you know only the first name, "Joe." -- What is one query would you use to obtain this information? SELECT actor_id, first_name, last_name from actor WHERE first_name = "Joe"; -- 2b. Find all actors whose last name contain the letters GEN SELECT actor_id, first_name, last_name from actor WHERE last_name LIKE '%GEN%'; -- 2c. Find all actors whose last names contain the letters LI. This time, order the rows by last name and first name, in that order: SELECT last_name, first_name from actor WHERE last_name LIKE '%LI%' ORDER BY last_name, first_name ASC; -- 2d. Using IN, display the country_id and country columns of the following countries: Afghanistan, Bangladesh, and China SELECT country_id, country from country WHERE country IN ('Afghanistan', 'Bangladesh', 'China'); -- 3a. You want to keep a description of each actor. You don't think you will be performing queries on a description, -- so create a column in the table actor named description and use the data type BLOB (Make sure to research the type BLOB, -- as the difference between it and VARCHAR are significant). ALTER TABLE actor ADD COLUMN Description BLOB(100) AFTER last_update; SELECT * FROM actor; -- 3b. Very quickly you realize that entering descriptions for each actor is too much effort. Delete the description column. ALTER TABLE actor DROP COLUMN description; SELECT * FROM actor; -- 4a. List the last names of actors, as well as how many actors have that last name. SELECT last_name, COUNT(last_name) FROM actor GROUP BY last_name; -- 4b. List last names of actors and the number of actors who have that last name, but only for names that are shared by at least two actors SELECT last_name, COUNT(last_name) AS "last_name_count" FROM actor GROUP BY last_name HAVING last_name_count >=2; -- 4c. The actor HARPO WILLIAMS was accidentally entered in the actor table as GROUCHO WILLIAMS. Write a query to fix the record. SELECT actor_id, first_name, last_name FROM actor WHERE first_name LIKE 'GROUCHO'; UPDATE actor SET first_name = 'HARPO' WHERE actor_id = 172; SELECT actor_id, first_name, last_name FROM actor WHERE first_name LIKE 'HARPO'; -- 4d. Perhaps we were too hasty in changing GROUCHO to HARPO. It turns out that GROUCHO was the correct name after all! In a single query, -- if the first name of the actor is currently HARPO, change it to GROUCHO. UPDATE actor SET first_name = 'GROUCHO' WHERE actor_id = 172; SELECT actor_id, first_name, last_name FROM actor WHERE first_name LIKE 'GROUCHO'; -- 5a. You cannot locate the schema of the address table. Which query would you use to re-create it? SHOW CREATE TABLE address; -- 6a. Use JOIN to display the first and last names, as well as the address, of each staff member. Use the tables staff and address: SELECT first_name, last_name, address FROM staff s JOIN address a ON (s.address_id = a.address_id); -- 6b. Use JOIN to display the total amount rung up by each staff member in August of 2005. Use tables staff and payment. -- SELECT * FROM payment; -- DESCRIBE payment; SELECT s.last_name, s.first_name, SUM(p.amount) AS 'Ring_Total' FROM staff s INNER JOIN payment p ON (s.staff_id = p.staff_id) AND p.payment_date LIKE '2005-08%' GROUP BY 1, 2; -- 6c. List each film and the number of actors who are listed for that film. Use tables film_actor and film. Use inner join. SELECT f.film_id, f.title, COUNT(a.actor_id) AS Actor_Count FROM film f INNER JOIN film_actor a ON (f.film_id = a.film_id) GROUP BY f.film_id; -- 6d. How many copies of the film Hunchback Impossible exist in the inventory system? SELECT title, (SELECT COUNT(*) FROM inventory WHERE film.film_id = inventory.film_id ) AS 'Number of Copies' FROM film WHERE title LIKE 'Hunchback Impossible'; -- 6e. Using the tables payment and customer and the JOIN command, list the total paid by each customer. List the customers alphabetically by last name SELECT c.first_name, c.last_name, SUM(p.amount) AS 'Total Amount Paid' FROM customer c INNER JOIN payment p ON (c.customer_id = p.customer_id) GROUP BY 1, 2 ORDER BY c.last_name ASC; -- 7a Use subqueries to display the titles of movies starting with the letters K and Q whose language is English. -- SELECT * FROM language; -- SELECT * FROM film WHERE title Like 'K%'; SELECT title FROM film WHERE title LIKE "K%" OR title LIKE "Q%" AND language_id IN ( SELECT language_id FROM language WHERE language_id = 1 ); -- 7b. Use subqueries to display all actors who appear in the film Alone Trip. SELECT first_name, last_name FROM actor WHERE actor_id IN ( SELECT actor_id FROM film_actor WHERE film_id IN ( SELECT film_id FROM film WHERE title = "Alone Trip" ) ); -- 7c. You want to run an email marketing campaign in Canada, for which you will need the names and email -- addresses of all Canadian customers. Use joins to retrieve this information. -- SELECT * FROM country; SELECT c.customer_id, first_name, last_name, email, country FROM customer c JOIN address a ON (c.address_id = a.address_id) JOIN city b ON (b.city_id = a.city_id) JOIN country d ON (d.country_id = b.country_id) WHERE country = 'Canada' -- 7d. Sales have been lagging among young families, and you wish to target all family movies for a promotion. Identify all movies categorized as family films. SELECT * FROM category; SELECT f.film_id, f.title, c.name FROM film f JOIN film_category fc ON (f.film_id = fc.film_id) JOIN category c ON (c.category_id = fc.category_id) WHERE c.name = 'Family'; -- 7e. Display the most frequently rented movies in descending order. SELECT f.title, COUNT(r.rental_id) AS 'Rental_Count' FROM film f JOIN inventory i ON (f.film_id = i.film_id) JOIN customer c ON (c.store_id = i.store_id) JOIN payment p ON (c.customer_id = p.customer_id) JOIN rental r ON (r.rental_id = p.rental_id) GROUP BY f.title ORDER BY 2 DESC; -- 7f. Write a query to display how much business, in dollars, each store brought in. SELECT s.store_id, SUM(amount) AS 'TOTAL REVENUE' FROM store s JOIN customer c ON (s.store_id = c.store_id) JOIN payment p ON (p.customer_id = c.customer_id) GROUP BY s.store_id; -- 7g. Write a query to display for each store its store ID, city, and country. SELECT s.store_id, c.city, d.country FROM store s JOIN address a ON (s.address_id = a.address_id) JOIN city c ON (c.city_id = a.city_id) JOIN country d ON (c.country_id = d.country_id); -- 7h. List the top five genres in gross revenue in descending order. -- (Hint: you may need to use the following tables: category, film_category, inventory, payment, and rental.) SELECT name, SUM(p.amount) AS "GROSS REVENUE" FROM category c JOIN film_category fc ON (c.category_id = fc.category_id) JOIN inventory i ON (i.film_id = fc.film_id) JOIN rental r ON (r.inventory_id = i.inventory_id) JOIN payment p ON (p.rental_id = r.rental_id) GROUP BY name ORDER BY 2 DESC LIMIT 5; -- 8a. In your new role as an executive, you would like to have an easy way of viewing the Top five genres by gross revenue. -- Use the solution from the problem above to create a view. -- If you haven't solved 7h, you can substitute another query to create a view. CREATE VIEW top_five AS SELECT name, SUM(p.amount) AS "GROSS REVENUE" FROM category c JOIN film_category fc ON (c.category_id = fc.category_id) JOIN inventory i ON (i.film_id = fc.film_id) JOIN rental r ON (r.inventory_id = i.inventory_id) JOIN payment p ON (p.rental_id = r.rental_id) GROUP BY name ORDER BY 2 DESC LIMIT 5; -- 8b. How would you display the view that you created in 8a? SELECT * FROM top_five; -- 8c. You find that you no longer need the view top_five_genres. Write a query to delete it. DROP VIEW top_five;
true
6bdb90d1420143fbc416e7af20eed4955663d61c
SQL
achintayya/spring-samples
/blogosphere-spring-mybatis/src/main/resources/sql/blogosphere.sql
UTF-8
3,597
3.78125
4
[]
no_license
--CREATE DATABASE IF NOT EXISTS blogosphere; --USE blogosphere; DROP TABLE IF EXISTS comments; DROP TABLE IF EXISTS post_tags; DROP TABLE IF EXISTS tags; DROP TABLE IF EXISTS posts; DROP TABLE IF EXISTS blogs; DROP TABLE IF EXISTS users; CREATE TABLE users ( user_id int(11) NOT NULL AUTO_INCREMENT, username varchar(50) NOT NULL, password varchar(50) NOT NULL, email_id varchar(50) NOT NULL, first_name varchar(50) NOT NULL, last_name varchar(50) DEFAULT NULL, disabled char(1) DEFAULT NULL, PRIMARY KEY (user_id), UNIQUE KEY username_unique (username), UNIQUE KEY email_id_unique (email_id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; /*Data for the table user */ insert into users(user_id,email_id,username,password,first_name,last_name,disabled) values (1,'admin@gmail.com','admin','admin','Administrator',NULL,'0'); insert into users(user_id,email_id,username,password,first_name,last_name,disabled) values (2,'sivaprasadreddy.k@gmail.com','siva','siva','Siva','K','0'); CREATE TABLE blogs ( blog_id int(11) NOT NULL AUTO_INCREMENT, blog_name varchar(50) NOT NULL, owner_id int(11) NOT NULL, created_on datetime DEFAULT NULL, PRIMARY KEY (blog_id), UNIQUE KEY blog_name_unique (blog_name), KEY FK_blog_owner (owner_id), CONSTRAINT FK_blog_owner FOREIGN KEY (owner_id) REFERENCES users (user_id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; insert into blogs(blog_id,blog_name,owner_id,created_on) values(1,'sivalabs',1,now()); CREATE TABLE tags ( tag_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, tag_name VARCHAR(50) NOT NULL, description VARCHAR(512), PRIMARY KEY (tag_id), UNIQUE INDEX tag_name_unique(tag_name) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO tags (tag_id,tag_name,description) VALUES (1,'java','Java'); INSERT INTO tags (tag_id,tag_name,description) VALUES (2,'java-ee','JavaEE'); INSERT INTO tags (tag_id,tag_name,description) VALUES (3,'spring','Spring'); INSERT INTO tags (tag_id,tag_name,description) VALUES (4,'hibernate','Hibernate'); INSERT INTO tags (tag_id,tag_name,description) VALUES (5,'ajax','Ajax'); INSERT INTO tags (tag_id,tag_name,description) VALUES (6,'tomcat','Tomcat'); CREATE TABLE posts ( post_id int(11) NOT NULL AUTO_INCREMENT, title varchar(256) NOT NULL, content longtext NOT NULL, created_on datetime NOT NULL, blog_id int(11) NOT NULL, PRIMARY KEY (post_id), KEY FK_post_blog_id (blog_id), CONSTRAINT FK_post_blog_id FOREIGN KEY (blog_id) REFERENCES blogs (blog_id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; insert into posts(post_id,title,content,created_on,blog_id) values (1,'My First Post','This my First post',now(),1); CREATE TABLE post_tags ( post_id int(11) NOT NULL default '0', tag_id int(11) NOT NULL default '0', PRIMARY KEY (post_id,tag_id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; insert into post_tags(post_id,tag_id) values(1,1); insert into post_tags(post_id,tag_id) values(1,3); CREATE TABLE comments ( comment_id int(11) NOT NULL AUTO_INCREMENT, title varchar(256) DEFAULT NULL, content longtext NOT NULL, created_on datetime NOT NULL, created_by int(11) NOT NULL, post_id int(11) NOT NULL, PRIMARY KEY (comment_id), KEY FK_comment_post_id (post_id), KEY FK_comment_created_by (created_by), CONSTRAINT FK_comment_created_by FOREIGN KEY (created_by) REFERENCES users (user_id), CONSTRAINT FK_comment_post_id FOREIGN KEY (post_id) REFERENCES posts (post_id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; insert into comments(comment_id,title,content,created_on,created_by,post_id) values (1,'RE: My First Post','Keep going',now(),1,1);
true
dc88f775be12473380081a99a6469d9496c4643d
SQL
javi-ramirez/Presidencia-Ahuacatl-n-1
/bd/Procedimientos Almacenados/sp_insertarRoles.sql
UTF-8
327
3.140625
3
[]
no_license
#Procedimiento para insertar Rol DROP procedure IF EXISTS sp_insertarroles; DELIMITER // create procedure sp_insertarroles(nombreRol varchar(45)) begin set @id= (select idRol from rol ORDER BY idRol DESC limit 1) ; set @id = (select IFNULL(@id, 0)); set @id=@id+1; insert into rol values(@id,nombreRol); end // DELIMITER ;
true
c0b5149099e7dd2e1335d6be815c446188e887bc
SQL
patelshani7112/DBS311-Assignments
/Assignments-01/Asgn1_Gr8.sql
UTF-8
5,988
4.21875
4
[]
no_license
-- DBS311NBB - Assignment 1 -- Group 8 -- Members: Eakampreet Singh (100828201) -- Shani Patel (152243192) -- Vishwa Inder Singh (129377206) -- Yash Padsala (150450195) ------------------------------------------ -- Question 1 SELECT employee_id "Emp#", (first_name || ' ' || last_name) "Full Name", job_title "Job", to_char(hire_date, 'fmDdspTH "of" Month"," YYYY') "Start Date" FROM employees WHERE to_char(hire_date, 'mm') NOT IN ('09', '10', '11') AND job_title LIKE 'A%' AND Length(job_title) <= 20 ORDER BY hire_date DESC; -- Question 2 SELECT (last_name ||', '|| first_name) "Emp Name", TO_CHAR(SUM(unit_price * quantity),'$999,999,999.99') "Total Sale" FROM orders o JOIN order_items oi USING(order_id) JOIN employees e ON o.salesman_id = e.employee_id GROUP BY salesman_id, last_name, first_name HAVING substr(first_name,length(first_name), 1) != 'y' ORDER BY 2 DESC; -- Question 3 SELECT (e.last_name || ', ' || e.first_name) "Emp Name", to_char(SUM(oi.quantity * oi.unit_price), '$99,999,999.99') "Total Sale" FROM employees e RIGHT JOIN orders o ON e.employee_id = o.salesman_id RIGHT JOIN order_items oi ON o.order_id = oi.order_id WHERE SUBSTR(lower(e.first_name),-1,1) <> '%y' OR o.salesman_id is null HAVING SUM(oi.quantity*oi.unit_price) > 4000000 GROUP BY e.last_name, e.first_name ORDER BY 2 DESC; --QUESTION 4 SELECT c.customer_id "CustId", c.name "Name", NVL(o.TotalOrderCust, 0) "Total Orders" FROM customers c FULL OUTER JOIN (SELECT customer_id, COUNT(*) AS TotalOrderCust FROM orders GROUP BY customer_id)o ON c.customer_id = o.customer_id WHERE NVL(o.TotalOrderCust, 0) < 2 AND ((substr(name,1,1) = 'B' AND INSTR(substr(name,2,30), 'l') > 0) OR (substr(name,1,1) = 'L' AND INSTR(substr(name,2,30), 'b') > 0)) AND (INSTR(Name, 'Bank of New York Mellon')) = 0 ORDER BY 3, 2; -- Question 5 SELECT customer_id "Cust#", NAME "Customer Name", order_id "Order#", order_date "Order Date", SUM(quantity) "Total#",To_CHAR(SUM(unit_price * quantity), 'fm$9,999,999.00') "Total Amount", last_name "LName" FROM customers c INNER JOIN orders USING (customer_id) INNER JOIN order_items USING (order_id) INNER JOIN contacts USING (customer_id) WHERE substr(phone, 4, 3) = '319' AND last_name NOT IN ('Norris') GROUP BY customer_id, name, order_id, order_date, last_name HAVING SUM(unit_price * quantity) < 800000 ORDER BY SUM(unit_price * quantity) desc; -- Question 6 SELECT warehouse_id "Wrhs#", warehouse_name "Warehouse Name", category_id "Category#", category_name "Category Name", TO_CHAR(MIN(list_price), 'fm$9,999,999.00') "Lowest Price" FROM warehouses w INNER JOIN inventories USING (warehouse_id) INNER JOIN products USING (product_id) INNER JOIN product_categories USING (category_id) INNER JOIN locations USING (location_id) INNER JOIN countries USING (country_id) WHERE country_name LIKE 'C%' GROUP BY warehouse_id, warehouse_name, category_id, category_name HAVING MIN(list_price) < 50.00 OR MIN(list_price) > 200 ORDER BY 1, 3; -- Question 7 SELECT product_id "ProdId", category_id "Category#", product_name "Product Name", list_price "Lprice" FROM products WHERE product_id IN (SELECT product_id FROM order_items WHERE order_id IN (SELECT order_id FROM orders WHERE salesman_id IN (SELECT employee_id FROM employees WHERE UPPER(last_name) LIKE 'E%' OR UPPER(last_name) LIKE 'F%'))) AND category_id = (SELECT category_id FROM product_categories WHERE UPPER(category_name) LIKE 'VIDEO%') ORDER BY 1 ASC; -- Question 8 SELECT product_id "ProdId", product_name "Product Name", list_price "Lprice" FROM products WHERE product_id IN (SELECT product_id FROM order_items WHERE order_id IN (SELECT order_id FROM orders WHERE salesman_id IN (SELECT employee_id FROM employees WHERE SUBSTR(UPPER(last_name), 1, 1) IN ('E', 'F') AND SUBSTR(TO_CHAR(hire_date), 4,3) = 'DEC'))) AND category_id = (SELECT category_id FROM product_categories WHERE UPPER(category_name) LIKE 'VIDEO%') ORDER BY 1 ASC; -- Question 9 SELECT product_id "Product ID", product_name "Product Name", TO_CHAR(list_price, 'fm$9,999,999.00') "List Price" FROM products INNER JOIN inventories USING (product_id) WHERE list_price < ANY (SELECT MIN(standard_cost) FROM warehouses INNER JOIN locations USING (location_id) INNER JOIN countries USING (country_id) INNER JOIN regions USING (region_id) INNER JOIN inventories USING (warehouse_id) INNER JOIN products USING (product_id) WHERE UPPER(region_name) IN ('EUROPE', 'ASIA') GROUP BY warehouse_id) AND quantity > ANY (SELECT MAX(quantity) FROM inventories GROUP BY warehouse_id) ORDER BY list_price DESC;
true
0cd25ae43ebdbaa247d6a0ffc8e5b8f660e7c4af
SQL
MarcceloSelv/DBA
/Análise DVM por Hash.sql
UTF-8
2,115
4.03125
4
[]
no_license
SELECT TOP 10 query_hash, query_plan_hash, cached_plan_object_count, execution_count, total_cpu_time_ms, total_elapsed_time_ms, total_logical_reads, total_logical_writes, total_physical_reads, sample_database_name, sample_object_name, sample_statement_text FROM ( SELECT query_hash, query_plan_hash, COUNT (*) AS cached_plan_object_count, MAX (plan_handle) AS sample_plan_handle, SUM (execution_count) AS execution_count, SUM (total_worker_time)/1000 AS total_cpu_time_ms, SUM (total_elapsed_time)/1000 AS total_elapsed_time_ms, SUM (total_logical_reads) AS total_logical_reads, SUM (total_logical_writes) AS total_logical_writes, SUM (total_physical_reads) AS total_physical_reads FROM sys.dm_exec_query_stats GROUP BY query_hash, query_plan_hash ) AS plan_hash_stats CROSS APPLY ( SELECT --TOP 1 qs.sql_handle AS sample_sql_handle, qs.statement_start_offset AS sample_statement_start_offset, qs.statement_end_offset AS sample_statement_end_offset, CASE WHEN [database_id].value = 32768 THEN 'ResourceDb' ELSE DB_NAME (CONVERT (int, [database_id].value)) END AS sample_database_name, OBJECT_NAME (CONVERT (int, [object_id].value), CONVERT (int, [database_id].value)) AS sample_object_name, t.StatementTextXml AS sample_statement_text FROM sys.dm_exec_sql_text(plan_hash_stats.sample_plan_handle) AS sql INNER JOIN sys.dm_exec_query_stats AS qs ON qs.plan_handle = plan_hash_stats.sample_plan_handle CROSS APPLY dbo.FN_Get_Statement_Text(qs.statement_start_offset, qs.statement_end_offset, sql.[text]) t CROSS APPLY sys.dm_exec_plan_attributes (plan_hash_stats.sample_plan_handle) AS [object_id] CROSS APPLY sys.dm_exec_plan_attributes (plan_hash_stats.sample_plan_handle) AS [database_id] WHERE [object_id].attribute = 'objectid' AND [database_id].attribute = 'dbid' ) AS sample_query_text ORDER BY total_logical_reads / execution_count DESC;
true
82ca30c0b75f61af2d25a932c9d7242f3f4063f1
SQL
griffy/cs1555
/myauction/queries/listOngoing.sql
UTF-8
150
3.171875
3
[]
no_license
select product.auction_id from customer join product on customer.login = product.seller where customer.login = ? and product.status = 'underauction'
true
3adee5a2830282c2367e34003ab1d04558dde6db
SQL
umbrielbellani/materiasipm.github.io
/bases/barrios.sql
UTF-8
5,833
2.6875
3
[]
no_license
USE examen; CREATE TABLE barrios ( id INT NOT NULL PRIMARY KEY, nombre VARCHAR(50) NOT NULL, nro_comuna INT NOT NULL, perimetro VARCHAR(50) NOT NULL, area VARCHAR(50) NOT NULL ); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (0,'CHACARITA',15,'7724.85295457','3115707.10627'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (1,'PATERNAL',15,'7087.51329533','2229829.03363'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (2,'VILLA CRESPO',15,'8131.85707532','3615977.55634'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (3,'VILLA DEL PARQUE',11,'7705.38979708','3399595.6414799998'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (4,'ALMAGRO',5,'8537.90136849','4050752.24524'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (5,'CABALLITO',6,'10990.9644715','6851028.91357'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (6,'VILLA SANTA RITA',11,'5757.75233471','2153690.81329'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (7,'MONTE CASTRO',10,'7361.03641755','2627481.32508'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (8,'VILLA REAL',10,'5070.96565244','1334146.08283'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (9,'FLORES',7,'15772.4395096','8590784.13129'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (10,'FLORESTA',10,'7519.6540918','2320640.73551'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (11,'CONSTITUCION',1,'6326.84137473','2101994.9981299997'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (12,'SAN CRISTOBAL',3,'5987.22647879','2043711.12166'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (13,'BOEDO',5,'6602.51026593','2609850.87921'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (14,'VELEZ SARSFIELD',10,'7045.57833172','2400518.32602'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (15,'VILLA LURO',10,'8652.93003127','2566936.8725099997'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (16,'PARQUE PATRICIOS',4,'7878.43499311','3743439.99645'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (17,'MATADEROS',9,'11124.6357921','7398178.84035'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (18,'VILLA LUGANO',8,'15057.468389399999','9296142.3614'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (19,'SAN TELMO',1,'5178.03283928','1232270.1587399999'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (20,'SAAVEDRA',12,'11132.1393456','5538676.83282'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (21,'COGHLAN',12,'4627.56313138','1279951.37256'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (22,'VILLA URQUIZA',12,'10021.459664799999','5449058.92285'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (23,'COLEGIALES',13,'6374.61904507','2289774.10428'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (24,'BALVANERA',3,'8375.82181081','4342280.26804'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (25,'VILLA GRAL. MITRE',11,'6290.44056056','2162275.11535'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (26,'PARQUE CHAS',15,'4531.25339628','1385411.5137399998'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (27,'AGRONOMIA',15,'6556.16777187','2122169.34212'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (28,'VILLA ORTUZAR',15,'5684.99521114','1853802.05203'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (29,'BARRACAS',4,'12789.791771200002','7953453.43143'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (30,'PARQUE AVELLANEDA',9,'10165.614027700001','4732708.20931'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (31,'PARQUE CHACABUCO',7,'8406.91432075','3832116.69922'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (32,'NUEVA POMPEYA',4,'11033.5103019','4951510.87427'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (33,'PALERMO',14,'22126.5318584','15845871.287999999'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (34,'VILLA RIACHUELO',8,'10596.8267392','4232595.924790001'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (35,'VILLA SOLDATI',8,'12441.695877299999','8688163.55828'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (36,'VILLA PUEYRREDON',12,'7522.36038243','3303239.50936'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (37,'VILLA DEVOTO',11,'11562.0068','6404480.8537099995'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (38,'LINIERS',9,'9256.92732129','4374418.736769999'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (39,'VERSALLES',10,'5650.46628643','1406833.5958'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (40,'PUERTO MADERO',1,'17725.7208212','5040970.88514'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (41,'MONSERRAT',1,'6739.22231102','2198621.94089'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (42,'SAN NICOLAS',1,'6548.08475396','2289007.5825900002'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (43,'BELGRANO',13,'20609.7753969','7999239.813839999'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (44,'RECOLETA',2,'21452.8386478','6317264.56056'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (45,'RETIRO',1,'18837.988687','4512710.90703'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (46,'NUÑEZ',13,'10785.2610814','4424199.26509'); INSERT INTO barrios (id,nombre,nro_comuna,perimetro,area) VALUES (47,'BOCA',4,'20060.0039394','5036240.45441');
true
7776420098be2b4c163a13b1fde3381278069618
SQL
better/dbt
/test/integration/001_simple_copy_test/tests/get_relation_quoting.sql
UTF-8
414
2.984375
3
[ "Apache-2.0" ]
permissive
{%- set tgt = ref('seed') -%} {%- set got = adapter.get_relation(database=tgt.database, schema=tgt.schema, identifier=tgt.identifier) | string -%} {% set replaced = got.replace('"', '-') %} {% set expected = "-" + tgt.database.upper() + '-.-' + tgt.schema.upper() + '-.-' + tgt.identifier.upper() + '-' %} with cte as ( select '{{ replaced }}' as name ) select * from cte where name not like '{{ expected }}'
true
999aa022d98328f7e7fd85e9b25fffaf55779792
SQL
GingerGabriela/Triggers
/ejertri8.sql
UTF-8
523
3.40625
3
[]
no_license
create or replace trigger borrarAlumnos before delete on alum for each row declare nue nuevos%rowtype; ant antiguos%rowtype; begin begin select * into nue from nuevos where nombre=:old.nombre; RAISE_APPLICATION_ERROR(-20199,'El alumno existe en la tabla nuevo'); EXCEPTION when no_data_found then null; end; begin select * into ant from antiguos where nombre=:old.nombre; RAISE_APPLICATION_ERROR(-20100,'El alumno existe en la tabla Antiguo'); EXCEPTION when no_data_found then null; end; end; /
true
84d8241d9ca14cbe23da967499fc983ab140946c
SQL
Jblew/MedManual2
/medmanual2/src/Model/Table/tables2.sql
UTF-8
3,844
3.640625
4
[]
no_license
ALTER DATABASE medmanual2 CHARACTER SET utf8 COLLATE utf8_bin; CREATE TABLE users ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50), password VARCHAR(255), role VARCHAR(20), created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL, api_key VARCHAR(255), api_key_plain VARCHAR(255) ); CREATE TABLE pages ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, title VARCHAR (255) NOT NULL UNIQUE, body LONGTEXT, user_id INT NOT NULL, version_date DATETIME DEFAULT NULL ); CREATE TABLE pages_parents ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, page_id INT UNSIGNED, parent_id INT UNSIGNED ); CREATE TABLE tags ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, tag VARCHAR(255) UNIQUE NOT NULL, page_id INT UNSIGNED NOT NULL ); # Sample data # Manuał Medyczny (1) # Manuał medyczny (1) > choroby i objawy (2) # #Manuał medyczny (1) > choroby i objawy (2) > układ immunologiczny (3) # Manuał medyczny (1) > choroby i objawy (2) > Choroby genetyczne (4) # Manuał medyczny (1) > choroby i objawy (2) > Choroby genetyczne (4) > Choroby jednogenowe (5) # Manuał medyczny (1) > choroby i objawy (2) > układ immunologiczny (3) > Wrodzony niedobór IgA (6) # Manuał medyczny (1) > choroby i objawy (2) > Choroby genetyczne (4) > Choroby jednogenowe (5) > Wrodzony niedobór IgA (6) insert into pages VALUES (1, 'Manuał Medyczny', 'Zapraszam!', 1, NOW()); # insert into pages VALUES (2, 'Choroby i objawy', '', 1, NOW()); # insert into pages VALUES (3, 'Układ immunologiczny', '', 1, NOW()); # insert into pages VALUES (4, 'Choroby genetyczne', '', 1, NOW()); # insert into pages VALUES (5, 'Choroby jednogenowe', '', 1, NOW()); # insert into pages VALUES (6, 'Wrodzony niedobór IgA', '', 1, NOW()); # insert into pages VALUES (7, 'Aberracje chromosomowe', '', 1, NOW()); # insert into pages VALUES (8, 'Zespół Patau', '', 1, NOW()); # insert into pages_parents (page_id, parent_id) VALUES (2, 1); # insert into pages_parents (page_id, parent_id) VALUES (3, 2); # insert into pages_parents (page_id, parent_id) VALUES (4, 2); # insert into pages_parents (page_id, parent_id) VALUES (5, 4); # insert into pages_parents (page_id, parent_id) VALUES (6, 3); # insert into pages_parents (page_id, parent_id) VALUES (6, 5); # insert into pages_parents (page_id, parent_id) VALUES (7, 4); # insert into pages_parents (page_id, parent_id) VALUES (8, 7); # Teraz chcę zdobyć ścieżki do (6). DROP PROCEDURE IF EXISTS get_paths_procedure; DELIMITER $$ CREATE PROCEDURE get_paths_procedure( IN current_page_id INT, IN children_path VARCHAR (253) ) BEGIN DECLARE my_parent_id INT; DECLARE bDone INT; DECLARE curs CURSOR FOR SELECT parent_id FROM pages_parents WHERE page_id=current_page_id; DECLARE CONTINUE HANDLER FOR NOT FOUND SET bDone = 1; IF current_page_id = 1 THEN INSERT INTO paths VALUES (CONCAT((SELECT title FROM pages WHERE id=current_page_id), '$$$', children_path)); ELSE OPEN curs; SET bDone = 0; read_loop: LOOP FETCH curs INTO my_parent_id; IF bDone THEN LEAVE read_loop; END IF; # INSERT INTO paths VALUES (my_parent_id); # INSERT INTO paths VALUES (CONCAT((SELECT title FROM pages WHERE id=parent_id), '$$$', children_path)); CALL get_paths_procedure(my_parent_id, CONCAT((SELECT title FROM pages WHERE id=current_page_id), '$$$', children_path)); END LOOP; CLOSE curs; END IF; END$$ DELIMITER ; SET @@GLOBAL.max_sp_recursion_depth = 255; SET @@session.max_sp_recursion_depth = 255; DROP TEMPORARY TABLE IF EXISTS paths; CREATE TEMPORARY TABLE paths (path VARCHAR(255)); CALL get_paths_procedure(6, ''); SELECT * FROM paths; DROP TEMPORARY TABLE IF EXISTS paths;
true
caff84a9db2515db5b1e8865c6ffeb5f4e82123f
SQL
demianbarry/web-db
/gerencia/DBScripts/OC no recibidas completas.sql
UTF-8
319
3.484375
3
[]
no_license
SELECT sum(t1.cantidad_recibida) as cantidad_recibida,t1.detalle_sc_id,t2.cantidad_pedida,t2.orden_compra_id FROM inventario.detalles_rc t1, inventario.detalle_sc t2 where t1.detalle_sc_id = t2.detalle_sc_id group by t1.detalle_sc_id,t2.cantidad_pedida,t2.orden_compra_id having cantidad_recibida < cantidad_pedida
true
6b97e00a42eb2fa27bb05824b852748ce111d4bb
SQL
maduhu/MARLO-CIAT
/marlo-ciat/marlo-ciat-web/src/main/resources/database/migrations/V1_0_0_20161123_0950__LocElementType.sql
UTF-8
3,566
2.875
3
[]
no_license
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for loc_element_types -- ---------------------------- DROP TABLE IF EXISTS `loc_element_types`; CREATE TABLE `loc_element_types` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(245) DEFAULT NULL, `parent_id` bigint(20) DEFAULT NULL, `crp_id` bigint(20) DEFAULT NULL, `has_coordinates` tinyint(1) DEFAULT NULL, `is_active` tinyint(1) NOT NULL, `created_by` bigint(20) DEFAULT NULL, `active_since` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified_by` bigint(20) NOT NULL, `modification_justification` text NOT NULL, `is_scope` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `FK_loc_element_type_parent_idx` (`parent_id`) USING BTREE, KEY `fk_crp_id_loc_element_type` (`crp_id`) USING BTREE, KEY `fk_loc_element_types_created_by_users_id` (`created_by`) USING BTREE, KEY `fk_loc_element_types_modified_by_users_id` (`modified_by`) USING BTREE, CONSTRAINT `loc_element_types_ibfk_1` FOREIGN KEY (`crp_id`) REFERENCES `crps` (`id`), CONSTRAINT `loc_element_types_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`), CONSTRAINT `loc_element_types_ibfk_3` FOREIGN KEY (`modified_by`) REFERENCES `users` (`id`), CONSTRAINT `loc_element_types_ibfk_4` FOREIGN KEY (`parent_id`) REFERENCES `loc_element_types` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of loc_element_types -- ---------------------------- INSERT INTO `loc_element_types` VALUES ('1', 'Region', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('2', 'Country', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('3', 'Province', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('4', 'District', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('5', 'Ward', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('6', 'Permanent agricultural trial site', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('7', 'River Basin', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('8', 'Village', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('9', 'Household', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('10', 'Climate smart village', null, '1', '1', '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('11', 'CCAFS Site', null, '1', '1', '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('12', 'Continent', null, null, null, '1', null, '2016-06-27 11:57:16', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('13', 'PIM Sites', null, '3', '0', '0', '1', '2016-06-27 13:33:41', '1', '', '0'); INSERT INTO `loc_element_types` VALUES ('14', 'Country', null, '7', '0', '1', '1087', '2016-08-11 06:30:36', '1087', '', '0'); INSERT INTO `loc_element_types` VALUES ('15', '', null, '1', '0', '1', '1106', '2016-08-30 11:28:33', '1106', '', '0'); INSERT INTO `loc_element_types` VALUES ('16', 'asd', null, '1', '0', '0', '1106', '2016-08-30 11:28:44', '1106', '', '0');
true