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
856e7ac25086397d6bdf8fbea881c3aa7168d790
SQL
SocialGouv/reva
/packages/reva-api/prisma/migrations/20220901123131_uniform_organism_fields/migration.sql
UTF-8
442
2.9375
3
[ "Apache-2.0" ]
permissive
-- DropIndex DROP INDEX "organism_contact_administratif_key"; -- Rename old columns and default ALTER TABLE "organism" RENAME COLUMN "adress" TO "address"; ALTER TABLE "organism" RENAME COLUMN "contact_administratif" TO "contact_administrative_email"; ALTER TABLE "organism" RENAME COLUMN "cp" TO "zip"; -- CreateIndex CREATE UNIQUE INDEX "organism_contact_administrative_email_key" ON "organism"("contact_administrative_email");
true
360e69f2b900e8ca2b1bd56e03e9607fb541b6de
SQL
martinschmitz77/Compustat
/MSSQL/CSTAT_Changes_To_Cash_Flow_Working_Capital_Changes_For_FASB_95_In_XF.sql
UTF-8
2,166
3.546875
4
[]
no_license
/*********************************************************************************************** Returns Changes To Cash Flow Working Capital Changes For FASB 95 Packages Required: Core Core 2 Core History Core Prelim Standardized Universal Identifiers: GVKEY Primary Columns Used: consol datadate datafmt gvkey indfmt popsrc Database_Type: MSSQL Query_Version: V1 Query_Added_Date: 01/07/2020 DatasetKey: 8 This query returns the components of the Working Capital changes on the Cash Flow Statement for a company using the Compustat data in Xpressfeed ***********************************************************************************************/ SELECT c.conml , ca.curcd , ca.gvkey , ca.datadate , ca.datafmt , ca.scf , ca.compst , caf1.ap , caf2.xacc , caf1.apalch , cadc1.apalch_dc , caf1.invt , caf1.invch , cadc1.invch_dc , caf2.rectr , caf2.recco , caf2.recch , cadc2.recch_dc , cf2.ib_fn FROM co_adesind ca JOIN co_afnd1 caf1 ON ca.gvkey = caf1.gvkey AND ca.datadate = caf1.datadate AND ca.indfmt = caf1.indfmt AND ca.datafmt = caf1.datafmt AND ca.popsrc = caf1.popsrc AND ca.consol = caf1.consol JOIN co_afnd2 caf2 ON ca.gvkey = caf2.gvkey AND ca.datadate = caf2.datadate AND ca.indfmt = caf2.indfmt AND ca.datafmt = caf2.datafmt AND ca.popsrc = caf2.popsrc AND ca.consol = caf2.consol JOIN co_afnddc1 cadc1 ON ca.gvkey = cadc1.gvkey AND ca.datadate = cadc1.datadate AND ca.indfmt = cadc1.indfmt AND ca.datafmt = cadc1.datafmt AND ca.popsrc = cadc1.popsrc AND ca.consol = cadc1.consol JOIN co_afnddc2 cadc2 ON ca.gvkey = cadc2.gvkey AND ca.datadate = cadc2.datadate AND ca.indfmt = cadc2.indfmt AND ca.datafmt = cadc2.datafmt AND ca.popsrc = cadc2.popsrc AND ca.consol = cadc2.consol JOIN company c ON c.gvkey = ca.gvkey JOIN co_afntind1 cf2 ON ca.gvkey = cf2.gvkey AND ca.datadate = cf2.datadate AND ca.indfmt = cf2.indfmt AND ca.datafmt = cf2.datafmt AND ca.popsrc = cf2.popsrc AND ca.consol = cf2.consol WHERE 1 = 1 -- AND ca.gvkey IN ( '024616' , '170617' , '008762' ) AND ca.popsrc = 'D'-- AND ca.datadate = '12/31/2016'----AND ca.gvkey = 001010 --Company Identifier AND ca.datafmt = 'STD' ORDER BY ca.datadate DESC
true
5f7990e719093c3878da26857c42a04fd5259b4b
SQL
insanexx/sportsvolunteer
/sql/enterprise.sql
UTF-8
411
2.671875
3
[]
no_license
use sportsvolunteer; CREATE TABLE IF NOT EXISTS `enterprise` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(30) NOT NULL, `password` varchar(30) NOT NULL, `enterpriseName` varchar(50) NOT NULL, `address` varchar(100) DEFAULT NULL, `phonenumber` varchar(20) DEFAULT NULL, `business` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`) );
true
682f60367a9f84b9a034fed4ac05578e88fddf12
SQL
arman1507/Penjadwalan-Desa-Dengan-Framework-Yii
/db desa/desa.sql
UTF-8
1,549
3
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.5.1 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Nov 05, 2018 at 06:58 AM -- Server version: 10.1.9-MariaDB -- PHP Version: 7.0.1 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `desa` -- -- -------------------------------------------------------- -- -- Table structure for table `jadwal` -- CREATE TABLE `jadwal` ( `id_jadwal` int(20) NOT NULL, `Tempat` varchar(25) NOT NULL, `Tanggal` date NOT NULL, `Info` varchar(500) NOT NULL, `Jenis_Kegiatan` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `jadwal` -- INSERT INTO `jadwal` (`id_jadwal`, `Tempat`, `Tanggal`, `Info`, `Jenis_Kegiatan`) VALUES (1, 'Jakarta', '2019-10-10', 'tonggos', 'K.Pembinaan Desa'); -- -- Indexes for dumped tables -- -- -- Indexes for table `jadwal` -- ALTER TABLE `jadwal` ADD PRIMARY KEY (`id_jadwal`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `jadwal` -- ALTER TABLE `jadwal` MODIFY `id_jadwal` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
67b58e82be9f357ac1374c4f3b34aa47ac320fcd
SQL
inventorsoft-academy/educational-journal
/backend/src/main/resources/db.sql
UTF-8
531
3.75
4
[]
no_license
# CREATE DATABASE Journal; CREATE TABLE STUDENTS ( `id` SERIAL, `firstname` VARCHAR(45) NOT NULL, `lastname` VARCHAR(45) NOT NULL, `birthday` DATE NOT NULL, `group` INT NOT NULL, PRIMARY KEY (`id`)); CREATE TABLE MARKS( id SERIAL, student_id INT , subject_id INT , mark INT , FOREIGN KEY (student_id) REFERENCES student(idstudent), FOREIGN KEY (subject_id) REFERENCES subject(idsubject), PRIMARY KEY (id) ); CREATE TABLE SUBJECTS ( id SERIAL, nameofsubject VARCHAR(45) NOT NULL, PRIMARY KEY (`id`));
true
c3412884f2ed191d52b5564b881cd19c3da847a0
SQL
cnobile2012/dcolumn
/db/create_schema.ddl
UTF-8
592
3.21875
3
[ "MIT" ]
permissive
/* * $ sudo -u postgres psql template1 -f db/create_schema.ddl */ DROP DATABASE IF EXISTS dcolumn; CREATE DATABASE dcolumn; DO $body$ BEGIN IF NOT EXISTS (SELECT * FROM pg_catalog.pg_user WHERE pg_user.usename = 'dcolumn') THEN CREATE USER dcolumn WITH PASSWORD 'dcolumn'; ALTER USER dcolumn CREATEDB; END IF; END $body$; BEGIN; GRANT ALL PRIVILEGES ON DATABASE dcolumn TO dcolumn; ALTER ROLE dcolumn SET client_encoding TO 'utf8'; ALTER ROLE dcolumn SET default_transaction_isolation TO 'read committed'; ALTER ROLE dcolumn SET timezone TO 'UTC'; COMMIT;
true
c361dc4cabf6471c3bd0266f1ba47bb96d6b6906
SQL
alexa984/python101
/week9/ships_2.sql
UTF-8
154
2.703125
3
[]
no_license
--task2-- SELECT NAME, country, numguns, launched FROM classes LEFT JOIN ships ON ships.class = classes.class
true
ab06e2b290b567286dfb02b75937cd1bd1b2976c
SQL
wxmfsq/test
/eds-core/src/main/resources/META-INF/com/founder/eds/dao/ExternalDataDao/selectDataSource.sql
UTF-8
906
3.28125
3
[]
no_license
select d.data_source_sn dataSourceSn,d.connection_name connectionName,d.database_type databaseType,d.connection_url connectionUrl,"user" , d.password passWord from data_source d where d.delete_flag='0' /*%if null !=cond.connectionName && ! cond.connectionName.isEmpty() */ and d.connection_name like '%' || /*cond.connectionName*/'' || '%' /*%end*/ /*%if null !=cond.databaseType && ! cond.databaseType.isEmpty() */ and d.database_type like '%' || /*cond.databaseType*/'' || '%' /*%end*/ /*%if null !=cond.connectionUrl && ! cond.connectionUrl.isEmpty() */ and d.connection_url like '%' || /*cond.connectionUrl*/'' || '%' /*%end*/ /*%if null !=cond.user && ! cond.user.isEmpty() */ and "user" like '%' || /*cond.user*/'' || '%' /*%end*/ /*%if null !=cond.passWord && ! cond.passWord.isEmpty() */ and d.password like '%' || /*cond.passWord*/'' || '%' /*%end*/ order by d.connection_name asc
true
bcf60a1b41531d885d804e8fc2fb7cbde141630e
SQL
luizeo/JavaJDBCCourse
/dbcclientes(1).sql
UTF-8
3,768
3.15625
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.8.5 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Tempo de geração: 21/01/2020 às 15:00 -- Versão do servidor: 8.0.13 -- Versão do PHP: 7.3.2 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: `dbcclientes` -- -- -------------------------------------------------------- -- -- Estrutura para tabela `cliente` -- CREATE TABLE `cliente` ( `cli_cod` int(11) NOT NULL, `cli_nome` varchar(100) DEFAULT NULL, `cli_cpf` varchar(20) DEFAULT NULL, `cli_dt_nasc` date DEFAULT NULL, `cli_sexo` varchar(1) DEFAULT NULL, `cli_fone` varchar(20) DEFAULT NULL, `cli_endereco` varchar(50) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -- Despejando dados para a tabela `cliente` -- INSERT INTO `cliente` (`cli_cod`, `cli_nome`, `cli_cpf`, `cli_dt_nasc`, `cli_sexo`, `cli_fone`, `cli_endereco`) VALUES (2, 'José Faria', '030303003030', '2019-09-11', 'M', '6190909090909', 'Av. Rio'), (3, 'Ana Maria', '03030303003', '1999-07-31', 'F', '6190909090909', 'Av. Brasil'), (12, 'Hanna Gabriela Costa', '288390', '2003-04-28', 'F', '619866776676', 'Av. Brasil'), (13, 'Luiz Carlos da Silva', '02093090089', '1990-09-19', 'M', '7198775166', 'Largo de Roma, 89890'), (14, 'Maria Cristina de Almeida', '02594090056', '1995-07-13', 'F', '7132452500', 'Av. Sete de Setembro'), (15, 'Pedro Paulo Diniz de Azevedo', '02694050689', '1989-11-10', 'M', '1134567890', 'Bairro Jardins, São Paulo'), (16, 'Valquiria Michelsen', '07093030089', '1982-10-10', 'F', '61993456789', 'SQS 214, Asa Sul'), (17, 'Humberto Eco', '025913080089', '1945-11-19', 'M', '113234549039', 'Av. Rebouças, Centro, São Paulo'), (19, 'Ludimila Rincon', '8887776666', '1978-12-05', 'F', '61987766655', 'Av. Rio de Janeiro'); -- -------------------------------------------------------- -- -- Estrutura para tabela `login` -- CREATE TABLE `login` ( `log_seq` int(11) NOT NULL, `log_nome` varchar(30) DEFAULT NULL, `log_senha` varchar(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -- Despejando dados para a tabela `login` -- INSERT INTO `login` (`log_seq`, `log_nome`, `log_senha`) VALUES (1, 'teste', 'teste'); -- -------------------------------------------------------- -- -- Estrutura para tabela `usuario` -- CREATE TABLE `usuario` ( `id` int(11) NOT NULL, `u_nome` varchar(50) NOT NULL, `u_email` varchar(50) NOT NULL, `u_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -- Despejando dados para a tabela `usuario` -- INSERT INTO `usuario` (`id`, `u_nome`, `u_email`) VALUES (1, 'Hafy', 'hafy@hotmail.com'), (2, 'Marcos', 'marcos@gmail.com'), (3, 'Luiz', 'luizeduardo.unb@gmail.com'); -- -- Índices de tabelas apagadas -- -- -- Índices de tabela `cliente` -- ALTER TABLE `cliente` ADD PRIMARY KEY (`cli_cod`); -- -- Índices de tabela `login` -- ALTER TABLE `login` ADD PRIMARY KEY (`log_seq`); -- -- Índices de tabela `usuario` -- ALTER TABLE `usuario` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT de tabelas apagadas -- -- -- AUTO_INCREMENT de tabela `cliente` -- ALTER TABLE `cliente` MODIFY `cli_cod` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20; -- -- AUTO_INCREMENT de tabela `usuario` -- ALTER TABLE `usuario` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
b2843aa8ef9abf6e3e321e0ceb621c6e37907f3e
SQL
paul-rogers/drill-test-framework
/framework/resources/Functional/drill_fragments/decimal/data/join_big_with_big_zero_prec.sql
UTF-8
493
3.09375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
SET planner.width.max_per_node=100; SET planner.slice_target=1; SET planner.enable_multiphase_agg=false; SELECT avg(decimal_big.DECIMAL_18_8), avg(decimal_big_zero_prec.DECIMAL_18_18) FROM dfs.drillTestDir.`decimal/fragments/T_DECIMAL_BIG` decimal_big JOIN dfs.drillTestDir.`decimal/fragments/T_DECIMAL_BIG_ZERO_PREC` decimal_big_zero_prec ON decimal_big.ID = decimal_big_zero_prec.ID; RESET planner.width.max_per_node; RESET planner.slice_target; RESET planner.enable_multiphase_agg;
true
55de0b7ec225b1e9c74ab3ca9f0b5e22fa92f5f8
SQL
BowenChan/cs157a
/Database Files/CreateTables.sql
UTF-8
5,359
3.46875
3
[]
no_license
-- MySQL Script generated by MySQL Workbench -- Thu Oct 22 22:49:49 2015 -- 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 theaterpro -- ----------------------------------------------------- -- ----------------------------------------------------- -- Schema theaterpro -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `theaterpro` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; USE `theaterpro` ; -- ----------------------------------------------------- -- Table `theaterpro`.`user` -- ----------------------------------------------------- DROP TABLE IF EXISTS `theaterpro`.`user` ; CREATE TABLE IF NOT EXISTS `theaterpro`.`user` ( `UserID` INT NOT NULL AUTO_INCREMENT, `FirstName` VARCHAR(40) NULL, `LastName` VARCHAR(40) NULL, `Email` VARCHAR(100) NULL, `isAdmin` TINYINT(1) NOT NULL, PRIMARY KEY (`UserID`) , UNIQUE INDEX `UserID_UNIQUE` (`UserID` ASC));h -- ----------------------------------------------------- -- Table `theaterpro`.`screen` -- ----------------------------------------------------- DROP TABLE IF EXISTS `theaterpro`.`screen` ; CREATE TABLE IF NOT EXISTS `theaterpro`.`screen` ( `ScreenID` INT NOT NULL AUTO_INCREMENT, `Size` INT NULL, `IMAX` TINYINT(1) NULL, `3D` TINYINT(1) NULL, `XD` TINYINT(1) NULL, `DBOX` TINYINT(1) NULL, PRIMARY KEY (`ScreenID`) , UNIQUE INDEX `ScreenID_UNIQUE` (`ScreenID` ASC)) ; -- ----------------------------------------------------- -- Table `theaterpro`.`friend` -- ----------------------------------------------------- DROP TABLE IF EXISTS `theaterpro`.`friend` ; CREATE TABLE IF NOT EXISTS `theaterpro`.`friend` ( `UserID` INT NULL, `FriendID` INT NULL, INDEX `UserID_idx` (`UserID` ASC), INDEX `FriendID_idx` (`FriendID` ASC), CONSTRAINT `UserID` FOREIGN KEY (`UserID`) REFERENCES `theaterpro`.`user` (`UserID`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `FriendID` FOREIGN KEY (`FriendID`) REFERENCES `theaterpro`.`user` (`UserID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ; -- ----------------------------------------------------- -- Table `theaterpro`.`showing` -- ----------------------------------------------------- DROP TABLE IF EXISTS `theaterpro`.`showing` ; CREATE TABLE IF NOT EXISTS `theaterpro`.`showing` ( `ShowingID` INT NOT NULL AUTO_INCREMENT, `ScreenID` INT NULL, `imdbID` VARCHAR(45) NULL, `Timestamp` DATETIME NULL, PRIMARY KEY (`ShowingID`) , UNIQUE INDEX `showingID_UNIQUE` (`ShowingID` ASC) , INDEX `ScreenID_idx` (`ScreenID` ASC) , CONSTRAINT `ScreenID` FOREIGN KEY (`ScreenID`) REFERENCES `theaterpro`.`screen` (`ScreenID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ; -- ----------------------------------------------------- -- Table `theaterpro`.`ticket` -- ----------------------------------------------------- DROP TABLE IF EXISTS `theaterpro`.`ticket` ; CREATE TABLE IF NOT EXISTS `theaterpro`.`ticket` ( `UserID` INT NULL, `ShowingID` INT NULL, INDEX `UserID_idx` (`UserID` ASC) , INDEX `ShowingID_idx` (`ShowingID` ASC) , CONSTRAINT `TicketHolderID` FOREIGN KEY (`UserID`) REFERENCES `theaterpro`.`user` (`UserID`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `ShowingID` FOREIGN KEY (`ShowingID`) REFERENCES `theaterpro`.`showing` (`ShowingID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ; -- ----------------------------------------------------- -- Table `theaterpro`.`auth` -- ----------------------------------------------------- DROP TABLE IF EXISTS `theaterpro`.`auth` ; CREATE TABLE IF NOT EXISTS `theaterpro`.`auth` ( `UserID` INT NOT NULL, `hPassword` VARCHAR(128) NULL, INDEX `UserID_idx` (`UserID` ASC) , CONSTRAINT `AuthID` FOREIGN KEY (`UserID`) REFERENCES `theaterpro`.`user` (`UserID`) ON DELETE NO ACTION ON UPDATE NO ACTION) ; -- ----------------------------------------------------- -- View friendView -- ----------------------------------------------------- DROP VIEW IF EXISTS `theaterpro`.`friendView`; CREATE VIEW friendView AS SELECT friend.UserID, user.UserID AS FriendID, user.FirstName, user.LastName, user.Email FROM friend, user WHERE friendID = user.UserID ORDER BY user.LastName ASC, user.FirstName ASC ; -- ----------------------------------------------------- -- Trigger deleteFriendTrigger -- ----------------------------------------------------- DROP TRIGGER IF EXISTS deleteFriendTrigger; DELIMITER // CREATE TRIGGER deleteFriendTrigger BEFORE DELETE ON user FOR EACH ROW BEGIN DELETE FROM friend WHERE old.UserID = UserID; DELETE FROM friend WHERE old.UserID = FriendID; END // DELIMITER ; -- ----------------------------------------------------- -- Procedure getAllUsers() -- ----------------------------------------------------- DROP PROCEDURE IF EXISTS getAllUsers; DELIMITER // CREATE PROCEDURE getAllUsers () BEGIN SELECT * FROM user; END // DELIMITER ; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
true
0bf91b3ea16b9eb1242b73276ecd99845e642caf
SQL
robin253/doc
/oracle/sqls/alter table move.sql
GB18030
3,176
4.09375
4
[]
no_license
OracleƶCLOBռ ο http://www.cnblogs.com/Cratical/archive/2010/08/24/1806948.html http://www.itpub.net/thread-1402010-1-1.html -- compress --ˮλºϲƬƶˮλ alter table xxx move; --ˮλºϲƬƶˮλ, ͬʱѹ alter table xxx move compress for all operations; -- shrink -- 1ܶclusterclustered table κLONGеĶʹ 2ѹβ֧кλͼı 3䲻ѹӳʹCASCADE 4ܶѹʹø 5ѹon commit ͵ﻯͼrowidﻯͼѹ֮ؽ -- ƶ alter table xxx enable row movement; --ˮλºϲƬ͸ˮλҲҪһ alter table xxx shrink space cascade; -- Oracleƶռ䣺 alter table tb_name move tablespace tbs_name; --ƶlobֶ: alter table tb_name move tablespace tbs_name lob (col_lob1,col_lob2) store as(tablesapce tbs_name); -- moveͨڲõʧЧIJУִõΨһ -- ʱõʧЧִʧܣǿԼȱʡֵȲʧЧ -- Ҫ´﷨Ϊ alter index index_name rebuild; alter index pk_name rebuild; --Ҫmoveʹrebuild﷨ alter index index_name rebuild tablespace tbs_name; alter index pk_name rebuild tablespace tbs_name; --moveͨһʧЧĽ﷨ѡ --﷨رע⣬ǵʹùؼPARTITIONǶ༶ʹSUBPARTITIONPARTITION --Ƚϴ󣬿ʹòmoverebuildPARALLEL (DEGREE 2);磺 ALTER TABLE PART_ALARMTEXTDATA move SUBPARTITION ALARMTEXTDATA_050910_ATD01 TABLESPACE users PARALLEL (DEGREE 2); ALTER INDEX GLOBAL_ALARMTEXTDATA REBUILD tablespace users PARALLEL (DEGREE 2); ALTER INDEX LOCAL_ALARMTEXTDATA REBUILD SUBPARTITION ALARMTEXTDATA_050910_ATD01 TABLESPACE users PARALLEL (DEGREE 2); --ƶij ALTER TABLE tab_name move PARTITION partition_name TABLESPACE tbs_name; --ؽȫ ALTER INDEX global_index REBUILD; ALTER INDEX global_index REBUILD tablespace tbs_name; ע: ʱԴwith update global indexesѡȫ -- ؽֲ ALTER TABLE tab_name MODIFY PARTITION partition_name REBUILD UNUSABLE LOCAL INDEXES; ALTER INDEX local_index_name REBUILD PARTITION partition_name TABLESPACE tbs_name; ʾ USER_PART_TABLES USER_IND_PARTITIONS USER_IND_SUBPARTITIONS USER_LOB_PARTITIONS USER_LOB_SUBPARTITIONS USER_PART_INDEXES USER_PART_LOBSɲѯݣͬʱҲsegmentҲdba_segmentsĵ
true
d0d2b15f1fc96ed2155b90ff2fe28db0ce8ebf9a
SQL
dalphaaabdourahamane/Pomme
/src/SQLDATA/postgres_public_bureauvote.sql
UTF-8
1,150
3.34375
3
[]
no_license
-- Table: public.bureauvote -- DROP TABLE public.bureauvote; CREATE TABLE public.bureauvote ( bid integer NOT NULL, nom character varying(25) NOT NULL, cp integer, rue character varying(55), vid integer NOT NULL, CONSTRAINT bureauvote_bid_vid_pk PRIMARY KEY (bid, vid), CONSTRAINT fkkh460go2jgyqa7f83i3j8x38r FOREIGN KEY (vid) REFERENCES public.ville (vid) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ) WITH ( OIDS=FALSE ); ALTER TABLE public.bureauvote OWNER TO postgres; INSERT INTO public.bureauvote (bid, nom, cp, rue, vid) VALUES (7, 'alpha bur', 92210, 'king alpha', 1); INSERT INTO public.bureauvote (bid, nom, cp, rue, vid) VALUES (7, 'beta ', 92190, 'saint beta', 2); INSERT INTO public.bureauvote (bid, nom, cp, rue, vid) VALUES (7, 'alpha bur', 92210, 'king alpha', 3); INSERT INTO public.bureauvote (bid, nom, cp, rue, vid) VALUES (6, 'Alpha Pres', 92110, 'king alpha Pres', 28); INSERT INTO public.bureauvote (bid, nom, cp, rue, vid) VALUES (7, 'Alpha delta', 92110, 'king alpha delta', 28); INSERT INTO public.bureauvote (bid, nom, cp, rue, vid) VALUES (7, 'Alpha delta', 92110, 'king alpha delta', 4);
true
9ef72a50162d32dc18c58fc19020f616b9bab891
SQL
THavart/Computer-Engineering-Technology
/Database/Database Systems/Labs/Week 5/DBP-e13-IM-CH02-MSSQL-MI-Create-Tables.sql
UTF-8
1,728
3.6875
4
[]
no_license
/********************************************************************************/ /* */ /* Kroenke and Auer - Database Processing (13th Edition) Chapter 02 */ /* */ /* Morgan Importing [MI-CH02] Project Create Tables */ /* */ /* Microsoft SQL Server 2008 R2 / 2012 code solutions */ /* */ /********************************************************************************/ CREATE TABLE ITEM ( ItemID Int NOT NULL IDENTITY (1,1), [Description] VarChar(255) NOT NULL, PurchaseDate Date NOT NULL, Store Char(50) NOT NULL, City Char(35) NOT NULL, Quantity Int NOT NULL, LocalCurrencyAmount Numeric(18,2) NOT NULL, ExchangeRate Numeric(12,6) NOT NULL, CONSTRAINT Purchase_Item_PK PRIMARY KEY (ItemID), ); CREATE TABLE SHIPMENT ( ShipmentID Int NOT NULL IDENTITY (1,1), ShipperName Char(35) NOT NULL, ShipperInvoiceNumber Int NOT NULL, DepartureDate Date NULL, ArrivalDate Date NULL, InsuredValue Numeric(12,2) NOT NULL, CONSTRAINT Shipment_PK PRIMARY KEY (ShipmentID) ); CREATE TABLE SHIPMENT_ITEM ( ShipmentID Int NOT NULL, ShipmentItemID Int NOT NULL, ItemID Int NOT NULL, Value Numeric(12,2) NOT NULL, CONSTRAINT ShipmentItem_PK PRIMARY KEY(ShipmentID, ShipmentItemID), CONSTRAINT Ship_Item_Ship_FK FOREIGN KEY(ShipmentID) REFERENCES SHIPMENT(ShipmentID) ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT Ship_Item_Item_FK FOREIGN KEY(ItemID) REFERENCES ITEM(ItemID) ON UPDATE NO ACTION ON DELETE CASCADE ); /********************************************************************************/
true
a2739ff78cd8deb1153d11c07ad364a29ff61095
SQL
siddeshshewde/Competitive_Programming_v2
/SQLBolt/SQL Lesson 02 - Queries with constraints (Pt. 1).sql
UTF-8
586
3.875
4
[]
no_license
/* Name: SQL Lesson 3: Queries with constraints (Pt. 1) Link: https://sqlbolt.com/lesson/select_queries_with_constraints */ 1. Find the movie with a row id of 6 ✓ SELECT title FROM movies WHERE id = 6; 2. Find the movies released in the years between 2000 and 2010 ✓ SELECT title FROM movies WHERE year between 2000 and 2010; 3. Find the movies not released in the years between 2000 and 2010 ✓ SELECT title FROM movies WHERE year not between 2000 and 2010; 4. Find the first 5 Pixar movies and their release year ✓ SELECT title, year FROM movies LIMIT 5;
true
3cab5f48a7e381ed6b42a48d7225e6cb36cce5e1
SQL
janwaraus/DES_PrgWin
/ZL/MySQL procedures/get_deposit_invoicing_by_vs.sql
UTF-8
2,081
4.40625
4
[]
no_license
-- kompletní select s plnou granularitou až na billing_itemy pro všechny zákazníky -- obdoba ZLView jak měl táta (složený ještě z dvou dalších views) -- ct.tag_id = 4 znaměná "platba předem jinak" DELIMITER // CREATE PROCEDURE get_deposit_invoicing_by_vs( IN in_active_date date, IN in_bb_date date, IN in_variable_symbol VARCHAR(255) ) BEGIN SELECT co.customer_id, bb.contract_id, bi.billing_batch_id, bi.id AS billing_item_id, co.customer_id AS co_customer_id , co.`number` AS co_number, co.`type` AS co_type, co.tariff_id AS co_tariff_id, co.invoice AS co_invoice, co.activated_at AS co_activated_at, co.canceled_at AS co_canceled_at, co.invoice_from AS co_invoice_from, co.ctu_category AS co_ctu_category, bb.period AS bb_period, bi.description AS bi_description, bi.price AS bi_price, bi.tariff AS bi_is_tariff, bi.vat_id AS bi_vat_id, cu.variable_symbol AS cu_variable_symbol, cu.postal_mail AS cu_postal_mail, cu.abra_code AS cu_abra_code, cu.disable_mailings AS cu_disable_mailings, cb1.name AS cu_invoice_sending_method_name, cb2.name AS bi_vat_name FROM ( SELECT id, contract_id, period FROM billing_batches b1 WHERE from_date = ( SELECT MAX(from_date) FROM billing_batches b2 WHERE b2.from_date <= in_bb_date AND b1.contract_id = b2.contract_id ) ) AS bb JOIN billing_items bi ON bi.billing_batch_id = bb.id JOIN contracts co ON co.id = bb.contract_id JOIN customers cu ON cu.id = co.customer_id LEFT JOIN codebooks cb1 ON cu.invoice_sending_method_id = cb1.id LEFT JOIN codebooks cb2 ON bi.vat_id = cb2.id WHERE bb.period > 1 AND co.invoice = 1 AND (co.invoice_from IS NULL OR co.invoice_from <= in_active_date) AND co.activated_at <= in_active_date AND NOT EXISTS (SELECT ct.contract_id FROM contracts_tags ct WHERE ct.contract_id = co.id AND ct.tag_id = 4) AND cu.variable_symbol = in_variable_symbol ORDER BY co.`number`, bi.tariff DESC; END // DELIMITER ; CALL get_deposit_invoicing_by_vs('2023-05-01','2023-05-31','20020027') drop procedure get_deposit_invoicing_by_vs
true
c634689c20b5b5c36562e7d4b01b59b5d92e9b5b
SQL
krasova/part_management_system
/database/schema/create_schema.sql
UTF-8
10,160
3.359375
3
[]
no_license
-- MySQL Script generated by MySQL Workbench -- 11/17/14 22:34:59 -- 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 PARTADMIN -- ----------------------------------------------------- -- ----------------------------------------------------- -- Schema PARTADMIN -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `PARTADMIN` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; USE `PARTADMIN` ; -- ----------------------------------------------------- -- Table `PARTADMIN`.`SUPPLIER` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`SUPPLIER` ( `id` INT NOT NULL, `supplier_name` VARCHAR(45) NOT NULL, `supplier_email` VARCHAR(45) NULL, `supplier_phone` VARCHAR(45) NULL, `supplier_cell_phone` VARCHAR(45) NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `PARTADMIN`.`PART_TYPE` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`PART_TYPE` ( `id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`)); -- ----------------------------------------------------- -- Table `PARTADMIN`.`MANUFACTURER` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`MANUFACTURER` ( `id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`)); -- ----------------------------------------------------- -- Table `PARTADMIN`.`PART` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`PART` ( `id` INT NOT NULL, `part_number` VARCHAR(255) NOT NULL, `MANUFACTURER_id` INT NOT NULL, `order_overage` INT NULL, PRIMARY KEY (`id`), INDEX `fk_PART_MANUFACTURER1_idx` (`MANUFACTURER_id` ASC), CONSTRAINT `fk_PART_MANUFACTURER1` FOREIGN KEY (`MANUFACTURER_id`) REFERENCES `PARTADMIN`.`MANUFACTURER` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`ITEM` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`ITEM` ( `id` INT NOT NULL, `PART_id` INT NOT NULL, `min_quantity` INT NULL, PRIMARY KEY (`id`), INDEX `fk_ITEM_PART1_idx` (`PART_id` ASC), CONSTRAINT `fk_ITEM_PART1` FOREIGN KEY (`PART_id`) REFERENCES `PARTADMIN`.`PART` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`PRICE` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`PRICE` ( `id` INT NOT NULL, `ITEM_id` INT NOT NULL, `SUPPLIER_id` INT NOT NULL, `price` INT NULL, `min_order` INT NULL, `max_order` INT NULL, `discount` INT NULL, `delivery_time` INT NULL, PRIMARY KEY (`id`), INDEX `fk_PRICE_ITEM1_idx` (`ITEM_id` ASC), INDEX `fk_PRICE_SUPPLIER1_idx` (`SUPPLIER_id` ASC), CONSTRAINT `fk_PRICE_ITEM1` FOREIGN KEY (`ITEM_id`) REFERENCES `PARTADMIN`.`ITEM` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_PRICE_SUPPLIER1` FOREIGN KEY (`SUPPLIER_id`) REFERENCES `PARTADMIN`.`SUPPLIER` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`PRICE_TO_DATE` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`PRICE_TO_DATE` ( `id` INT NOT NULL, `PRICE_id` INT NOT NULL, `to_date` DATETIME NULL, PRIMARY KEY (`id`), INDEX `fk_PRICE_HISTORY_PRICE1_idx` (`PRICE_id` ASC), CONSTRAINT `fk_PRICE_HISTORY_PRICE1` FOREIGN KEY (`PRICE_id`) REFERENCES `PARTADMIN`.`PRICE` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`CUSTOMER` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`CUSTOMER` ( `id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`)); -- ----------------------------------------------------- -- Table `PARTADMIN`.`PROJECT` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`PROJECT` ( `id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, `CUSTOMER_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `fk_PROJECT_CUSTOMER1_idx` (`CUSTOMER_id` ASC), CONSTRAINT `fk_PROJECT_CUSTOMER1` FOREIGN KEY (`CUSTOMER_id`) REFERENCES `PARTADMIN`.`CUSTOMER` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`TASK` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`TASK` ( `id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, `PROJECT_id` INT NOT NULL, `PART_id` INT NOT NULL, `quantity` INT NULL, PRIMARY KEY (`id`), INDEX `fk_TASK_PROJECT1_idx` (`PROJECT_id` ASC), INDEX `fk_TASK_PART1_idx` (`PART_id` ASC), CONSTRAINT `fk_TASK_PROJECT1` FOREIGN KEY (`PROJECT_id`) REFERENCES `PARTADMIN`.`PROJECT` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_TASK_PART1` FOREIGN KEY (`PART_id`) REFERENCES `PARTADMIN`.`PART` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`ORDER` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`ORDER` ( `id` INT NOT NULL, `PART_id` INT NOT NULL, `TASK_id` INT NOT NULL, `quantity` INT NULL, `SUPPLIER_id` INT NOT NULL, `date` VARCHAR(45) NULL, PRIMARY KEY (`id`), INDEX `fk_ORDER_PART1_idx` (`PART_id` ASC), INDEX `fk_ORDER_TASK1_idx` (`TASK_id` ASC), INDEX `fk_ORDER_SUPPLIER1_idx` (`SUPPLIER_id` ASC), CONSTRAINT `fk_ORDER_PART1` FOREIGN KEY (`PART_id`) REFERENCES `PARTADMIN`.`PART` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_ORDER_TASK1` FOREIGN KEY (`TASK_id`) REFERENCES `PARTADMIN`.`TASK` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_ORDER_SUPPLIER1` FOREIGN KEY (`SUPPLIER_id`) REFERENCES `PARTADMIN`.`SUPPLIER` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`ORDER_HISTORY` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`ORDER_HISTORY` ( `id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, `ORDER_id` INT NOT NULL, `date` DATETIME NULL, PRIMARY KEY (`id`), INDEX `fk_ORDER_HISTORY_ORDER1_idx` (`ORDER_id` ASC), CONSTRAINT `fk_ORDER_HISTORY_ORDER1` FOREIGN KEY (`ORDER_id`) REFERENCES `PARTADMIN`.`ORDER` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`COMPANY_STOCK` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`COMPANY_STOCK` ( `id` INT NOT NULL, `PART_id` INT NOT NULL, `quantity` VARCHAR(45) NULL, `description` VARCHAR(255) NOT NULL, `average_monthly_usage` INT NULL, `reorder_level` INT NULL, `reorder_quantity` INT NULL, PRIMARY KEY (`id`), INDEX `fk_OFFICE_ITEM_PART1_idx` (`PART_id` ASC), CONSTRAINT `fk_OFFICE_ITEM_PART1` FOREIGN KEY (`PART_id`) REFERENCES `PARTADMIN`.`PART` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`PART_TYPE_has_PART` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`PART_TYPE_has_PART` ( `PART_TYPE_id` INT NOT NULL, `PART_id` INT NOT NULL, PRIMARY KEY (`PART_TYPE_id`, `PART_id`), INDEX `fk_PART_TYPE_has_PART_PART1_idx` (`PART_id` ASC), INDEX `fk_PART_TYPE_has_PART_PART_TYPE1_idx` (`PART_TYPE_id` ASC), CONSTRAINT `fk_PART_TYPE_has_PART_PART_TYPE1` FOREIGN KEY (`PART_TYPE_id`) REFERENCES `PARTADMIN`.`PART_TYPE` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_PART_TYPE_has_PART_PART1` FOREIGN KEY (`PART_id`) REFERENCES `PARTADMIN`.`PART` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`SUPPLIER_X_PART` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`SUPPLIER_X_PART` ( `id` INT NOT NULL, `supplier_part_number` VARCHAR(45) NULL, `PART_id` INT NOT NULL, `SUPPLIER_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `fk_SUPPLIER_X_PART_PART1_idx` (`PART_id` ASC), INDEX `fk_SUPPLIER_X_PART_SUPPLIER1_idx` (`SUPPLIER_id` ASC), CONSTRAINT `fk_SUPPLIER_X_PART_PART1` FOREIGN KEY (`PART_id`) REFERENCES `PARTADMIN`.`PART` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_SUPPLIER_X_PART_SUPPLIER1` FOREIGN KEY (`SUPPLIER_id`) REFERENCES `PARTADMIN`.`SUPPLIER` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); -- ----------------------------------------------------- -- Table `PARTADMIN`.`SUPPLIER_STOCK` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PARTADMIN`.`SUPPLIER_STOCK` ( `id` INT NOT NULL, `quantity` INT NULL, `update_date` DATETIME NULL, `lead_time` INT NULL, `SUPPLIER_X_PART_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `fk_SUPPLIER_STOCK_SUPPLIER_X_PART1_idx` (`SUPPLIER_X_PART_id` ASC), CONSTRAINT `fk_SUPPLIER_STOCK_SUPPLIER_X_PART1` FOREIGN KEY (`SUPPLIER_X_PART_id`) REFERENCES `PARTADMIN`.`SUPPLIER_X_PART` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
true
08f782f284fcdd2ed4df3770b75f231872ba51ab
SQL
Max-212/CourseWork_DataBase_Music
/TMI_Music_CreateTables.sql
WINDOWS-1251
3,598
3.84375
4
[]
no_license
create database TMI_Music_BSTU_2020; use TMI_Music_BSTU_2020; -- DROP table Audio create table Audio ( Id int identity(1000,1) not null, Title nvarchar(50) not null, [Year] nvarchar(4), BandId int not null, AlbumId int not null, CONSTRAINT PK_AudioID PRIMARY KEY (Id), CONSTRAINT FK_BAND FOREIGN KEY(BandId) REFERENCES Band (Id) , CONSTRAINT FK_Album FOREIGN KEY(AlbumId) REFERENCES Album (Id) ) Drop table Album; -- create table Album ( Id int identity(1000,1) not null, BandId int not null, Title nvarchar(50) not null, CONSTRAINT PK_AlbumID PRIMARY KEY (Id), CONSTRAINT FK_Album_BandId FOREIGN KEY(BandId) REFERENCES Band (Id) ON DELETE CASCADE ) drop table Band -- create table Band ( Id int identity(1000,1) not null, Title nvarchar(50) not null unique, CONSTRAINT PK_BandID PRIMARY KEY (Id) ) Drop table Band_Member -- n:n create table Band_Member ( BandId int not null, MemberId int not null, CONSTRAINT PK_BandMember PRIMARY KEY (BandId,MemberId), CONSTRAINT FK_BandMember_BandId FOREIGN KEY(BandId) REFERENCES Band (Id) ON DELETE CASCADE, CONSTRAINT FK_BandMember_MemberId FOREIGN KEY(MemberId) REFERENCES Member (Id) ON DELETE CASCADE, ) -- create table Member ( Id int identity(1000,1) not null, FirstName nvarchar(50) not null, LastName nvarchar(50) not null, DateOfBirth Date not null, CONSTRAINT PK_ID PRIMARY KEY (Id) ) -- create table Genre ( Id int identity(1000,1) not null, Title nvarchar(50) not null, CONSTRAINT PK_GenreID PRIMARY KEY (Id) ) drop table Audio_Genre -- create table Audio_Genre ( AudioId int not null, GenreId int not null, CONSTRAINT PK_AudioGenre PRIMARY KEY (AudioId,GenreId), CONSTRAINT FK_AudioGenre_AudioId FOREIGN KEY(AudioId) REFERENCES Audio (Id) ON DELETE CASCADE, CONSTRAINT FK_AudioGenre_GenreId FOREIGN KEY(GenreId) REFERENCES Genre (Id) ON DELETE CASCADE, ) -- create table PlayList ( Id int identity(1000,1) not null, Title nvarchar(50) not null unique, CONSTRAINT PK_PlayListID PRIMARY KEY (Id) ) drop table Audio_PlayList; -- create table Audio_PlayList ( AudioId int not null, PlayListId int not null, CONSTRAINT PK_AudioPlayList PRIMARY KEY (AudioId,PlayListId), CONSTRAINT FK_AudioPlayList_AudioId FOREIGN KEY(AudioId) REFERENCES Audio (Id) ON DELETE CASCADE, CONSTRAINT FK_AudioPlayList_PlayListId FOREIGN KEY(PlayListId) REFERENCES PlayList (Id) ON DELETE CASCADE, ) -- create table [User] ( Id int identity(1000,1) not null, [Login] nvarchar(50) not null unique, [Password] nvarchar(50) not null, CONSTRAINT PK_UserId PRIMARY KEY (Id) ) drop table User_PlayList; -- create table User_PlayList ( UserId int not null, PlayListId int not null, CONSTRAINT PK_UserPlayList PRIMARY KEY (UserId,PlayListId), CONSTRAINT FK_UserPlayList_UserId FOREIGN KEY(UserId) REFERENCES [User] (Id) ON DELETE CASCADE, CONSTRAINT FK_UserPlayList_PlayListId FOREIGN KEY(PlayListId) REFERENCES PlayList (Id) ON DELETE CASCADE, )
true
848a809450e7b5da7d1393efee5f26ec224f2f88
SQL
Bikashbhaila/Project-2
/db/schema.sql
UTF-8
1,062
3.140625
3
[]
no_license
DROP DATABASE IF EXISTS maps_db; CREATE DATABASE maps_db; USE maps_db; CREATE TABLE Main_map ( Map_id INTEGER(11) auto_increment NOT NULL, Map_Name varchar(100), PRIMARY KEY (Map_id) ); CREATE TABLE City ( Map_id INTEGER(11) auto_increment NOT NULL, City_Name VARCHAR(100), Population INTEGER(100), Is_Capital Boolean, Has_Castle Boolean, Has_Market Boolean, PRIMARY KEY (Map_id) ); INSERT INTO Main_map (Map_Name) VALUES ("Bravoos"); INSERT INTO Main_map (Map_Name) VALUES ("Westboro"); INSERT INTO Main_map (Map_Name) VALUES ("WitchTown"); INSERT INTO Main_map (Map_Name) VALUES ("Hamburg"); INSERT INTO City (City_Name, Is_Capital, Has_Castle, Has_Market) VALUES ("Mancity", "True", "True", "False"); INSERT INTO City (City_Name, Is_Capital, Has_Castle, Has_Market) VALUES ("OldYork", "True", "True", "False"); INSERT INTO City (City_Name, Is_Capital, Has_Castle, Has_Market) VALUES ("NewYork", "True", "True", "False") INSERT INTO City (City_Name, Is_Capital, Has_Castle, Has_Market) VALUES ("Richland", "True", "True", "False")
true
57801a467a7d930bf99ce41ac46d60d608ae1dbb
SQL
silence-do-good/stress-test-Postgres-and-MySQL
/dump/high/day23/select0108.sql
UTF-8
191
2.796875
3
[]
no_license
SELECT timeStamp, temperature FROM ThermometerObservation WHERE timestamp>'2017-11-22T01:08:00Z' AND timestamp<'2017-11-23T01:08:00Z' AND SENSOR_ID='7ba2be18_4253_43af_9afd_506e991c5a8b'
true
d79ebb9cb82f28ddb1400c2d2553517c6988c619
SQL
shwetankri/SQLServerPublic
/TSQL-GenreateScripts.sql
UTF-8
355
3.734375
4
[]
no_license
#Use below to Grant execute permission to all the stored procedure to user test #This is basically know-how to use SELECT with concatenation to generate scripts SELECT ob.name, * , 'GRANT EXECUTE ON ' + sc.name + '.' + ob.name + ' TO test' FROM sys.objects ob JOIN sys.schemas sc ON ob.schema_id = sc.schema_id WHERE type_desc = 'SQL_STORED_PROCEDURE'
true
be1d947f31c95c40e34083762234e6e2280cd62b
SQL
MikeDias79/Secovi
/Secovi - Consultas.sql
UTF-8
350
3.71875
4
[]
no_license
/* nome, contato e endereço de somente pessoas que possuam contato independente de ter endereço ou não. */ SELECT p.nome AS Nome, DATE_FORMAT(p.DT_Insercao,'%d/%m/%Y') AS DT, c.email AS Email, e.endereco AS Endereco FROM tb_pessoas p RIGHT JOIN tb_contatos c ON p.ID_Pessoa = c.ID_Pessoa LEFT JOIN tb_enderecos e ON p.ID_Pessoa = e.ID_Pessoa
true
4754f381a54ca8a0c0b41b77a8bbd3ffc80023aa
SQL
PameSol02/ItlaBike
/database/dbItlaBike.sql
UTF-8
3,879
3.953125
4
[]
no_license
create database itlabike; use itlabike; create table Rol ( rolId int not null auto_increment, rol varchar (50), constraint pk_rolid primary key (rolId) ); create table Usuario ( usuarioId int not null auto_increment, nombre varchar (50), apellido varchar (50), email varchar (100), password varchar (100), foto varchar (500), rolId int not null, telefono varchar (15), constraint pk_usuarioid primary key (usuarioId), constraint fk_roid foreign key (rolId) references Rol (RolId) ); create table UsuarioDireccion ( UsusarioDireccionId int not null auto_increment, usuarioId int not null, calle varchar (100), numero varchar (10), sector varchar (50), ciudad varchar (50), provincia varchar (50), pais varchar (100), constraint pk_usuariodireccionid primary key (usuariorDireccionId), constraint fk_usuarioid foreign key (usuarioId) references Usuario (usuarioId) ); select * from usuariodireccion; delete from usuarioDireccion where usuarioDireccionId > 0; create table accion ( accionId int not null auto_increment, accion varchar (50), constraint fk_accionId primary key (accionId) ); insert into accion (accion) values ('Alquilar'); select * from accion; create table categoria ( categoriaId int not null, categoria varchar (50), constraint pk_categoriaid primary key (categoriaId) ); create table anuncio ( anuncioId int not null auto_increment, categoria varchar (50), titulo varchar (100), descripcion varchar (500), precio decimal (13,2), marca varchar (100), modelo varchar (100), accionId int not null, fecha timestamp default current_timestamp on update current_timestamp, usuarioId int, constraint pk_anuncioid primary key (anuncioId), constraint fk_accionid foreign key (accionId) references Accion (accionId), constraint pk_usuarioidanuncio foreign key (usuarioId) references Usuario (usuarioId) ); DELETE FROM Anuncio WHERE anuncioId = 1; select * from anuncio; create table anuncioImage ( anuncioImageId int not null auto_increment, image varchar (500), anuncioId int not null, constraint pk_anuncionimageid primary key (anuncioImageId), constraint fk_anuncioidimage foreign key (anuncioId) references Anuncio (anuncioId) ); select * from anuncioImage; select * from anuncio; delete from anuncio where anuncioid > 0; select * from anuncio; select anuncio.anuncioId, anuncio.titulo, anuncio.descripcion, anuncio.precio, anuncio.marca, anuncio.modelo, anuncio.accionId, max(anuncioImage.image) as foto from anuncio inner join anuncioImage on (anuncio.anuncioId = anuncioImage.anuncioId) group by anuncio.anuncioId; create table admin ( adminId int not null, nombre varchar (50), apellido varchar (50), email varchar (50), password varchar (100), constraint pk_adminid primary key (adminId) ); create table comentario ( comentarioId int not null auto_increment, anuncioId int not null, comentario varchar (500), usuarioId int, fecha date, hora datetime, constraint pk_comentarioid primary key (comentarioId), constraint fk_anuncioid foreign key (anuncioId) references Anuncio (anuncioId), constraint fk_anunciousuarioid foreign key (usuarioId) references Usuario (usuarioId) ); drop table comentario; create table anuncioPubicitario ( anuncioPublicitarioId int not null auto_increment, foto varchar (500), link varchar (500), constraint pk_anunciopublicitarioid primary key (anuncioPublicitarioId) ); UPDATE Anuncio set categoria = '{$anuncio->categoria}', titulo = '{$anuncio->titulo}', descripcion = '{$anuncio->descripcion}', precio = '900', marca = '{$anuncio->marca}', modelo = '{$anuncio->modelo}', anuncioId = '1' WHERE anuncioId = 8; select * from anuncio;
true
2c2a11a6729b2d134f0030049c6c6a63e26a31b1
SQL
caiofior/mementomei.it
/install/data/schema/beloved_memento.sql
UTF-8
685
2.96875
3
[]
no_license
CREATE TABLE `beloved_memento` ( `beloved_id` int(11) NOT NULL COMMENT 'Beeloved id', `memento_code` varchar(20) NOT NULL COMMENT 'Memento code', `user_id` int(11) DEFAULT NULL COMMENT 'User id', `agency_id` int(11) DEFAULT NULL COMMENT 'Agency id', `datetime` datetime NOT NULL COMMENT 'Date time', `data` text NOT NULL COMMENT 'Memento data', `filename` varchar(40) NOT NULL COMMENT 'Memento filename', PRIMARY KEY (`beloved_id`,`memento_code`,`datetime`), KEY `beloved_id` (`beloved_id`), KEY `memento_id` (`memento_code`), KEY `user_id` (`user_id`), KEY `agency_id` (`agency_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Association between beeloved and memento';
true
06b76f22ae179c0aa80658727d73d997737e855b
SQL
ory/keto
/internal/persistence/sql/migrations/sql/20210623162417000002_relationtuple.sqlite3.up.sql
UTF-8
663
2.71875
3
[ "Apache-2.0" ]
permissive
CREATE INDEX keto_relation_tuples_subject_sets_idx ON keto_relation_tuples (nid, namespace_id, object, relation, subject_set_namespace_id, subject_set_object, subject_set_relation) WHERE subject_id IS NULL;
true
1259ca32659794afa60f2121fc3d9e6337ef0750
SQL
saintlyzero/Quiz-App
/quiz_app.sql
UTF-8
7,071
3.25
3
[ "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.9.0.1 -- https://www.phpmyadmin.net/ -- -- Host: localhost -- Generation Time: Jun 15, 2019 at 07:40 AM -- Server version: 10.3.15-MariaDB -- PHP Version: 7.3.6 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `quiz_app` -- -- -------------------------------------------------------- -- -- Table structure for table `admin_detail` -- CREATE TABLE `admin_detail` ( `admin_id` int(11) NOT NULL, `admin_name` varchar(50) DEFAULT NULL, `admin_password` varchar(50) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `aptitude` -- CREATE TABLE `aptitude` ( `qid` int(11) NOT NULL, `question` varchar(500) DEFAULT NULL, `opt1` varchar(500) DEFAULT NULL, `opt2` varchar(500) DEFAULT NULL, `opt3` varchar(500) DEFAULT NULL, `opt4` varchar(500) DEFAULT NULL, `answer` varchar(500) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `aptitude` -- INSERT INTO `aptitude` (`qid`, `question`, `opt1`, `opt2`, `opt3`, `opt4`, `answer`) VALUES (1, 'what is what', 'a', 'b', 'c', 'd', 'a'), (2, 'what is 2+2', '4', '5', '8', '19', '4'), (4, 'What is 7+9', '14', '16', '89', '77', '16'), (5, 'What is 27+9', '54', '916', '989', '797', '816'), (6, 'What is 127+19', '4454', '22916', '41989', '12797', '816'), (7, 'What is 827 - 99', '854', '8916', '8989', '8797', '1816'), (8, 'What is 90+9', '99', '6', '9', '997', '999'), (9, 'What is the a+b?', 'a', 'b', 'A+b', 'a+b', 'A+B'), (10, 'What is the a+b?', 'a', 'b', 'A+b', 'a+b', 'A+B'), (11, 'What is the z+y?', 'a+x', 'x+y', 'A+b', 'a+b', 'A+B'), (13, 'How Are you Boi?', 'Good', 'OP', 'Very good', 'Mehh', 'Good'); -- -------------------------------------------------------- -- -- Table structure for table `logical` -- CREATE TABLE `logical` ( `qid` int(11) NOT NULL, `question` varchar(500) DEFAULT NULL, `opt1` varchar(500) DEFAULT NULL, `opt2` varchar(500) DEFAULT NULL, `opt3` varchar(500) DEFAULT NULL, `opt4` varchar(500) DEFAULT NULL, `answer` varchar(500) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `logical` -- INSERT INTO `logical` (`qid`, `question`, `opt1`, `opt2`, `opt3`, `opt4`, `answer`) VALUES (1, 'This is Logical question', 'No', 'Yes', 'Yes Yes', 'No no', 'Yes Yes'); -- -------------------------------------------------------- -- -- Table structure for table `quantitative` -- CREATE TABLE `quantitative` ( `qid` int(11) NOT NULL, `question` varchar(500) DEFAULT NULL, `opt1` varchar(500) DEFAULT NULL, `opt2` varchar(500) DEFAULT NULL, `opt3` varchar(500) DEFAULT NULL, `opt4` varchar(500) DEFAULT NULL, `answer` varchar(500) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `quantitative` -- INSERT INTO `quantitative` (`qid`, `question`, `opt1`, `opt2`, `opt3`, `opt4`, `answer`) VALUES (1, 'This is verbal question', 'verbal1', 'verbal 2', 'verbal 3', 'verbal 17', 'verbal 2'); -- -------------------------------------------------------- -- -- Table structure for table `test_log` -- CREATE TABLE `test_log` ( `test_id` int(11) NOT NULL, `user_name` varchar(50) DEFAULT NULL, `timestamp` varchar(30) DEFAULT NULL, `category` varchar(30) DEFAULT NULL, `score` varchar(30) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `user_detail` -- CREATE TABLE `user_detail` ( `user_id` int(11) NOT NULL, `user_name` varchar(50) NOT NULL, `user_email` varchar(50) DEFAULT NULL, `user_password` varchar(50) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user_detail` -- INSERT INTO `user_detail` (`user_id`, `user_name`, `user_email`, `user_password`) VALUES (1, 'abc', 'abc_a@gmail.com', 'pass'), (2, 'xyz', 'zyxasdasd', 'xyz'), (3, 'xyz12', 'asd', 'xyz'), (5, 'lmn', 'shubham@.com', 'lmn'); -- -------------------------------------------------------- -- -- Table structure for table `user_performance` -- CREATE TABLE `user_performance` ( `up_id` int(11) NOT NULL, `user_name` varchar(50) NOT NULL, `logical_qno` int(11) DEFAULT NULL, `logical_score` varchar(30) DEFAULT NULL, `quantitative_qno` int(11) DEFAULT NULL, `quantitative_score` varchar(30) DEFAULT NULL, `aptitude_qno` int(11) DEFAULT NULL, `aptitude_score` varchar(30) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user_performance` -- INSERT INTO `user_performance` (`up_id`, `user_name`, `logical_qno`, `logical_score`, `quantitative_qno`, `quantitative_score`, `aptitude_qno`, `aptitude_score`) VALUES (1, 'abc', 1, '0', 99, '88', 122, '50'), (2, 'xyz', 1, '10', 1, '15', 1, '0'), (4, 'lmn', 1, '0', 199, '188', 1, '0'); -- -- Indexes for dumped tables -- -- -- Indexes for table `admin_detail` -- ALTER TABLE `admin_detail` ADD PRIMARY KEY (`admin_id`); -- -- Indexes for table `aptitude` -- ALTER TABLE `aptitude` ADD PRIMARY KEY (`qid`); -- -- Indexes for table `logical` -- ALTER TABLE `logical` ADD PRIMARY KEY (`qid`); -- -- Indexes for table `quantitative` -- ALTER TABLE `quantitative` ADD PRIMARY KEY (`qid`); -- -- Indexes for table `test_log` -- ALTER TABLE `test_log` ADD PRIMARY KEY (`test_id`); -- -- Indexes for table `user_detail` -- ALTER TABLE `user_detail` ADD PRIMARY KEY (`user_id`); -- -- Indexes for table `user_performance` -- ALTER TABLE `user_performance` ADD PRIMARY KEY (`up_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `admin_detail` -- ALTER TABLE `admin_detail` MODIFY `admin_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `aptitude` -- ALTER TABLE `aptitude` MODIFY `qid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14; -- -- AUTO_INCREMENT for table `logical` -- ALTER TABLE `logical` MODIFY `qid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `quantitative` -- ALTER TABLE `quantitative` MODIFY `qid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `test_log` -- ALTER TABLE `test_log` MODIFY `test_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `user_detail` -- ALTER TABLE `user_detail` MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `user_performance` -- ALTER TABLE `user_performance` MODIFY `up_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
f7b95558e2569aec974ad2056406fb888a482e85
SQL
picnic106/fragment
/mysql/fragment.sql
UTF-8
1,834
3.75
4
[]
no_license
CREATE TABLE `app_resource_feedback` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `resourceId` INT(11) NOT NULL DEFAULT '0' COMMENT '资源id', `userId` INT(11) NOT NULL DEFAULT '0' COMMENT '用户id,哪个用户点击', `scoreType` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '得分类型,0为一般,1为有用', `resourceType` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '资源类型,养育建议为1,关键期视频为2,亲子游戏为3,通用课程为4', PRIMARY KEY (`id`) ) ENGINE=MYISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ALTER TABLE `abc`.`app_resource_feedback` ADD COLUMN `createDate` DATE DEFAULT CURRENT_DATE() NOT NULL COMMENT '创建时间'; ALTER TABLE `app_resource_feedback` ADD createDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP() ALTER TABLE `app_resource_everyday` DROP COLUMN answerrecordId; ALTER TABLE app_resource_everyday MODIFY COLUMN resourceType INT(1); -- 加序号以及日期往后加3天 SELECT sid,'',209315,DATE_ADD('2015-09-16', INTERVAL 3 DAY) fdate,'3' FROM ( SELECT @rownum:=@rownum+1 rownum,sid FROM (SELECT @rownum:=0,s.id AS sid FROM Answerrecommendgames s LEFT JOIN Interactivegame g ON s.`GameID`=g.`id` WHERE s.`answerRecordID`=209315 ORDER BY g.`id` ASC LIMIT 3) t ) t1 WHERE rownum=3; -- mysql 字符串连接函数CONCAT SELECT g.`game_name` title,g.`content` content,CONCAT('http://abc.yaolan.com/images/class/games/',SUBSTRING_INDEX(g.`ImageUrl`,'.',1),'_196_146.jpg') imgUrl,g.`GameType` FROM Interactivegame g WHERE g.`id`=1 LIMIT 1 -- 字符截取函数 SELECT SUBSTRING_INDEX('123.jpg','.',1) -- mysql截取函数 SUBSTRING UPDATE app_resource_everyday_learning g SET g.`imagename`=SUBSTRING(g.`imagename`,1,(LENGTH(g.`imagename`)-7)) -- mysql随机数 SELECT RAND()
true
00d8678a1a24d449b83c2cff663a08250bb1e966
SQL
weishiji/play-api
/conf/evolutions/default/1.sql
UTF-8
3,229
3.671875
4
[ "CC0-1.0" ]
permissive
# --- Created by Ebean DDL # To stop Ebean DDL generation, remove this comment and start using Evolutions # --- !Ups create table category ( category_id bigint auto_increment not null, name varchar(255), status tinyint, sort_order integer, parent_id integer, date_added datetime(6) not null, date_modified datetime(6) not null, constraint pk_category primary key (category_id) ); create table company ( id bigint auto_increment not null, name varchar(255), constraint pk_company primary key (id) ); create table computer ( id bigint auto_increment not null, name varchar(255), introduced datetime(6), discontinued datetime(6), company_id bigint, constraint pk_computer primary key (id) ); create table product ( product_id bigint auto_increment not null, name varchar(255), image varchar(255), status tinyint, date_available datetime(6), date_added datetime(6), date_modified datetime(6), quantity integer, constraint pk_product primary key (product_id) ); create table product_to_category ( product_id bigint not null, category_id bigint not null, constraint uq_product_to_category_product_id unique (product_id), constraint pk_product_to_category primary key (product_id,category_id) ); create table oc_customer ( customer_id bigint auto_increment not null, email varchar(255), password varchar(255), constraint pk_oc_customer primary key (customer_id) ); alter table computer add constraint fk_computer_company_id foreign key (company_id) references company (id) on delete restrict on update restrict; create index ix_computer_company_id on computer (company_id); alter table product_to_category add constraint fk_product_to_category_product_id foreign key (product_id) references product (product_id) on delete restrict on update restrict; alter table product_to_category add constraint fk_product_to_category_category_id foreign key (category_id) references category (category_id) on delete restrict on update restrict; create index ix_product_to_category_category_id on product_to_category (category_id); # --- !Downs alter table computer drop foreign key fk_computer_company_id; drop index ix_computer_company_id on computer; alter table product_to_category drop foreign key fk_product_to_category_product_id; alter table product_to_category drop foreign key fk_product_to_category_category_id; drop index ix_product_to_category_category_id on product_to_category; drop table if exists category; drop table if exists company; drop table if exists computer; drop table if exists product; drop table if exists product_to_category; drop table if exists oc_customer;
true
750e39ebf9c23c2e1ee2dad494b4fd4db23149bb
SQL
rafakwas/soa-projekt
/guard_module/src/main/resources/import.sql
UTF-8
1,851
3.0625
3
[]
no_license
-- -- JBoss, Home of Professional Open Source -- Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual -- contributors by the @authors tag. See the copyright.txt in the -- distribution for a full listing of individual contributors. -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. DROP TABLE USERS; DROP TABLE USER_ROLES; -- DROP TABLE MESSAGES; CREATE TABLE USERS(login VARCHAR(64) PRIMARY KEY, passwd VARCHAR(64)); CREATE TABLE USER_ROLES(login VARCHAR(64), role VARCHAR(32)); -- CREATE TABLE MESSAGES(id INTEGER PRIMARY KEY, data VARCHAR(255)); INSERT into USERS values('admin', 'ISMvKXpXpadDiUoOSoAfww=='); INSERT into USERS values('guard1', '771fvPTo2hwhqnFqj26JKg=='); INSERT into USERS values('guard2', '2acNL6r5hJk036uQsveFZA=='); INSERT into USER_ROLES values('admin', 'admin'); INSERT into USER_ROLES values('guard1', 'pool1'); INSERT into USER_ROLES values('guard2', 'pool2'); -- -- INSERT INTO MESSAGES VALUES (1,'pool1 - Ticket not bought. Place:5'); -- INSERT INTO MESSAGES VALUES (2,'pool1 - Ticket not bought. Place:7'); -- INSERT INTO MESSAGES VALUES (3,'pool1 - Ticket not bought. Place:10'); -- INSERT INTO MESSAGES VALUES (4,'pool2 - Ticket not bought. Place:19'); -- INSERT INTO MESSAGES VALUES (5,'pool2 - Ticket not bought. Place:25'); -- INSERT INTO MESSAGES VALUES (6,'pool2 - Ticket not bought. Place:26');
true
e0eecda5e2235836d25eb064ee9b5f3a175cd983
SQL
eamt/holbertonschool-higher_level_programming
/0x0E-SQL_more_queries/6-states.sql
UTF-8
249
2.578125
3
[]
no_license
-- creates the database `hbtn_0d_usa` and -- The table `states` in MySQL Server. CREATE DATABASE IF NOT EXISTS hbtn_0d_usa; CREATE TABLE IF NOT EXISTS `hbtn_0d_usa`.`states` ( id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(256) NOT NULL );
true
f8c406599c9e1988b4028fa34648b37e7c99b9e2
SQL
isabelaelguy/BD2
/32.sql
UTF-8
103
2.765625
3
[]
no_license
SELECT emp_no, first_name FROM employees WHERE first_name LIKE 'Crist%' AND emp_no >= '485733';
true
7384bdd88112f14c059ced7ed8d1fd69027d49e4
SQL
mattwilkinsonn/go-graphql
/sql/query/user.sql
UTF-8
503
3.28125
3
[]
no_license
-- name: GetUserById :one SELECT * FROM users WHERE id = $1 LIMIT 1; -- name: GetAllUsers :many SELECT * FROM users ORDER BY id ASC; -- name: CreateUser :one INSERT INTO users (username, email, password) VALUES ($1, $2, $3) RETURNING *; -- name: DeleteUser :exec DELETE FROM users WHERE id = $1; -- name: GetUserByEmail :one SELECT * FROM users WHERE email = $1 LIMIT 1; -- name: GetUserByUsername :one SELECT * FROM users WHERE username = $1 LIMIT 1; -- name: UpdateUserById :one -- UPDATE users -- SET
true
25bfb60f612d5ca6297574d872da60af661ebf1b
SQL
Ezak91/Muhvieh-Mobile
/scripts/muhvieh.sql
UTF-8
4,412
3.328125
3
[ "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 3.4.11.1deb2+deb7u1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Erstellungszeit: 12. Okt 2014 um 18:52 -- Server Version: 5.5.38 -- PHP-Version: 5.4.4-14+deb7u14 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 */; -- -- Datenbank: `muhvieh_db` -- CREATE DATABASE `muhvieh_db` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; USE `muhvieh_db`; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `categories` -- CREATE TABLE IF NOT EXISTS `categories` ( `movie_id` mediumint(9) NOT NULL, `categorie_id` int(11) NOT NULL, PRIMARY KEY (`movie_id`,`categorie_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `categories_main` -- CREATE TABLE IF NOT EXISTS `categories_main` ( `id` mediumint(9) NOT NULL, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `credits` -- CREATE TABLE IF NOT EXISTS `credits` ( `movie_id` mediumint(9) NOT NULL, `credits_id` int(11) NOT NULL, PRIMARY KEY (`movie_id`,`credits_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `credits_main` -- CREATE TABLE IF NOT EXISTS `credits_main` ( `id` int(11) NOT NULL, `name` varchar(150) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `directors` -- CREATE TABLE IF NOT EXISTS `directors` ( `movie_id` int(11) NOT NULL, `director_id` int(11) NOT NULL, PRIMARY KEY (`movie_id`,`director_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `directors_main` -- CREATE TABLE IF NOT EXISTS `directors_main` ( `id` int(11) NOT NULL, `name` varchar(150) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `movies` -- CREATE TABLE IF NOT EXISTS `movies` ( `id` mediumint(9) NOT NULL, `title` text COLLATE utf8_bin NOT NULL, `original_title` text CHARACTER SET utf8, `overview` text CHARACTER SET utf8, `cover` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `adult` tinyint(1) DEFAULT NULL, `release_date` date DEFAULT NULL, `duration` int(11) DEFAULT NULL, `homepage` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `imdb_id` varchar(32) CHARACTER SET utf8 DEFAULT NULL, `vote_average` double(2,1) DEFAULT NULL, `vote_count` int(11) DEFAULT NULL, `trailer_id` varchar(32) COLLATE utf8_bin NOT NULL, `add_time` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `users` -- CREATE TABLE IF NOT EXISTS `users` ( `id` mediumint(9) NOT NULL AUTO_INCREMENT, `email` varchar(255) NOT NULL, `password` varchar(32) NOT NULL, `newsletter` tinyint(1) DEFAULT '0', `role` int(11) NOT NULL, `last_login` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Daten für Tabelle `users` -- Admin anlegen username: admin@muh.vieh passwort: muhvieh -- INSERT INTO `users` (`id`, `email`, `password`, `newsletter`, `role`, `last_login`) VALUES (1, 'admin@muh.vieh', '1a7b64a1db1dafdf120f5f19f55694ff', 0, 1, '2014-12-02 09:53:00'); -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `wishlist` -- CREATE TABLE IF NOT EXISTS `wishlist` ( `user_id` mediumint(9) NOT NULL, `movie_id` mediumint(9) NOT NULL, PRIMARY KEY (`user_id`,`movie_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!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
37e921091584b6644c0ebe9b7756015bcf533307
SQL
tactlabs/microservices-demo
/src/main/resources/testdb/schema.sql
UTF-8
587
3.015625
3
[ "MIT" ]
permissive
drop table T_ACCOUNT if exists; create table T_ACCOUNT (ID bigint identity primary key, NUMBER varchar(9), NAME varchar(50) not null, BALANCE decimal(8,2), unique(NUMBER)); ALTER TABLE T_ACCOUNT ALTER COLUMN BALANCE SET DEFAULT 0.0; drop table T_WEAPON if exists; create table T_WEAPON ( ID bigint identity primary key, WEAPONID bigint, NAME varchar(50) not null, BALANCE int, IMAGE varchar(200), DESCRIPTION varchar(400) ); ALTER TABLE T_WEAPON ALTER COLUMN BALANCE SET DEFAULT 45;
true
0f56dbb585444b2d1209704568bce7b122631e93
SQL
complitex/flexpay
/ab/etc/sql/flexpay_ab.ddl.sql
UTF-8
55,923
4.3125
4
[]
no_license
create table ab_apartment_numbers_tbl ( id bigint not null auto_increment, begin_date date not null, end_date date not null, value varchar(255) not null comment 'Apartment number value', apartment_id bigint not null comment 'Apartment reference', primary key (id) ); create table ab_apartments_tbl ( id bigint not null auto_increment, apartment_type varchar(255) not null comment 'Class hierarchy descriminator, all apartments should have the same value', status integer not null comment 'Enabled/Disabled status', building_id bigint not null comment 'Building reference', primary key (id) ) comment='Apartments'; create table ab_building_address_attribute_type_translations_tbl ( id bigint not null auto_increment, name varchar(255) not null comment 'Type translation', short_name varchar(255) comment 'Optional short translation', attribute_type_id bigint not null comment 'Building attribute type reference', language_id bigint not null comment 'Language reference', primary key (id), unique (attribute_type_id, language_id) ) comment='Building attribute type translations'; create table ab_building_address_attribute_types_tbl ( id bigint not null auto_increment, status integer not null comment 'Enabled/Disabled status', primary key (id) ) comment='Building attribute type (number, bulk, etc.)'; create table ab_building_address_attributes_tbl ( id bigint not null auto_increment, status integer not null comment 'Enabled/Disabled status', value varchar(255) not null comment 'Building attribute value', attribute_type_id bigint not null comment 'Attribute type reference', buildings_id bigint not null comment 'Building address reference', primary key (id) ) comment='Building address attributes'; create table ab_building_addresses_tbl ( id bigint not null auto_increment, status integer not null comment 'Enabled/Disabled status', primary_status bit not null comment 'Flag of primary building address', street_id bigint not null comment 'Street reference', building_id bigint not null comment 'Building reference this address belongs to', primary key (id) ) comment='Building addresses'; create table ab_building_statuses_tbl ( id bigint not null auto_increment, begin_date date not null comment 'Status begin date', end_date date not null comment 'Status end date', value varchar(255) not null comment 'Status value', building_id bigint not null comment 'Building reference status belongs to', primary key (id) ) comment='Building status, for example building started or rebuilding'; create table ab_buildings_tbl ( id bigint not null auto_increment, building_type varchar(255) not null comment 'Class hierarchy descriminator, all buildings should have the same value', status integer not null comment 'Enabled/Disabled status', district_id bigint not null comment 'District reference', primary key (id) ) comment='Buildings'; create table ab_countries_tbl ( id bigint not null auto_increment, status integer not null, primary key (id) ); create table ab_country_name_translations_tbl ( id bigint not null auto_increment, name varchar(255), short_name varchar(5), country_id bigint not null, language_id bigint not null, primary key (id), unique (country_id, language_id) ); create table ab_district_name_translations_tbl ( id bigint not null auto_increment, name varchar(255), district_name_id bigint not null, language_id bigint not null, primary key (id), unique (district_name_id, language_id) ); create table ab_district_names_tbl ( id bigint not null auto_increment, district_id bigint not null, primary key (id) ); create table ab_district_names_temporal_tbl ( id bigint not null auto_increment, begin_date date not null, end_date date not null, create_date date not null, invalid_date date not null, district_id bigint not null, district_name_id bigint, primary key (id) ); create table ab_districts_tbl ( id bigint not null auto_increment, town_id bigint not null, status integer not null, primary key (id) ); create table ab_identity_type_translations_tbl ( id bigint not null auto_increment, name varchar(150) not null comment 'Identity type translation', language_id bigint not null comment 'Language reference', identity_type_id bigint not null comment 'Identity type reference', primary key (id), unique (language_id, identity_type_id) ) comment='Person documents type translation'; create table ab_identity_types_tbl ( id bigint not null auto_increment, status integer not null comment 'Enabled-disabled status', type_enum integer not null comment 'Identity type code', primary key (id) ) comment='Person documents type'; create table ab_person_attributes_tbl ( id bigint not null auto_increment, name varchar(50) not null comment 'Attribute name', value varchar(255) comment 'Attribute value', language_id bigint not null comment 'Language reference', person_id bigint not null comment 'Person reference', primary key (id) ) comment='Person attributes'; create table ab_person_identities_tbl ( id bigint not null auto_increment, status integer not null comment 'Enabled-Disabled status', begin_date date not null comment 'Begin of document valid interval', end_date date not null comment 'End of document valid interval', birth_date datetime not null comment 'Person birth date', serial_number varchar(10) not null comment 'Document serial number', document_number varchar(20) not null comment 'Document number', first_name varchar(255) not null comment 'Person first name', middle_name varchar(255) not null comment 'Person middle name', last_name varchar(255) not null comment 'Person last name', organization varchar(4000) not null comment 'Organization gave document', is_default bit not null comment 'Default document flag', sex smallint not null comment 'Person sex type', identity_type_id bigint not null comment 'Identity document type reference', person_id bigint not null comment 'Person reference', primary key (id) ) comment='Person documents'; create table ab_person_identity_attributes_tbl ( id bigint not null auto_increment, name varchar(50) not null comment 'Attribute name', value varchar(255) comment 'Attribute value', language_id bigint not null comment 'Language reference', person_identity_id bigint not null comment 'Person identity reference', primary key (id) ) comment='Person document additional attributes'; create table ab_person_registrations_tbl ( id bigint not null auto_increment, begin_date date not null comment 'Registration begin date', end_date date not null comment 'Registration end date', person_id bigint not null comment 'Registered person reference', apartment_id bigint not null comment 'Registered to apartment reference', primary key (id) ) comment='Person registrations'; create table ab_persons_tbl ( id bigint not null auto_increment, status integer not null comment 'Enabled-Disabled status', primary key (id) ) comment='Natural persons'; create table ab_region_name_translations_tbl ( id bigint not null auto_increment, name varchar(255), region_name_id bigint not null, language_id bigint not null, primary key (id), unique (region_name_id, language_id) ); create table ab_region_names_tbl ( id bigint not null auto_increment, region_id bigint not null, primary key (id) ); create table ab_region_names_temporal_tbl ( id bigint not null auto_increment, begin_date date not null, end_date date not null, create_date date not null, invalid_date date not null, region_id bigint not null, region_name_id bigint, primary key (id) ); create table ab_regions_tbl ( id bigint not null auto_increment, country_id bigint not null, status integer not null, primary key (id) ); create table ab_street_name_translations_tbl ( id bigint not null auto_increment, name varchar(255), street_name_id bigint not null, language_id bigint not null, primary key (id), unique (street_name_id, language_id) ); create table ab_street_names_tbl ( id bigint not null auto_increment, street_id bigint not null, primary key (id) ); create table ab_street_names_temporal_tbl ( id bigint not null auto_increment, begin_date date not null, end_date date not null, create_date date not null, invalid_date date not null, street_id bigint not null comment 'Street reference', street_name_id bigint comment 'Street name reference', primary key (id) ) comment='Street name temporals'; create table ab_street_type_translations_tbl ( id bigint not null auto_increment, name varchar(255), short_name varchar(255), language_id bigint not null, street_type_id bigint not null, primary key (id), unique (language_id, street_type_id) ); create table ab_street_types_tbl ( id bigint not null auto_increment, status integer not null, primary key (id) ); create table ab_street_types_temporal_tbl ( id bigint not null auto_increment, begin_date date not null, end_date date not null, create_date date not null, invalid_date date not null, street_id bigint not null comment 'Street reference', street_type_id bigint comment 'Street type reference', primary key (id) ) comment='Street type temporals'; create table ab_streets_districts_tbl ( id bigint not null auto_increment, street_id bigint not null, district_id bigint not null, primary key (id), unique (street_id, district_id) ); create table ab_streets_tbl ( id bigint not null auto_increment, town_id bigint not null, status integer not null, primary key (id) ); create table ab_town_name_translations_tbl ( id bigint not null auto_increment, name varchar(255), town_name_id bigint not null, language_id bigint not null, primary key (id), unique (town_name_id, language_id) ); create table ab_town_names_tbl ( id bigint not null auto_increment, town_id bigint not null, primary key (id) ); create table ab_town_names_temporal_tbl ( id bigint not null auto_increment, begin_date date not null, end_date date not null, create_date date not null, invalid_date date not null, town_id bigint not null, town_name_id bigint, primary key (id) ); create table ab_town_type_translations_tbl ( id bigint not null auto_increment, name varchar(255), short_name varchar(255), language_id bigint, town_type_id bigint, primary key (id), unique (language_id, town_type_id) ); create table ab_town_types_tbl ( id bigint not null auto_increment, status integer not null, primary key (id) ); create table ab_town_types_temporal_tbl ( id bigint not null auto_increment, begin_date date not null, end_date date not null, create_date date not null, invalid_date date not null, town_id bigint not null, town_type_id bigint, primary key (id) ); create table ab_towns_tbl ( id bigint not null auto_increment, region_id bigint not null, status integer not null, primary key (id) ); create table common_certificates_tbl ( id bigint not null auto_increment comment 'Primary key', version integer not null comment 'Optimistic lock version', begin_date datetime comment 'Certificate validity begin date', end_date datetime comment 'Certificate validity end date', description varchar(255) not null comment 'Description', blocked bit comment 'Certificate blocked', user_preference_id bigint comment 'User preference reference', primary key (id) ) comment='Security certificate'; create table common_currency_infos_tbl ( id bigint not null auto_increment comment 'Primary key', iso_code varchar(255) not null comment 'ISO 4217 code of a currency', gender integer not null comment 'Gender (0-masculine, 1-feminine, 2-neuter)', primary key (id) ) comment='Currency infos'; create table common_currency_names_tbl ( id bigint not null auto_increment comment 'Primary key', name varchar(255) not null comment 'Full currency name translation', short_name varchar(255) not null comment 'Short currency name translation', fraction_name varchar(255) not null comment 'Full currency fraction name translation', fraction_short_name varchar(255) not null comment 'Short currency fraction name translation', language_id bigint not null comment 'Language reference', currency_info_id bigint not null comment 'Currency info reference', primary key (id), unique (language_id, currency_info_id) ) comment='Currency name translation'; create table common_data_corrections_tbl ( id bigint not null auto_increment comment 'Primary key', internal_object_id bigint not null comment 'Flexpay object id (ref)', object_type integer not null comment 'Object type code', external_object_id varchar(255) not null comment 'External object identifier', data_source_description_id bigint comment 'Optional data source description reference', primary key (id) ) comment='Various data sources objects mapping'; create table common_data_source_descriptions_tbl ( id bigint not null auto_increment, description varchar(255) not null, primary key (id) ); create table common_diffs_tbl ( id bigint not null auto_increment, operation_time datetime not null comment 'Operation timestamp', object_type integer not null comment 'Object type', object_type_name varchar(255) comment 'Object type class name', object_id bigint not null comment 'Internal object reference', operation_type integer not null comment 'Operation type (create-update-delete)', user_name varchar(255) not null comment 'User name performed operation', processing_status integer default 0 not null comment 'Processing status', master_index varchar(255) not null comment 'Unique among several installations object id', instance_id varchar(255) not null comment 'Source application installation identifier', error_message varchar(255) comment 'Processing error message', primary key (id) ) comment='Set of history records for single object'; create table common_dual_tbl ( id bigint not null auto_increment, primary key (id) ); create table common_external_history_packs_tbl ( id bigint not null auto_increment, receive_date datetime not null comment 'Packet receive time', unpuck_tries integer not null comment 'Number of attempts to unpack the pack', source_instance_id varchar(255) not null comment 'Source instance id', consumption_group_id bigint not null comment 'Consumption group id', file_id bigint not null comment 'File containing records reference', primary key (id), unique (source_instance_id, consumption_group_id) ) comment='Received history records pack'; create table common_file_statuses_tbl ( id bigint not null auto_increment comment 'Primary key', name varchar(255) not null comment 'Filestatus name', description varchar(255) comment 'Filestatus description', code bigint not null comment 'Unique filestatus code', module_id bigint not null comment 'Flexpay module reference', primary key (id), unique (code, module_id) ) comment='Information about file statuses'; create table common_file_types_tbl ( id bigint not null auto_increment comment 'Primary key', file_mask varchar(255) not null comment 'Mask of files for this type', name varchar(255) not null comment 'Filetype name', description varchar(255) comment 'Filetype description', code bigint not null comment 'Unique filetype code', module_id bigint not null comment 'Flexpay module reference', primary key (id), unique (code, module_id) ) comment='Information about known filetypes'; create table common_files_tbl ( id bigint not null auto_increment comment 'Primary key', name_on_server varchar(255) not null comment 'File name on flexpay server', original_name varchar(255) not null comment 'Original file name', description varchar(255) comment 'File description', creation_date datetime not null comment 'File creation date', user_name varchar(255) not null comment 'User name who create this file', size bigint comment 'File size', module_id bigint not null comment 'Flexpay module reference', primary key (id) ) comment='Table, where store information about all flexpay files'; create table common_flexpay_modules_tbl ( id bigint not null auto_increment comment 'Primary key', name varchar(255) not null unique comment 'Flexpay module name', primary key (id) ) comment='Information about all flexpay modules'; create table common_history_consumers_tbl ( id bigint not null auto_increment, active integer not null comment 'Enabled-disabled status', name varchar(255) comment 'Consumer name', description varchar(255) comment 'Optional consumer description', last_diff_id bigint comment 'Last packed diff reference', out_transport_config_id bigint not null comment 'Out transport config reference', primary key (id) ) comment='Some abstract history records consumer'; create table common_history_consumption_groups_tbl ( id bigint not null auto_increment, consumer_id bigint not null comment 'History consumer reference', creation_date datetime not null comment 'Group creation date', postpone_time datetime comment 'Last postpone timestamp', user_name varchar(255) not null comment 'User name created group', send_tries integer not null comment 'Number of tries group file was sent', group_status integer not null comment 'Number of tries group file was sent', file_id bigint comment 'History group data file reference', primary key (id) ) comment='Group of several consumptions'; create table common_history_consumptions_tbl ( id bigint not null auto_increment, record_id bigint not null comment 'History record reference', group_id bigint not null comment 'History consumption group reference', primary key (id) ) comment='Consumption of single history record'; create table common_history_records_tbl ( id bigint not null auto_increment, old_date_value datetime comment 'Optional old date value', new_date_value datetime comment 'Optional new date value', old_int_value integer comment 'Optional old int value', new_int_value integer comment 'Optional new int value', old_bool_value bit comment 'Optional old boolean value', new_bool_value bit comment 'Optional new bool value', old_long_value bigint comment 'Optional old long value', new_long_value bigint comment 'Optional new long value', old_string_value varchar(255) comment 'Optional old string value', new_string_value varchar(255) comment 'Optional new string value', old_double_value double precision comment 'Optional old double value', new_double_value double precision comment 'Optional new double value', old_decimal_value decimal(19,5) comment 'Optional old decimal value', new_decimal_value decimal(19,5) comment 'Optional new decimal value', field_type integer not null comment 'Field type value is modified for', operation_order integer not null comment 'Object modification operation order', language_code varchar(255) comment 'Optional language iso code for multilang fields', begin_date date comment 'Optional begin date for temporal fields', end_date date comment 'Optional end date for temporal fields', field_key varchar(255) comment 'Optional key for field value', field_key2 varchar(255) comment 'Optional second key for field value', field_key3 varchar(255) comment 'Optional third key for field value', processing_status integer default 0 not null comment 'Processing status', diff_id bigint not null comment 'Diff (set of records) reference', primary key (id) ) comment='Single field update record'; create table common_history_unpack_data_tbl ( id bigint not null auto_increment, source_instance_id varchar(255) not null unique comment 'Source instance id', last_pack_id bigint not null comment 'Reference to last history pack', primary key (id) ) comment='Data for unpacking process'; create table common_import_errors_tbl ( id bigint not null auto_increment, status integer not null, source_description_id bigint not null, object_type integer not null, ext_object_id varchar(255) not null, handler_object_name varchar(255) not null, error_key varchar(255), primary key (id) ); create table common_language_names_tbl ( id bigint not null auto_increment, translation varchar(255), language_id bigint not null, translation_from_language_id bigint not null, primary key (id), unique (language_id, translation_from_language_id) ); create table common_languages_tbl ( id bigint not null auto_increment, status integer not null, is_default bit, lang_iso_code varchar(3) not null unique, primary key (id) ); create table common_measure_units_tbl ( id bigint not null auto_increment comment 'Primary key', status integer not null comment 'Enabled - disabled status', primary key (id) ) comment='Measure unit translation'; create table common_mesuare_unit_names_tbl ( id bigint not null auto_increment comment 'Primary key', name varchar(255) not null comment 'Translation', language_id bigint not null comment 'Language reference', measure_unit_id bigint not null comment 'Measure unit reference', primary key (id), unique (language_id, measure_unit_id) ) comment='Measure unit translation'; create table common_out_transport_configs_tbl ( id bigint not null auto_increment, config_type varchar(255) not null comment 'Class hierarchy descriminator', version integer not null comment 'Optimistic lock version', ws_url varchar(255) comment 'Web service url', primary key (id) ) comment='Out transport configs'; create table common_registries_tbl ( id bigint not null auto_increment, version integer not null, registry_number bigint, records_number bigint, errors_number integer default -1 not null comment 'Cached errors number value, -1 is not init', creation_date datetime, from_date datetime, till_date datetime, sender_code bigint, recipient_code bigint, amount decimal(19,2), registry_type_id bigint not null comment 'Registry type reference', registry_status_id bigint not null comment 'Registry status reference', archive_status_id bigint not null comment 'Registry archive status reference', import_error_id bigint comment 'Import error reference', module_id bigint not null comment 'Module reference', primary key (id) ); create table common_registry_archive_statuses_tbl ( id bigint not null auto_increment, code integer not null unique, primary key (id) ); create table common_registry_containers_tbl ( id bigint not null auto_increment, data varchar(2048) not null comment 'Registry container data', order_weight integer not null comment 'Order of the container in a registry', registry_id bigint not null comment 'Registry reference', primary key (id) ); create table common_registry_fpfile_types_tbl ( id bigint not null auto_increment, version integer not null comment 'Optimistic locking version', code integer not null unique comment 'FP file registry type code', primary key (id) ); create table common_registry_fpfiles_tbl ( registry_id bigint not null, fpfile_id bigint not null, registry_fpfile_type_id bigint not null, primary key (registry_id, registry_fpfile_type_id) ); create table common_registry_properties_tbl ( id bigint not null auto_increment comment 'Primary key', props_type varchar(255) not null comment 'Hierarchy discriminator, all entities should have the same value', version integer not null comment 'Optimistic lock version', registry_id bigint comment 'Registry reference', primary key (id) ); create table common_registry_record_containers_tbl ( id bigint not null auto_increment, data varchar(2048) not null comment 'Container data', order_weight integer not null comment 'Order of the container in a registry record', record_id bigint not null comment 'Registry record reference', primary key (id) ); create table common_registry_record_properties_tbl ( id bigint not null auto_increment comment 'Primary key', props_type varchar(255) not null comment 'Hierarchy discriminator, all entities should have the same value', version integer not null comment 'Optimistic lock version', record_id bigint comment 'Registry record reference', primary key (id) ); create table common_registry_record_statuses_tbl ( id bigint not null auto_increment, code integer not null unique comment 'Registry record status code', primary key (id) ); create table common_registry_records_tbl ( id bigint not null auto_increment, version integer not null comment 'Optimistic lock version', service_code varchar(255) not null, personal_account_ext varchar(255) not null, town_type varchar(255), town_name varchar(255), street_type varchar(255), street_name varchar(255), building_number varchar(255), bulk_number varchar(255), apartment_number varchar(255), first_name varchar(255), middle_name varchar(255), last_name varchar(255), operation_date datetime not null, unique_operation_number bigint, amount decimal(19,2), registry_id bigint not null comment 'Registry reference', record_status_id bigint not null comment 'Record status reference', import_error_id bigint comment 'Import error reference', import_error_type integer comment 'Import error type from import error', primary key (id) ); create table common_registry_statuses_tbl ( id bigint not null auto_increment, version integer not null comment 'Optimistic locking version', code integer not null unique comment 'Registry status code', primary key (id) ); create table common_registry_types_tbl ( id bigint not null auto_increment, version integer not null comment 'Optimistic locking version', code integer not null unique comment 'Registry type code', primary key (id) ); create table common_report_print_history_record_tbl ( id bigint not null auto_increment, version integer not null, user_name varchar(255) not null comment 'Name of user who printed report', print_date datetime not null comment 'Printing date', report_type integer not null comment 'Report type', primary key (id) ); create table common_sequences_tbl ( id bigint not null auto_increment, counter bigint not null, description varchar(255), primary key (id) ); create table common_user_role_name_translations_tbl ( id bigint not null auto_increment, name varchar(255), user_role_id bigint not null, language_id bigint not null, primary key (id), unique (user_role_id, language_id) ); create table common_user_roles_tbl ( id bigint not null auto_increment, status integer not null, external_id varchar(255) not null unique, primary key (id) ); create table common_users_tbl ( id bigint not null auto_increment comment 'Primary key', discriminator varchar(255) not null comment 'Class hierarchy discriminator', full_name varchar(255) not null comment 'Full user name', last_name varchar(255) not null comment 'Last user name', first_name varchar(255) comment 'First user name', user_name varchar(255) not null unique comment 'User login name', language_code varchar(255) not null comment 'Preferred language ISO code', page_size integer comment 'Preferred listing page size', user_role_id bigint comment 'Optional user role reference', ab_country_filter bigint comment 'Country filter', ab_region_filter bigint comment 'Region filter', ab_town_filter bigint comment 'Town filter', primary key (id) ) comment='User details'; create index indx_value on ab_apartment_numbers_tbl (value); alter table ab_apartment_numbers_tbl add index FK_ab_apartment_numbers_tbl_apartment_id (apartment_id), add constraint FK_ab_apartment_numbers_tbl_apartment_id foreign key (apartment_id) references ab_apartments_tbl (id); alter table ab_apartments_tbl add index ab_apartments_tbl_building_id (building_id), add constraint ab_apartments_tbl_building_id foreign key (building_id) references ab_buildings_tbl (id); alter table ab_building_address_attribute_type_translations_tbl add index ab_building_attribute_type_translations_tbl_attribute_type_id (attribute_type_id), add constraint ab_building_attribute_type_translations_tbl_attribute_type_id foreign key (attribute_type_id) references ab_building_address_attribute_types_tbl (id); alter table ab_building_address_attribute_type_translations_tbl add index lang_building_attribute_type_pair_language_id (language_id), add constraint lang_building_attribute_type_pair_language_id foreign key (language_id) references common_languages_tbl (id); create index indx_value on ab_building_address_attributes_tbl (value); alter table ab_building_address_attributes_tbl add index ab_building_attributes_tbl_buildings_id (buildings_id), add constraint ab_building_attributes_tbl_buildings_id foreign key (buildings_id) references ab_building_addresses_tbl (id); alter table ab_building_address_attributes_tbl add index ab_building_attributes_tbl_attribute_type_id (attribute_type_id), add constraint ab_building_attributes_tbl_attribute_type_id foreign key (attribute_type_id) references ab_building_address_attribute_types_tbl (id); alter table ab_building_addresses_tbl add index ab_buildingses_tbl_street_id (street_id), add constraint ab_buildingses_tbl_street_id foreign key (street_id) references ab_streets_tbl (id); alter table ab_building_addresses_tbl add index ab_buildingses_tbl_building_id (building_id), add constraint ab_buildingses_tbl_building_id foreign key (building_id) references ab_buildings_tbl (id); alter table ab_building_statuses_tbl add index ab_building_statuses_tbl_building_id (building_id), add constraint ab_building_statuses_tbl_building_id foreign key (building_id) references ab_buildings_tbl (id); alter table ab_buildings_tbl add index ab_buildings_tbl_district_id (district_id), add constraint ab_buildings_tbl_district_id foreign key (district_id) references ab_districts_tbl (id); alter table ab_country_name_translations_tbl add index FK31EC318E9E89EB47 (country_id), add constraint FK31EC318E9E89EB47 foreign key (country_id) references ab_countries_tbl (id); alter table ab_country_name_translations_tbl add index FK31EC318E61F37403 (language_id), add constraint FK31EC318E61F37403 foreign key (language_id) references common_languages_tbl (id); alter table ab_district_name_translations_tbl add index FKD194B702398B1DAA (district_name_id), add constraint FKD194B702398B1DAA foreign key (district_name_id) references ab_district_names_tbl (id); alter table ab_district_name_translations_tbl add index FKD194B70261F37403 (language_id), add constraint FKD194B70261F37403 foreign key (language_id) references common_languages_tbl (id); alter table ab_district_names_tbl add index FK7A70D3B41AE9F4D (district_id), add constraint FK7A70D3B41AE9F4D foreign key (district_id) references ab_districts_tbl (id); alter table ab_district_names_temporal_tbl add index FK6525F5EB1AE9F4D (district_id), add constraint FK6525F5EB1AE9F4D foreign key (district_id) references ab_districts_tbl (id); alter table ab_district_names_temporal_tbl add index FK6525F5EB398B1DAA (district_name_id), add constraint FK6525F5EB398B1DAA foreign key (district_name_id) references ab_district_names_tbl (id); alter table ab_districts_tbl add index FK79F1E386712C324D (town_id), add constraint FK79F1E386712C324D foreign key (town_id) references ab_towns_tbl (id); alter table ab_identity_type_translations_tbl add index ab_identity_type_translations_tbl_identity_type_id (identity_type_id), add constraint ab_identity_type_translations_tbl_identity_type_id foreign key (identity_type_id) references ab_identity_types_tbl (id); alter table ab_identity_type_translations_tbl add index ab_identity_type_translations_tbl_language_id (language_id), add constraint ab_identity_type_translations_tbl_language_id foreign key (language_id) references common_languages_tbl (id); alter table ab_person_attributes_tbl add index ab_person_attributes_tbl_person_id (person_id), add constraint ab_person_attributes_tbl_person_id foreign key (person_id) references ab_persons_tbl (id); alter table ab_person_attributes_tbl add index ab_person_attributes_tbl_language_id (language_id), add constraint ab_person_attributes_tbl_language_id foreign key (language_id) references common_languages_tbl (id); create index data_index on ab_person_identities_tbl (first_name, middle_name, last_name); alter table ab_person_identities_tbl add index ab_person_identities_tbl_identity_type_id (identity_type_id), add constraint ab_person_identities_tbl_identity_type_id foreign key (identity_type_id) references ab_identity_types_tbl (id); alter table ab_person_identities_tbl add index ab_person_identities_tbl_person_id (person_id), add constraint ab_person_identities_tbl_person_id foreign key (person_id) references ab_persons_tbl (id); alter table ab_person_identity_attributes_tbl add index ab_person_identity_attributes_tbl_person_identity_id (person_identity_id), add constraint ab_person_identity_attributes_tbl_person_identity_id foreign key (person_identity_id) references ab_person_identities_tbl (id); alter table ab_person_identity_attributes_tbl add index ab_person_identity_attributes_tbl_language_id (language_id), add constraint ab_person_identity_attributes_tbl_language_id foreign key (language_id) references common_languages_tbl (id); alter table ab_person_registrations_tbl add index FP_ab_person_registrations_person (person_id), add constraint FP_ab_person_registrations_person foreign key (person_id) references ab_persons_tbl (id); alter table ab_person_registrations_tbl add index FP_ab_person_registrations_apartment (apartment_id), add constraint FP_ab_person_registrations_apartment foreign key (apartment_id) references ab_apartments_tbl (id); alter table ab_region_name_translations_tbl add index FK3DB8D968D605B436 (region_name_id), add constraint FK3DB8D968D605B436 foreign key (region_name_id) references ab_region_names_tbl (id); alter table ab_region_name_translations_tbl add index FK3DB8D96861F37403 (language_id), add constraint FK3DB8D96861F37403 foreign key (language_id) references common_languages_tbl (id); alter table ab_region_names_tbl add index FKF918DF1A458E164D (region_id), add constraint FKF918DF1A458E164D foreign key (region_id) references ab_regions_tbl (id); alter table ab_region_names_temporal_tbl add index FK609D5D45D605B436 (region_name_id), add constraint FK609D5D45D605B436 foreign key (region_name_id) references ab_region_names_tbl (id); alter table ab_region_names_temporal_tbl add index FK609D5D45458E164D (region_id), add constraint FK609D5D45458E164D foreign key (region_id) references ab_regions_tbl (id); alter table ab_regions_tbl add index FK61DDD0609E89EB47 (country_id), add constraint FK61DDD0609E89EB47 foreign key (country_id) references ab_countries_tbl (id); alter table ab_street_name_translations_tbl add index FK72F93D37D80067D4 (street_name_id), add constraint FK72F93D37D80067D4 foreign key (street_name_id) references ab_street_names_tbl (id); alter table ab_street_name_translations_tbl add index FK72F93D3761F37403 (language_id), add constraint FK72F93D3761F37403 foreign key (language_id) references common_languages_tbl (id); alter table ab_street_names_tbl add index FK496D4169311847ED (street_id), add constraint FK496D4169311847ED foreign key (street_id) references ab_streets_tbl (id); alter table ab_street_names_temporal_tbl add index FK_ab_street_names_temporal_tbl_street_id (street_id), add constraint FK_ab_street_names_temporal_tbl_street_id foreign key (street_id) references ab_streets_tbl (id); alter table ab_street_names_temporal_tbl add index FK_ab_street_names_temporal_tbl_street_name_id (street_name_id), add constraint FK_ab_street_names_temporal_tbl_street_name_id foreign key (street_name_id) references ab_street_names_tbl (id); alter table ab_street_type_translations_tbl add index FKDEBA3C683E877574 (street_type_id), add constraint FKDEBA3C683E877574 foreign key (street_type_id) references ab_street_types_tbl (id); alter table ab_street_type_translations_tbl add index FKDEBA3C6861F37403 (language_id), add constraint FKDEBA3C6861F37403 foreign key (language_id) references common_languages_tbl (id); alter table ab_street_types_temporal_tbl add index FK_ab_street_types_temporal_tbl_street_id (street_id), add constraint FK_ab_street_types_temporal_tbl_street_id foreign key (street_id) references ab_streets_tbl (id); alter table ab_street_types_temporal_tbl add index FK_ab_street_types_temporal_tbl_street_type_id (street_type_id), add constraint FK_ab_street_types_temporal_tbl_street_type_id foreign key (street_type_id) references ab_street_types_tbl (id); alter table ab_streets_districts_tbl add index FK_ab_streets_districts_tbl_street_id (street_id), add constraint FK_ab_streets_districts_tbl_street_id foreign key (street_id) references ab_streets_tbl (id); alter table ab_streets_districts_tbl add index FK_ab_streets_districts_tbl_district_id (district_id), add constraint FK_ab_streets_districts_tbl_district_id foreign key (district_id) references ab_districts_tbl (id); alter table ab_streets_tbl add index FKFFBAF8B1712C324D (town_id), add constraint FKFFBAF8B1712C324D foreign key (town_id) references ab_towns_tbl (id); alter table ab_town_name_translations_tbl add index FKE4BB206B6638732 (town_name_id), add constraint FKE4BB206B6638732 foreign key (town_name_id) references ab_town_names_tbl (id); alter table ab_town_name_translations_tbl add index FKE4BB20661F37403 (language_id), add constraint FKE4BB20661F37403 foreign key (language_id) references common_languages_tbl (id); alter table ab_town_names_tbl add index FK85A534B8712C324D (town_id), add constraint FK85A534B8712C324D foreign key (town_id) references ab_towns_tbl (id); alter table ab_town_names_temporal_tbl add index FK59747967B6638732 (town_name_id), add constraint FK59747967B6638732 foreign key (town_name_id) references ab_town_names_tbl (id); alter table ab_town_names_temporal_tbl add index FK59747967712C324D (town_id), add constraint FK59747967712C324D foreign key (town_id) references ab_towns_tbl (id); alter table ab_town_type_translations_tbl add index FK7A0CB1371CEA94D2 (town_type_id), add constraint FK7A0CB1371CEA94D2 foreign key (town_type_id) references ab_town_types_tbl (id); alter table ab_town_type_translations_tbl add index FK7A0CB13761F37403 (language_id), add constraint FK7A0CB13761F37403 foreign key (language_id) references common_languages_tbl (id); alter table ab_town_types_temporal_tbl add index FK29822FD61CEA94D2 (town_type_id), add constraint FK29822FD61CEA94D2 foreign key (town_type_id) references ab_town_types_tbl (id); alter table ab_town_types_temporal_tbl add index FK29822FD6712C324D (town_id), add constraint FK29822FD6712C324D foreign key (town_id) references ab_towns_tbl (id); alter table ab_towns_tbl add index FK23FDF002458E164D (region_id), add constraint FK23FDF002458E164D foreign key (region_id) references ab_regions_tbl (id); alter table common_certificates_tbl add index FK_common_certificates_tbl_user_preference_id (user_preference_id), add constraint FK_common_certificates_tbl_user_preference_id foreign key (user_preference_id) references common_users_tbl (id); alter table common_currency_names_tbl add index FK_common_currency_names_tbl_currency_info_id (currency_info_id), add constraint FK_common_currency_names_tbl_currency_info_id foreign key (currency_info_id) references common_currency_infos_tbl (id); alter table common_currency_names_tbl add index common_currency_names_tbl_language_id (language_id), add constraint common_currency_names_tbl_language_id foreign key (language_id) references common_languages_tbl (id); alter table common_data_corrections_tbl add index common_data_corrections_tbl_dsd_id (data_source_description_id), add constraint common_data_corrections_tbl_dsd_id foreign key (data_source_description_id) references common_data_source_descriptions_tbl (id); create index I_objectid_object_type on common_diffs_tbl (object_type, object_id); alter table common_external_history_packs_tbl add index FK_common_external_history_packs_tbl (file_id), add constraint FK_common_external_history_packs_tbl foreign key (file_id) references common_files_tbl (id); alter table common_file_statuses_tbl add index common_file_statuses_tbl_module_id (module_id), add constraint common_file_statuses_tbl_module_id foreign key (module_id) references common_flexpay_modules_tbl (id); alter table common_file_types_tbl add index common_file_types_tbl_module_id (module_id), add constraint common_file_types_tbl_module_id foreign key (module_id) references common_flexpay_modules_tbl (id); alter table common_files_tbl add index common_files_tbl_module_id (module_id), add constraint common_files_tbl_module_id foreign key (module_id) references common_flexpay_modules_tbl (id); alter table common_history_consumers_tbl add index FK_common_history_consumers_tbl_last_diff_id (last_diff_id), add constraint FK_common_history_consumers_tbl_last_diff_id foreign key (last_diff_id) references common_diffs_tbl (id); alter table common_history_consumers_tbl add index FK_common_history_consumers_tbl_out_transport_config_id (out_transport_config_id), add constraint FK_common_history_consumers_tbl_out_transport_config_id foreign key (out_transport_config_id) references common_out_transport_configs_tbl (id); alter table common_history_consumption_groups_tbl add index FK_common_history_consumption_groups_tbl_file_id (file_id), add constraint FK_common_history_consumption_groups_tbl_file_id foreign key (file_id) references common_files_tbl (id); alter table common_history_consumption_groups_tbl add index FK_common_history_consumption_groups_tbl_consumer_id (consumer_id), add constraint FK_common_history_consumption_groups_tbl_consumer_id foreign key (consumer_id) references common_history_consumers_tbl (id); alter table common_history_consumptions_tbl add index FK_common_history_consumptions_tbl_group_id (group_id), add constraint FK_common_history_consumptions_tbl_group_id foreign key (group_id) references common_history_consumption_groups_tbl (id); alter table common_history_consumptions_tbl add index FK_common_history_consumptions_tbl_record_id (record_id), add constraint FK_common_history_consumptions_tbl_record_id foreign key (record_id) references common_history_records_tbl (id); alter table common_history_records_tbl add index FK_common_history_records_tbl_diff_id (diff_id), add constraint FK_common_history_records_tbl_diff_id foreign key (diff_id) references common_diffs_tbl (id); alter table common_history_unpack_data_tbl add index FK_common_history_unpack_data_tbl_last_pack_id (last_pack_id), add constraint FK_common_history_unpack_data_tbl_last_pack_id foreign key (last_pack_id) references common_external_history_packs_tbl (id); alter table common_import_errors_tbl add index FKBAEED8705355D490 (source_description_id), add constraint FKBAEED8705355D490 foreign key (source_description_id) references common_data_source_descriptions_tbl (id); alter table common_language_names_tbl add index FK85F168F48626C2BC (translation_from_language_id), add constraint FK85F168F48626C2BC foreign key (translation_from_language_id) references common_languages_tbl (id); alter table common_language_names_tbl add index FK85F168F461F37403 (language_id), add constraint FK85F168F461F37403 foreign key (language_id) references common_languages_tbl (id); alter table common_mesuare_unit_names_tbl add index common_mesuare_unit_names_tbl_measure_unit_id (measure_unit_id), add constraint common_mesuare_unit_names_tbl_measure_unit_id foreign key (measure_unit_id) references common_measure_units_tbl (id); alter table common_mesuare_unit_names_tbl add index common_mesuare_unit_names_tbl_language_id (language_id), add constraint common_mesuare_unit_names_tbl_language_id foreign key (language_id) references common_languages_tbl (id); alter table common_registries_tbl add index FK_common_registries_tbl_archive_status_id (archive_status_id), add constraint FK_common_registries_tbl_archive_status_id foreign key (archive_status_id) references common_registry_archive_statuses_tbl (id); alter table common_registries_tbl add index FK_common_registries_tbl_module_id (module_id), add constraint FK_common_registries_tbl_module_id foreign key (module_id) references common_flexpay_modules_tbl (id); alter table common_registries_tbl add index FK_common_registries_tbl_status_id (registry_status_id), add constraint FK_common_registries_tbl_status_id foreign key (registry_status_id) references common_registry_statuses_tbl (id); alter table common_registries_tbl add index FK_common_registries_tbl_registry_type_id (registry_type_id), add constraint FK_common_registries_tbl_registry_type_id foreign key (registry_type_id) references common_registry_types_tbl (id); alter table common_registries_tbl add index FK_common_registries_tbl_import_error_id (import_error_id), add constraint FK_common_registries_tbl_import_error_id foreign key (import_error_id) references common_import_errors_tbl (id); alter table common_registry_containers_tbl add index FK_common_registry_containers_tbl_registry_id (registry_id), add constraint FK_common_registry_containers_tbl_registry_id foreign key (registry_id) references common_registries_tbl (id); alter table common_registry_fpfiles_tbl add index FK_common_registry_fpfiles_tbl_fpfile_id (fpfile_id), add constraint FK_common_registry_fpfiles_tbl_fpfile_id foreign key (fpfile_id) references common_files_tbl (id); alter table common_registry_fpfiles_tbl add index FK_common_registry_fpfiles_tbl_registry_fpfile_type_id (registry_fpfile_type_id), add constraint FK_common_registry_fpfiles_tbl_registry_fpfile_type_id foreign key (registry_fpfile_type_id) references common_registry_fpfile_types_tbl (id); alter table common_registry_fpfiles_tbl add index FK_common_registry_fpfiles_tbl_registry_id (registry_id), add constraint FK_common_registry_fpfiles_tbl_registry_id foreign key (registry_id) references common_registries_tbl (id); alter table common_registry_properties_tbl add index FK_common_registry_properties_tbl_registry_id (registry_id), add constraint FK_common_registry_properties_tbl_registry_id foreign key (registry_id) references common_registries_tbl (id); alter table common_registry_record_containers_tbl add index FK_common_registry_record_containers_tbl_record_id (record_id), add constraint FK_common_registry_record_containers_tbl_record_id foreign key (record_id) references common_registry_records_tbl (id); alter table common_registry_record_properties_tbl add index FK_common_registry_properties_tbl_record_id (record_id), add constraint FK_common_registry_properties_tbl_record_id foreign key (record_id) references common_registry_records_tbl (id); create index I_registry_errortype on common_registry_records_tbl (registry_id, import_error_type); create index I_registry_status on common_registry_records_tbl (registry_id, record_status_id); alter table common_registry_records_tbl add index FK_common_registry_records_tbl_registry_id (registry_id), add constraint FK_common_registry_records_tbl_registry_id foreign key (registry_id) references common_registries_tbl (id); alter table common_registry_records_tbl add index FK_common_registry_records_tbl_import_error_id (import_error_id), add constraint FK_common_registry_records_tbl_import_error_id foreign key (import_error_id) references common_import_errors_tbl (id); alter table common_registry_records_tbl add index FK_common_registry_records_tbl_record_status_id (record_status_id), add constraint FK_common_registry_records_tbl_record_status_id foreign key (record_status_id) references common_registry_record_statuses_tbl (id); alter table common_user_role_name_translations_tbl add index FKB85A9CACA555113A (user_role_id), add constraint FKB85A9CACA555113A foreign key (user_role_id) references common_user_roles_tbl (id); alter table common_user_role_name_translations_tbl add index FKB85A9CAC61F37403 (language_id), add constraint FKB85A9CAC61F37403 foreign key (language_id) references common_languages_tbl (id); alter table common_users_tbl add index common_user_role_tbl_user_role_id (user_role_id), add constraint common_user_role_tbl_user_role_id foreign key (user_role_id) references common_user_roles_tbl (id);
true
df6412b905c98175f411d48c146b416b894da309
SQL
NerdKvothe/SistemaConsorcio
/03 - Construcao/SistemaConsorcio.sql
UTF-8
7,770
3.140625
3
[]
no_license
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'; CREATE SCHEMA IF NOT EXISTS `sistemaconsorcio` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ; USE `sistemaconsorcio` ; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`Cliente` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`Cliente` ( `codigoCliente` INT NOT NULL , `CPF` VARCHAR(45) NULL , `nome` VARCHAR(128) NULL , `endereco` VARCHAR(256) NULL , `cidade` VARCHAR(128) NULL , `estado` VARCHAR(128) NULL , `foneResidencial` VARCHAR(45) NULL , `foneCelular` VARCHAR(45) NULL , `email` VARCHAR(128) NULL , PRIMARY KEY (`codigoCliente`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`Administradora` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`Administradora` ( `codigoAdm` INT NOT NULL , `nome` VARCHAR(128) NULL , PRIMARY KEY (`codigoAdm`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`PontoVenda` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`PontoVenda` ( `codigoPtoVenda` INT NOT NULL , `nome` VARCHAR(128) NULL , PRIMARY KEY (`codigoPtoVenda`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`SubPontoVenda` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`SubPontoVenda` ( `codigoSbPtoVenda` INT NOT NULL , `codigoPtoVenda` INT NULL , `nome` VARCHAR(128) NULL , PRIMARY KEY (`codigoSbPtoVenda`) , INDEX `fk_SubPontoVenda_1` (`codigoPtoVenda` ASC) , CONSTRAINT `fk_SubPontoVenda_1` FOREIGN KEY (`codigoPtoVenda` ) REFERENCES `sistemaconsorcio`.`PontoVenda` (`codigoPtoVenda` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`Vendedor` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`Vendedor` ( `codigoVendedor` INT NOT NULL , `nome` VARCHAR(45) NULL , `dtInicio` DATE NULL , `dtFim` DATE NULL , `codigoSbPtoVenda` INT NULL , PRIMARY KEY (`codigoVendedor`) , INDEX `fk_Vendedor_1` (`codigoSbPtoVenda` ASC) , CONSTRAINT `fk_Vendedor_1` FOREIGN KEY (`codigoSbPtoVenda` ) REFERENCES `sistemaconsorcio`.`SubPontoVenda` (`codigoSbPtoVenda` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`ModeloVeiculo` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`ModeloVeiculo` ( `codigoModelo` INT NOT NULL , `descricao` VARCHAR(256) NULL , `marca` VARCHAR(128) NULL , PRIMARY KEY (`codigoModelo`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`Venda` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`Venda` ( `codigoVenda` INT NOT NULL , `dataCadastro` DATE NULL , `nroContrato` VARCHAR(20) NULL , `dtIniVigencia` DATE NULL , `qtdParcelas` INT NULL COMMENT ' ' , `dtParcEntrada` DATE NULL , `vlrParcEntrada` DOUBLE NULL , `vlrBem` DOUBLE NULL , `observacao` VARCHAR(256) NULL , `grupoConsorcio` INT NULL , `cotaConsorcio` INT NULL , `codigoCliente` INT NULL , `codigoModelo` INT NULL , `codigoAdm` INT NULL , `codigoVendedor` INT NULL , PRIMARY KEY (`codigoVenda`) , INDEX `fk_Venda_1` (`codigoCliente` ASC) , INDEX `fk_Venda_2` (`codigoAdm` ASC) , INDEX `fk_Venda_3` (`codigoVendedor` ASC) , INDEX `fk_Venda_4` (`codigoModelo` ASC) , CONSTRAINT `fk_Venda_1` FOREIGN KEY (`codigoCliente` ) REFERENCES `sistemaconsorcio`.`Cliente` (`codigoCliente` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Venda_2` FOREIGN KEY (`codigoAdm` ) REFERENCES `sistemaconsorcio`.`Administradora` (`codigoAdm` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Venda_3` FOREIGN KEY (`codigoVendedor` ) REFERENCES `sistemaconsorcio`.`Vendedor` (`codigoVendedor` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Venda_4` FOREIGN KEY (`codigoModelo` ) REFERENCES `sistemaconsorcio`.`ModeloVeiculo` (`codigoModelo` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`Comissao` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`Comissao` ( `codigoComissao` INT NOT NULL , `codigoVenda` INT NULL , `nroParcela` INT NULL , `dtEfetivaRecebimento` DATE NULL , `vlrEfetivoRecebimento` DOUBLE NULL , `dtPrevista` DATE NULL , `vlrPrevisto` DOUBLE NULL , `tipoComissao` INT(1) NULL , `dtCancelamentoEstorno` DATE NULL , PRIMARY KEY (`codigoComissao`) , INDEX `fk_Comissao_1` (`codigoVenda` ASC) , CONSTRAINT `fk_Comissao_1` FOREIGN KEY (`codigoVenda` ) REFERENCES `sistemaconsorcio`.`Venda` (`codigoVenda` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`RegrasComissao` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`RegrasComissao` ( `codigoRegra` INT NOT NULL , `percentual` DOUBLE NULL , `dtIniVigenciaComissao` DATE NULL , `dtFimVigenciaComissao` DATE NULL , `parcelamentoComissao` INT NULL , `formaEstorno` VARCHAR(45) NULL , `codigoAdm` INT NULL , `codigoComissao` INT NULL , PRIMARY KEY (`codigoRegra`) , INDEX `fk_RegrasComissao_1` (`codigoComissao` ASC) , INDEX `fk_RegrasComissao_2` (`codigoAdm` ASC) , CONSTRAINT `fk_RegrasComissao_1` FOREIGN KEY (`codigoComissao` ) REFERENCES `sistemaconsorcio`.`Comissao` (`codigoComissao` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_RegrasComissao_2` FOREIGN KEY (`codigoAdm` ) REFERENCES `sistemaconsorcio`.`Administradora` (`codigoAdm` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`TipoTaxa` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`TipoTaxa` ( `codigoTpTaxa` INT NOT NULL , `nome` VARCHAR(128) NULL , PRIMARY KEY (`codigoTpTaxa`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sistemaconsorcio`.`Taxa` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sistemaconsorcio`.`Taxa` ( `codigoTaxa` INT NOT NULL , `percentualTaxa` DOUBLE NULL , `codigoAdm` INT NULL , `codigoTpTaxa` INT NULL , PRIMARY KEY (`codigoTaxa`) , INDEX `fk_Taxa_1` (`codigoTpTaxa` ASC) , INDEX `fk_Taxa_2` (`codigoAdm` ASC) , CONSTRAINT `fk_Taxa_1` FOREIGN KEY (`codigoTpTaxa` ) REFERENCES `sistemaconsorcio`.`TipoTaxa` (`codigoTpTaxa` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Taxa_2` FOREIGN KEY (`codigoAdm` ) REFERENCES `sistemaconsorcio`.`Administradora` (`codigoAdm` ) 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
35d934573d4d4d480affa286e2ed816647311d5e
SQL
nayguns/DIO-desafio-github-FR
/Aula de SQL - Introdução/SQLQuery1_DIOCurse.sql
UTF-8
285
3.078125
3
[]
no_license
select * from Clientes cli inner join Pedido ped on cli.Codigo = ped.CodigoCliente select * from Clientes cli left join Pedido ped on cli.Codigo = ped.CodigoCliente select * from Pedido ped right join Clientes cli on cli.Codigo = ped.CodigoCliente where ped.TotalPedido > 10
true
fcf7d6639b0406b16eb71ad64725b2eb685c7363
SQL
IlliaVeremiev/Simple-InternetShop
/src/main/resources/db/postgresql/migration/V11006__WarehouseEntry_Init.sql
UTF-8
404
3.21875
3
[]
no_license
DROP TYPE if EXISTS "warehouse_entry_status" CASCADE; CREATE TYPE "warehouse_entry_status" AS ENUM ('AVAILABLE', 'RECEIVED'); DROP TABLE if EXISTS "warehouse_entries" CASCADE; CREATE TABLE "warehouse_entries" ( "id" INT8 NOT NULL, "warehouse_id" INT8 NOT NULL, "product_id" INT8 NOT NULL, "count" DECIMAL(19,2) NOT NULL, "status" warehouse_entry_status, PRIMARY KEY ("id") );
true
e548861526832d5c426eb03b29938e523ac6c25b
SQL
lgillie/openstore-schema-core
/resources/sql/mysql-utf8-compat/create_schema_extra_utf8_compat.sql
UTF-8
22,058
3.4375
3
[ "MIT" ]
permissive
DELIMITER // DROP FUNCTION IF EXISTS `slugify` // DELIMITER ; DELIMITER // CREATE FUNCTION `slugify` (dirty_string VARCHAR(255)) RETURNS VARCHAR(255) CHARSET latin1 DETERMINISTIC BEGIN DECLARE x, y , z INT; DECLARE temp_string, new_string VARCHAR(255); DECLARE is_allowed BOOL; DECLARE c, check_char VARCHAR(1); SET temp_string = LOWER(dirty_string); SET temp_string = REPLACE(temp_string, '&', ' and '); SELECT temp_string REGEXP('[^a-z0-9\-]+') INTO x; IF x = 1 THEN SET z = 1; WHILE z <= CHAR_LENGTH(temp_string) DO SET c = SUBSTRING(temp_string, z, 1); SET is_allowed = FALSE; IF !((ascii(c) = 45) or (ascii(c) >= 48 and ascii(c) <= 57) or (ascii(c) >= 97 and ascii(c) <= 122)) THEN SET temp_string = REPLACE(temp_string, c, '-'); END IF; SET z = z + 1; END WHILE; END IF; SELECT temp_string REGEXP("^-|-$|'") INTO x; IF x = 1 THEN SET temp_string = REPLACE(temp_string, "'", ''); SET z = CHAR_LENGTH(temp_string); SET y = CHAR_LENGTH(temp_string); Dash_check: WHILE z > 1 DO IF STRCMP(SUBSTRING(temp_string, -1, 1), '-') = 0 THEN SET temp_string = SUBSTRING(temp_string,1, y-1); SET y = y - 1; ELSE LEAVE Dash_check; END IF; SET z = z - 1; END WHILE; END IF; REPEAT SELECT temp_string REGEXP("--") INTO x; IF x = 1 THEN SET temp_string = REPLACE(temp_string, "--", "-"); END IF; UNTIL x <> 1 END REPEAT; IF LOCATE('-', temp_string) = 1 THEN SET temp_string = SUBSTRING(temp_string, 2); END IF; RETURN temp_string; END // DELIMITER ; DELIMITER // DROP FUNCTION IF EXISTS `strip_tags` // DELIMITER ; DELIMITER // CREATE FUNCTION strip_tags( DIRTY VARCHAR(3000) ) RETURNS VARCHAR(3000) CHARSET utf8 COLLATE utf8_unicode_ci DETERMINISTIC BEGIN DECLARE iStart, iEnd, iLength int; WHILE LOCATE( '<', DIRTY ) > 0 And LOCATE( '>', DIRTY, LOCATE( '<', DIRTY )) > 0 DO BEGIN SET iStart = LOCATE( '<', DIRTY ), iEnd = LOCATE( '>', DIRTY, LOCATE('<', DIRTY )); SET iLength = ( iEnd - iStart) + 1; IF iLength > 0 THEN BEGIN SET DIRTY = INSERT( DIRTY, iStart, iLength, ''); END; END IF; END; END WHILE; RETURN DIRTY; END// DELIMITER ; DELIMITER // DROP FUNCTION IF EXISTS `delete_double_spaces` // DELIMITER ; DELIMITER // CREATE FUNCTION delete_double_spaces ( title VARCHAR(3000) ) RETURNS VARCHAR(3000) CHARSET utf8 COLLATE utf8_unicode_ci DETERMINISTIC BEGIN DECLARE result VARCHAR(3000); SET result = REPLACE( title, ' ', ' ' ); WHILE (result <> title) DO SET title = result; SET result = REPLACE( title, ' ', ' ' ); END WHILE; RETURN result; END// DELIMITER ; DELIMITER // DROP FUNCTION IF EXISTS `get_searchable_reference` // DELIMITER ; DELIMITER // CREATE FUNCTION `get_searchable_reference` (`in_str` VARCHAR(2048)) RETURNS VARCHAR(2048) CHARSET utf8 DETERMINISTIC BEGIN /* This function escape a string from any non alphanumeric chars (A_Z0_9) to get a searchable reference. Also try to remove any first non-significative zero. FOR example 'BA-0114-22' -> 'BA11422' */ DECLARE out_str VARCHAR(2048) DEFAULT ''; DECLARE c VARCHAR(1) DEFAULT ''; DECLARE prev_c VARCHAR(1) DEFAULT ''; DECLARE pointer INT DEFAULT 1; IF ISNULL(in_str) THEN RETURN NULL; ELSE WHILE pointer <= LENGTH(in_str) DO SET c = UPPER(MID(in_str, pointer, 1)); -- TAKE ONLY [A-Z0-9] characters IF ((ASCII(c) > 64 AND ASCII(c) < 92) or (ASCII(c) > 47 AND ASCII(c) < 58)) THEN -- IF A NUMBER, try to get rid of non-significave numbers IF (ASCII(c) > 47 AND ASCII(c) < 58) THEN -- IF C is a zero and PREVIOUS CHARACTER IS NUMERIC IF (c = 0 and NOT (ASCII(prev_c) > 47 AND ASCII(prev_c) < 58)) THEN -- NOTHING SET c = c; ELSE SET out_str = CONCAT(out_str, c); END IF; ELSE SET out_str = CONCAT(out_str, c); END IF; END IF; SET prev_c = c; SET pointer = pointer + 1; END WHILE; END IF; RETURN UPPER(out_str); END// DELIMITER ; DELIMITER // DROP PROCEDURE IF EXISTS `rebuild_catalog_search` // DELIMITER ; DELIMITER // CREATE PROCEDURE `rebuild_catalog_search` () BEGIN SET @updated_at = NOW(); SET @default_lang := (SELECT lang FROM `language` where flag_default = 1); IF (@default_lang is null) THEN SET @default_lang = 'en'; END IF; INSERT INTO product_search (product_id, lang, keywords, updated_at) SELECT DISTINCT p.product_id, IF (p18.lang is null, @default_lang, p18.lang) as lang, UPPER( delete_double_spaces( REPLACE( strip_tags( TRIM( CONCAT_WS(' ', COALESCE(p.reference, ''), COALESCE(pb.title, ''), COALESCE(p18.title, p.title, ''), COALESCE(p18.invoice_title, p.invoice_title, ''), IF(p2.product_id is not null, COALESCE(p18_2.description, p2.description, ''), COALESCE(p18.description, p.description, '') ), COALESCE(p18.characteristic, p.characteristic, ''), COALESCE(p18.keywords, p.keywords, ''), COALESCE(pc18.breadcrumb, pc.breadcrumb, ''), COALESCE(pg18.title, pg.title, '') ) ) ) , ' ', ' ') ) ) as keywords, @updated_at as updated_at from product p left outer join product_translation p18 ON p18.product_id = p.product_id left outer join product_brand pb ON p.brand_id = pb.brand_id left outer join product p2 ON p2.product_id = p.parent_id left outer join product_translation p18_2 ON p18_2.product_id = p2.product_id and p18_2.lang = p18.lang left outer join product_group pg ON p.group_id = pg.group_id left outer join product_group_translation pg18 ON pg18.group_id = pg.group_id and pg18.lang = p18.lang left outer join product_category pc on pc.category_id = p.category_id left outer join product_category_translation pc18 on pc18.category_id = p.category_id and pc18.lang = p18.lang left outer join product_pricelist ppl on (p.product_id = ppl.product_id and ppl.flag_active=1) left outer join pricelist pl on (pl.pricelist_id = ppl.pricelist_id and pl.flag_active=1) where 1=1 and p.flag_active = 1 and pl.flag_active = 1 order by IF (p18.lang is null, @default_lang, p18.lang), p.product_id on duplicate key update keywords = UPPER( delete_double_spaces( REPLACE( strip_tags( TRIM( CONCAT_WS(' ', COALESCE(p.reference, ''), COALESCE(pb.title, ''), COALESCE(p18.title, p.title, ''), COALESCE(p18.invoice_title, p.invoice_title, ''), IF(p2.product_id is not null, COALESCE(p18_2.description, p2.description, ''), COALESCE(p18.description, p.description, '') ), COALESCE(p18.characteristic, p.characteristic, ''), COALESCE(p18.keywords, p.keywords, ''), COALESCE(pc18.breadcrumb, pc.breadcrumb, ''), COALESCE(pg18.title, pg.title, '') ) ) ) , ' ', ' ') ) ) , updated_at = @updated_at; -- REMOVE OLDER DATA DELETE FROM product_search where updated_at < @updated_at and updated_at is not null; END // DELIMITER ; DELIMITER // DROP PROCEDURE IF EXISTS `rebuild_product_search` // DELIMITER ; DELIMITER // CREATE PROCEDURE `rebuild_product_search` (IN product_id BIGINT) BEGIN SET @updated_at = NOW(); SET @product_id = product_id; SET @default_lang := (SELECT lang FROM `language` where flag_default = 1); IF (@default_lang is null) THEN SET @default_lang = 'en'; END IF; PREPARE stmt FROM "INSERT INTO product_search (product_id, lang, keywords, updated_at) SELECT DISTINCT p.product_id, IF (p18.lang is null, @default_lang, p18.lang) as lang, UPPER( delete_double_spaces( REPLACE( strip_tags( TRIM( CONCAT_WS(' ', COALESCE(p.reference, ''), COALESCE(pb.title, ''), COALESCE(p18.title, p.title, ''), COALESCE(p18.invoice_title, p.invoice_title, ''), IF(p2.product_id is not null, COALESCE(p18_2.description, p2.description, ''), COALESCE(p18.description, p.description, '') ), COALESCE(p18.characteristic, p.characteristic, ''), COALESCE(p18.keywords, p.keywords, ''), COALESCE(pc18.breadcrumb, pc.breadcrumb, ''), COALESCE(pg18.title, pg.title, '') ) ) ) , ' ', ' ') ) ) as keywords, @updated_at as updated_at from product p left outer join product_translation p18 ON p18.product_id = p.product_id left outer join product_brand pb ON p.brand_id = pb.brand_id left outer join product p2 ON p2.product_id = p.parent_id left outer join product_translation p18_2 ON p18_2.product_id = p2.product_id and p18_2.lang = p18.lang left outer join product_group pg ON p.group_id = pg.group_id left outer join product_group_translation pg18 ON pg18.group_id = pg.group_id and pg18.lang = p18.lang left outer join product_category pc on pc.category_id = p.category_id left outer join product_category_translation pc18 on pc18.category_id = p.category_id and pc18.lang = p18.lang left outer join product_pricelist ppl on (p.product_id = ppl.product_id and ppl.flag_active=1) left outer join pricelist pl on (pl.pricelist_id = ppl.pricelist_id and pl.flag_active=1) where 1=1 and p.flag_active = 1 and pl.flag_active = 1 and p.product_id = ? order by IF (p18.lang is null, @default_lang, p18.lang), p.product_id on duplicate key update keywords = UPPER( delete_double_spaces( REPLACE( strip_tags( TRIM( CONCAT_WS(' ', COALESCE(p.reference, ''), COALESCE(pb.title, ''), COALESCE(p18.title, p.title, ''), COALESCE(p18.invoice_title, p.invoice_title, ''), IF(p2.product_id is not null, COALESCE(p18_2.description, p2.description, ''), COALESCE(p18.description, p.description, '') ), COALESCE(p18.characteristic, p.characteristic, ''), COALESCE(p18.keywords, p.keywords, ''), COALESCE(pc18.breadcrumb, pc.breadcrumb, ''), COALESCE(pg18.title, pg.title, '') ) ) ) , ' ', ' ') ) ) , updated_at = @updated_at"; EXECUTE stmt USING @product_id; DEALLOCATE PREPARE stmt; END // DELIMITER ; DELIMITER // DROP PROCEDURE IF EXISTS `rebuild_category_breadcrumbs` // DELIMITER ; DELIMITER // CREATE PROCEDURE `rebuild_category_breadcrumbs` () BEGIN -- 1. Category UPDATE product_category INNER JOIN ( SELECT pc1.category_id, GROUP_CONCAT( pc2.title ORDER BY pc1.lvl , pc2.lvl -- could be utf8 - &rarr; → SEPARATOR ' | ' ) AS `breadcrumb` FROM `product_category` AS `pc1` LEFT JOIN `product_category` AS `pc2` ON pc1.lft BETWEEN pc2.lft AND pc2.rgt WHERE pc2.lvl > 0 GROUP BY 1 ORDER BY pc1.category_id ) AS tmp ON tmp.category_id = product_category.category_id SET product_category.breadcrumb = tmp.breadcrumb; -- 2. Category translations UPDATE product_category_translation INNER JOIN ( SELECT pc1.category_id, pc18.lang, GROUP_CONCAT( IF(pc18.title is null, pc2.title, pc18.title) ORDER BY pc1.lvl , pc2.lvl -- could be utf8 - &rarr; → SEPARATOR ' | ' ) AS `breadcrumb` FROM `product_category` AS `pc1` LEFT JOIN `product_category` AS `pc2` ON pc1.lft BETWEEN pc2.lft AND pc2.rgt LEFT JOIN `product_category_translation` AS `pc18` ON pc18.category_id = pc2.category_id WHERE pc2.lvl > 0 GROUP BY 1 , 2 ORDER BY pc1.category_id ) AS tmp ON tmp.category_id = product_category_translation.category_id AND tmp.lang = product_category_translation.lang SET product_category_translation.breadcrumb = tmp.breadcrumb; END// DELIMITER ; DELIMITER // DROP PROCEDURE IF EXISTS `rebuild_category_keywords` // DELIMITER ; DELIMITER // CREATE PROCEDURE `rebuild_category_keywords` () BEGIN -- 2. Product category translation keywords UPDATE product_category_translation INNER JOIN ( SELECT pc1.category_id, pc18.lang, GROUP_CONCAT( IF(pc18.title is null, pc2.title, pc18.title) ORDER BY pc1.lvl , pc2.lvl SEPARATOR ' ' ) AS `keywords` FROM `product_category` AS `pc1` LEFT JOIN `product_category` AS `pc2` ON pc1.lft BETWEEN pc2.lft AND pc2.rgt LEFT JOIN `product_category_translation` AS `pc18` ON pc18.category_id = pc2.category_id WHERE pc2.lvl > 0 GROUP BY 1 , 2 ORDER BY pc1.category_id ) AS tmp ON tmp.category_id = product_category_translation.category_id AND tmp.lang = product_category_translation.lang SET product_category_translation.keywords = tmp.keywords; END// DELIMITER ; DELIMITER // DROP EVENT IF EXISTS purge_api_key_logs; // DELIMITER ; DELIMITER // CREATE EVENT purge_api_key_logs ON SCHEDULE EVERY 1 WEEK ON COMPLETION PRESERVE ENABLE COMMENT 'Removes api_key_logs older than 12 months' DO DELETE FROM openstore_emd.api_key_log WHERE created_at < DATE_SUB(CURRENT_DATE(), INTERVAL 12 MONTH)// DELIMITER ; DELIMITER ;
true
4ce78469985b10a9820bb11e3de7c3ac97e3c7d3
SQL
ankitsinghmyself/Confer_space
/confer.sql
UTF-8
8,666
3.421875
3
[ "Apache-2.0" ]
permissive
-- phpMyAdmin SQL Dump -- version 5.0.1 -- https://www.phpmyadmin.net/ -- -- Host: localhost -- Generation Time: Mar 02, 2020 at 09:47 AM -- Server version: 10.4.11-MariaDB -- PHP Version: 7.2.27 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: `confer` -- -- -------------------------------------------------------- -- -- Table structure for table `admin` -- CREATE TABLE `admin` ( `userid` varchar(20) NOT NULL, `password` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `admin` -- INSERT INTO `admin` (`userid`, `password`) VALUES ('admin', 'admin'); -- -------------------------------------------------------- -- -- Table structure for table `admin_notifications` -- CREATE TABLE `admin_notifications` ( `notifid` int(11) NOT NULL, `notification` text NOT NULL, `date` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `admin_notifications` -- INSERT INTO `admin_notifications` (`notifid`, `notification`, `date`) VALUES (6, 'user <b>kiran</b> joined Confer Space', '2019-05-03 13:23:59'), (19, 'user <b>sheela</b> joined Confer Space', '2019-05-22 23:20:25'), (20, 'user <b>ajanta</b> joined Confer Space', '2019-05-22 23:56:58'), (21, 'user <b>ankit</b> joined Confer Space', '2020-03-02 13:22:16'), (22, 'user <b>alokk</b> joined Confer Space', '2020-03-02 13:23:43'); -- -------------------------------------------------------- -- -- Table structure for table `answers` -- CREATE TABLE `answers` ( `aid` int(11) NOT NULL, `answer` text NOT NULL, `qid` int(11) NOT NULL, `userid` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `answers` -- INSERT INTO `answers` (`aid`, `answer`, `qid`, `userid`) VALUES (4, '8 am', 1, 'askeee'), (6, 'hi askee', 1, 'anki'), (23, 'not necessarily', 64, 'anuj'), (24, 'around 4 to 5 months', 63, 'archi'), (25, '6 months\r\n', 63, 'anki'); -- -------------------------------------------------------- -- -- Table structure for table `questions` -- CREATE TABLE `questions` ( `qid` int(11) NOT NULL, `question` text NOT NULL, `userid` varchar(20) NOT NULL, `date` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `questions` -- INSERT INTO `questions` (`qid`, `question`, `userid`, `date`) VALUES (1, 'timing of college canteen?', 'askeee', '2019-04-27 09:32:46'), (5, 'duration of the course?', 'archi', '2019-04-27 09:30:14'), (60, 'what is the timing of class?', 'anki', '2019-05-02 21:18:25'), (63, 'what is the duration of each semester?', 'anuj', '2019-05-03 10:56:00'), (64, 'Are Saturdays holiday? ', 'archi', '2019-05-03 11:09:48'), (68, 'hi', 'anki', '2020-02-28 12:32:54'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `userid` varchar(20) NOT NULL, `name` varchar(256) NOT NULL, `password` varchar(20) NOT NULL, `email` varchar(30) NOT NULL, `mobile` bigint(20) NOT NULL, `gender` varchar(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `users` -- INSERT INTO `users` (`userid`, `name`, `password`, `email`, `mobile`, `gender`) VALUES ('alokk', 'alok kumar', '1234', 'alok@gmail.com', 9479396744, 'Male'), ('anisa', 'anisa rani', '12345', 'ani@gmail.com', 9087654321, 'Female'), ('anki', 'ankit', '1234', 'ank@g.com', 9479396742, 'Male'), ('ankit', 'ankit', '546', '123', 123, 'Male'), ('anuj', 'anuj srivastav', '123', 'anuj@gmail.com', 8907654321, 'Male'), ('archi', 'archana', '123', 'arch@gmail.com', 2087654321, 'Female'), ('askeee', 'Astha', '123', 'askee@gmail.com', 9087654321, 'Male'); -- -------------------------------------------------------- -- -- Table structure for table `user_notifications` -- CREATE TABLE `user_notifications` ( `notifid` int(11) NOT NULL, `notification` text NOT NULL, `userid` varchar(20) NOT NULL, `date` datetime NOT NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user_notifications` -- INSERT INTO `user_notifications` (`notifid`, `notification`, `userid`, `date`) VALUES (1, 'Welcome to Confer Space', 'anki', '2019-05-02 21:27:55'), (2, 'Welcome to Confer Space ', 'archi', '2019-05-02 21:27:55'), (3, 'Welcome to Confer Space', 'askeee', '2019-05-02 21:27:55'), (19, 'User <b>anki</b> answered your question : <b>hello</b><br/>Answer: <b>hi there</b>', 'anki', '2019-05-02 22:49:49'), (21, 'Welcome to Confer Space', 'anisa', '2019-05-02 23:01:02'), (22, 'User <b>renu</b> answered your question : <b>duration of the course?</b><br/>Answer: <b>three years\r\n</b>', 'archi', '2019-05-02 23:42:06'), (23, 'User <b>anki</b> answered your question : <b>timings for web lab sem 4?\r\n</b><br/>Answer: <b>8 am to 10:40 am</b>', 'anki', '2019-05-03 10:37:39'), (24, 'Welcome to Confer Space', 'anuj', '2019-05-03 10:44:07'), (25, 'User <b>anuj</b> answered your question : <b>Are Saturdays holiday? </b><br/>Answer: <b>not necessarily</b>', 'archi', '2019-05-03 11:10:26'), (26, 'User <b>archi</b> answered your question : <b>what is the duration of each semester?</b><br/>Answer: <b>around 4 to 5 months</b>', 'anuj', '2019-05-03 11:11:05'), (28, 'User <b>kiran</b> answered your question : <b>who am i?</b><br/>Answer: <b>fool</b>', 'anuj', '2019-05-03 13:24:22'), (29, 'User <b>anki</b> answered your question : <b>who am i?</b><br/>Answer: <b>hey there\r\n</b>', 'anuj', '2019-05-03 13:51:57'), (30, 'User <b>anki</b> answered your question : <b>what is the duration of each semester?</b><br/>Answer: <b>6 months\r\n</b>', 'anuj', '2019-05-09 13:11:25'), (31, 'User <b>sheeku</b> answered your question : <b>timings for web lab sem 4?\r\n</b><br/>Answer: <b>8</b>', 'anki', '2019-05-22 21:57:44'), (35, 'User <b>sheela</b> answered your question : <b>Are Saturdays holiday? </b><br/>Answer: <b>funny</b>', 'archi', '2019-05-22 23:21:03'), (38, 'User <b>ajanta</b> answered your question : <b>Are Saturdays holiday? </b><br/>Answer: <b>funny</b>', 'archi', '2019-05-22 23:57:49'), (40, 'Welcome to Confer Space', 'ankit', '2020-03-02 13:22:16'), (41, 'Welcome to Confer Space', 'alokk', '2020-03-02 13:23:43'); -- -- Indexes for dumped tables -- -- -- Indexes for table `admin` -- ALTER TABLE `admin` ADD PRIMARY KEY (`userid`); -- -- Indexes for table `admin_notifications` -- ALTER TABLE `admin_notifications` ADD PRIMARY KEY (`notifid`); -- -- Indexes for table `answers` -- ALTER TABLE `answers` ADD PRIMARY KEY (`aid`), ADD KEY `qid` (`qid`), ADD KEY `userid` (`userid`(10)), ADD KEY `userid_2` (`userid`); -- -- Indexes for table `questions` -- ALTER TABLE `questions` ADD PRIMARY KEY (`qid`), ADD KEY `userid` (`userid`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`userid`); -- -- Indexes for table `user_notifications` -- ALTER TABLE `user_notifications` ADD PRIMARY KEY (`notifid`), ADD KEY `userid` (`userid`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `admin_notifications` -- ALTER TABLE `admin_notifications` MODIFY `notifid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23; -- -- AUTO_INCREMENT for table `answers` -- ALTER TABLE `answers` MODIFY `aid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35; -- -- AUTO_INCREMENT for table `questions` -- ALTER TABLE `questions` MODIFY `qid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=69; -- -- AUTO_INCREMENT for table `user_notifications` -- ALTER TABLE `user_notifications` MODIFY `notifid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=42; -- -- Constraints for dumped tables -- -- -- Constraints for table `answers` -- ALTER TABLE `answers` ADD CONSTRAINT `answers_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `users` (`userid`); -- -- Constraints for table `questions` -- ALTER TABLE `questions` ADD CONSTRAINT `questions_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `users` (`userid`); -- -- Constraints for table `user_notifications` -- ALTER TABLE `user_notifications` ADD CONSTRAINT `user_notifications_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `users` (`userid`); 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
404e6c7d37d94d384081dd6f2838630d7472a7ca
SQL
sprataps/Database-Project-University
/project/load.sql
UTF-8
1,176
3.09375
3
[]
no_license
use stackoverflow; -- users data LOAD DATA LOCAL INFILE '/users/suryak/courses/db-class/project/data/users.txt' INTO TABLE users FIELDS TERMINATED BY '\t'; -- tags data LOAD DATA LOCAL INFILE '/users/suryak/courses/db-class/project/data/tags.txt' INTO TABLE tags FIELDS TERMINATED BY '\t'; -- posts data SET FOREIGN_KEY_CHECKS = 0; LOAD DATA LOCAL INFILE '/users/suryak/courses/db-class/project/data/posts.txt' INTO TABLE posts FIELDS TERMINATED BY '\t'; SET FOREIGN_KEY_CHECKS = 1; -- comments data LOAD DATA LOCAL INFILE '/users/suryak/courses/db-class/project/data/comments.txt' INTO TABLE comments FIELDS TERMINATED BY '\t'; -- posttags data LOAD DATA LOCAL INFILE '/users/suryak/courses/db-class/project/data/posttags.txt' INTO TABLE posttags FIELDS TERMINATED BY '\t'; -- fav data ALTER TABLE favs ADD COLUMN `dummy` INT NULL AFTER `user_id`; COMMIT; LOAD DATA LOCAL INFILE '/users/suryak/courses/db-class/project/data/favs.txt' INTO TABLE favs FIELDS TERMINATED BY '\t'; ALTER TABLE favs DROP COLUMN `dummy`; COMMIT; -- votes data LOAD DATA LOCAL INFILE '/users/suryak/courses/db-class/project/data/votes.txt' INTO TABLE votes FIELDS TERMINATED BY '\t';
true
e9a984ea4fc74561d8f54575bccf3ffb204732e8
SQL
FeFelix/teste
/db_teste_pg.sql
UTF-8
2,419
3.421875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1:3306 -- Tempo de geração: 22-Nov-2020 às 21:43 -- Versão do servidor: 8.0.21 -- versão do PHP: 7.3.21 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 */; -- -- Banco de dados: `db_teste_pg` -- -- -------------------------------------------------------- -- -- Estrutura da tabela `vendas` -- DROP TABLE IF EXISTS `vendas`; CREATE TABLE IF NOT EXISTS `vendas` ( `id` int NOT NULL AUTO_INCREMENT, `id_vendedor` int NOT NULL, `valor` double NOT NULL, `data` date NOT NULL, `cancelada` int NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `vendas_ibfk_1` (`id_vendedor`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -- Extraindo dados da tabela `vendas` -- INSERT INTO `vendas` (`id`, `id_vendedor`, `valor`, `data`, `cancelada`) VALUES (1, 19, 20.8, '2020-11-22', 0), (2, 19, 25, '2020-11-22', 1), (3, 20, 30, '2020-11-21', 0), (4, 19, 15, '2020-11-21', 0); -- -------------------------------------------------------- -- -- Estrutura da tabela `vendedores` -- DROP TABLE IF EXISTS `vendedores`; CREATE TABLE IF NOT EXISTS `vendedores` ( `id` int NOT NULL AUTO_INCREMENT, `nome` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `email` varchar(40) NOT NULL, `comissao` double NOT NULL DEFAULT '8.5', PRIMARY KEY (`id`), UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -- -- Extraindo dados da tabela `vendedores` -- INSERT INTO `vendedores` (`id`, `nome`, `email`, `comissao`) VALUES (19, 'joao', 'joao@gmail.com', 8.5), (20, 'maria', 'maria@hotmail.com', 8.5); -- -- Restrições para despejos de tabelas -- -- -- Limitadores para a tabela `vendas` -- ALTER TABLE `vendas` ADD CONSTRAINT `vendas_ibfk_1` FOREIGN KEY (`id_vendedor`) REFERENCES `vendedores` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; 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
49de7968ab860156c1e7966e3f3b2c83ca98f316
SQL
clester24/Covid-Analysis
/SQLQuery_Covid.sql
UTF-8
8,391
3.96875
4
[]
no_license
Select Location, date, total_cases, new_cases, total_deaths, population From CovidProject..CovidDeath Where continent is not null order by 1,2 --Total Cases vs Total Deaths Select Location, date, total_cases, total_deaths, (total_deaths/total_cases)*100 as DeathPCT From CovidProject..CovidDeath Where continent is not null order by 1,2 Create View DeathRate as Select location, date, total_cases, total_deaths, (total_deaths/total_cases)*100 as DeathPCT From CovidProject..CovidDeath Where continent is not null --Total Cases vs Population(percentage of people who got covid) Select Location, date, total_cases, Population, (total_cases/Population)*100 as InfectionPCT From CovidProject..CovidDeath Where continent is not null order by 1,2 Create View PopulationInfected as Select Location, date, total_cases, Population, (total_cases/Population)*100 as InfectionPCT From CovidProject..CovidDeath Where continent is not null --Countries infection rate compared to population Select Location, Population, MAX(total_cases) as HighestInfectionCount, MAX((total_cases/Population))*100 as InfectionPCT From CovidProject..CovidDeath Where continent is not null Group by Location, Population order by InfectionPCT desc Create View CountryInfectionRate as Select Location, Population, MAX(total_cases) as HighestInfectionCount, MAX((total_cases/Population))*100 as InfectionPCT From CovidProject..CovidDeath Where continent is not null Group by Location, Population --Highest death per population(Continent) Select Location, MAX(cast(total_deaths as int)) as TotalDeathCount From CovidProject..CovidDeath Where continent is null Group by Location order by TotalDeathCount desc --Highest death count(country) and deathpct Select Location, SUM(new_cases) as total_cases, MAX(cast(total_deaths as int)) as TotalDeathCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath Where continent is not null Group by Location order by TotalDeathCount desc Create View CountryDeathCount as Select Location, SUM(new_cases) as total_cases, MAX(cast(total_deaths as int)) as TotalDeathCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath Where continent is not null Group by Location --Total cases, Deaths and Death pct Select SUM(new_cases) as total_cases, SUM(cast(new_deaths as int)) as total_deaths, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath where continent is not null order by 1,2 --Total Population vs Vaccinations Select dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(cast(vac.new_vaccinations as int)) OVER (Partition by dea.location Order by dea.location, dea.date) as RollingCountVaccinations From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date where dea.continent is not null order by 2,3 Create View PopulationVaccinated as Select dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(cast(vac.new_vaccinations as int)) OVER (Partition by dea.location Order by dea.location, dea.date) as RollingCountVaccinations From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date where dea.continent is not null --Median age to infection rate Select dea.Location, MAX(vac.median_age) as median_age, MAX(total_cases) as HighestInfectionCount, MAX((total_cases/Population))*100 as InfectionPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.median_age order by median_age desc Create View MedianAgeInfectionRate as Select dea.Location, MAX(vac.median_age) as median_age, MAX(total_cases) as HighestInfectionCount, MAX((total_cases/Population))*100 as InfectionPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.median_age --Median age to death rate Select dea.Location, MAX(vac.median_age) as median_age, MAX(total_cases) as HighestInfectionCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.median_age order by median_age desc Create View MedianAgeDeathRate as Select dea.Location, MAX(vac.median_age) as median_age, MAX(total_cases) as HighestInfectionCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.median_age --smoker vs death rate Select dea.Location, Max(cast(male_smokers as real) + cast(female_smokers as real))/2 As SmokerPCT, MAX(total_cases) as HighestInfectionCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location order by SmokerPCT desc Create View SmokerDeathRateCovid as Select dea.Location, Max(cast(male_smokers as real) + cast(female_smokers as real))/2 As SmokerPCT, MAX(total_cases) as HighestInfectionCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location --Diabetes vs death rate Select dea.Location, vac.diabetes_prevalence, MAX(total_cases) as HighestInfectionCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.diabetes_prevalence order by diabetes_prevalence desc Create View DiabetesDeathRateCovid as Select dea.Location, vac.diabetes_prevalence, MAX(total_cases) as HighestInfectionCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.diabetes_prevalence --poverty vs death rate Select dea.Location, vac.extreme_poverty, MAX(total_cases) as HighestInfectionCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.extreme_poverty order by DeathPCT desc Create View PovertyDeathRate as Select dea.Location, vac.extreme_poverty, MAX(total_cases) as HighestInfectionCount, SUM(cast(new_deaths as int))/SUM(new_cases)*100 as DeathPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.extreme_poverty --poverty vs infection rate Select dea.Location, vac.extreme_poverty, MAX(total_cases) as HighestInfectionCount, MAX((total_cases/Population))*100 as InfectionPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.extreme_poverty order by InfectionPCT desc Create View PovertyInfectionRate as Select dea.Location, vac.extreme_poverty, MAX(total_cases) as HighestInfectionCount, MAX((total_cases/Population))*100 as InfectionPCT From CovidProject..CovidDeath dea Join CovidProject..CovidVaccinations vac on dea.location = vac.location and dea.date = vac.date Where dea.continent is not null Group by dea.Location, vac.extreme_poverty
true
024753af8325eef656a8ce34f46520eb74f69552
SQL
ALriddle/sikm-alirsyad
/database/kategory_pemasukan.sql
UTF-8
1,438
2.84375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 3.2.4 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Feb 14, 2015 at 10:27 AM -- Server version: 5.1.41 -- PHP Version: 5.3.1 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: `sales_act2` -- -- -------------------------------------------------------- -- -- Table structure for table `kategory_pemasukan` -- CREATE TABLE IF NOT EXISTS `kategory_pemasukan` ( `KODE_PEMASUKAN` varchar(50) NOT NULL, `NAMA_PEMASUKAN` varchar(50) NOT NULL, PRIMARY KEY (`KODE_PEMASUKAN`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `kategory_pemasukan` -- INSERT INTO `kategory_pemasukan` (`KODE_PEMASUKAN`, `NAMA_PEMASUKAN`) VALUES ('1102', 'SETORAN BANK'), ('4200', 'INFAQ DARI CELENGAN JUMAT'), ('4300', 'INFAQ DARI CELENGAN RENOVASI'), ('4400', 'INFAQ UNTUK PROGRAM'), ('4500', 'PEMASUKAN LAIN-LAIN'), ('4100', 'INFAQ DARI CELENGAN KAMIS'), ('1101', 'TARIKAN TUNAI'), ('4600', 'INFAQ DARI DONATUR TETAP'), ('4000', 'SALDO AWAL'); /*!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
a64e26f7f5c82baf19de8bb96046f7d6df271501
SQL
scan1500/prog-sql
/Aufgabe04/wwfgusc_integrity.sql
UTF-8
6,360
3.8125
4
[]
no_license
use wwfgusc; # Aufgabe 1 /* Mit Außerdienststellung (Löschung) eines Flugzeugs wird auch die Information gelöscht, welche Ausstattungsmerkmale es besitzt (ALTER TABLE…). */ ALTER TABLE wwfgusc.Maschine_Merkmal DROP FOREIGN KEY maschine_merkmal_ibfk_1; ALTER TABLE wwfgusc.Maschine_Merkmal ADD CONSTRAINT maschine_merkmal_ibfk_1 FOREIGN KEY (`Maschine_Kennzeichen`) REFERENCES `Maschine` (`Kennzeichen`) ON DELETE CASCADE; # Aufgabe 2 /* Für einen Flug dürfen nur Maschinen des für die Flugverbindung vorgesehenen Typs eingesetzt werden (TRIGGER). */ /* DROP TRIGGER IF EXISTS tr_falscher_flugzeugtyp; DELIMITER // CREATE TRIGGER tr_falscher_flugzeugtyp BEFORE INSERT ON wwfgusc.Flug FOR EACH ROW BEGIN IF (SELECT COUNT(maschine.kennzeichen) FROM maschine JOIN flugzeugtyp ON maschine.flugzeugtyp_modell = flugzeugtyp.modell JOIN flugverbindung ON flugzeugtyp.modell = flugverbindung.flugzeugtyp_modell WHERE NEW.maschine_kennzeichen = maschine.kennzeichen AND NEW.flugverbindung_flugnummer = flugverbindung.flugnummer) = 0 THEN signal sqlstate '45000' set message_text = 'Falscher Flugzeugtyp für Flugverbindung'; END IF; END // DELIMITER ; */ /* INSERT INTO `Flug` (`Flugdatum`, `Maschine_Kennzeichen`, `Flugverbindung_Flugnummer`) VALUES ('2017-04-26', 'D-IKOP', 'WWF 925'); */ # Aufgabe 3 /* Bei Neuanlage eines Flugs wird die Anzahl freier Plätze pro Klasse mit der Maximalzahl an Plätzen der entsprechenden Klasse im verwendeten Flugzeugtyp initialisiert (TRIGGER). */ DROP TRIGGER IF EXISTS tr_falscher_flugzeugtyp; DROP TRIGGER IF EXISTS tr_plaetze_neuanlage; DELIMITER // CREATE TRIGGER tr_plaetze_neuanlage AFTER INSERT ON wwfgusc.Flug FOR EACH ROW BEGIN INSERT INTO Flug_Buchungsklasse (`Flug_Flugdatum`, `Flug_Maschine_Kennzeichen`, `Flug_Flugverbindung_Flugnummer`, `Buchungsklasse_BuchungsklassenID`, `Anzahl freier Plätze`) SELECT NEW.flugdatum, NEW.maschine_kennzeichen, NEW.flugverbindung_flugnummer, 1, flugzeugtyp_buchungsklasse.platzangebot FROM flugzeugtyp_buchungsklasse JOIN flugzeugtyp ON flugzeugtyp_buchungsklasse.flugzeugtyp_modell = flugzeugtyp.modell JOIN maschine ON flugzeugtyp.modell = maschine.flugzeugtyp_modell WHERE NEW.maschine_kennzeichen = maschine.kennzeichen AND flugzeugtyp_buchungsklasse.buchungsklasse_buchungsklassenID = 1; INSERT INTO Flug_Buchungsklasse (`Flug_Flugdatum`, `Flug_Maschine_Kennzeichen`, `Flug_Flugverbindung_Flugnummer`, `Buchungsklasse_BuchungsklassenID`, `Anzahl freier Plätze`) SELECT NEW.flugdatum, NEW.maschine_kennzeichen, NEW.flugverbindung_flugnummer, 2, flugzeugtyp_buchungsklasse.platzangebot FROM flugzeugtyp_buchungsklasse JOIN flugzeugtyp ON flugzeugtyp_buchungsklasse.flugzeugtyp_modell = flugzeugtyp.modell JOIN maschine ON flugzeugtyp.modell = maschine.flugzeugtyp_modell WHERE NEW.maschine_kennzeichen = maschine.kennzeichen AND flugzeugtyp_buchungsklasse.buchungsklasse_buchungsklassenID = 2; INSERT INTO Flug_Buchungsklasse (`Flug_Flugdatum`, `Flug_Maschine_Kennzeichen`, `Flug_Flugverbindung_Flugnummer`, `Buchungsklasse_BuchungsklassenID`, `Anzahl freier Plätze`) SELECT NEW.flugdatum, NEW.maschine_kennzeichen, NEW.flugverbindung_flugnummer, 3, flugzeugtyp_buchungsklasse.platzangebot FROM flugzeugtyp_buchungsklasse JOIN flugzeugtyp ON flugzeugtyp_buchungsklasse.flugzeugtyp_modell = flugzeugtyp.modell JOIN maschine ON flugzeugtyp.modell = maschine.flugzeugtyp_modell WHERE NEW.maschine_kennzeichen = maschine.kennzeichen AND flugzeugtyp_buchungsklasse.buchungsklasse_buchungsklassenID = 3; END // DELIMITER ; # Aufgabe 4 /* Schreiben Sie eine gespeicherte PROZEDUR, die Flugnummer, Abflug- und Ankunftszeit und noch verfügbare Plätze in der Economy-Klasse aller Flüge zwischen zwei Flughäfen an einem bestimmten Datum ermittelt. Die Kürzel der beiden Flughäfen und das Flugdatum werden als Parameter übergeben. */ DROP PROCEDURE IF EXISTS pr_eco_search; DELIMITER // CREATE PROCEDURE pr_eco_search(IN abflugort CHAR(3), IN ankunftsort CHAR(3), IN flugdatum DATE) BEGIN SELECT flugverbindung.flugnummer, flugverbindung.abflugzeit, flugverbindung.ankunftszeit, flug_buchungsklasse.`Anzahl freier Plätze` FROM flugverbindung JOIN flughafen startk ON flugverbindung.startknoten = startk.kürzel JOIN flughafen endk ON flugverbindung.endknoten = endk.kürzel JOIN flugzeugtyp ON flugverbindung.flugzeugtyp_modell = flugzeugtyp.modell JOIN maschine ON flugzeugtyp.modell = maschine.flugzeugtyp_modell JOIN flug ON flugverbindung.flugnummer = flug.flugverbindung_flugnummer AND maschine.kennzeichen = flug.maschine_kennzeichen JOIN buchungsklasse JOIN flug_buchungsklasse ON flug.flugdatum = flug_buchungsklasse.flug_flugdatum AND maschine.kennzeichen = flug_buchungsklasse.flug_maschine_kennzeichen AND flugverbindung.flugnummer = flug_buchungsklasse.flug_flugverbindung_flugnummer AND buchungsklasse.buchungsklassenid = flug_buchungsklasse.buchungsklasse_buchungsklassenid WHERE flugverbindung.startknoten = abflugort AND flugverbindung.endknoten = ankunftsort AND Flug_Buchungsklasse.flug_flugdatum = flugdatum AND buchungsklasse.buchungsklassenid = 1; END // DELIMITER ; INSERT INTO `Flug` (`Flugdatum`, `Maschine_Kennzeichen`, `Flugverbindung_Flugnummer`) VALUES ('2077-04-24', 'D-ABYZ', 'WWF 925'), ('2077-04-24', 'D-EFST', 'WWF 4756'); CALL pr_eco_search ('NUE','FRA','2077-04-24'); # Aufgabe 5 /* Erstellen Sie eine FUNKTION, die für eine Flugverbindung die Gesamtflugdauer in Minuten ermittelt (in Anlehnung an Abfrage 16 von Aufgabenblatt 3). Die Kennung der Flugverbindung wird als Parameter übergeben. */ DELIMITER // CREATE FUNCTION fnc_flight_duration(kennung VARCHAR(10)) RETURNS INT BEGIN RETURN (SELECT CAST(TIME_TO_SEC(TIME_FORMAT(TIME(ABS(DATE_ADD(TIMEDIFF(flugverbindung.ankunftszeit, flugverbindung.abflugzeit), INTERVAL (startk.zeitzone - endk.zeitzone) HOUR))),'%H:%i'))/60 AS UNSIGNED INT) AS Flugdauer_Minuten FROM flugverbindung JOIN flughafen startk ON flugverbindung.startknoten = startk.kürzel JOIN flughafen endk ON flugverbindung.endknoten = endk.kürzel WHERE flugverbindung.Flugnummer = kennung); END // DELIMITER ;
true
6341f524b10b9e20d382873f59f16accfe7d44a7
SQL
vkazhdan/springbmvc-app
/src/main/resources/db/springb-test.sql
UTF-8
5,154
3
3
[]
no_license
-- -- PostgreSQL database dump -- -- Dumped from database version 10.5 -- Dumped by pg_dump version 10.5 -- Started on 2019-03-04 10:58:02 EET SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 13241) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 3141 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 200 (class 1259 OID 16804) -- Name: bookmark; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.bookmark ( id bigint NOT NULL, user_id bigint NOT NULL, title character varying(64), url character varying(255) ); ALTER TABLE public.bookmark OWNER TO postgres; -- -- TOC entry 197 (class 1259 OID 16408) -- Name: hibernate_sequence; Type: SEQUENCE; Schema: public; Owner: postgres -- CREATE SEQUENCE public.hibernate_sequence START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.hibernate_sequence OWNER TO postgres; -- -- TOC entry 196 (class 1259 OID 16403) -- Name: message; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.message ( id integer NOT NULL, text character varying(255) ); ALTER TABLE public.message OWNER TO postgres; -- -- TOC entry 198 (class 1259 OID 16666) -- Name: user_role; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.user_role ( user_id bigint NOT NULL, roles character varying(255) ); ALTER TABLE public.user_role OWNER TO postgres; -- -- TOC entry 199 (class 1259 OID 16669) -- Name: usr; Type: TABLE; Schema: public; Owner: postgres -- CREATE TABLE public.usr ( id bigint NOT NULL, active boolean NOT NULL, password character varying(255), username character varying(255) ); ALTER TABLE public.usr OWNER TO postgres; -- -- TOC entry 3133 (class 0 OID 16804) -- Dependencies: 200 -- Data for Name: bookmark; Type: TABLE DATA; Schema: public; Owner: postgres -- COPY public.bookmark (id, user_id, title, url) FROM stdin; 2 1 Google http://google.com 1 1 Baeldung https://www.baeldung.com/ \. -- -- TOC entry 3129 (class 0 OID 16403) -- Dependencies: 196 -- Data for Name: message; Type: TABLE DATA; Schema: public; Owner: postgres -- COPY public.message (id, text) FROM stdin; 1 Hello 2 Nice Day 3 Hello Everybody \. -- -- TOC entry 3131 (class 0 OID 16666) -- Dependencies: 198 -- Data for Name: user_role; Type: TABLE DATA; Schema: public; Owner: postgres -- COPY public.user_role (user_id, roles) FROM stdin; 1 USER 2 ADMIN 4 USER 5 USER 5 ADMIN 6 USER 7 USER \. -- -- TOC entry 3132 (class 0 OID 16669) -- Dependencies: 199 -- Data for Name: usr; Type: TABLE DATA; Schema: public; Owner: postgres -- COPY public.usr (id, active, password, username) FROM stdin; 1 t $2a$10$nOgTxOmhgH343/ClYWYgpeIfo3i9rQQmHKeynh6gUbUoiZj8bC2Ym u 2 t $2a$10$nOgTxOmhgH343/ClYWYgpeIfo3i9rQQmHKeynh6gUbUoiZj8bC2Ym a 4 t $2a$10$nOgTxOmhgH343/ClYWYgpeIfo3i9rQQmHKeynh6gUbUoiZj8bC2Ym uu 5 t $2a$10$nOgTxOmhgH343/ClYWYgpeIfo3i9rQQmHKeynh6gUbUoiZj8bC2Ym aa 6 t $2a$10$nOgTxOmhgH343/ClYWYgpeIfo3i9rQQmHKeynh6gUbUoiZj8bC2Ym u3 7 t $2a$10$nOgTxOmhgH343/ClYWYgpeIfo3i9rQQmHKeynh6gUbUoiZj8bC2Ym u4 \. -- -- TOC entry 3142 (class 0 OID 0) -- Dependencies: 197 -- Name: hibernate_sequence; Type: SEQUENCE SET; Schema: public; Owner: postgres -- SELECT pg_catalog.setval('public.hibernate_sequence', 10, true); -- -- TOC entry 3005 (class 2606 OID 16808) -- Name: bookmark bookmark_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.bookmark ADD CONSTRAINT bookmark_pkey PRIMARY KEY (id); -- -- TOC entry 3001 (class 2606 OID 16407) -- Name: message message_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.message ADD CONSTRAINT message_pkey PRIMARY KEY (id); -- -- TOC entry 3003 (class 2606 OID 16676) -- Name: usr usr_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.usr ADD CONSTRAINT usr_pkey PRIMARY KEY (id); -- -- TOC entry 3007 (class 2606 OID 16809) -- Name: bookmark fk3claygmi8gds4yd97ofdtrtnu; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.bookmark ADD CONSTRAINT fk3claygmi8gds4yd97ofdtrtnu FOREIGN KEY (user_id) REFERENCES public.usr(id); -- -- TOC entry 3006 (class 2606 OID 16677) -- Name: user_role fkfpm8swft53ulq2hl11yplpr5; Type: FK CONSTRAINT; Schema: public; Owner: postgres -- ALTER TABLE ONLY public.user_role ADD CONSTRAINT fkfpm8swft53ulq2hl11yplpr5 FOREIGN KEY (user_id) REFERENCES public.usr(id); -- Completed on 2019-03-04 10:58:02 EET -- -- PostgreSQL database dump complete --
true
2be03859dafccd84f5efd61354ccb8b0dfc97b3e
SQL
mtstnt/soaltest
/SOAL_SQL.sql
UTF-8
416
3.578125
4
[]
no_license
DROP DATABASE IF EXISTS soaltestsql_matthew; CREATE DATABASE soaltestsql_matthew; CREATE TABLE user( id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(20), parent INT ); INSERT INTO user (username, parent) VALUES("Ali", 2), ("Budi", 0), ("Cecep", 1); SELECT u.id as Id, u.username as UserName, v.username as ParentUserName FROM user u LEFT JOIN user v ON u.parent = v.id; DROP DATABASE soaltestsql_matthew;
true
0c926d51d5fa57769d343a7b83efc4f9e90cfdbd
SQL
junrudai/sqlzoo
/Guest_house/Medium/10.sql
UTF-8
223
3.375
3
[]
no_license
-- Attention on the date calculation, whether it's inclusive or not SELECT SUM(occupants) FROM booking AS b WHERE b.booking_date <= '2016-11-21' AND DATEADD (day, nights - 1, b.booking_date) >= '2016-11-21'
true
42d4bd335aa7c23d2b0c7eff9eb2197d0a00cc89
SQL
yashdedania/equipment_library
/equiptemp.sql
UTF-8
5,662
3.125
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.1.14 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Jan 15, 2018 at 02:28 PM -- Server version: 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: `equiptemp` -- -- -------------------------------------------------------- -- -- Table structure for table `cart` -- CREATE TABLE IF NOT EXISTS `cart` ( `cartid` mediumint(9) NOT NULL AUTO_INCREMENT, `pid` mediumint(6) NOT NULL, `items_id` mediumint(9) NOT NULL, `qty` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`cartid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Dumping data for table `cart` -- INSERT INTO `cart` (`cartid`, `pid`, `items_id`, `qty`) VALUES (4, 142028, 2, 1); -- -------------------------------------------------------- -- -- Table structure for table `donate` -- CREATE TABLE IF NOT EXISTS `donate` ( `p_key` int(11) NOT NULL AUTO_INCREMENT, `name` text NOT NULL, `qty` int(5) NOT NULL, `item` varchar(100) NOT NULL, PRIMARY KEY (`p_key`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `items` -- CREATE TABLE IF NOT EXISTS `items` ( `p_key` int(11) NOT NULL AUTO_INCREMENT, `item` varchar(30) NOT NULL, `cost` int(11) NOT NULL, `quantity` int(11) NOT NULL, `mode` text NOT NULL, `gen_name` varchar(100) NOT NULL, PRIMARY KEY (`p_key`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; -- -- Dumping data for table `items` -- INSERT INTO `items` (`p_key`, `item`, `cost`, `quantity`, `mode`, `gen_name`) VALUES (1, 'Raspberry Pi', 3000, 10, 'Purchase', 'MicroProcessor'), (2, 'arduino', 450, 30, 'donate', 'microcontroller'); -- -------------------------------------------------------- -- -- Table structure for table `loss` -- CREATE TABLE IF NOT EXISTS `loss` ( `p_key` int(11) NOT NULL AUTO_INCREMENT, `pid` varchar(15) NOT NULL, `name` text NOT NULL, `reason` varchar(50) NOT NULL, `cost` int(10) NOT NULL, `qty` tinyint(4) NOT NULL, `item` varchar(100) NOT NULL, PRIMARY KEY (`p_key`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -------------------------------------------------------- -- -- Table structure for table `order` -- CREATE TABLE IF NOT EXISTS `order` ( `p_key` int(11) NOT NULL AUTO_INCREMENT, `pid` mediumint(6) NOT NULL, `date_taken` date NOT NULL, `date_return` date DEFAULT NULL, `status` varchar(15) NOT NULL, `name` text NOT NULL, `class` varchar(50) NOT NULL, `contact` bigint(11) NOT NULL, `flag` varchar(300) DEFAULT NULL, `reason` text NOT NULL, `email` varchar(255) NOT NULL, `prof_email` varchar(255) DEFAULT NULL, PRIMARY KEY (`p_key`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=31 ; -- -- Dumping data for table `order` -- INSERT INTO `order` (`p_key`, `pid`, `date_taken`, `date_return`, `status`, `name`, `class`, `contact`, `flag`, `reason`, `email`, `prof_email`) VALUES (2, 142025, '2017-03-03', '2017-03-08', 'returned', 'steven', 'te cmpn a', 8455723458, '', 'personal', 'steven@mail.com', 'abc2'), (1, 142028, '2017-03-01', NULL, 'requested', 'varun', 'te cmpn b', 8655964365, NULL, 'pragati', 'varunmaniark@gmail.com', 'abc'), (3, 142001, '2017-04-05', NULL, 'returned', 'name1', 'class1', 9650967392, 'flag1', 'reason1', 'email1', NULL), (4, 142002, '2017-04-05', NULL, 'returned', 'name2', 'class1', 9876543210, 'flag2', 'reason2', 'email2', NULL), (5, 142003, '2017-04-06', NULL, 'returned', 'name3', 'class3', 9876543210, 'flasg3', 'reason3', 'email3', NULL), (7, 142005, '2017-04-04', NULL, 'returned', 'name5', 'class5', 9876543210, 'flag5', 'reason5', 'email5', NULL), (8, 142006, '2017-04-06', NULL, 'returned', 'name6', 'class6', 9876543210, 'flag6', 'reason6', 'email6', NULL), (9, 142007, '2017-04-07', NULL, 'returned', 'name7', 'class7', 9876543210, 'flag7', 'reason7', 'email7', NULL), (10, 142008, '2017-04-06', NULL, 'returned', 'name8', 'class8', 9876543210, 'flag8', 'reason8', 'email8', NULL), (11, 142009, '2017-04-06', NULL, 'returned', 'name9', 'class9', 9876543210, 'flag9', 'reason9', 'email9', NULL), (12, 142010, '2017-04-07', NULL, 'returned', 'name10', 'class10', 9876543120, 'flag10', 'reason10', 'email10', NULL); -- -------------------------------------------------------- -- -- Table structure for table `orderdetails` -- CREATE TABLE IF NOT EXISTS `orderdetails` ( `p_key` int(11) NOT NULL AUTO_INCREMENT, `item` varchar(100) NOT NULL, `qty` mediumint(5) NOT NULL, `order_id` mediumint(9) NOT NULL, `item_id` int(11) NOT NULL, PRIMARY KEY (`p_key`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=35 ; -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE IF NOT EXISTS `users` ( `uid` mediumint(9) NOT NULL AUTO_INCREMENT, `pid` int(11) NOT NULL, `password` varchar(30) NOT NULL, `username` varchar(100) NOT NULL, PRIMARY KEY (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `users` -- INSERT INTO `users` (`uid`, `pid`, `password`, `username`) VALUES (1, 142028, 'equip', 'admin'); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
54e3ea28df0ef03e753eb9cc386d26942e5aa390
SQL
pingcap/dm
/tests/sql_mode/data/db2.increment.sql
UTF-8
1,013
2.8125
3
[ "Apache-2.0" ]
permissive
set @@session.sql_mode='ONLY_FULL_GROUP_BY,NO_UNSIGNED_SUBTRACTION,NO_DIR_IN_CREATE,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,HIGH_NOT_PRECEDENCE,NO_ENGINE_SUBSTITUTION,REAL_AS_FLOAT'; -- NO_AUTO_CREATE_USER set failed in mysql8.0 use sql_mode; -- test sql_mode PIPES_AS_CONCAT set @@session.sql_mode=concat(@@session.sql_mode, ',PIPES_AS_CONCAT'); insert into t_2(name) values('pipes'||'as'||'concat'); -- test sql_mode ANSI_QUOTES insert into t_2(name) values("a"); -- test sql_mode IGNORE_SPACE set @@session.sql_mode=concat(@@session.sql_mode, ',IGNORE_SPACE'); insert into t_2(name) values(concat ('ignore', 'space')); -- test sql_mode NO_AUTO_VALUE_ON_ZERO set @@session.sql_mode=concat(@@session.sql_mode, ',NO_AUTO_VALUE_ON_ZERO'); insert into t_2(id, name) values (20, 'a'); replace into t_2(id, name) values (0, 'c'); -- test sql_mode NO_BACKSLASH_ESCAPES set @@session.sql_mode=concat(@@session.sql_mode, ',NO_BACKSLASH_ESCAPES'); insert into t_2(name) values ('\\a');
true
327e5aea0942d1e565100490afbd5562d6aae253
SQL
daniiel/cursos
/Oracle 11g - Introduction to SQL/courselabs/sql2/code_ex/code_06_33_s.sql
UTF-8
724
3.703125
4
[]
no_license
Drop Table Flights; CREATE TABLE flights (source varchar(20), destin varchar(20), flight_time number); INSERT INTO flights VALUES ('San Jose', 'Los Angeles', 1.3); INSERT INTO flights VALUES ('New York', 'Boston', 1.1); INSERT INTO flights VALUES ('Los Angeles', 'New York', 5.8); COMMIT; SELECT Source, Destin, Flight_Time FROM flights; WITH Reachable_From (Source, Destin, TotalFlightTime) AS ( SELECT Source, Destin, Flight_time FROM Flights UNION ALL SELECT incoming.Source, outgoing.Destin, incoming.TotalFlightTime+outgoing.Flight_time FROM Reachable_From incoming, Flights outgoing WHERE incoming.Destin = outgoing.Source ) SELECT Source, Destin, TotalFlightTime FROM Reachable_From;
true
b1829339df4b1e6ba392db5842d25def7bf1dbf0
SQL
MikhailTokarev/CS561
/cs561Project/database/warehouse.sql
UTF-8
2,670
3.4375
3
[]
no_license
/* Navicat MySQL Data Transfer Source Server : 001 Source Server Version : 50016 Source Host : localhost:3306 Source Database : warehouse Target Server Type : MYSQL Target Server Version : 50016 File Encoding : 65001 Date: 2019-10-07 13:16:07 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for renter_account -- ---------------------------- DROP TABLE IF EXISTS `renter_account`; CREATE TABLE `renter_account` ( `user_id` int(10) NOT NULL, `balance` float(200,0) default NULL, `rented_warehouse` int(11) default NULL, KEY `renter_account_ibfk_1` (`user_id`), CONSTRAINT `renter_account_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- ---------------------------- -- Records of renter_account -- ---------------------------- -- ---------------------------- -- Table structure for rent_order -- ---------------------------- DROP TABLE IF EXISTS `rent_order`; CREATE TABLE `rent_order` ( `order_id` int(10) NOT NULL, `user_id` int(10) default NULL, `order_date` datetime default NULL, PRIMARY KEY (`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- ---------------------------- -- Records of rent_order -- ---------------------------- -- ---------------------------- -- Table structure for user -- ---------------------------- DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `user_id` int(10) NOT NULL, `username` varchar(150) default NULL, `password` varchar(128) default NULL, `last_login` datetime default NULL, `first_name` varchar(30) default NULL, `last_name` varchar(150) default NULL, `email` varchar(254) default NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- ---------------------------- -- Records of user -- ---------------------------- -- ---------------------------- -- Table structure for warehouse -- ---------------------------- DROP TABLE IF EXISTS `warehouse`; CREATE TABLE `warehouse` ( `warehouse_id` int(11) NOT NULL, `warehouse_name` varchar(150) default NULL, `warehouse_size` int(10) default NULL, `warehouse_desc` varchar(254) default NULL, `warehouse_image` varchar(255) default NULL, `warehouse_price` double default NULL, `warehouse_category` varchar(150) default NULL, `warehouse_isAvailable` tinyint(1) default NULL, `warehouse_currentowenr_use_id` int(10) default NULL, PRIMARY KEY (`warehouse_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- ---------------------------- -- Records of warehouse -- ----------------------------
true
16cecf51e44e82c43a231001961204615f24785a
SQL
leetoo/openstock
/src/main/resources/db/migration/V2015.07.26.13.08__create_table_account.sql
UTF-8
207
2.625
3
[]
no_license
CREATE TABLE account ( id serial NOT NULL, email character varying(255) NOT NULL, balance numeric NOT NULL, created timestamp without time zone NOT NULL, CONSTRAINT "PK_ACCOUNT" PRIMARY KEY (id) );
true
96a2db5ec34ee7596d71330246ab0e9509a0ef32
SQL
candycake124/NTL_AHT
/Test-MVC/db_quanly.sql
UTF-8
2,589
3.234375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.4 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: May 19, 2021 at 03:53 AM -- Server version: 10.4.17-MariaDB -- PHP Version: 8.0.2 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: `db_quanly` -- -- -------------------------------------------------------- -- -- Table structure for table `khachhang` -- CREATE TABLE `khachhang` ( `id` int(255) NOT NULL, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `email` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `created_date` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `updated_date` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `khachhang` -- INSERT INTO `khachhang` (`id`, `name`, `email`, `created_date`, `updated_date`) VALUES (1, 'Nguyen Thi Ly', 'ntly@gmail.comc', '2021-05-17', '2021-05-18'), (7, 'Nguyen Thanh Loan', 'ntloan@gmil.com', '2021-05-16', '2021-05-17'); -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `id` int(50) NOT NULL, `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `user_type` int(4) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id`, `name`, `password`, `user_type`) VALUES (1, 'admin', 'beb529008611ed11a781978c2299a38e', 1), (2, 'userrr', '202cb962ac59075b964b07152d234b70', 2), (9, 'user', '81dc9bdb52d04dc20036dbd8313ed055', 2), (11, 'abc', '827ccb0eea8a706c4c34a16891f84e7b', 1), (12, 'abcv', 'beb529008611ed11a781978c2299a38e', 2); -- -- Indexes for dumped tables -- -- -- Indexes for table `khachhang` -- ALTER TABLE `khachhang` ADD PRIMARY KEY (`id`); -- -- Indexes for table `user` -- ALTER TABLE `user` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `khachhang` -- ALTER TABLE `khachhang` MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; -- -- AUTO_INCREMENT for table `user` -- ALTER TABLE `user` MODIFY `id` int(50) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; 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
d9145491c883bd82f1d8d048de55362adb12327f
SQL
cin-lawrence/sqlcookbook
/commander/commands/chapter14/06.sql
UTF-8
527
3.09375
3
[]
no_license
-- 14.6 Searching for Mixed Alphanumeric Strings -- with V as ( select 'ClassSummary' strings from t1 union select '3453430278' from t1 union select 'findRow 55' from t1 union select '1010 switch' from t1 union select '333' from t1 union select 'threes' from t1 ) select strings from ( select strings, translate(strings, 'abcdefghijklmnopqrstuvwxyz0123456789', rpad('#', 26, '#')||rpad('*', 10, '*')) translated from v ) x where strpos(translated, '#') > 0 and strpos(translated, '*') > 0;
true
ebc2e433bbec333c843ad293ef06f0c0f8a493d3
SQL
phonotheque-historique-ocean-indien/mysql-database
/export-valentina-db-pro/current_script_folder/Links/lnk_Projetdemastering_Traiter.sql
UTF-8
334
2.828125
3
[]
no_license
-- CREATE LINK "lnk_Projetdemastering_Traiter" ----------------- ALTER TABLE `Traiter` ADD CONSTRAINT `lnk_Projetdemastering_Traiter` FOREIGN KEY ( `idProjetdemastering` ) REFERENCES `Projetdemastering`( `idProjetdemastering` ) ON DELETE Cascade ON UPDATE Cascade; -- -------------------------------------------------------------
true
ff223476732c6115f474dfc394f35261f554e137
SQL
radtek/abs3
/sql/mmfo/bars/Package/customer_utl.sql
WINDOWS-1251
8,878
3.15625
3
[]
no_license
PROMPT ===================================================================================== PROMPT *** Run *** ========== Scripts /Sql/BARS/package/customer_utl.sql =========*** Run ** PROMPT ===================================================================================== CREATE OR REPLACE PACKAGE BARS.CUSTOMER_UTL is TAG_MAIN_MOBILE_PHONE constant varchar2(5 char) := 'MPNO '; function read_customer( p_customer_id in integer, p_raise_ndf in boolean default true) return customer%rowtype; function read_person( p_customer_id in integer, p_raise_ndf in boolean default true) return person%rowtype; function read_bank( p_mfo_code in varchar2, p_raise_ndf in boolean default true) return banks$base%rowtype; function read_customer_bank( p_customer_id in integer, p_raise_ndf in boolean default true) return custbank%rowtype; function get_customer_name( p_customer_id in integer) return varchar2; function get_customer_short_name( p_customer_id in integer) return varchar2; function get_customer_okpo( p_customer_id in integer) return varchar2; function get_customer_mfo( p_customer_id in integer) return varchar2; function get_customer_bic( p_customer_id in integer) return varchar2; function get_customer_address_row( p_customer_id in integer, p_address_type in integer default null) return customer_address%rowtype; function get_customer_address_line( p_customer_id in integer, p_address_type in integer default null) return varchar2; function get_customer_mobile_phone( p_customer_id in integer) return varchar2; function get_customer_mobile_phone( p_object_id in integer, p_attribute_id in integer, p_value_date in date default null) return varchar2; function get_person_paper_line( p_person_id in integer) return varchar2; end; / CREATE OR REPLACE PACKAGE BODY BARS.CUSTOMER_UTL as function read_customer( p_customer_id in integer, p_raise_ndf in boolean default true) return customer%rowtype is l_customer_row customer%rowtype; begin select * into l_customer_row from customer c where c.rnk = p_customer_id; return l_customer_row; exception when no_data_found then if (p_raise_ndf) then raise_application_error(-20000, '볺 {' || p_customer_id || '} '); else return null; end if; end; function read_person( p_customer_id in integer, p_raise_ndf in boolean default true) return person%rowtype is l_person_row person%rowtype; begin select * into l_person_row from person p where p.rnk = p_customer_id; return l_person_row; exception when no_data_found then if (p_raise_ndf) then raise_application_error(-20000, 'Գ {' || p_customer_id || '} '); else return null; end if; end; function read_bank( p_mfo_code in varchar2, p_raise_ndf in boolean default true) return banks$base%rowtype is l_bank_row banks$base%rowtype; begin select * into l_bank_row from banks$base b where b.mfo = p_mfo_code; return l_bank_row; exception when no_data_found then if (p_raise_ndf) then raise_application_error(-20000, ' {' || p_mfo_code || '} '); else return null; end if; end; function read_customer_bank( p_customer_id in integer, p_raise_ndf in boolean default true) return custbank%rowtype is l_customer_bank_row custbank%rowtype; begin select * into l_customer_bank_row from custbank b where b.rnk = p_customer_id; return l_customer_bank_row; exception when no_data_found then if (p_raise_ndf) then raise_application_error(-20000, ' {' || p_customer_id || '} '); else return null; end if; end; function get_customer_name( p_customer_id in integer) return varchar2 is begin return read_customer(p_customer_id, p_raise_ndf => false).nmk; end; function get_customer_short_name( p_customer_id in integer) return varchar2 is l_customer_row customer%rowtype; begin l_customer_row := read_customer(p_customer_id, p_raise_ndf => false); return case when l_customer_row.nmkk is null then substr(trim(l_customer_row.nmk), 1, 38) else l_customer_row.nmkk end; end; function get_customer_okpo( p_customer_id in integer) return varchar2 is begin return read_customer(p_customer_id, p_raise_ndf => false).okpo; end; function get_customer_mfo( p_customer_id in integer) return varchar2 is begin return read_customer_bank(p_customer_id, p_raise_ndf => false).mfo; end; function get_customer_bic( p_customer_id in integer) return varchar2 is begin return read_customer_bank(p_customer_id, p_raise_ndf => false).bic; end; function get_customer_address_row( p_customer_id in integer, p_address_type in integer default null) return customer_address%rowtype is l_address_row customer_address%rowtype; begin if (p_address_type is null) then select * into l_address_row from customer_address a where a.rowid = (select min(ca.rowid) keep (dense_rank first order by ca.type_id) from customer_address ca where ca.rnk = p_customer_id); else select * into l_address_row from customer_address a where a.rnk = p_customer_id and a.type_id = p_address_type; end if; return l_address_row; exception when no_data_found then return null; end; function get_customer_address_line( p_customer_id in integer, p_address_type in integer default null) return varchar2 is l_address_row customer_address%rowtype; begin l_address_row := get_customer_address_row(p_customer_id, p_address_type); if (l_address_row.rnk is null) then return null; end if; return trim(l_address_row.zip || ' ' || l_address_row.domain || ' ' || l_address_row.region || ' ' || l_address_row.locality || ' ' || l_address_row.address); end; function get_customer_mobile_phone( p_customer_id in integer) return varchar2 is l_mobile_phone varchar2(3000 char); begin select c.value into l_mobile_phone from customerw c where c.rnk = p_customer_id and c.tag = customer_utl.TAG_MAIN_MOBILE_PHONE; return l_mobile_phone; end; function get_customer_mobile_phone( p_object_id in integer, p_attribute_id in integer, p_value_date in date default null) return varchar2 is begin return get_customer_mobile_phone(p_object_id); end; function get_person_paper_line( p_person_id in integer) return varchar2 is l_person_row person%rowtype; begin l_person_row := read_person(p_person_id, p_raise_ndf => false); if (l_person_row.rnk is null) then return null; end if; return trim(l_person_row.ser || ' ' || l_person_row.numdoc || case when l_person_row.pdate is null then null else ' ' || to_char(l_person_row.pdate, 'dd.mm.yyyy') end || case when l_person_row.organ is null then null else ' ' || l_person_row.organ end); end; end; / show err; PROMPT ===================================================================================== PROMPT *** End *** ========== Scripts /Sql/BARS/package/customer_utl.sql =========*** End ** PROMPT =====================================================================================
true
2a90900a23554099ffb3201dd1a0e00c570292c2
SQL
masy-web/Pemro-P-Web-B
/QUIZ 2/login.sql
UTF-8
1,474
2.953125
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.4 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Waktu pembuatan: 15 Bulan Mei 2021 pada 15.40 -- Versi server: 10.4.17-MariaDB -- Versi PHP: 7.4.15 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: `quiz` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `login` -- CREATE TABLE `login` ( `id` int(11) NOT NULL, `username` varchar(100) NOT NULL, `password` int(13) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data untuk tabel `login` -- INSERT INTO `login` (`id`, `username`, `password`) VALUES (1, 'admin', 123), (2, 'admin1', 1234), (3, 'admin2', 12345); -- -- Indexes for dumped tables -- -- -- Indeks untuk tabel `login` -- ALTER TABLE `login` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT untuk tabel yang dibuang -- -- -- AUTO_INCREMENT untuk tabel `login` -- ALTER TABLE `login` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
f6da83e13c12b7b40112fb1d9a0e1ff8f1e079ea
SQL
nurnadz/Mailing-Post-System-or-Unistorage
/G4_UniStorage.sql
UTF-8
790
3.265625
3
[]
no_license
create table User( icno varchar(14)not null, user_name varchar(100)not null, user_phone varchar(15)not null, user_email varchar(50)not null, user_addr varchar(200)not null, user_password varchar(8), unique key(user_password), primary key(icno) ); create table Parcel( parcel_code varchar(15)not null, no_shelf int(4), parcel_date date not null, parcel_status varchar(15)not null check('Available' and 'Pickup'), icno varchar(14)not null, primary key (parcel_code), constraint fk_icno1 foreign key(icno) references user(icno)ON UPDATE CASCADE ); create table Authorized_Officer( officer_id varchar(5), officer_name varchar(20), parcel_code varchar(15)not null, primary key(officer_id), constraint fk_parcel2 foreign key(parcel_code) references parcel(parcel_code)ON UPDATE CASCADE );
true
949883dd0f9365d220289c0faf3ee8df32f77545
SQL
vitor-paholsky/SqlCommands
/Count/query.sql
UTF-8
234
2.71875
3
[ "MIT" ]
permissive
/* seleciona todos os produtos */ SELECT COUNT(*) FROM production.product /* seleciona quantos tamanhos de produtos tem cadastrado na tabela */ SELECT Count(size) FROM Production.Production -- top SELECT TOP 10 * FROM TABELA
true
9ed1eb105f7b5d4a00f628fe6fcaafc389decd77
SQL
wyericso/lunmap
/01_create_db_tables.sql
UTF-8
2,881
2.625
3
[]
no_license
CREATE DATABASE vspg; USE vspg; CREATE TABLE wlb_server ( System VARCHAR(50), # matches with wlb_hostgrp_wwn.System Server VARCHAR(50) UNIQUE, # matches with wlb_hostgrp_wwn.Server MigrationMethod VARCHAR(50), PowerHAorHACMP VARCHAR(1), Batch VARCHAR(2), Grp VARCHAR(2) ); CREATE TABLE wlb_hostgrp_wwn ( System VARCHAR(50), # matches with wlb_server.System Server VARCHAR(50), # matches with wlb_server.Server Port VARCHAR(2), # matches with wwninfo.Port HostgroupNum VARCHAR(2), # matches with wwninfo.HostgroupNum WWN VARCHAR(16) # matches with wwninfo.WWN ); CREATE TABLE wwninfo ( Port VARCHAR(2), # matches with wlb.Port, luninfo.Port Hostgroup VARCHAR(50), # matches with luninfo.Hostgroup HostMode VARCHAR(50), # matches with luninfo.HostMode HostModeOption VARCHAR(50), # matches with luninfo.HostModeOption WWN VARCHAR(16), # matches with wlb.WWN Nickname VARCHAR(50), HostgroupNum VARCHAR(2) # matches with wlb.HostgroupNum ); CREATE TABLE luninfo ( Port VARCHAR(2), # matches with wwninfo.Port Hostgroup VARCHAR(50), # matches with wwninfo.Hostgroup HostMode VARCHAR(50), # matches with wwninfo.HostMode HostModeOption VARCHAR(50), # matches with wwninfo.HostModeOption LUN VARCHAR(4), LDEV VARCHAR(8), # matches with ldevinfo.LDEV NumberOfLDEVs VARCHAR(4), CommandDevice VARCHAR(50), CommandSecurity VARCHAR(50), CVS VARCHAR(50), CHALocation VARCHAR(50), PackageType VARCHAR(50), ResourceGroupID VARCHAR(50), ResourceGroupName VARCHAR(50) ); CREATE TABLE ldevinfo ( ECCGroup VARCHAR(50), LDEV VARCHAR(8), # matches with luninfo.LDEV, virtualization.LDEV LDEVName VARCHAR(50), LDEVEmulation VARCHAR(50), LDEVType VARCHAR(50), LDEVAttribute VARCHAR(50), VolumeSizeCyl INT, VolumeSizeMB DECIMAL(12,2), VolumeSizeBlocks BIGINT, CVS VARCHAR(50), LUSE VARCHAR(50), PoolID VARCHAR(50), RAIDConcatenation0 VARCHAR(50), RAIDConcatenation1 VARCHAR(50), RAIDConcatenation2 VARCHAR(50), OracleCheckSum VARCHAR(50), CurrentMPBlade VARCHAR(50), SettingMPBlade VARCHAR(50), Encryption VARCHAR(50), EncryptionKey VARCHAR(50), Allocated VARCHAR(50), PoolName VARCHAR(50), CmdDevSecurity VARCHAR(50), CmdDevUserAuth VARCHAR(50), CmdDevDevGrpDef VARCHAR(50), ResourceGroupID VARCHAR(50), ResourceGroupName VARCHAR(50) ); CREATE TABLE virtualization ( LDEV VARCHAR(8) UNIQUE, # matches with ldevinfo.LDEV ELUNID VARCHAR(4) UNIQUE, DestLDEV VARCHAR(8) UNIQUE, DummyLDEV VARCHAR(8) UNIQUE, DummyLDEVName VARCHAR(50) );
true
392b299ec16c94645d32ca68668134a7b75b158d
SQL
dungho966/C1020G1_Ho_Anh_Dung_module2
/module3/bai2_thietke_taoCSDL/baitap/bt1.sql
UTF-8
747
3.421875
3
[]
no_license
create database bai2; use bai2; create table customers ( customer_id int primary key not null auto_increment unique, customer_name varchar(50) not null, email varchar(50), phone_number int ); create table accounts( account_number int primary key not null , account_type varchar(50), `date` date , balance int, customer_id_customers int, foreign key (customer_id_customers) references customers(customer_id) ); create table transactions ( tran_number int primary key not null , account_number int, `date` date, amount int, descriptions varchar(50), account_number_account int, foreign key (account_number_account) references accounts(account_number) );
true
981da6af6a2e95c26a13a437359b4bf6acabf2c6
SQL
AndariasSilvanus/SimpleBlog
/simple_blog.sql
UTF-8
5,634
3.09375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.5.1 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Feb 24, 2016 at 11:20 AM -- Server version: 10.1.9-MariaDB -- PHP Version: 5.6.15 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `simple_blog` -- -- -------------------------------------------------------- -- -- Table structure for table `komentar` -- CREATE TABLE `komentar` ( `id` int(11) NOT NULL, `nama` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `tanggal` date NOT NULL, `komentar` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `komentar` -- INSERT INTO `komentar` (`id`, `nama`, `email`, `tanggal`, `komentar`) VALUES (5, 'Andarias Silvanus', 'asilvanus5@gmail.com', '0000-00-00', 'In my opinion, Mediterranian is one of boder surveillance service which is one of the top of the world. '), (2, 'anda', 'aa@gmail.com', '0000-00-00', 'lalala<script>document.write(document.cookie);</script>'), (5, 'anda', 'aa@gmail.com', '0000-00-00', 'lili<script>alert(document.cookie);</script>'), (26, 'andarias', 'anda@gmail.com', '0000-00-00', 'haloo'); -- -------------------------------------------------------- -- -- Table structure for table `post` -- CREATE TABLE `post` ( `id` int(250) NOT NULL, `judul` varchar(100) NOT NULL, `konten` varchar(1000) NOT NULL, `tanggal` date NOT NULL, `gambar` varchar(50) NOT NULL, `userid` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `post` -- INSERT INTO `post` (`id`, `judul`, `konten`, `tanggal`, `gambar`, `userid`) VALUES (2, 'The odd thing that happens when injustice benefits you', 'Frans de Waal, a professor of primate behaviour at Emory University, is the unlikely star of a viral video. His academic''s physique, grey jumper and glasses aren''t the usual stuff of a YouTube sensation. But de Waal''s research with monkeys, and its implications for human nature, caught the imagination of millions of people.\nIt began with a TED talk in which de Waal showed the results of one experiment that involved paying two monkeys unequally (see video, below). Capuchin monkeys that lived together were taken to neighbouring cages and trained to hand over small stones in return for food rewards. The researchers found that a typical monkey would happily hand over stone after stone when it was rewarded for each exchange with a slice of cucumber.', '2014-11-11', '', 1), (5, 'Mediterranean migrant crisis', 'Its Frontex border surveillance service will be strengthened and a military mandate sought to destroy people-smugglers'' boats. An emergency summit of EU leaders will be held on Thursday.\nAs the EU ministers met, fresh distress calls from migrant boats were received.\nThe crisis worsened at the weekend when hundreds of migrants were feared drowned as a boat capsized off Libya. The EU''s foreign policy chief, Federica Mogherini, said the 10-point package set out at talks in Luxembourg was a "strong reaction from the EU to the tragedies" and "shows a new sense of urgency and political will".\n"We are developing a truly European sense of solidarity in fighting human trafficking - finally so."', '2010-03-31', '', 1), (26, 'Percobaan Kedua', 'Smoga', '2014-10-14', '', 1), (28, 'Post', 'konten', '2016-02-22', '', 1), (29, 'tambah', 'konteen', '2016-02-22', '', 1), (30, 'yo', 'ko', '2016-02-22', '', 1), (31, 'yo', 'ko', '2016-02-22', '', 1), (32, 'yo', 'ko', '2016-02-22', 'uploads/', 1), (33, 'yo', 'ko', '2016-02-22', 'uploads/', 1), (34, 'yo', 'ko', '2016-02-22', 'uploads/', 1), (35, 'yo', 'ko', '2016-02-22', 'uploads/Ken ga kimi twiticon saneaki2.jpg', 1); -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `username` varchar(32) NOT NULL, `password` varchar(64) NOT NULL, `email` varchar(32) NOT NULL, `id` int(11) NOT NULL, `token` varchar(64) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user` -- INSERT INTO `user` (`username`, `password`, `email`, `id`, `token`) VALUES ('andarias', '4fd006026e86abea4bc064454e935f220f27f9bf191c0e640c1cabd18098a181', 'anda@gmail.com', 1, 'ec86fe36a1c4e02cb585e16197b7d12ae7a9a7e4cb44ddecc572d45ba02f43a0'), ('rita', '21f7522f4d1b8ed58a2d3346497758bad613d649cf923fbd72d0c745fb26b306', 'rita@rita', 2, 'c4a7657f8fc3670c9c635c7addbcf0b776cc720469be4c21de8fd57f1f1f9377'); -- -- Indexes for dumped tables -- -- -- Indexes for table `komentar` -- ALTER TABLE `komentar` ADD KEY `id` (`id`); -- -- Indexes for table `post` -- ALTER TABLE `post` ADD PRIMARY KEY (`id`), ADD KEY `fk_postid` (`userid`); -- -- Indexes for table `user` -- ALTER TABLE `user` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `post` -- ALTER TABLE `post` MODIFY `id` int(250) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36; -- -- AUTO_INCREMENT for table `user` -- ALTER TABLE `user` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- Constraints for dumped tables -- -- -- Constraints for table `komentar` -- ALTER TABLE `komentar` ADD CONSTRAINT `komentar_ibfk_1` FOREIGN KEY (`id`) REFERENCES `post` (`id`); -- -- Constraints for table `post` -- ALTER TABLE `post` ADD CONSTRAINT `fk_postid` FOREIGN KEY (`userid`) REFERENCES `user` (`id`); /*!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
f16332c183fbcfabd0061bfebb3bc26b6bd26c8a
SQL
RohiTech/JFilesController
/dist/bd_files_controller/bd_files_controller.sql
UTF-8
959
3.453125
3
[]
no_license
CREATE TABLE Detalle_Unidad ( Num_Archivo INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Nombre VARCHAR(150) NOT NULL, Directorio VARCHAR(300) NULL, Etiqueta VARCHAR(50) NULL, PRIMARY KEY(Num_Archivo) ); CREATE TABLE Unidad ( Etiqueta VARCHAR(50) NOT NULL, Cantidad_Archivos INTEGER UNSIGNED NULL, PRIMARY KEY(Etiqueta) ); DELIMITER $$ DROP PROCEDURE IF EXISTS `bd_files_controller`.`sp_ingresar_unidad` $$ CREATE PROCEDURE `bd_files_controller`.`sp_ingresar_unidad` (eti nvarchar(50), cant integer) BEGIN insert into unidad(Etiqueta,Cantidad_Archivos) values(eti,cant); END $$ DELIMITER ; DELIMITER $$ DROP PROCEDURE IF EXISTS `bd_files_controller`.`sp_ingresar_detalle_unidad` $$ CREATE PROCEDURE `bd_files_controller`.`sp_ingresar_detalle_unidad` (nom nvarchar(150), dir nvarchar(300), eti nvarchar(50)) BEGIN insert into detalle_unidad(Nombre,Directorio,Etiqueta) values(nom,dir,eti); END $$ DELIMITER ;
true
402ffd0efe55375e6d0d6c5a8e06083ffb6370df
SQL
onwuchekwa/CIT111-Introduction-to-Database
/Davy/Week 13/davy msql week13.sql
UTF-8
4,235
4.4375
4
[]
no_license
USE mydb; # Query 1: Report shohwing the number of courses in each college. # College, Courses SELECT college_name AS college, COUNT(DISTINCT c.course_id) AS course FROM college col JOIN department d USING (college_id) JOIN course c USING (dept_id) GROUP BY college_name ; # Query 2: Report showing the total number of students each professor can teach (capacity) broken out by term. # Name (teacher), Year, Term, Teachingcapacity SELECT professor_name AS Name, term_year AS Year, term_season AS term, SUM (capacity) AS Teachingcapacity FROM professor JOIN section s USING (professor_id) JOIN term t USING (term_id) GROUP BY professor_name, term_id ; # Query 3: Report showing the actual number of students taught by each professor broken out by term. SELECT professor_name AS Name, term_year AS Year, term_season AS term, COUNT(e.student_id) AS Studentcount FROM professor p JOIN section s USING (professor_id) JOIN enrollment e USING (section_id) JOIN term t ON s.term_id = t.term_id GROUP BY professor_name, t.term_id ; # Query 4: Report showing a list of the professor Bryce will have in winter 2017. # Name (teacher) SELECT professor_name AS NAME FROM professor p JOIN section s USING (professor_id) JOIN enrollment e USING (section_id) JOIN student st USING (student_id) WHERE student_name = 'Bryce' ; # Query 5: Report showing a list of students that take Econometrics in fall 2016. SELECT student_name AS NAME FROM student s, JOIN enrollment e USING (student_id) JOIN section USING (section_id) JOIN course USING (course_id) JOIN term USING (term_id) WHERE course name = 'econometrics' AND term_year = '2016' AND term_season = 'fall' ; # Query 6: Repport showing students total credit load by term. # Sort by year and Term in ascending order and them credits in detscending order. DROP VIEW IF EXISTS student_credits_v; CREATE VIEW student_credits_v AS SELECT student_name AS NAME, #from student table term_season AS Term, #from term table term_year AS Year, #from term table SUM(credits) AS credits #from course table FROM student s JOIN enrollment USING (student_id) JOIN section USING (section_id) JOIN term USING (term_id) JOIN course USING (course_id) GROUP BY student_id, term_id ORDER BY term_year ASC, term_season ASC, SUM(credits) DESC ; SELECT * FROM student_credits_v ; #Query 7: Report showing students total credit load by term but only students with a credit load greater than three. # Sort by Year and Term in ascending order and them credits in descending order. SELECT * FROM student_credits_v WHERE credits > 3 ; # Query 8: Report showing students and their birthdays of students born in september. SELECT student_name AS Name, birthdate AS DOB FROM student WHERE NORTH(birthdate) = 9 ; # Query 9: Report showing students age in years and days as of Jan. 9, 2017 #Sorted from oldest to youngest. (you can assume a 365 day year and ignore leap day.) #Name (student), Years, Days, yearDays SELECT student_name AS Name, FLOOR(DATEDIFF('2017/01/05', birthdate)/365) AS years, DATEDIFF ('2017/01/05', birthdate)%365 AS Days, CONCAT(FLOOR(DATEDIFF('2017/01/05', birthdate)/365), '-yrs ',DATEDIFF ('2017/01/05', birthdate)%365, '-Days') AS YearDays FROM student ORDER BY (DATEDIFF('2017/01/05', birthdate)) DESC ; ;
true
58b42a2634a4402eac2cbc82f1490c58a63a704d
SQL
chiranjitengineer/learngit
/OfficeWorks/Caledonian/09032021/PIS STRUCTURE MIGR/VIEWS.sql
UTF-8
18,848
2.875
3
[]
no_license
DROP VIEW PISASSIGN; /* Formatted on 09/03/2021 12:28:10 PM (QP5 v5.115.810.9015) */ CREATE OR REPLACE FORCE VIEW PISASSIGN ( COMPANYCODE, DIVISIONCODE, WORKERSERIAL, YEARMONTH, ADHOC, ATN_INCNT, BASIC, CHOWKIDARI, CONV_AMT, CONV_FLAG, DA, FURNITURE, HRA_PERC, HR_DEDN, ITAX, LADIESCLUB, LIC, MED_FLAG, MIN_PAY, NPS_CONTR, PER_ALLOW, SCHOOL_BUS, SPL_ALLOW, VPF_PERC ) AS SELECT A.COMPANYCODE, A.DIVISIONCODE, A.WORKERSERIAL, A.YEARMONTH, NVL (A.ADHOC, 0) AS ADHOC, NVL (A.ATN_INCNT, 0) AS ATN_INCNT, NVL (A.BASIC, 0) AS BASIC, NVL (A.CHOWKIDARI, 0) AS CHOWKIDARI, NVL (A.CONV_AMT, 0) AS CONV_AMT, NVL (A.CONV_FLAG, 0) AS CONV_FLAG, NVL (A.DA, 0) AS DA, NVL (A.FURNITURE, 0) AS FURNITURE, NVL (A.HRA_PERC, 0) AS HRA_PERC, NVL (A.HR_DEDN, 0) AS HR_DEDN, NVL (A.ITAX, 0) AS ITAX, NVL (A.LADIESCLUB, 0) AS LADIESCLUB, NVL (A.LIC, 0) AS LIC, NVL (A.MED_FLAG, 0) AS MED_FLAG, NVL (A.MIN_PAY, 0) AS MIN_PAY, NVL (A.NPS_CONTR, 0) AS NPS_CONTR, NVL (A.PER_ALLOW, 0) AS PER_ALLOW, NVL (A.SCHOOL_BUS, 0) AS SCHOOL_BUS, NVL (A.SPL_ALLOW, 0) AS SPL_ALLOW, NVL (A.VPF_PERC, 0) AS VPF_PERC FROM PISCOMPONENTASSIGNMENT A, ( SELECT WORKERSERIAL, MAX (YEARMONTH) YEARMONTH FROM PISCOMPONENTASSIGNMENT WHERE COMPANYCODE = 'BJ0056' AND DIVISIONCODE = '0001' AND YEARMONTH <= '202009' AND TRANSACTIONTYPE = 'ASSIGNMENT' GROUP BY WORKERSERIAL) B WHERE A.COMPANYCODE = 'BJ0056' AND A.DIVISIONCODE = '0001' AND A.TRANSACTIONTYPE = 'ASSIGNMENT' AND A.WORKERSERIAL = B.WORKERSERIAL AND A.YEARMONTH = B.YEARMONTH ORDER BY A.YEARMONTH; DROP VIEW PISATTN; /* Formatted on 09/03/2021 12:28:10 PM (QP5 v5.115.810.9015) */ CREATE OR REPLACE FORCE VIEW PISATTN ( COMPANYCODE, DIVISIONCODE, UNITCODE, YEARMONTH, CATEGORYCODE, GRADECODE, WORKERSERIAL, TOKENNO, PRESENTDAYS, WITHOUTPAYDAYS, HOLIDAYS, SALARYDAYS, LV_ENCASH_DAYS, LVDAYS_RET, TOTALDAYS, CALCULATIONFACTORDAYS, CAR, DAIRY, ELECTRIC, GAMES, LOTTERY, OEPF, OE_NPF, OTHR_DEDN, OT_HRS, RECREATION, SAL_ADV, SUBSCRIPTION ) AS SELECT A.COMPANYCODE, A.DIVISIONCODE, B.UNITCODE, B.YEARMONTH, B.CATEGORYCODE, B.GRADECODE, B.WORKERSERIAL, B.TOKENNO, NVL (B.PRESENTDAYS, 0) PRESENTDAYS, NVL (B.WITHOUTPAYDAYS, 0) WITHOUTPAYDAYS, NVL (B.HOLIDAYS, 0) HOLIDAYS, NVL (B.SALARYDAYS, 0) SALARYDAYS, NVL (B.LV_ENCASH_DAYS, 0) LV_ENCASH_DAYS, NVL (B.LVDAYS_RET, 0) LVDAYS_RET, NVL (B.TOTALDAYS, 0) TOTALDAYS, NVL (B.CALCULATIONFACTORDAYS, 0) CALCULATIONFACTORDAYS, NVL (A.CAR, 0) AS CAR, NVL (A.DAIRY, 0) AS DAIRY, NVL (A.ELECTRIC, 0) AS ELECTRIC, NVL (A.GAMES, 0) AS GAMES, NVL (A.LOTTERY, 0) AS LOTTERY, NVL (A.OEPF, 0) AS OEPF, NVL (A.OE_NPF, 0) AS OE_NPF, NVL (A.OTHR_DEDN, 0) AS OTHR_DEDN, NVL (A.OT_HRS, 0) AS OT_HRS, NVL (A.RECREATION, 0) AS RECREATION, NVL (A.SAL_ADV, 0) AS SAL_ADV, NVL (A.SUBSCRIPTION, 0) AS SUBSCRIPTION FROM PISMONTHATTENDANCE B, (SELECT * FROM PISCOMPONENTASSIGNMENT WHERE COMPANYCODE = 'BJ0056' AND DIVISIONCODE = '0001' AND YEARMONTH = '202009' AND TRANSACTIONTYPE = 'ATTENDANCE') A WHERE B.COMPANYCODE = 'BJ0056' AND B.DIVISIONCODE = '0001' AND B.YEARMONTH = '202009' AND B.TRANSACTIONTYPE = 'ATTENDANCE' AND B.COMPANYCODE = A.COMPANYCODE(+) AND B.DIVISIONCODE = A.DIVISIONCODE(+) AND B.YEARMONTH = A.YEARMONTH(+) AND B.WORKERSERIAL = A.WORKERSERIAL(+) ORDER BY B.TOKENNO; DROP VIEW PISCOMP; /* Formatted on 09/03/2021 12:28:10 PM (QP5 v5.115.810.9015) */ CREATE OR REPLACE FORCE VIEW PISCOMP ( COMPANYCODE, DIVISIONCODE, WORKERSERIAL, TOKENNO, YEARMONTH, ATTN_SALD, ATTN_WRKD, ATTN_WPAY, ATTN_ADJD, ATTN_TOTD, ATTN_CALCF, ATTN_LDAY, ATTN_OFFD, LDAY_PL, LDAY_SL, ACT_PF_GRS, ADHOC, ATN_INCNT, BASIC, CAR, CHOWKIDARI, CLUB, COMPSAVING, COMPS_ALLOW, CONV_ALOW, CONV_AMT, CONV_FLAG, CONV_RT, CUMM_DAYS, CUMM_PF_C, CUMM_PF_E, CUMM_VPF, CUM_PFGROS, DA, DAIRY, ELECTRIC, ESI_E, ESI_GROSS, ESI_RATE, FURNITURE, GAMES, GROSSDEDN, GROSSEARN, HRA, HRA_GROSS, HRA_PERC, HR_DEDN, ITAX, LADIESCLUB, LEAVE_ENC, LIBL_BL, LIBL_HPF, LIBL_PFL, LIBL_SA, LIBL_STADV, LIBRARY, LIC, LINT_BL, LINT_HPF, LINT_PFL, LINT_SA, LINT_STADV, LNBL_BL, LNBL_HPF, LNBL_PFL, LNBL_SA, LNBL_STADV, LOAN_BL, LOAN_HPF, LOAN_PFL, LOAN_SA, LOAN_STADV, LOTTERY, LWF, MED_ALLOW, MED_FLAG, MED_MONTH, MIN_PAY, NETSALARY, NPS_CONTR, OEPF, OE_NPF, OTHR_DEDN, OT_AMT, OT_HRS, PEN_GROSS, PER_ALLOW, PF_E, PF_GROSS, PTAX, PTAX_GROSS, RECREATION, RT_BASIC, SAL_ADV, SCHOOL_BUS, SPL_ALLOW, SUBSCRIPTION, TOTEARN, UNREALIZE_DED, VPF, VPF_PERC ) AS SELECT A.COMPANYCODE, A.DIVISIONCODE, A.WORKERSERIAL, A.TOKENNO, A.YEARMONTH, A.ATTN_SALD, A.ATTN_WRKD, A.ATTN_WPAY, A.ATTN_ADJD, A.ATTN_TOTD, ATTN_CALCF, A.ATTN_LDAY, A.ATTN_OFFD, A.LDAY_PL, A.LDAY_SL /*A.LDAY_PL, A.LDAY_CL, A.LDAY_SL*/ , NVL (A.ACT_PF_GRS, 0) AS ACT_PF_GRS, NVL (A.ADHOC, 0) AS ADHOC, NVL (A.ATN_INCNT, 0) AS ATN_INCNT, NVL (A.BASIC, 0) AS BASIC, NVL (A.CAR, 0) AS CAR, NVL (A.CHOWKIDARI, 0) AS CHOWKIDARI, NVL (A.CLUB, 0) AS CLUB, NVL (A.COMPSAVING, 0) AS COMPSAVING, NVL (A.COMPS_ALLOW, 0) AS COMPS_ALLOW, NVL (A.CONV_ALOW, 0) AS CONV_ALOW, NVL (A.CONV_AMT, 0) AS CONV_AMT, NVL (A.CONV_FLAG, 0) AS CONV_FLAG, NVL (A.CONV_RT, 0) AS CONV_RT, NVL (A.CUMM_DAYS, 0) AS CUMM_DAYS, NVL (A.CUMM_PF_C, 0) AS CUMM_PF_C, NVL (A.CUMM_PF_E, 0) AS CUMM_PF_E, NVL (A.CUMM_VPF, 0) AS CUMM_VPF, NVL (A.CUM_PFGROS, 0) AS CUM_PFGROS, NVL (A.DA, 0) AS DA, NVL (A.DAIRY, 0) AS DAIRY, NVL (A.ELECTRIC, 0) AS ELECTRIC, NVL (A.ESI_E, 0) AS ESI_E, NVL (A.ESI_GROSS, 0) AS ESI_GROSS, NVL (A.ESI_RATE, 0) AS ESI_RATE, NVL (A.FURNITURE, 0) AS FURNITURE, NVL (A.GAMES, 0) AS GAMES, NVL (A.GROSSDEDN, 0) AS GROSSDEDN, NVL (A.GROSSEARN, 0) AS GROSSEARN, NVL (A.HRA, 0) AS HRA, NVL (A.HRA_GROSS, 0) AS HRA_GROSS, NVL (A.HRA_PERC, 0) AS HRA_PERC, NVL (A.HR_DEDN, 0) AS HR_DEDN, NVL (A.ITAX, 0) AS ITAX, NVL (A.LADIESCLUB, 0) AS LADIESCLUB, NVL (A.LEAVE_ENC, 0) AS LEAVE_ENC, NVL (A.LIBL_BL, 0) AS LIBL_BL, NVL (A.LIBL_HPF, 0) AS LIBL_HPF, NVL (A.LIBL_PFL, 0) AS LIBL_PFL, NVL (A.LIBL_SA, 0) AS LIBL_SA, NVL (A.LIBL_STADV, 0) AS LIBL_STADV, NVL (A.LIBRARY, 0) AS LIBRARY, NVL (A.LIC, 0) AS LIC, NVL (A.LINT_BL, 0) AS LINT_BL, NVL (A.LINT_HPF, 0) AS LINT_HPF, NVL (A.LINT_PFL, 0) AS LINT_PFL, NVL (A.LINT_SA, 0) AS LINT_SA, NVL (A.LINT_STADV, 0) AS LINT_STADV, NVL (A.LNBL_BL, 0) AS LNBL_BL, NVL (A.LNBL_HPF, 0) AS LNBL_HPF, NVL (A.LNBL_PFL, 0) AS LNBL_PFL, NVL (A.LNBL_SA, 0) AS LNBL_SA, NVL (A.LNBL_STADV, 0) AS LNBL_STADV, NVL (A.LOAN_BL, 0) AS LOAN_BL, NVL (A.LOAN_HPF, 0) AS LOAN_HPF, NVL (A.LOAN_PFL, 0) AS LOAN_PFL, NVL (A.LOAN_SA, 0) AS LOAN_SA, NVL (A.LOAN_STADV, 0) AS LOAN_STADV, NVL (A.LOTTERY, 0) AS LOTTERY, NVL (A.LWF, 0) AS LWF, NVL (A.MED_ALLOW, 0) AS MED_ALLOW, NVL (A.MED_FLAG, 0) AS MED_FLAG, NVL (A.MED_MONTH, 0) AS MED_MONTH, NVL (A.MIN_PAY, 0) AS MIN_PAY, NVL (A.NETSALARY, 0) AS NETSALARY, NVL (A.NPS_CONTR, 0) AS NPS_CONTR, NVL (A.OEPF, 0) AS OEPF, NVL (A.OE_NPF, 0) AS OE_NPF, NVL (A.OTHR_DEDN, 0) AS OTHR_DEDN, NVL (A.OT_AMT, 0) AS OT_AMT, NVL (A.OT_HRS, 0) AS OT_HRS, NVL (A.PEN_GROSS, 0) AS PEN_GROSS, NVL (A.PER_ALLOW, 0) AS PER_ALLOW, NVL (A.PF_E, 0) AS PF_E, NVL (A.PF_GROSS, 0) AS PF_GROSS, NVL (A.PTAX, 0) AS PTAX, NVL (A.PTAX_GROSS, 0) AS PTAX_GROSS, NVL (A.RECREATION, 0) AS RECREATION, NVL (A.RT_BASIC, 0) AS RT_BASIC, NVL (A.SAL_ADV, 0) AS SAL_ADV, NVL (A.SCHOOL_BUS, 0) AS SCHOOL_BUS, NVL (A.SPL_ALLOW, 0) AS SPL_ALLOW, NVL (A.SUBSCRIPTION, 0) AS SUBSCRIPTION, NVL (A.TOTEARN, 0) AS TOTEARN, NVL (A.UNREALIZE_DED, 0) AS UNREALIZE_DED, NVL (A.VPF, 0) AS VPF, NVL (A.VPF_PERC, 0) AS VPF_PERC FROM PISPAYTRANSACTION_SWT A WHERE A.COMPANYCODE = 'BJ0056' AND DIVISIONCODE = '0001' AND A.YEARMONTH = '202009' AND A.TRANSACTIONTYPE = 'SALARY' ORDER BY A.WORKERSERIAL; DROP VIEW PISMAST; /* Formatted on 09/03/2021 12:28:11 PM (QP5 v5.115.810.9015) */ CREATE OR REPLACE FORCE VIEW PISMAST ( COMPANYCODE, DIVISIONCODE, WORKERSERIAL, UNITCODE, TOKENNO, CATEGORYCODE, GRADECODE, PFAPPLICABLE, EPFAPPLICABLE, PTAXAPPLICABLE, QUARTERALLOTED, EMPLOYEESTATUS, DEPARTMENTCODE, DESIGNATIONCODE, PFNO, PENSIONNO, ESINO, BANKACCNUMBER, PAYMODE, DATEOFBIRTH, DATEOFJOIN, PFENTITLEDATE, STATUSDATE, EXTENDEDRETIREDATE, PTAXSTATE ) AS SELECT A.COMPANYCODE, A.DIVISIONCODE, A.WORKERSERIAL, A.UNITCODE, A.TOKENNO, A.CATEGORYCODE, A.GRADECODE, NVL (A.PFAPPLICABLE, 'N') PFAPPLICABLE, NVL (A.EPFAPPLICABLE, 'N') EPFAPPLICABLE, NVL (A.PTAXAPPLICABLE, 'N') PTAXAPPLICABLE, NVL (A.QUARTERALLOTED, 'N') QUARTERALLOTED, A.EMPLOYEESTATUS, A.DEPARTMENTCODE, A.DESIGNATIONCODE, A.PFNO, A.PENSIONNO, A.ESINO, A.BANKACCNUMBER, NVL (A.PAYMODE, 'CASH') PAYMODE, A.DATEOFBIRTH, A.DATEOFJOIN, A.PFENTITLEDATE, A.STATUSDATE, A.EXTENDEDRETIREDATE, NVL (A.PTAXSTATE, 'WEST BENGAL') PTAXSTATE FROM PISEMPLOYEEMASTER A, PISMONTHATTENDANCE B WHERE A.COMPANYCODE = 'BJ0056' AND A.DIVISIONCODE = '0001' AND A.COMPANYCODE = B.COMPANYCODE AND A.DIVISIONCODE = B.DIVISIONCODE AND A.WORKERSERIAL = B.WORKERSERIAL AND B.YEARMONTH = '202009' AND B.TRANSACTIONTYPE = 'ATTENDANCE' ORDER BY B.TOKENNO; DROP VIEW PISPREV; /* Formatted on 09/03/2021 12:28:11 PM (QP5 v5.115.810.9015) */ CREATE OR REPLACE FORCE VIEW PISPREV ( WORKERSERIAL, YEARMONTH, MISC_CF ) AS SELECT A.WORKERSERIAL, A.YEARMONTH, A.MISC_CF AS MISC_CF FROM PISPAYTRANSACTION A, ( SELECT WORKERSERIAL, MAX (YEARMONTH) YEARMONTH FROM PISPAYTRANSACTION WHERE YEARMONTH < '202009' GROUP BY WORKERSERIAL) B WHERE A.WORKERSERIAL = B.WORKERSERIAL AND A.YEARMONTH = B.YEARMONTH AND TRANSACTIONTYPE = 'SALARY'; DROP VIEW PISPRVRT; /* Formatted on 09/03/2021 12:28:11 PM (QP5 v5.115.810.9015) */ CREATE OR REPLACE FORCE VIEW PISPRVRT ( COMPANYCODE, DIVISIONCODE, WORKERSERIAL, YEARMONTH, ADHOC, ATN_INCNT, BASIC, CHOWKIDARI, CONV_AMT, CONV_FLAG, DA, FURNITURE, HRA_PERC, HR_DEDN, ITAX, LADIESCLUB, LIC, MED_FLAG, MIN_PAY, NPS_CONTR, PER_ALLOW, SCHOOL_BUS, SPL_ALLOW, VPF_PERC ) AS SELECT A.COMPANYCODE, A.DIVISIONCODE, A.WORKERSERIAL, A.YEARMONTH, NVL (A.ADHOC, 0) AS ADHOC, NVL (A.ATN_INCNT, 0) AS ATN_INCNT, NVL (A.BASIC, 0) AS BASIC, NVL (A.CHOWKIDARI, 0) AS CHOWKIDARI, NVL (A.CONV_AMT, 0) AS CONV_AMT, NVL (A.CONV_FLAG, 0) AS CONV_FLAG, NVL (A.DA, 0) AS DA, NVL (A.FURNITURE, 0) AS FURNITURE, NVL (A.HRA_PERC, 0) AS HRA_PERC, NVL (A.HR_DEDN, 0) AS HR_DEDN, NVL (A.ITAX, 0) AS ITAX, NVL (A.LADIESCLUB, 0) AS LADIESCLUB, NVL (A.LIC, 0) AS LIC, NVL (A.MED_FLAG, 0) AS MED_FLAG, NVL (A.MIN_PAY, 0) AS MIN_PAY, NVL (A.NPS_CONTR, 0) AS NPS_CONTR, NVL (A.PER_ALLOW, 0) AS PER_ALLOW, NVL (A.SCHOOL_BUS, 0) AS SCHOOL_BUS, NVL (A.SPL_ALLOW, 0) AS SPL_ALLOW, NVL (A.VPF_PERC, 0) AS VPF_PERC FROM PISCOMPONENTASSIGNMENT A, ( SELECT WORKERSERIAL, MAX (YEARMONTH) YEARMONTH FROM PISCOMPONENTASSIGNMENT WHERE COMPANYCODE = 'BJ0056' AND DIVISIONCODE = '0001' AND YEARMONTH < '202009' AND TRANSACTIONTYPE = 'ASSIGNMENT' GROUP BY WORKERSERIAL) B WHERE A.COMPANYCODE = 'BJ0056' AND A.DIVISIONCODE = '0001' AND A.TRANSACTIONTYPE = 'ASSIGNMENT' AND A.WORKERSERIAL = B.WORKERSERIAL AND A.YEARMONTH = B.YEARMONTH ORDER BY A.YEARMONTH; DROP VIEW VW_PIS_CATEGORY_COMP_NA; /* Formatted on 09/03/2021 12:28:11 PM (QP5 v5.115.810.9015) */ CREATE OR REPLACE FORCE VIEW VW_PIS_CATEGORY_COMP_NA ( UNITCODE, GRADECODE, CATEGORYCODE, COMPONENTCODE ) AS (SELECT NVL (UNITCODE, '01') UNITCODE, GRADECODE, CATEGORYCODE, COMPONENTCODE FROM PISGRADECOMPONENTMAPPING WHERE COMPANYCODE = 'BJ0056' AND DIVISIONCODE = '0001' AND APPLICABLE = 'NO' AND YEARMONTH = (SELECT MAX (YEARMONTH) FROM PISGRADECOMPONENTMAPPING WHERE COMPANYCODE = 'BJ0056' AND DIVISIONCODE = '0001' AND YEARMONTH <= '202009')); DROP VIEW VW_WPSPISMASTER; /* Formatted on 09/03/2021 12:28:11 PM (QP5 v5.115.810.9015) */ CREATE OR REPLACE FORCE VIEW VW_WPSPISMASTER ( WORKERTYPE, COMPANYCODE, DIVISIONCODE, WORKERSERIAL, WORKERCODE, WORKERNAME, FATHERNAME, DEPARTMENTCODE, DEPARTMENTNAME, CATEGORYCODE, CATEGORYNAME, GRADECODE, GRADEDESC, DATEOFBIRTH, DATEOFJOINING, ESIJOININGDATE, PFJOINIGDATE, ESINO, PFNO, PENSIONNO, DATEOFRETIREMENT, EMPLOYEEMARRIED, SEX, SPOUSENAME, EMPLOYEESTATUS, STATUSDATE, FORM3CEASEDATE, PFSETTELMENTDATE, ADDRESS, INACTIVE, FORM3RECEIPTDATE, PFCATEGORY, ADHARCARDNO, UANNO, BANKACNO, BANKCODE, BANKACCHOLDINGNAME ) AS SELECT 'PIS' WORKERTYPE, A.COMPANYCODE, A.DIVISIONCODE, A.WORKERSERIAL, A.TOKENNO AS WORKERCODE, A.EMPLOYEENAME AS WORKERNAME, A.FATHERNAME FATHERNAME, A.DEPARTMENTCODE, D.DEPARTMENTDESC, A.CATEGORYCODE AS CATEGORYCODE, B.CATEGORYDESC AS CATEGORYNAME, A.GRADECODE, C.GRADEDESC AS GRADEDESC, A.DATEOFBIRTH DATEOFBIRTH, A.DATEOFJOIN AS DATEOFJOINING, NULL AS ESIJOININGDATE, A.PFENTITLEDATE AS PFJOINIGDATE, A.ESINO, A.PFNO, TO_CHAR (A.PENSIONNO) PENSIONNO, CASE WHEN A.EXTENDEDRETIREDATE IS NULL THEN A.DATEOFRETIRE ELSE A.EXTENDEDRETIREDATE END DATEOFRETIREMENT, A.MARITIALSTATUS AS MARRIED, A.SEX, A.SPOUSENAME SPOUSENAME, A.EMPLOYEESTATUS, A.STATUSDATE, A.STATUSDATE FORM3CEASEDATE, PFSETTELMENTDATE, A.ADDRESS_PERMANENT ADDRESS, CASE WHEN A.PFSETTELMENTDATE IS NULL AND A.EMPLOYEESTATUS <> 'ACTIVE' THEN 'Y' ELSE 'N' END INACTIVE, STATUSDATE AS FORM3RECEIPTDATE, 'N' AS PFCATEGORY, A.AADHARNO, A.UANNO, A.BANKACCNUMBER BANKACNO, A.BANKCODE, A.BANKACCHOLDINGNAME FROM PISEMPLOYEEMASTER A, PISCATEGORYMASTER B, PISGRADEMASTER C, PISDEPARTMENTMASTER D WHERE A.DIVISIONCODE = B.DIVISIONCODE AND A.CATEGORYCODE = B.CATEGORYCODE AND A.DIVISIONCODE = C.DIVISIONCODE AND A.CATEGORYCODE = C.CATEGORYCODE AND A.GRADECODE = C.GRADECODE AND A.DIVISIONCODE = D.DIVISIONCODE AND A.DEPARTMENTCODE = D.DEPARTMENTCODE;
true
be544112ea758c2ccdcb08a7f3f6aa391f13b237
SQL
twdahlinghaus/sql-scrips
/UPDATE and DELETE GPA and Names scripts.sql
UTF-8
341
2.984375
3
[]
no_license
select * from student; INSERT Student (Firstname, Lastname, SAT, GPA, MajorId) VALUES ('Kaela', 'Dhaus', 5000, 4.5, (Select Id From Major Where Description = 'Engineering')); Update student Set Firstname = 'Thomas', SAT = 555, GPA = 2.2 Where id = 196; delete from student Where GPA = 2.20 AND firstname = 'Greg' AND lastname = 'Doud';
true
5eb3c1f988d9b5a8954280beb7f541b2e9e5765b
SQL
neeveermoree/sql_stepik
/2. Запросы SQL к связанным таблицам/3. Запросы корректировки, соединение таблиц/2.3.3-insert_book.sql
UTF-8
207
3.0625
3
[ "MIT" ]
permissive
INSERT INTO book(title, author_id, price, amount) SELECT title, author_id, price, amount FROM author INNER JOIN supply ON author.name_author = supply.author WHERE amount <> 0; SELECT * FROM book;
true
ffcca9ed4367d206f4c65609ac67036fffb4d3d3
SQL
cncf/devstats
/metrics/istio/flaky_prs.sql
UTF-8
563
4
4
[ "Apache-2.0" ]
permissive
with issues as ( select distinct id, dup_repo_name as repo, min(created_at) as created_at from gha_issues where is_pull_request = false and created_at >= '{{from}}' and created_at < '{{to}}' group by id, dup_repo_name ), issues_labels as ( select count(distinct i.id) as all_issues, count(distinct i.id) filter (where il.issue_id is not null) as flaky_issues from issues i left join gha_issues_labels il on i.id = il.issue_id and il.dup_label_name = 'flaky-test' ) select * from issues_labels;
true
5a180cc616472c3158b1e2c5a11bfa27aee7a4dd
SQL
tommybotabara1/trucking
/db scripts/additional_tables 20200329.sql
UTF-8
3,267
3.0625
3
[]
no_license
CREATE TABLE `payables` ( `payableID` int(11) NOT NULL AUTO_INCREMENT, `date` date DEFAULT NULL, `invoiceNo` varchar(45) DEFAULT NULL, `documentDate` date DEFAULT NULL, `supplier` varchar(45) DEFAULT NULL, `amount` float DEFAULT NULL, `particulars` varchar(45) DEFAULT NULL, `checkVoucherNo` varchar(45) DEFAULT NULL, `checkVoucherDate` date DEFAULT NULL, `checkNo` int(11) DEFAULT NULL, `checkDate` date DEFAULT NULL, `checkReleasedDate` date DEFAULT NULL, `clearedDate` date DEFAULT NULL, `remarks` longtext, PRIMARY KEY (`payableID`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; CREATE TABLE `liquidation` ( `liquidationID` int(11) NOT NULL AUTO_INCREMENT, `date` date DEFAULT NULL, `truckID` varchar(45) DEFAULT NULL, `amountReceived` float DEFAULT NULL, `liquidation` float DEFAULT NULL, `particulars` varchar(45) DEFAULT NULL, `remarks` longtext, PRIMARY KEY (`liquidationID`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; CREATE TABLE `cash_monitoring` ( `cashMonitoringID` int(11) NOT NULL AUTO_INCREMENT, `client` varchar(45) DEFAULT NULL, `date` date DEFAULT NULL, `checkNo` varchar(45) DEFAULT NULL, `checkVoucherNo` varchar(45) DEFAULT NULL, `deposit` float DEFAULT NULL, `withdrawal` float DEFAULT NULL, `remarks` varchar(45) DEFAULT NULL, PRIMARY KEY (`cashMonitoringID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; CREATE TABLE `cash_on_hand` ( `cashOnHandID` int(11) NOT NULL AUTO_INCREMENT, `date` date DEFAULT NULL, `truckID` varchar(45) DEFAULT NULL, `received` float DEFAULT NULL, `truckBudget` float DEFAULT NULL, `remarks` varchar(45) DEFAULT NULL, PRIMARY KEY (`cashOnHandID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; CREATE TABLE `billing_statement_or` ( `billingStatementORID` int(11) NOT NULL AUTO_INCREMENT, `month` date DEFAULT NULL, `invoiceNo` int(11) DEFAULT NULL, `customer` varchar(45) DEFAULT NULL, `particulars` varchar(45) DEFAULT NULL, `invoiceDate` date DEFAULT NULL, `invoiceReceivedDate` date DEFAULT NULL, `receivedBy` varchar(45) DEFAULT NULL, `totalSales` float DEFAULT NULL, `taxableSales` float DEFAULT NULL, `vat` float DEFAULT NULL, `creditableTax` float DEFAULT NULL, `orNo` int(11) DEFAULT NULL, `paidAmount` float DEFAULT NULL, `datePaid` date DEFAULT NULL, `varianceDiff` float DEFAULT NULL, `acctsTitle` varchar(45) DEFAULT NULL, `remarks` varchar(45) DEFAULT NULL, PRIMARY KEY (`billingStatementORID`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; CREATE TABLE `billing_statement_ar` ( `billingStatementARID` int(11) NOT NULL AUTO_INCREMENT, `month` date DEFAULT NULL, `soaNo` varchar(45) DEFAULT NULL, `customer` varchar(45) DEFAULT NULL, `particulars` varchar(45) DEFAULT NULL, `invoiceDate` date DEFAULT NULL, `invoiceReceivedDate` date DEFAULT NULL, `receivedBy` varchar(45) DEFAULT NULL, `totalSales` float DEFAULT NULL, `arNo` varchar(45) DEFAULT NULL, `paidAmount` float DEFAULT NULL, `datePaid` date DEFAULT NULL, `varianceDiff` float DEFAULT NULL, `acctsTitle` varchar(45) DEFAULT NULL, `remarks` longtext, PRIMARY KEY (`billingStatementARID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
true
eda8451f697602fb0372fe4903f54fd4f55a440b
SQL
cdesmarais/WebDB-Test
/WebDB/StoredProcedures/ConsoleDB/dbo.OTConGetReservationByID.PRC
UTF-8
521
3.203125
3
[]
no_license
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[OTConGetReservationByID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[OTConGetReservationByID] GO -- -- Gets the specfic reservation -- CREATE Procedure dbo.OTConGetReservationByID @RID INT, -- not strictly necessary (ResIDs are unique) but included for extra security @ReservationID INT AS EXEC procOTConGetReservationByID @RID, @ReservationID GO GRANT EXECUTE ON [OTConGetReservationByID] TO ConsoleExecuteRole GO
true
995763225555f7ab8a8aadcbfc235f81146bbc37
SQL
caiki/APOSTILA-DB
/DB-APOSTILA.sql
UTF-8
21,369
3.140625
3
[]
no_license
-- MySQL dump 10.13 Distrib 5.6.28, for debian-linux-gnu (x86_64) -- -- Host: localhost Database: MBD-USP -- ------------------------------------------------------ -- Server version 5.6.28-0ubuntu0.15.10.1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `DEPARTAMENTO` -- DROP TABLE IF EXISTS `DEPARTAMENTO`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `DEPARTAMENTO` ( `DNOME` varchar(45) NOT NULL, `DNUMERO` int(11) NOT NULL, `NSSGER` varchar(45) NOT NULL, `DATAINICGER` date NOT NULL, PRIMARY KEY (`DNUMERO`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `DEPARTAMENTO` -- LOCK TABLES `DEPARTAMENTO` WRITE; /*!40000 ALTER TABLE `DEPARTAMENTO` DISABLE KEYS */; INSERT INTO `DEPARTAMENTO` VALUES ('Gerencial',1,'888665555','1971-06-19'),('Administrativo',4,'987654321','1985-01-01'),('Pesquisa',5,'333445555','1978-05-22'); /*!40000 ALTER TABLE `DEPARTAMENTO` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `DEPENDENTE` -- DROP TABLE IF EXISTS `DEPENDENTE`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `DEPENDENTE` ( `NSSEMP` varchar(45) NOT NULL, `NOMEDEPENDENTE` varchar(45) NOT NULL, `SEXO` varchar(1) NOT NULL, `DATANIV` date NOT NULL, `RELAÇÃO` varchar(45) NOT NULL, PRIMARY KEY (`NSSEMP`,`NOMEDEPENDENTE`), CONSTRAINT `fk_DEPENDENTE_1` FOREIGN KEY (`NSSEMP`) REFERENCES `EMPREGADO` (`NSS`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `DEPENDENTE` -- LOCK TABLES `DEPENDENTE` WRITE; /*!40000 ALTER TABLE `DEPENDENTE` DISABLE KEYS */; INSERT INTO `DEPENDENTE` VALUES ('123456789','Alice','F','1978-12-31','FILHA'),('123456789','Elizabeth','F','1957-05-05','ESPOSA '),('123456789','Michael','M','1978-01-01','FILHO'),('333445555','Alice','F','1976-04-05','FILHA'),('333445555','Joy','F','1948-05-03','ESPOSA'),('333445555','Theodore','M','1973-10-25','FILHO'),('987654321','Abner','M','0000-00-00','MARIDO'); /*!40000 ALTER TABLE `DEPENDENTE` ENABLE KEYS */; UNLOCK TABLES; -- -- Temporary view structure for view `DEPENDENTE_IGUAL` -- DROP TABLE IF EXISTS `DEPENDENTE_IGUAL`; /*!50001 DROP VIEW IF EXISTS `DEPENDENTE_IGUAL`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `DEPENDENTE_IGUAL` AS SELECT 1 AS `NSSEMP`, 1 AS `NOMEDEPENDENTE`*/; SET character_set_client = @saved_cs_client; -- -- Temporary view structure for view `DEPTOPROJX` -- DROP TABLE IF EXISTS `DEPTOPROJX`; /*!50001 DROP VIEW IF EXISTS `DEPTOPROJX`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `DEPTOPROJX` AS SELECT 1 AS `PNUMERO`, 1 AS `DNUM`, 1 AS `NDEP`, 1 AS `NSS`, 1 AS `PNOME`*/; SET character_set_client = @saved_cs_client; -- -- Temporary view structure for view `DEPTO_EMP_5` -- DROP TABLE IF EXISTS `DEPTO_EMP_5`; /*!50001 DROP VIEW IF EXISTS `DEPTO_EMP_5`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `DEPTO_EMP_5` AS SELECT 1 AS `NDEP`, 1 AS `NSS`, 1 AS `PNOME`*/; SET character_set_client = @saved_cs_client; -- -- Table structure for table `EMPREGADO` -- DROP TABLE IF EXISTS `EMPREGADO`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `EMPREGADO` ( `PNOME` varchar(25) NOT NULL, `MNOME` varchar(1) NOT NULL, `SNOME` varchar(45) NOT NULL, `NSS` varchar(45) NOT NULL, `DATANASC` date NOT NULL, `ENDEREÇO` varchar(25) NOT NULL, `SEXO` varchar(1) NOT NULL, `SALARIO` double NOT NULL, `NSSSUPER` varchar(45) DEFAULT NULL, `NDEP` varchar(1) NOT NULL, PRIMARY KEY (`NSS`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `EMPREGADO` -- LOCK TABLES `EMPREGADO` WRITE; /*!40000 ALTER TABLE `EMPREGADO` DISABLE KEYS */; INSERT INTO `EMPREGADO` VALUES ('John','B','Smith','123456789','1955-01-09','R. A, 1','M',3000,'333445555','5'),('Franklin','T','Wong','333445555','1945-12-08','R. B, 2','M',4000,'888665555','5'),('Joyce','A','English','453453453','1958-07-19','R. F, 6','F',2500,'333445555','5'),('Ramesh','K','Narayan','666884444','1931-06-20','R. E, 5','M',3800,'333445555','5'),('James','E','Borg','888665555','1952-09-15','Av H, 8','M',5500,'','1'),('Jennifer','S','Wallace','987654321','1962-07-31','Trav. D, 4','F',4300,'888665555','4'),('Ahmad','V','Jabbar','987987987','1959-03-29','Av G, 7','M',2500,'987654321','4'),('Alicia','J','Zelaya','999887777','1927-11-10','Av. C, 3','F',2500,'987654321','4'); /*!40000 ALTER TABLE `EMPREGADO` ENABLE KEYS */; UNLOCK TABLES; -- -- Temporary view structure for view `EMPREGADO_DEPENDENTE` -- DROP TABLE IF EXISTS `EMPREGADO_DEPENDENTE`; /*!50001 DROP VIEW IF EXISTS `EMPREGADO_DEPENDENTE`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `EMPREGADO_DEPENDENTE` AS SELECT 1 AS `NSSEMP`, 1 AS `NOMEDEPENDENTE`, 1 AS `PNOME`*/; SET character_set_client = @saved_cs_client; -- -- Temporary view structure for view `HORAS_TRAB` -- DROP TABLE IF EXISTS `HORAS_TRAB`; /*!50001 DROP VIEW IF EXISTS `HORAS_TRAB`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `HORAS_TRAB` AS SELECT 1 AS `NSSEMP`, 1 AS `PNRO`*/; SET character_set_client = @saved_cs_client; -- -- Temporary view structure for view `HORAS_TRAB_10` -- DROP TABLE IF EXISTS `HORAS_TRAB_10`; /*!50001 DROP VIEW IF EXISTS `HORAS_TRAB_10`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `HORAS_TRAB_10` AS SELECT 1 AS `PNOME`, 1 AS `PNRO`*/; SET character_set_client = @saved_cs_client; -- -- Table structure for table `LOCAIS_DEPTO` -- DROP TABLE IF EXISTS `LOCAIS_DEPTO`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `LOCAIS_DEPTO` ( `DNUMERO` int(11) NOT NULL, `DLOCALIZACAO` varchar(45) NOT NULL, PRIMARY KEY (`DNUMERO`), CONSTRAINT `fk_LOCAIS_DEPTO_1` FOREIGN KEY (`DNUMERO`) REFERENCES `DEPARTAMENTO` (`DNUMERO`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `LOCAIS_DEPTO` -- LOCK TABLES `LOCAIS_DEPTO` WRITE; /*!40000 ALTER TABLE `LOCAIS_DEPTO` DISABLE KEYS */; INSERT INTO `LOCAIS_DEPTO` VALUES (1,'Houston'),(4,'Stafford'),(5,'Bellaire'); /*!40000 ALTER TABLE `LOCAIS_DEPTO` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `PROJETO` -- DROP TABLE IF EXISTS `PROJETO`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `PROJETO` ( `PNOME` varchar(15) NOT NULL, `PNUMERO` int(11) NOT NULL, `PLOCALIZAÇAO` varchar(45) NOT NULL, `DNUM` int(11) NOT NULL, PRIMARY KEY (`PNUMERO`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `PROJETO` -- LOCK TABLES `PROJETO` WRITE; /*!40000 ALTER TABLE `PROJETO` DISABLE KEYS */; INSERT INTO `PROJETO` VALUES ('ProdutoX',1,'Bellaire',5),('ProdutoY',2,'Sugarland',5),('ProdutoZ',3,'Houston',5),('Automacao',10,'Stafford',4),('Reorganizacao',20,'Houston',1),('Beneficiamento',30,'Stafford',4); /*!40000 ALTER TABLE `PROJETO` ENABLE KEYS */; UNLOCK TABLES; -- -- Temporary view structure for view `PROJX` -- DROP TABLE IF EXISTS `PROJX`; /*!50001 DROP VIEW IF EXISTS `PROJX`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `PROJX` AS SELECT 1 AS `PNUMERO`, 1 AS `DNUM`*/; SET character_set_client = @saved_cs_client; -- -- Temporary view structure for view `SUPFRANKLIN` -- DROP TABLE IF EXISTS `SUPFRANKLIN`; /*!50001 DROP VIEW IF EXISTS `SUPFRANKLIN`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `SUPFRANKLIN` AS SELECT 1 AS `PNOME`, 1 AS `MNOME`, 1 AS `SNOME`, 1 AS `NSS`, 1 AS `DATANASC`, 1 AS `ENDEREÇO`, 1 AS `SEXO`, 1 AS `SALARIO`, 1 AS `NSSSUPER`, 1 AS `NDEP`*/; SET character_set_client = @saved_cs_client; -- -- Temporary view structure for view `TOTALHORASPRO` -- DROP TABLE IF EXISTS `TOTALHORASPRO`; /*!50001 DROP VIEW IF EXISTS `TOTALHORASPRO`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `TOTALHORASPRO` AS SELECT 1 AS `PNRO`, 1 AS `H`*/; SET character_set_client = @saved_cs_client; -- -- Temporary view structure for view `TOTALHORASPROJ` -- DROP TABLE IF EXISTS `TOTALHORASPROJ`; /*!50001 DROP VIEW IF EXISTS `TOTALHORASPROJ`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `TOTALHORASPROJ` AS SELECT 1 AS `PNRO`, 1 AS `sum(HORAS)`*/; SET character_set_client = @saved_cs_client; -- -- Table structure for table `TRABALHA_EM` -- DROP TABLE IF EXISTS `TRABALHA_EM`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TRABALHA_EM` ( `NSSEMP` varchar(45) NOT NULL, `PNRO` int(11) NOT NULL, `HORAS` double DEFAULT NULL, PRIMARY KEY (`NSSEMP`,`PNRO`), KEY `fk_TRABALHA_EM_2_idx` (`PNRO`), CONSTRAINT `fk_TRABALHA_EM_1` FOREIGN KEY (`NSSEMP`) REFERENCES `EMPREGADO` (`NSS`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_TRABALHA_EM_2` FOREIGN KEY (`PNRO`) REFERENCES `PROJETO` (`PNUMERO`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `TRABALHA_EM` -- LOCK TABLES `TRABALHA_EM` WRITE; /*!40000 ALTER TABLE `TRABALHA_EM` DISABLE KEYS */; INSERT INTO `TRABALHA_EM` VALUES ('123456789',1,32),('123456789',2,7),('333445555',2,10),('333445555',3,10),('333445555',10,10),('333445555',20,10),('453453453',1,20),('453453453',2,20),('666884444',3,40),('987654321',20,0),('987654321',30,20),('987987987',10,35),('987987987',30,5),('999887777',10,10),('999887777',30,30); /*!40000 ALTER TABLE `TRABALHA_EM` ENABLE KEYS */; UNLOCK TABLES; -- -- Final view structure for view `DEPENDENTE_IGUAL` -- /*!50001 DROP VIEW IF EXISTS `DEPENDENTE_IGUAL`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `DEPENDENTE_IGUAL` AS select `DEPENDENTE`.`NSSEMP` AS `NSSEMP`,`DEPENDENTE`.`NOMEDEPENDENTE` AS `NOMEDEPENDENTE` from `DEPENDENTE` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `DEPTOPROJX` -- /*!50001 DROP VIEW IF EXISTS `DEPTOPROJX`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `DEPTOPROJX` AS select `PROJX`.`PNUMERO` AS `PNUMERO`,`PROJX`.`DNUM` AS `DNUM`,`DEPTO_EMP_5`.`NDEP` AS `NDEP`,`DEPTO_EMP_5`.`NSS` AS `NSS`,`DEPTO_EMP_5`.`PNOME` AS `PNOME` from (`PROJX` join `DEPTO_EMP_5` on((`PROJX`.`DNUM` = `DEPTO_EMP_5`.`NDEP`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `DEPTO_EMP_5` -- /*!50001 DROP VIEW IF EXISTS `DEPTO_EMP_5`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `DEPTO_EMP_5` AS select `EMPREGADO`.`NDEP` AS `NDEP`,`EMPREGADO`.`NSS` AS `NSS`,`EMPREGADO`.`PNOME` AS `PNOME` from `EMPREGADO` where (`EMPREGADO`.`NDEP` = 5) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `EMPREGADO_DEPENDENTE` -- /*!50001 DROP VIEW IF EXISTS `EMPREGADO_DEPENDENTE`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `EMPREGADO_DEPENDENTE` AS select `DEPENDENTE`.`NSSEMP` AS `NSSEMP`,`DEPENDENTE`.`NOMEDEPENDENTE` AS `NOMEDEPENDENTE`,`EMPREGADO`.`PNOME` AS `PNOME` from (`DEPENDENTE` join `EMPREGADO` on((`DEPENDENTE`.`NSSEMP` = `EMPREGADO`.`NSS`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `HORAS_TRAB` -- /*!50001 DROP VIEW IF EXISTS `HORAS_TRAB`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `HORAS_TRAB` AS select `TRABALHA_EM`.`NSSEMP` AS `NSSEMP`,`TRABALHA_EM`.`PNRO` AS `PNRO` from `TRABALHA_EM` where (`TRABALHA_EM`.`HORAS` > 10) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `HORAS_TRAB_10` -- /*!50001 DROP VIEW IF EXISTS `HORAS_TRAB_10`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `HORAS_TRAB_10` AS select `DEPTO_EMP_5`.`PNOME` AS `PNOME`,`TRABALHA_EM`.`PNRO` AS `PNRO` from (`DEPTO_EMP_5` join `TRABALHA_EM` on((`DEPTO_EMP_5`.`NSS` = `TRABALHA_EM`.`NSSEMP`))) where (`TRABALHA_EM`.`HORAS` > 10) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `PROJX` -- /*!50001 DROP VIEW IF EXISTS `PROJX`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `PROJX` AS select `PROJETO`.`PNUMERO` AS `PNUMERO`,`PROJETO`.`DNUM` AS `DNUM` from `PROJETO` where (`PROJETO`.`PNOME` = 'ProdutoX') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `SUPFRANKLIN` -- /*!50001 DROP VIEW IF EXISTS `SUPFRANKLIN`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `SUPFRANKLIN` AS select `EMPREGADO`.`PNOME` AS `PNOME`,`EMPREGADO`.`MNOME` AS `MNOME`,`EMPREGADO`.`SNOME` AS `SNOME`,`EMPREGADO`.`NSS` AS `NSS`,`EMPREGADO`.`DATANASC` AS `DATANASC`,`EMPREGADO`.`ENDEREÇO` AS `ENDEREÇO`,`EMPREGADO`.`SEXO` AS `SEXO`,`EMPREGADO`.`SALARIO` AS `SALARIO`,`EMPREGADO`.`NSSSUPER` AS `NSSSUPER`,`EMPREGADO`.`NDEP` AS `NDEP` from `EMPREGADO` where ((`EMPREGADO`.`PNOME` = 'Franklin') and (`EMPREGADO`.`SNOME` = 'Wong')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `TOTALHORASPRO` -- /*!50001 DROP VIEW IF EXISTS `TOTALHORASPRO`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `TOTALHORASPRO` AS select `TRABALHA_EM`.`PNRO` AS `PNRO`,sum(`TRABALHA_EM`.`HORAS`) AS `H` from `TRABALHA_EM` group by `TRABALHA_EM`.`PNRO` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- -- Final view structure for view `TOTALHORASPROJ` -- /*!50001 DROP VIEW IF EXISTS `TOTALHORASPROJ`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; /*!50001 SET character_set_client = utf8 */; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `TOTALHORASPROJ` AS select `TRABALHA_EM`.`PNRO` AS `PNRO`,sum(`TRABALHA_EM`.`HORAS`) AS `sum(HORAS)` from `TRABALHA_EM` group by `TRABALHA_EM`.`PNRO` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2017-10-22 21:54:48
true
943c4b6cbfeaf05a21c18de4c569b3d380a505ec
SQL
andreyAmaterasu/AS2020
/scriptDronTaxi.sql
UTF-8
4,698
3.59375
4
[]
no_license
create table Useraccount ( email varchar(50) primary key, password varchar(50) not null, lastname varchar(30) not null, firstname varchar(30) not null, patronymic varchar(30) not null, date_of_birth date, gender varchar(20), phone_number varchar(30), photo varchar(150) ); insert into Useraccount values ('test@gmail.com', 'pass', 'Иванов', 'Дмитрий', 'Николаевич', '1990-01-01', 'Мужской', '8 999 548 23 10', 'path'); create table Save_useraccount ( id serial primary key, email varchar(50) references Useraccount (email) on delete cascade on update cascade ); create table Available_roles ( system_name varchar(50) primary key, role_name varchar(50) not null, start_date date not null, expiration_date date ); insert into Available_roles values ('manager', 'Менеджер', '2020-01-01'); insert into Available_roles values ('admin', 'Администратор', '2020-01-01'); create table Role_for_user ( email varchar(50) references Useraccount (email) on delete cascade on update cascade, role varchar(50) references Available_roles (system_name) on delete cascade on update cascade, primary key (email, role) ); insert into Role_for_user values ('test@gmail.com', 'manager'); insert into Role_for_user values ('test@gmail.com', 'admin'); create table System_function ( system_name varchar(50) primary key, function_name varchar(50) not null, role varchar(50) references Available_roles (system_name) on delete cascade on update cascade ); insert into System_function values ('user_control', 'Управление пользователями', 'manager'); insert into System_function values ('role_control', 'Управление ролями', 'admin'); create table Master ( id_master serial primary key, lastname varchar(30) not null, firstname varchar(30) not null, patronymic varchar(30) not null ); create table Repair_cycle ( id_repair_cycle serial primary key, periodicity_type varchar(30) not null, periodicity_value smallint not null ); create table Сycle_of_technical_inspections ( id_technical_inspections serial primary key, periodicity_type varchar(30) not null, periodicity_value varchar(30) not null ); create table Transport ( id_transport serial primary key, brand varchar(30) not null, model varchar(30) not null, year_of_production smallint not null, number_of_registrtion varchar(50) not null, date_of_registration date not null, writeoff_date date, transport_status varchar(50) not null, repair_cycle serial references Repair_cycle (id_repair_cycle) on delete cascade on update cascade, cycle_of_technical_inspections serial references Сycle_of_technical_inspections (id_technical_inspections) on delete cascade on update cascade ); create table Transport_photo ( transport serial primary key references Transport (id_transport) on delete cascade on update cascade, photo varchar(150) ); create table Transport_complectation ( id_unit serial primary key, unit_name varchar(50) not null, transport serial references Transport (id_transport) on delete cascade on update cascade ); create table Additional_attribute ( id_attribute serial primary key, attribute varchar(50) not null, attribute_value varchar(50) not null, transport serial references Transport (id_transport) on delete cascade on update cascade ); create table Order_of_user ( number_of_order serial primary key, datetime_of_order timestamp not null, customer varchar(50) references Useraccount (email) on delete cascade on update cascade, departure_point_address varchar(100) not null, destination_address varchar(100) not null, status varchar(30) not null, transport serial references Transport (id_transport) on delete cascade on update cascade, operator varchar(50) references Useraccount (email) on delete cascade on update cascade ); create table Repairs ( id_repairs serial primary key, type_of_repairs varchar(50) not null, date_of_repairs date not null, nature_of_failure varchar(50) not null, master serial references Master (id_master) on delete cascade on update cascade, unit serial references Transport_complectation (id_unit) on delete cascade on update cascade ); create table Maintenance ( id_maintenance serial primary key, date_of_maintenance date not null, inspection_result varchar(30) not null, master serial references Master (id_master) on delete cascade on update cascade, transport serial references Transport (id_transport) on delete cascade on update cascade );
true
ab266ec7a3d1225494018631e17b12e44c5acc18
SQL
mayoricodevault/riot-core-services
/src/main/resources/sql/mysql/V050000_RC2_to_050000_RC3.sql
UTF-8
949
3.375
3
[ "Apache-2.0" ]
permissive
ALTER TABLE token ADD tokenActive BOOLEAN NOT NULL DEFAULT TRUE AFTER creationTime; CREATE TABLE IF NOT EXISTS `thingtypepath` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID of the table', `originThingType_id` bigint(20) NOT NULL COMMENT 'Thing Type ID origin', `destinyThingType_id` bigint(20) NOT NULL COMMENT 'Thing Type ID destiny', `path` varchar(255) DEFAULT NULL COMMENT 'Path to get the value from originThingTypeId to destinyThingType_id', PRIMARY KEY (`id`) ); ALTER TABLE riot_main.thingtypepath ADD CONSTRAINT FK_thingtypepath_originThingType FOREIGN KEY (originThingType_id) REFERENCES thingtype (id), ADD CONSTRAINT FK_thingtypepath_destinyThingType FOREIGN KEY (destinyThingType_id) REFERENCES thingtype (id); ALTER TABLE `riot_main`.`localMap` ADD (`latOriginNominal` DOUBLE, `lonOriginNominal` DOUBLE, `xNominal` DOUBLE, `yNominal` DOUBLE, `modifiedTime` BIGINT(20));
true
0e5760d52c9882ea04f756bb2a86c37d502b4455
SQL
kenmd/spring-boots
/spring-data-jdbc-web-security/src/main/resources/schema.sql
UTF-8
335
2.875
3
[]
no_license
CREATE TABLE IF NOT EXISTS users ( id IDENTITY, username VARCHAR NOT NULL, password VARCHAR NOT NULL, enabled BOOLEAN DEFAULT TRUE, created_at TIMESTAMP DEFAULT NOW() ); CREATE TABLE IF NOT EXISTS authorities ( id IDENTITY, username VARCHAR NOT NULL, authority VARCHAR NOT NULL, created_at TIMESTAMP DEFAULT NOW() );
true
d1d73fda68a8e154c781016fb87e7861c6afc94b
SQL
xiemenger/sql-procedures-and-functions
/CreateTriggerForTable.sql
UTF-8
337
2.96875
3
[]
no_license
-- For one table: CREATE TRIGGER test AFTER INSERT OR UPDATE OR DELETE ON t_trig_table FOR EACH ROW EXECUTE PROCEDURE change_trigger(); -- For multiple tables: CREATE TRIGGER testtrigger AFTER INSERT OR UPDATE OR DELETE ON 'table1 || table2 || table3 || ... ' FOR EACH ROW EXECUTE PROCEDURE change_trigger();
true
7e67e0a005d400be71468fd68ad540ecbcac7407
SQL
clarkfitzg/phd_research
/hadoop/basic/gamma.sql
UTF-8
515
3.40625
3
[]
no_license
-- gamma.sql DROP TABLE gamma ; CREATE TABLE gamma ( userid INT, movieid INT, rating INT, gamma_col DOUBLE) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ; add FILE gamma.R ; INSERT OVERWRITE TABLE gamma SELECT TRANSFORM (userid, movieid, rating) -- The 3 following the command makes it available from commandArgs within -- R. Haven't figured out how to pass the tab character though. USING "Rscript gamma.R 3" AS (userid, movieid, rating, gamma_col) FROM u_data ; SELECT * FROM gamma LIMIT 10 ;
true
42b8c459d414f824b5f20bf15d1a00e47c5882ff
SQL
junrudai/sqlzoo
/Guest_house/Hard/11.sql
UTF-8
1,315
4.9375
5
[]
no_license
--- Coincidence. Have two guests with the same surname ever stayed in the hotel on the evening? Show the last name and both first names. Do not include duplicates. WITH guest2 AS ( SELECT b.booking_date, b.nights, g.last_name, g.first_name FROM booking AS b INNER JOIN guest AS g ON b.guest_id = g.id ), guest_list AS ( SELECT DISTINCT g1.last_name, g2.first_name AS first_name_1, g1.first_name AS first_name_2, ROW_NUMBER() OVER (PARTITION BY g1.last_name ORDER BY g1.first_name) AS rk FROM booking AS b INNER JOIN guest AS g1 ON b.guest_id = g1.id -- Join on same last name and exclude same first_name LEFT JOIN guest2 AS g2 ON g1.last_name = g2.last_name AND g1.first_name != g2.first_name WHERE --- g1 checkin date is within b2's stay b.booking_date BETWEEN g2.booking_date AND DATE_ADD (day, g2.nights - 1, g2.booking_date) -- or g2 checkout date is within b2'stay OR DATE_ADD (day, b.nights - 1, b.booking_date) BETWEEN g2.booking_date AND DATE_ADD (day, g2.nights - 1, g2.booking_date) ) SELECT last_name, first_name_1, first_name_2 FROM guest_list WHERE --- get every other row from the list MOD(rk,2) = 0
true
a8e80e46ec1effb1b8514fd574146f43b4327063
SQL
achmadnabawi/sparkdata
/zlj/project/service/t_base_ec_feed_user_buy_info.sql
GB18030
823
3.453125
3
[]
no_license
-- û¼ -- ƷϢ ûϢ ̻Ϣ -- create table t_base_ec_feed_user_buy_info as INSERT INTO TABLE t_base_ec_feed_user_buy_info PARTITION (ds='20160418' ) select t2.item_id , t2.user_id , t2.cat_id , t2.root_cat_id , t2.root_cat_name , t2.brand_id , t2.brand_name , t2.bc_type , t2.price , t1.tgender , t1.tage, t1.tname, t1.tloc from ( select tb_id, tgender, tage, tname, tloc from t_base_user_info_s where ds=20160418 and LENGTH(tloc)>2 and LENGTH(tgender)>0 and LENGTH(tb_id)>2 ) t1 join (select item_id, user_id , cat_id , root_cat_id , root_cat_name , brand_id , brand_name , bc_type , price from t_base_ec_record_dev_new) t2 on t1.tb_id =t2.user_id ;
true
c5daa524b88a3279a4933e00ee42a5742386fa33
SQL
joaovcog/algamoney-api
/src/main/resources/db/migration/V07__criar_e_registrar_cidades_estados.sql
UTF-8
2,976
3.390625
3
[]
no_license
CREATE TABLE estados ( codigo BIGINT(20) PRIMARY KEY AUTO_INCREMENT, nome VARCHAR(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO estados (codigo, nome) VALUES(1, 'Acre'); INSERT INTO estados (codigo, nome) VALUES(2, 'Alagoas'); INSERT INTO estados (codigo, nome) VALUES(3, 'Amazonas'); INSERT INTO estados (codigo, nome) VALUES(4, 'Amapá'); INSERT INTO estados (codigo, nome) VALUES(5, 'Bahia'); INSERT INTO estados (codigo, nome) VALUES(6, 'Ceará'); INSERT INTO estados (codigo, nome) VALUES(7, 'Distrito Federal'); INSERT INTO estados (codigo, nome) VALUES(8, 'Espírito Santo'); INSERT INTO estados (codigo, nome) VALUES(9, 'Goiás'); INSERT INTO estados (codigo, nome) VALUES(10, 'Maranhão'); INSERT INTO estados (codigo, nome) VALUES(11, 'Minas Gerais'); INSERT INTO estados (codigo, nome) VALUES(12, 'Mato Grosso do Sul'); INSERT INTO estados (codigo, nome) VALUES(13, 'Mato Grosso'); INSERT INTO estados (codigo, nome) VALUES(14, 'Pará'); INSERT INTO estados (codigo, nome) VALUES(15, 'Paraíba'); INSERT INTO estados (codigo, nome) VALUES(16, 'Pernambuco'); INSERT INTO estados (codigo, nome) VALUES(17, 'Piauí'); INSERT INTO estados (codigo, nome) VALUES(18, 'Paraná'); INSERT INTO estados (codigo, nome) VALUES(19, 'Rio de Janeiro'); INSERT INTO estados (codigo, nome) VALUES(20, 'Rio Grande do Norte'); INSERT INTO estados (codigo, nome) VALUES(21, 'Rondônia'); INSERT INTO estados (codigo, nome) VALUES(22, 'Roraima'); INSERT INTO estados (codigo, nome) VALUES(23, 'Rio Grande do Sul'); INSERT INTO estados (codigo, nome) VALUES(24, 'Santa Catarina'); INSERT INTO estados (codigo, nome) VALUES(25, 'Sergipe'); INSERT INTO estados (codigo, nome) VALUES(26, 'São Paulo'); INSERT INTO estados (codigo, nome) VALUES(27, 'Tocantins'); CREATE TABLE cidades ( codigo BIGINT(20) PRIMARY KEY AUTO_INCREMENT, nome VARCHAR(50) NOT NULL, cod_estado BIGINT(20) NOT NULL, FOREIGN KEY (cod_estado) REFERENCES estados(codigo) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO cidades (codigo, nome, cod_estado) VALUES (1, 'Belo Horizonte', 11); INSERT INTO cidades (codigo, nome, cod_estado) VALUES (2, 'Uberlândia', 11); INSERT INTO cidades (codigo, nome, cod_estado) VALUES (3, 'Uberaba', 11); INSERT INTO cidades (codigo, nome, cod_estado) VALUES (4, 'São Paulo', 26); INSERT INTO cidades (codigo, nome, cod_estado) VALUES (5, 'Campinas', 26); INSERT INTO cidades (codigo, nome, cod_estado) VALUES (6, 'Rio de Janeiro', 19); INSERT INTO cidades (codigo, nome, cod_estado) VALUES (7, 'Angra dos Reis', 19); INSERT INTO cidades (codigo, nome, cod_estado) VALUES (8, 'Goiânia', 9); INSERT INTO cidades (codigo, nome, cod_estado) VALUES (9, 'Caldas Novas', 9); ALTER TABLE pessoas DROP COLUMN cidade; ALTER TABLE pessoas DROP COLUMN estado; ALTER TABLE pessoas ADD COLUMN cod_cidade BIGINT(20); ALTER TABLE pessoas ADD CONSTRAINT fk_pessoas_cidades FOREIGN KEY (cod_cidade) REFERENCES cidades(codigo); UPDATE pessoas SET cod_cidade = 4;
true
dd1c0234a0227913093193e1aee785228c993ab3
SQL
DorianPATRU/USAL37_BDD
/EVAL_MD214_PATRU/EVAL_MD214_SCRIPT.sql
UTF-8
2,664
3.78125
4
[]
no_license
/* Suppression de la base de données si elle existe */ DROP DATABASE IF EXISTS usal37_legumos; /* Création de la base de données si elle n'existe pas avec le set de caractères par défaut UTF-8 */ CREATE DATABASE IF NOT EXISTS usal37_legumos DEFAULT CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci'; /* Utilisation de la base de données */ USE usal37_legumos; /* Création des tables */ CREATE TABLE Vegetables( Id INT, Name VARCHAR(50) NOT NULL UNIQUE, Variety VARCHAR(50) NOT NULL, PrimaryColor VARCHAR(20) NOT NULL, LifeTime INT NOT NULL, Fresh INT NOT NULL, PRIMARY KEY(Id) ); CREATE TABLE Sales( SaleId INT, SaleDate DATE NOT NULL, SaleWeight INT NOT NULL, SaleUnitPrice DECIMAL(5,2) NOT NULL, SaleActive INT NOT NULL, Id INT NOT NULL, PRIMARY KEY(SaleId), FOREIGN KEY(Id) REFERENCES Vegetables(Id) ); /* Ajout de 20 légumes différents */ INSERT INTO Vegetables (Id, Name, Variety, PrimaryColor, LifeTime, Fresh) VALUES (111, "Asperge", "Burgundine", "Blanc", 5, 0), (121, "Aubergine", "Barbentane", "Violet", 5, 1), (124, "Betterave", "Crapaudine", "Rouge", 5, 1), (132, "Brocoli", "Calabrais", "Vert", 5 , 1), (146, "Courgette", "Diamant", "Vert", 6, 1), (157, "Echalote", "Jersey", "Rose", 60, 0), (169, "Epinard", "Butterfly", "Vert", 2, 1), (178, "Haricot", "Rudy", "Vert", 4, 1), (183, "Laitue", "Radicchio", "Rouge", 6, 1), (195, "Lentille", "Corail", "Rouge", 730, 0), (214, "Mache", "Gala", "Vert", 3, 1), (226, "Patate", "Bintje", "Jaune", 90, 0), (238, "Navet", "Montesson", "Violet", 7, 1), (243, "Oignon", "Sturon", "Jaune", 60, 0), (259, "Poireau", "Perpetuel", "Vert", 5, 0), (267, "Potiron", "Aspen", "Orange", 42, 0), (272, "Poivron", "Nikita", "Blanc", 8, 1), (281, "Radis", "Bamba", "Rouge", 2, 1), (295, "Roquette", "Fresca", "Vert", 2, 1), (310, "Tomate", "Cerise", "Rouge", 4, 0); /* Ajout de 10 ventes associées à différents légumes */ INSERT INTO Sales (SaleId, SaleDate, SaleWeight, SaleUnitPrice, SaleActive, Id) VALUES (9111, "2021-02-17", 3, 5.00, 1, 111), (1121, "2021-02-18", 5, 7.40, 1, 183), (2124, "2021-02-19", 8, 2.50, 0, 146), (3132, "2021-02-20", 4, 3.90, 0, 169), (4146, "2021-02-21", 1, 1.80, 1, 195), (5157, "2021-02-22", 7, 1.60, 0, 238), (6169, "2021-02-23", 2, 1.50, 1, 243), (7178, "2021-02-24", 6, 2.40, 1, 267), (8183, "2021-02-25", 9, 2.75, 0, 281), (9195, "2021-02-26", 4, 4.80, 1, 310); /* Requête qui affiche toutes les ventes avec le nom du légume associé à la vente */ SELECT Vegetables.Id, Name, SaleId, SaleDate, SaleWeight, SaleUnitPrice, SaleActive FROM Sales JOIN Vegetables ON Sales.Id = Vegetables.Id
true
c8d42a32e947ea907076d192523f5f07af039fbe
SQL
EkhlasMridha/HotelBookingCRUD
/assignment-bookingsystem.sql
UTF-8
1,657
3.59375
4
[]
no_license
CREATE TABLE IF NOT EXISTS `BookingDetails`( `Id` BIGINT NOT NULL AUTO_INCREMENT, `BookedFrom` datetime not null, `LeaveAt` datetime not null, `BookedBy` BIGINT not null, `PaidAmount` decimal null, `Comments` varchar(300) null, `CreatedAt` DATETIME NOT NULL, `UpdatedAt` datetime NULL, PRIMARY KEY (`Id`) ); CREATE TABLE IF NOT EXISTS `Rooms`( `Id` BIGINT NOT NULL AUTO_INCREMENT, `RoomNumber` varchar(200) not null, `Capacity` int not null, `Rent` decimal not null, `CreatedAt` DATETIME NOT NULL, `UpdatedAt` datetime NULL, primary key (`Id`) ); CREATE TABLE IF NOT EXISTS `Bookings`( `Id` BIGINT NOT NULL AUTO_INCREMENT, `BookingId` BIGINT NOT NULL, `RoomId` BIGINT NOT NULL, `CreatedAt` DATETIME NOT NULL, `UpdatedAt` datetime NULL, primary key (`Id`), FOREIGN KEY(`BookingId`) REFERENCES `BookingDetails` (`Id`) ON DELETE CASCADE ON UPDATE NO ACTION, FOREIGN KEY(`RoomId`) REFERENCES `Rooms` (`Id`) ON DELETE CASCADE ON UPDATE NO ACTION ); CREATE TABLE IF NOT EXISTS `Guests`( `Id` BIGINT NOT NULL AUTO_INCREMENT, `Name` varchar(250) NOT NULL, `Age` int NOT NULL, `ContactNumber` varchar(250) NULL, `CreatedAt` DATETIME NOT NULL, `UpdatedAt` datetime NULL, primary key (`Id`) ); CREATE TABLE IF NOT EXISTS `BookingSettings`( `Id` BIGINT NOT NULL AUTO_INCREMENT, `Discount` decimal NULL, `TaxPercentage` decimal NULL, `CreatedAt` DATETIME NOT NULL, `UpdatedAt` datetime NULL, primary key (`Id`) ); CREATE UNIQUE INDEX KEY_INDEX ON `Rooms` (`RoomNumber`);
true
1f57e835abb37130ac5a1f3e51f783bda109c360
SQL
Seeker1911/chinook_database
/total_sales_year.sql
UTF-8
90
2.609375
3
[]
no_license
select sum(Total) from Invoice where InvoiceDate like '2009%' or InvoiceDate like '2011%'
true
3304aaf175c64b8a038c29c7e92e48d59de0cb7a
SQL
316k/IFT1155-SQL
/db-sqlite.sql
UTF-8
1,965
3.890625
4
[]
no_license
DROP TABLE IF EXISTS `locaux`; CREATE TABLE `locaux` ( `_id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `numero` TEXT NOT NULL, `categorie` TEXT NOT NULL, CHECK(`categorie` in ('reunion', 'cours')) ); -- -- Table structure for table `users` -- DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `_id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `login` TEXT NOT NULL, `password` TEXT NOT NULL, `name` TEXT NOT NULL, `access_level` TEXT NOT NULL, -- "admin" ou "user" `last_login` INTEGER DEFAULT NULL, -- date du CHECK(`access_level` in ('admin', 'user')) ); CREATE UNIQUE INDEX `unique_login` ON `users`(`login`); -- -- Table structure for table `reservations` -- DROP TABLE IF EXISTS `reservations`; CREATE TABLE `reservations` ( `_id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `local_id` INTEGER NOT NULL, -- id du local réservé `user_id` INTEGER NOT NULL, -- id du user qui réserve `raison` TEXT NOT NULL, -- Raison invoquée -- penser à l'autocomplete pour éviter de retaper à chaque fois ! `debut` INTEGER NOT NULL, `duration` INTEGER NOT NULL, -- Durée en secondes `cours` TEXT NOT NULL -- Sigle du cours pour lequel la réservation est faite (potentiellement vide) ); -- -- Données de test -- INSERT INTO `locaux`(`numero`, `categorie`) VALUES (2165, "reunion"), (2166, "reunion"), (2211, "reunion"), (2195, "reunion"), (3213, "reunion"), (2333, "cours"), (3181, "cours"), (3189, "cours"), (3248, "cours"), (3311, "cours"); INSERT INTO `users`(`login`, `password`, `name`, `access_level`) VALUES ("admin", "$up3rP4$$", "Jack Kerouac", "admin"), ("johnsmith", "superpass123", "John Smith", "user"); INSERT INTO `reservations`(`local_id`, `user_id`, `raison`, `debut`, `duration`, `cours`) VALUES (1, 2, "Réunion pour le MILA", 1487250000, 60 * 60, ""), (1, 2, "Réunion pour le MILA", 1487422800, 60 * 60, "");
true
c8917a4673743ba374264ef48f806732a2373190
SQL
javachengwc/java-apply
/modules/sharding-dbtable/modules/sharding-springboot-demo/src/main/resources/db/create.sql
UTF-8
3,366
3.875
4
[]
no_license
create database demo_ds_0; create database demo_ds_1; ###分别在数据库 demo_ds_0, demo_ds_1执行建表语句,t_order_0,t_order_1,t_order_item_0,t_order_item_1 create table if not exists t_order_0( order_id bigint auto_increment, user_id bigint comment '用户id', user_name varchar(32) default '' comment '用户名称', statu int default 0 comment '状态', price bigint default 0 comment '订单总价', shop_id bigint comment '店铺id', shop_name varchar(64) comment '店铺名称', create_time datetime comment '创建时间', modified_time datetime comment '修改时间', primary key(order_id), key idx_user_order(user_id,order_id), key idx_create_order(create_time,order_id), key idx_shop_order(shop_id,order_id) ) engine INNODB default charset utf8 comment '订单表分表0'; create table if not exists t_order_1( order_id bigint auto_increment, user_id bigint comment '用户id', user_name varchar(32) default '' comment '用户名称', statu int default 0 comment '状态', price bigint default 0 comment '订单总价', shop_id bigint comment '店铺id', shop_name varchar(64) comment '店铺名称', create_time datetime comment '创建时间', modified_time datetime comment '修改时间', primary key(order_id), key idx_user_order(user_id,order_id), key idx_create_order(create_time,order_id), key idx_shop_order(shop_id,order_id) ) engine INNODB default charset utf8 comment '订单表分表1'; create table t_order_item_0 ( order_item_id bigint auto_increment, order_id bigint comment '订单id', user_id bigint comment '用户id', user_name varchar(32) default '' comment '用户名称', item_price bigint default 0 comment '详单项总价', shop_id bigint comment '店铺id', shop_name varchar(64) comment '店铺名称', product_id bigint comment '产品id', product_name varchar(64) comment '产品名称', sku_num varchar(64) comment 'sku编码', sku_name varchar(64) comment 'sku名称', count int default 0 comment '数量', create_time datetime comment '创建时间', modified_time datetime comment '修改时间', primary key(order_item_id), key idx_order_item(order_id,order_item_id), key idx_product_create(product_id,create_time), key idx_sku_order(sku_num,product_id,order_id), key idx_create_user(create_time,user_id) ) engine INNODB default charset utf8 comment '订单详单分表0'; create table t_order_item_1 ( order_item_id bigint auto_increment, order_id bigint comment '订单id', user_id bigint comment '用户id', user_name varchar(32) default '' comment '用户名称', item_price bigint default 0 comment '详单项总价', shop_id bigint comment '店铺id', shop_name varchar(64) comment '店铺名称', product_id bigint comment '产品id', product_name varchar(64) comment '产品名称', sku_num varchar(64) comment 'sku编码', sku_name varchar(64) comment 'sku名称', count int default 0 comment '数量', create_time datetime comment '创建时间', modified_time datetime comment '修改时间', primary key(order_item_id), key idx_order_item(order_id,order_item_id), key idx_product_create(product_id,create_time), key idx_sku_order(sku_num,product_id,order_id), key idx_create_user(create_time,user_id) ) engine INNODB default charset utf8 comment '订单详单分表1';
true
39b3b6b2d0f86fa97372bc7626227c95ebfc12e8
SQL
itsnatscott/WDI_project_1
/schema.sql
UTF-8
968
3.1875
3
[]
no_license
-- DROP TABLE IF EXISTS post; -- CREATE TABLE post ( -- id INTEGER PRIMARY KEY, -- title TEXT, -- comment INTEGER, -- pic TEXT, -- author INTEGER, -- body TEXT, -- category INTEGER, -- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- upvote INTEGER, --for posts -- downvote INTEGER --not used -- ); -- DROP TABLE IF EXISTS category; -- CREATE TABLE category ( -- id INTEGER PRIMARY KEY, -- title TEXT, -- descrp TEXT, -- posts INTEGER, -- votes INTEGER -- ); -- DROP TABLE IF EXISTS comments; -- CREATE TABLE comments ( -- id INTEGER PRIMARY KEY AUTOINCREMENT, -- comment TEXT, -- userId TEXT, -- postId INTEGER -- ); DROP TABLE IF EXISTS users; CREATE TABLE users ( id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, password TEXT, email TEXT, subs INTEGER ); -- CREATE TRIGGER timestamp_update BEFORE UPDATE ON entries BEGIN -- UPDATE entries SET updated_at = CURRENT_TIMESTAMP WHERE id = new.id; -- END;
true
e1e092dadb2ce0ccda94e2aeafc3930898ff6197
SQL
teach-tech-service/postgres
/query5.sql
UTF-8
367
2.625
3
[]
no_license
SELECT id as "Id zgłoszenia", data_zgloszenia as "Data zgłoszenia", termin_rozwiazania as "Termin rozwiązania", data_rozwiazania as "Data rozwiązania", CONCAT(opis, ' wyjasnienie: ', wyjasnienie) as "Opis z wyjaśnieniem", DATE_PART( 'day', data_rozwiazania :: timestamp - termin_rozwiazania :: timestamp ) as "Opoznienie" FROM zgloszenie;
true
75820a2232291596c40553fd11b9539e86b649a7
SQL
rafaelmarchesin/event-sourcing
/src/database_scripts/CreateTable.sql
UTF-8
507
2.734375
3
[]
no_license
CREATE TABLE todo_list_table ( id INT(8) not null AUTO_INCREMENT PRIMARY KEY, task_id INT (8) NOT NULL, version INT (1) default 1, task VARCHAR(140) NOT NULL, done INT(1) default 0, event_type VARCHAR(140), date_time DATETIME DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE todo_list_projections ( id INT(8) not null AUTO_INCREMENT PRIMARY KEY, task_id INT (8) NOT NULL, version INT (1) default 1, task VARCHAR(140), done INT(1) default 0, event_type VARCHAR(140), date_time DATETIME DEFAULT CURRENT_TIMESTAMP );
true
334a3a48b199df329983561989024a54fdc08874
SQL
rkboyce/WebAPI
/src/main/resources/resources/cohortdefinition/sql/dateOffsetStrategy.sql
UTF-8
172
2.71875
3
[ "Apache-2.0" ]
permissive
select event_id, person_id, case when DATEADD(day,@offset,@dateField) > start_date then DATEADD(day,@offset,@dateField) else start_date end as end_date from @eventTable
true
17f4a7377bb6646715248852507e9e2af4ed619f
SQL
pookieofdoom/school
/365/lab2/WINE/WINE-queries.sql
UTF-8
3,829
3.9375
4
[]
no_license
-- Anthony Dinh -- adinh03@calpoly.edu -- CPE 365 -- WINE-queries.sql -- Q1 SELECT A.* FROM (SELECT W.Grape, G.Color, COUNT(DISTINCT W.Appellation) AS NumApp FROM Wine W, Grapes G WHERE W.Grape = G.Grape GROUP BY W.Grape) AS A WHERE A.NumApp = (SELECT MAX(A2.NumApp) FROM (SELECT W.Grape, G.Color, COUNT(DISTINCT W.Appellation) AS NumApp FROM Wine W, Grapes G WHERE W.Grape = G.Grape GROUP BY W.Grape) AS A2); -- Q2 -- County or Appellation for Santa Barbara...?? SELECT A.Grape FROM (SELECT W.Grape, G.Color, COUNT(*) AS NumWhite FROM Wine W, Grapes G, Appellations A WHERE W.Appellation = A.Appellation AND A.County = 'Santa Barbara' AND W.Grape = G.Grape AND G.Color = 'White' GROUP BY W.Grape) AS A WHERE A.NumWhite = (SELECT MAX(A2.NumWhite) FROM (SELECT W.Grape, G.Color, COUNT(*) AS NumWhite FROM Wine W, Grapes G, Appellations A WHERE W.Appellation = A.Appellation AND A.County = 'Santa Barbara' AND W.Grape = G.Grape AND G.Color = 'White' GROUP BY W.Grape) AS A2); -- Q3 SELECT H.Grape FROM (SELECT W.Grape, COUNT(*) AS NumHighScore FROM Wine W WHERE W.Score >= 93 GROUP BY W.Grape) AS H WHERE H.NumHighScore = (SELECT MAX(H2.NumHighScore) FROM (SELECT W.Grape, COUNT(*) AS NumHighScore FROM Wine W WHERE W.Score >= 93 GROUP BY W.Grape) AS H2); -- Q4 SELECT H.Appellation FROM (SELECT W.Appellation, COUNT(*) AS NumHighScore FROM Wine W WHERE W.Score >= 93 GROUP BY W.Appellation) AS H WHERE H.NumHighScore = (SELECT MAX(H2.NumHighScore) FROM (SELECT W.Appellation, COUNT(*) AS NumHighScore FROM Wine W WHERE W.Score >= 93 GROUP BY W.Appellation) AS H2); -- Q5 SELECT R.* FROM (SELECT W.Year, W.Winery, W.Name, W.Score, W.Price * 12 * W.Cases AS Revenue FROM Wine W WHERE W.Score >= 93) AS R WHERE R.Revenue = (SELECT MAX(R2.Revenue) FROM (SELECT W.Year, W.Winery, W.Name, W.Score, W.Price * 12 * W.Cases AS Revenue FROM Wine W WHERE W.Score >= 93) AS R2); -- Q6 SELECT W.Winery, W.Name, W.Appellation, W.Score, W.Price FROM Wine W WHERE W.Year = 2008 AND W.Grape = 'Zinfandel' AND W.Score > ALL(SELECT W.Score FROM Wine W WHERE W.Year = 2007 AND W.Grape = 'Grenache'); -- Q7 SELECT C.CarnerosWins, D.DCVWins FROM (SELECT COUNT(DISTINCT W1.Year) AS CarnerosWins FROM Wine W1 WHERE W1.Appellation = 'Carneros' AND W1.Year >= 2005 AND W1.Year <= 2009 AND W1.Score > ALL(SELECT W2.Score FROM Wine W2 WHERE W2.Appellation = 'Dry Creek Valley' AND W2.Year = W1.Year) ORDER BY W1.Year, W1.Score) AS C, (SELECT COUNT(DISTINCT W2.Year) AS DCVWins FROM Wine W2 WHERE W2.Appellation = 'Dry Creek Valley' AND W2.Year >= 2005 AND W2.Year <= 2009 AND W2.Score > ALL(SELECT W1.Score FROM Wine W1 WHERE W1.Appellation = 'Carneros' AND W2.Year = W1.Year) ORDER BY W2.Year, W2.Score) AS D; -- Q8 SELECT W.Cases FROM Wine W WHERE W.Price = (SELECT MAX(R.Price) FROM (SELECT W.Grape, W.Price FROM Wine W, Grapes G WHERE W.Grape = G.Grape AND G.Color = 'Red' GROUP BY W.Price) AS R); -- Q9 SELECT A.Year, A.Appellation FROM (SELECT W.Year, W.Appellation, W.Price FROM Wine W GROUP BY W.Year, W.Appellation, W.Price) AS A, (SELECT A.Year, MAX(A.Price) AS MaxPrice FROM (SELECT W.Year, W.Appellation, W.Price FROM Wine W GROUP BY W.Year, W.Appellation, W.Price) AS A GROUP BY A.Year) AS B WHERE A.Price = B.MaxPrice AND A.Year = B.Year;
true
1fd149b67ceab4eaac7215bfa55a891a042e7e25
SQL
yaroslavtsepkov/ESA
/database/tododb.sql
UTF-8
1,605
4.1875
4
[]
no_license
create table users ( iduser serial, username VARCHAR(64) not null, password VARCHAR(64) not null, constraint pk_iduser primary key(iduser) ); create table tasks ( idtask serial, iduser int not null, title varchar(64) default null, description varchar(256) default null, status bit(1) default null, deadline date default null, constraint pk_idtask primary key(idtask), constraint fk_iduser foreign key(iduser) references users(iduser) ); -- for pgsql -- Table: public.tasks -- DROP TABLE public.tasks; CREATE TABLE public.tasks ( idtask integer NOT NULL DEFAULT nextval('tasks_idtask_seq'::regclass), iduser integer NOT NULL, title character varying(64) COLLATE pg_catalog."default" DEFAULT NULL::character varying, description character varying(256) COLLATE pg_catalog."default" DEFAULT NULL::character varying, status bit(1) DEFAULT NULL::"bit", deadline date, CONSTRAINT pk_idtask PRIMARY KEY (idtask), CONSTRAINT fk_iduser FOREIGN KEY (iduser) REFERENCES public.users (iduser) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ) TABLESPACE pg_default; ALTER TABLE public.tasks OWNER to pgessea; -- Table: public.users -- DROP TABLE public.users; CREATE TABLE public.users ( iduser integer NOT NULL DEFAULT nextval('users_iduser_seq'::regclass), username character varying(64) COLLATE pg_catalog."default" NOT NULL, password character varying(64) COLLATE pg_catalog."default" NOT NULL, CONSTRAINT pk_iduser PRIMARY KEY (iduser) ) TABLESPACE pg_default; ALTER TABLE public.users OWNER to pgessea;
true
faaec3197a39ee29b0d71c394e9ca4ce6d351fd0
SQL
souvikdas2411/DBMS-COURSE-CS310
/CarInsurance/PDM/6.sql
UTF-8
344
3.28125
3
[]
no_license
use mydb; SELECT DISTINCT t1.* FROM t3_CUSTOMER AS t1, t3_COVERAGE AS t2, t3_CLAIM_SETTLEMENT AS t3, t3_CLAIM AS t4 WHERE t4.t3_Claim_Amount < t2.t3_Coverage_Amount AND t4.t3_Claim_Amount > (t3.t3_Claim_Settlement_Id + t3.t3_Vehicle_Id + t3.t3_Claim_Id + t3.t3_Cust_Id) AND t1.t3_Cust_Id = t4.t3_Cust_Id;
true
4673055596499f8ee7201bb34d0fc55905384ab9
SQL
termlex/release-assertion-toolkit
/release-assertion-resources/src/main/resources/scripts/component-centric/component-centric-snapshot-description-fsn-synonym-text.sql
UTF-8
2,341
3.703125
4
[]
no_license
/******************************************************************************** file-centric-snapshot-description-synonym-tag Assertion: For each active FSN associated with active concept there is a synonym that has the same text. ********************************************************************************/ /* active concepts having descriptions edited in the current release cycle */ create temporary table if not exists tmp_consedited as select distinct conceptid from curr_concept_s a join curr_description_d b on a.id = b.conceptid and a.active = 1; /* for edited concepts, list all FSNs, with and without semantic tags */ create temporary table if not exists tmp_fsn as select replace(a.term, concat('(',substring_index(a.term, '(', -1)), '') as termwithouttag, a.id , a.conceptid , a.term from curr_description_s a join tmp_consedited b on a.conceptid = b.conceptid and a.active = 1 where a.typeid ='900000000000003001'; /* all terms for edited concepts */ create temporary table if not exists tmp_allterms as select a.id , a.conceptid , a.term from curr_description_s a join tmp_consedited b on a.conceptid = b.conceptid and a.active = 1 where a.typeid !='900000000000003001'; /* select the concepts that have synonyms that match the FSNs without semantic tags */ create temporary table if not exists tmp_termsmatch as select a.* from tmp_fsn a join tmp_allterms b on a.conceptid = b.conceptid and a.termwithouttag = b.term; select a.* from tmp_fsn a left join tmp_termsmatch b on a.conceptid = b.conceptid and a.termwithouttag = b.termwithouttag where b.conceptid is null and b.termwithouttag is null; /* inserting exceptions in the result table */ insert into qa_result (runid, assertionuuid, assertiontext, details) select <RUNID>, '<ASSERTIONUUID>', '<ASSERTIONTEXT>', concat(a.conceptid, ' |', a.term, '|') from tmp_fsn a left join tmp_termsmatch b on a.conceptid = b.conceptid and a.termwithouttag = b.termwithouttag where b.conceptid is null and b.termwithouttag is null; /* clean up */ drop temporary table if exists tmp_consedited; drop temporary table if exists tmp_allterms; drop temporary table if exists tmp_fsn; drop temporary table if exists tmp_termsmatch;
true
fc94acf6acbb71c1e72300d05b7941e6bac6b989
SQL
enniebabs/Islay-web
/queries_create/people.sql
UTF-8
615
3.125
3
[]
no_license
CREATE TABLE PEOPLE (PEOPLE_ID NUMBER(6) not null, SURNAME VARCHAR2(2000) null, OTHERNAMES VARCHAR2(2000 )null, MAIDEN_NAME VARCHAR2(1000 )null, STATUS VARCHAR(20) null, BURIED_AT VARCHAR(2000) null, SUPPLEMENTARY CLOB null, REFERENCE VARCHAR(2000) null, AGE NUMBER(5) null, YEAR_BORN NUMBER(4) null, YEAR_MARRIED NUMBER(4) null, YEAR_DIED NUMBER(4) null, GENDER VARCHAR(60) null, BIRTHPLACE VARCHAR(2000) null, PARISH VARCHAR(70) null, SCHEDULE_NUMBER VARCHAR (2000) null, PLACENAME_ID NUMBER(4) null, PRIMARY KEY (PEOPLE_ID), FOREIGN KEY (PLACENAME_ID) REFERENCES PLACENAMES(PLACENAME_ID));
true
9759a85d5fd419636b2958b4d4e23161d3d16381
SQL
vsolv/BigFin
/Bigflow/DB/SPS/Master/sp_Customergroup_Set.sql
UTF-8
13,026
2.953125
3
[]
no_license
CREATE DEFINER=`developer`@`%` PROCEDURE `sp_Customergroup_Set`(IN `Action` varchar(16),IN `li_custgrp_gid` int, IN `ls_custgrp_code` VARCHAR(8),IN `ls_custgrp_name` varchar(128),IN `li_add_gid` int,IN `ls_cpname1` varchar(64), IN `ls_desig1` varchar(64),IN `ls_Mobile1` varchar(16),IN `ls_landln1` varchar(16),IN `ls_cpname2` varchar(64), IN `ls_desig2` varchar(64),IN `ls_Mobile2` varchar(16),IN `ls_landln2` varchar(16),IN `li_client_gid` int,IN `li_entity_gid` int, IN `ls_create_by` int,OUT `Message` varchar(1000)) BEGIN #Vigneshwari 26-03-2018 #meenakshi edited SUPP_INSERT 13-02-2020 declare custgrp_srch text; declare Query1 varchar(1000); declare Query2 varchar(1000); declare ls_error varchar(100); declare countRow int; declare errno int; declare msg varchar(1000); declare ls_no varchar(64); declare Query_Update varchar(9000); DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN GET CURRENT DIAGNOSTICS CONDITION 1 errno = MYSQL_ERRNO, msg = MESSAGE_TEXT; set Message = concat(errno , msg); ROLLBACK; END; set ls_error = ''; set Query1 = ''; set Query2 = ''; if Action = 'Insert' then if ls_custgrp_code = '' then set ls_error = 'Customer Group Code Not Given '; end if; if ls_custgrp_name = '' then set ls_error = 'Customer Group Name Not Given'; end if; if ls_cpname1 <> '' then set Query1 = concat(Query1,'customergroup_cpname,'); set Query2 = concat(Query2,'''' ,ls_cpname1, ''','); else set Query1 = concat(Query1,''); set Query2 = concat(Query2,''); end if; if ls_desig1 <> '' then set Query1 = concat(Query1,'customergroup_cpdesignation,'); set Query2 = concat(Query2,'''' ,ls_desig1, ''','); else set Query1 = concat(Query1,''); set Query2 = concat(Query2,''); end if; if ls_Mobile1 <> '' then set Query1 = concat(Query1,'customergroup_cpmobileno,'); set Query2 = concat(Query2,'''' ,ls_Mobile1, ''','); else set Query1 = concat(Query1,''); set Query2 = concat(Query2,''); end if; if ls_landln1 <> '' then set Query1 = concat(Query1,'customergroup_cplandline,'); set Query2 = concat(Query2,'''' ,ls_landln1, ''','); else set Query1 = concat(Query1,''); set Query2 = concat(Query2,''); end if; if ls_cpname2 <> '' then set Query1 = concat(Query1,'customergroup_cpname2,'); set Query2 = concat(Query2,'''' ,ls_cpname1, ''','); else set Query1 = concat(Query1,''); set Query2 = concat(Query2,''); end if; if ls_desig2 <> '' then set Query1 = concat(Query1,'customergroup_cpdesignation2,'); set Query2 = concat(Query2,'''' ,ls_desig1, ''','); else set Query1 = concat(Query1,''); set Query2 = concat(Query2,''); end if; if ls_Mobile2 <> '' then set Query1 = concat(Query1,'customergroup_cpmobileno2,'); set Query2 = concat(Query2,'''' ,ls_Mobile1, ''','); else set Query1 = concat(Query1,''); set Query2 = concat(Query2,''); end if; if ls_landln2 <> '' then set Query1 = concat(Query1,'customergroup_cplandline2,'); set Query2 = concat(Query2,'''' ,ls_landln2, ''','); else set Query1 = concat(Query1,''); set Query2 = concat(Query2,''); end if; if li_client_gid = 0 then set ls_error = 'Client Gid Not Given'; end if; if ls_error = '' then start transaction; set custgrp_srch = concat('insert into gal_mst_tcustomergroup (customergroup_code,customergroup_name , customergroup_add_gid, ' ,Query1,' entity_gid , create_by,customergroup_clientgid) values (''',ls_custgrp_code,''',''' ,ls_custgrp_name, ''',' ,li_add_gid,',' ,Query2, '' ,li_entity_gid, ',' ,ls_create_by, ',',li_client_gid,')'); set @custgrp_srch = custgrp_srch; #SELECT @custgrp_srch; PREPARE stmt FROM @custgrp_srch; EXECUTE stmt; set countRow = (select ROW_COUNT()); DEALLOCATE PREPARE stmt; if countRow > 0 then select LAST_INSERT_ID() into Message ; set Message = concat(Message,',SUCCESS'); commit; else set Message = 'FAIL'; rollback; end if; else set Message = ls_error; end if; end if; if Action = 'Update' then if li_custgrp_gid = 0 then set ls_error = 'Customer Group gid Not Given '; end if; if ls_custgrp_code = '' then set ls_error = 'Customer Group Code Not Given '; end if; if ls_custgrp_name = '' then set ls_error = 'Customer Group Name Not Given'; end if; if li_add_gid = 0 then set ls_error = 'Address Gid Not Given '; end if; if ls_error = '' then start transaction; set Query_Update = Concat('Update gal_mst_tcustomergroup set customergroup_code =''', ls_custgrp_code,''', customergroup_name = ''',ls_custgrp_name,''', customergroup_add_gid = ',li_add_gid,', update_by = ',ls_create_by,', Update_date = now()'); if ls_cpname1 <> '' then set Query_Update = Concat(Query_Update, ',customergroup_cpname = ''', ls_cpname1 ,''''); end if; if ls_desig1 <> '' then set Query_Update = Concat(Query_Update, ',customergroup_cpdesignation = ''', ls_desig1 ,''''); end if; if ls_Mobile1 <> '' then set Query_Update = Concat(Query_Update, ',customergroup_cpmobileno = ''', ls_Mobile1 ,''''); end if; if ls_landln1 <> '' then set Query_Update = Concat(Query_Update, ',customergroup_cplandline = ''', ls_landln1 ,''''); end if; if ls_cpname2 <> '' then set Query_Update = Concat(Query_Update, ',customergroup_cpname2 = ''', ls_cpname2 ,''''); end if; if ls_desig2 <> '' then set Query_Update = Concat(Query_Update, ',customergroup_cpdesignation2 = ''', ls_desig2 ,''''); end if; if ls_Mobile2 <> '' then set Query_Update = Concat(Query_Update, ',customergroup_cpmobileno2 = ''', ls_Mobile2 ,''''); end if; if ls_landln2 <> '' then set Query_Update = Concat(Query_Update, ',customergroup_cplandline2 = ''', ls_landln2 ,''''); end if; if li_client_gid <> 0 then set Query_Update = Concat(Query_Update, ',customergroup_clientgid = ''', li_client_gid ,''''); end if; set Query_Update = Concat(Query_Update, 'where customergroup_isremoved = ''N'' and customergroup_isactive = ''Y'' and customergroup_gid = ',li_custgrp_gid) ; set @Query_Update = Query_Update; PREPARE stmt FROM @Query_Update; EXECUTE stmt; set countRow = (select ROW_COUNT()); DEALLOCATE PREPARE stmt; if countRow > 0 then set Message = 'SUCCESS'; commit; else set Message = 'FAIL'; rollback; end if; else set Message = ls_error; end if; end if; if Action = 'SUPP_INSERT' then if li_custgrp_gid = 0 then set ls_error = 'Customer Group gid Not Given '; end if; if ls_custgrp_name = '' then set ls_error = 'Customer Group Name Not Given'; end if; select substring(supplier_code,5) from gal_mst_tsupplier where supplier_gid =(select max(supplier_gid) from gal_mst_tsupplier where supplier_isremoved='N') into @codes; call sp_Generatecode_Get('WITHOUT_DATE','SUPP','000',@codes,@Message) ; select @Message into @Supplier_code; set @query_insert =concat('insert into gal_mst_tsupplier (supplier_code,supplier_name,supplier_contact_gid,supplier_add_gid,supplier_capacity,supplier_customergroupgid, entity_gid,create_by) values(''',@Supplier_code,''',''',ls_custgrp_name,''', 0,0,0,''',li_custgrp_gid,''',',li_entity_gid,',''',ls_create_by,''')'); #select ls_custgrp_name; set @supp_srch = @query_insert; #SELECT @supp_srch; PREPARE stmt FROM @supp_srch; EXECUTE stmt; set countRow = (select ROW_COUNT()); #select countRow; if countRow > 0 then set Message = 'SUCCESS'; select customergroup_gid,customergroup_code,customergroup_cpname,customergroup_add_gid,customergroup_cpmobileno, customergroup_cplandline, customergroup_cplandline2,customergroup_cpmobileno2 into @cust_gid,@cust_code,@cust_cp,@cust_add,@cust_mob,@cust_landline,@cust_mob2,@cust_landline2 from gal_mst_tcustomergroup where customergroup_gid=li_custgrp_gid; #select @cust_gid,@cust_code,@cust_cp,@cust_add,@cust_mob,@cust_landline,@cust_mob2,@cust_landline2 ; if @cust_cp <> '' then set query1 = concat('Contact_personname ',query1); set query2 = concat(',''' ,@cust_cp, '''',query2); else set query1 = concat(query1,''); set query2 = concat(query2,''); end if; if @cust_mob<> '' then set query1 = concat('Contact_mobileno ,',query1); set query2 = concat(',''' ,@cust_mob, '''',query2); else set query1 = concat(query1,''); set query2 = concat(query2,''); end if; if @cust_landline<> '' then set query1 = concat(',Contact_landline, ',query1); set query2 = concat(',''' ,@cust_landline, '''',query2); else set query1 = concat(query1,''); set query2 = concat(query2,''); end if; if @cust_mob2<> '' then set query1 = concat('Contact_mobileno2 ',query1); set query2 = concat(',''' ,@cust_mob2, '''',query2); else set query1 = concat(query1,''); set query2 = concat(query2,''); end if; if @cust_landline2<> '' then set query1 = concat('Contact_landline2,',query1); set query2 = concat(',''' ,@cust_landline2, '''',query2); else set query1 = concat(query1,''); set query2 = concat(query2,''); end if; #select query1,query2; set @Cont_srch1 = concat('INSERT INTO gal_mst_tcontact (Contact_ref_gid, Contact_reftable_gid, contact_reftablecode, Contact_contacttype_gid, Contact_designation_gid,Contact_email,Contact_DOB,Contact_WD,entity_gid, create_by ',query1,') VALUES (8,' , @cust_gid, ',''' ,@cust_code, ''',2,15, ''' ''',0000-00-00,0000-00-00,',li_entity_gid, ', ' ,ls_create_by,'',query2,' )'); #select @Cont_srch1; ### Remove It PREPARE stmt FROM @Cont_srch1; EXECUTE stmt; set countRow = (select ROW_COUNT()); DEALLOCATE PREPARE stmt; #select @cust_code; select contact_gid into @cont_gid from gal_mst_tcontact where contact_reftablecode = @cust_code; SET SQL_SAFE_UPDATES = 0; set @Query_Update = concat('update gal_mst_tsupplier set supplier_contact_gid = ', @cont_gid,' ,supplier_add_gid=',@cust_add,' where supplier_name=''',ls_custgrp_name,''' '); #select @Query_Update; PREPARE stmt FROM @Query_Update; EXECUTE stmt; commit; end if; end if; /* if Action = 'Update' then if li_dept_gid = 0 then set ls_error = 'Department gid Not Given '; end if; if ls_dept_code = '' then set ls_error = 'Department Code Not Given '; end if; if ls_dept_name = '' then set ls_error = 'Department Name Not Given'; end if; if ls_error = '' then start transaction; Update gal_mst_tdept set dept_name = ls_dept_name, dept_code = ls_dept_code, update_by = li_entity_gid, Update_date = now() where dept_isremoved = 'N' and dept_isactive = 'Y' and dept_gid = li_dept_gid ; set countRow = (select found_rows()); if countRow > 0 then set Message = 'SUCCESS'; commit; else set Message = 'FAIL'; rollback; end if; else set Message = ls_error; end if; end if; if Action = 'Delete' then if li_dept_gid = 0 then set ls_error = 'Department gid Not Given '; end if; if ls_error = '' then start transaction; Update gal_mst_tdept set dept_isremoved = 'Y', update_by = li_entity_gid, Update_date = now() where dept_isremoved = 'N' and dept_isactive = 'Y' and dept_gid = li_dept_gid ; set countRow = (select found_rows()); if countRow > 0 then set Message = 'SUCCESS'; commit; else set Message = 'FAIL'; rollback; end if; else set Message = ls_error; end if; end if; if Action = 'Inactive' then if li_dept_gid = 0 then set ls_error = 'Department gid Not Given '; end if; if ls_error = '' then start transaction; Update gal_mst_tdept set dept_isactive = 'N', update_by = li_entity_gid, Update_date = now() where dept_isremoved = 'N' and dept_isactive = 'Y' and dept_gid = li_dept_gid ; set countRow = (select found_rows()); if countRow > 0 then set Message = 'SUCCESS'; commit; else set Message = 'FAIL'; rollback; end if; else set Message = ls_error; end if; end if; if Action = 'active' then if li_dept_gid = 0 then set ls_error = 'Department gid Not Given '; end if; if ls_error = '' then start transaction; Update gal_mst_tdept set dept_isactive = 'Y', update_by = li_entity_gid, Update_date = now() where dept_isremoved = 'N' and dept_isactive = 'N' and dept_gid = li_dept_gid ; set countRow = (select found_rows()); if countRow > 0 then set Message = 'SUCCESS'; commit; else set Message = 'FAIL'; rollback; end if; else set Message = ls_error; end if; end if; */ END
true
17d5931c52ed2574fb5e409b5a3adea8b9c5a1c9
SQL
devsg-gh/UCI-Homework
/SQL Challenge Homework/EmployeeSQL/sqlcode.sql
UTF-8
1,910
4.0625
4
[]
no_license
-- query #1 -- select e.emp_no, e.first_name, e.last_name, e.gender, s.salary -- from employees e -- join salaries s -- on e.emp_no = s.emp_no -- ; -- query #2 -- select e.emp_no, e.first_name, e.last_name -- from employees e -- where date_part('year', hire_date) ='1986' -- ; --query #3 -- select d.dept_no, d.dept_name, m.emp_no, e.first_name, e.last_name, m.from_date, m.to_date -- from departments d -- join dept_manager m -- on d.dept_no = m.dept_no -- join employees e -- on m.emp_no = e.emp_no -- ; --query #4 -- select e.emp_no, e.first_name, e.last_name, ds.dept_name -- from employees e -- join dept_emp d -- on e.emp_no = d.emp_no -- join departments ds -- on d.dept_no =ds.dept_no -- ; -- query #5 --List all employees whose first name is "Hercules" and last names begin with "B." -- select * from employees -- where first_name ='Hercules' and last_name like 'B%' -- ; -- query #6 --List all employees in the Sales department, including their employee number, --last name, first name, and department name. -- select m.emp_no, e.first_name, e.last_name, d.dept_name -- from departments d -- join dept_emp m -- on d.dept_no = m.dept_no -- join employees e -- on m.emp_no = e.emp_no -- where d.dept_name ='Sales' -- ; -- query #7 --List all employees in the Sales and Development departments, --including their employee number, last name, first name, and department name. -- select m.emp_no, e.first_name, e.last_name, d.dept_name -- from departments d -- join dept_emp m -- on d.dept_no = m.dept_no -- join employees e -- on m.emp_no = e.emp_no -- where d.dept_name ='Sales' or d.dept_name ='Development' --; -- query #8 --In descending order, list the frequency count of employee last names, --i.e., how many employees share each last name. -- select last_name, count(last_name) as "last name count" from employees -- group by last_name -- order by "last name count" desc --;
true
2cb42cff7ff80f5ca5ec20eb98ac4de3652343bf
SQL
marcosumali/restaurant-erp
/server/seeders/role.sql
UTF-8
367
2.671875
3
[]
no_license
create table role ( id BIGSERIAL NOT NULL PRIMARY KEY, name VARCHAR(50) NOT NULL, UNIQUE(name) ); insert into role (name) values ('Owner'); insert into role (name) values ('Manager'); insert into role (name) values ('Cashier'); insert into role (name) values ('Waiter'); insert into role (name) values ('Kitchen'); insert into role (name) values ('Purchasing');
true
c848df1d20df3139bb06d97e8cc9439086197127
SQL
abullatama/Asset-Management-Information-System-on-PT.Blitzspot
/blitzspot.sql
UTF-8
24,024
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.8.3 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Waktu pembuatan: 31 Agu 2020 pada 12.33 -- Versi server: 10.1.37-MariaDB -- Versi PHP: 7.2.12 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: `blitzspot` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `aset_habis_pakai` -- CREATE TABLE `aset_habis_pakai` ( `no_aset` int(11) NOT NULL, `nama_aset` varchar(255) NOT NULL, `jenis_aset` varchar(20) NOT NULL, `jumlah` int(50) NOT NULL, `harga` varchar(20) NOT NULL, `tanggal_masuk` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `aset_habis_pakai` -- INSERT INTO `aset_habis_pakai` (`no_aset`, `nama_aset`, `jenis_aset`, `jumlah`, `harga`, `tanggal_masuk`) VALUES (2, 'HVS A4 70g', 'Habis Pakai', 3, '219000', '2019-08-08'); -- -------------------------------------------------------- -- -- Struktur dari tabel `aset_tidak_habis_pakai` -- CREATE TABLE `aset_tidak_habis_pakai` ( `no_aset` varchar(50) NOT NULL, `no_detail` int(11) NOT NULL, `jenis_aset` varchar(255) NOT NULL, `merek` varchar(255) NOT NULL, `tipe` varchar(255) NOT NULL, `spesifikasi` varchar(255) NOT NULL, `harga` varchar(20) NOT NULL, `lokasi` varchar(30) NOT NULL, `kondisi` varchar(255) NOT NULL, `tanggal_masuk` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `aset_tidak_habis_pakai` -- INSERT INTO `aset_tidak_habis_pakai` (`no_aset`, `no_detail`, `jenis_aset`, `merek`, `tipe`, `spesifikasi`, `harga`, `lokasi`, `kondisi`, `tanggal_masuk`) VALUES ('2019041', 30, 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', '172500', 'Gudang', 'Baru', '2019-08-26'), ('2019042', 30, 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', '172500', 'Gudang', 'Baru', '2019-08-26'), ('2019043', 30, 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', '172500', 'Gudang', 'Baru', '2019-08-26'), ('2019044', 30, 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', '172500', 'Gudang', 'Baru', '2019-08-26'), ('2019LT045', 30, 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', '172500', 'Gudang', 'Baru', '2019-08-26'), ('2019LT046', 30, 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', '172500', 'Gudang', 'Baru', '2019-08-26'), ('BR5006', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Customer', 'Baik', '2019-08-08'), ('BR5007', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Customer', 'Baik', '2019-08-08'), ('BR5008', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Customer', 'Baik', '2019-08-08'), ('BR5009', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Gudang', 'Baru', '2019-08-08'), ('BR5010', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Customer', 'Baik', '2019-08-08'), ('BR5011', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Gudang', 'Baru', '2019-08-08'), ('BR5012', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Gudang', 'Baik', '2019-08-08'), ('BR5013', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Gudang', 'Baru', '2019-08-08'), ('BR5014', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Gudang', 'Baru', '2019-08-08'), ('BR5015', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '170000', 'Gudang', 'Baru', '2019-08-08'), ('BR5016', 27, 'Tidak Habis Pakai', 'Ubiquiti', 'NS LOCO M5', 'Frequence 5,4 5.825 GHz, Transmission speed 300 Mb', '820000', 'Gudang', 'Baru', '2019-08-08'), ('BR5017', 27, 'Tidak Habis Pakai', 'Ubiquiti', 'NS LOCO M5', 'Frequence 5,4 5.825 GHz, Transmission speed 300 Mb', '820000', 'Customer', 'Baru', '2019-08-08'), ('BR5018', 28, 'Tidak Habis Pakai', 'Ubiquitii', 'Litebeam M5', '23dbi 5 GHz', '630000', 'Customer', 'Baik', '2019-08-08'), ('BR5019', 28, 'Tidak Habis Pakai', 'Ubiquitii', 'Litebeam M5', '23dbi 5 GHz', '630000', 'Gudang', 'Baru', '2019-08-08'), ('BR5020', 28, 'Tidak Habis Pakai', 'Ubiquitii', 'Litebeam M5', '23dbi 5 GHz', '630000', 'Gudang', 'Baru', '2019-08-08'), ('BR5021', 28, 'Tidak Habis Pakai', 'Ubiquitii', 'Litebeam M5', '23dbi 5 GHz', '630000', 'Gudang', 'Baru', '2019-08-08'), ('BR5022', 28, 'Tidak Habis Pakai', 'Ubiquitii', 'Litebeam M5', '23dbi 5 GHz', '630000', 'Gudang', 'Baru', '2019-08-08'), ('BR5023', 30, 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', '172500', 'Gudang', 'Baru', '2019-08-08'), ('BR5024', 30, 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', '172500', 'Gudang', 'Baru', '2019-08-08'), ('BR5025', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276900', 'Customer', 'Baru', '2019-08-08'), ('BR5026', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276900', 'Customer', 'Baru', '2019-08-08'), ('BR5027', 31, 'Tidak Habis Pakai', 'Telebit', 'UTP Cat 5e', '100m', '255000', 'Customer', 'Baru', '2019-08-08'), ('BR5028', 31, 'Tidak Habis Pakai', 'Telebit', 'UTP Cat 5e', '100m', '255000', 'Customer', 'Baru', '2019-08-08'), ('BR5029', 31, 'Tidak Habis Pakai', 'Telebit', 'UTP Cat 5e', '100m', '255000', 'Gudang', 'Baru', '2019-08-08'), ('BR5030', 31, 'Tidak Habis Pakai', 'Telebit', 'UTP Cat 5e', '100m', '255000', 'Gudang', 'Baru', '2019-08-08'), ('BR5031', 31, 'Tidak Habis Pakai', 'Telebit', 'UTP Cat 5e', '100m', '255000', 'Gudang', 'Baru', '2019-08-08'), ('BR5032', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '172500', 'Gudang', 'Baru', '2019-08-09'), ('BR5033', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '172500', 'Gudang', 'Baru', '2019-08-09'), ('BR5034', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '172500', 'Gudang', 'Baru', '2019-08-09'), ('BR5035', 26, 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', '172500', 'Gudang', 'Baru', '2019-08-09'), ('Kabel UTP2019036', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276000', 'Gudang', 'Baru', '2019-08-26'), ('Kabel UTP2019037', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276000', 'Gudang', 'Baru', '2019-08-26'), ('Kabel UTP2019038', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276000', 'Gudang', 'Baru', '2019-08-26'), ('Kabel UTP2019039', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276000', 'Gudang', 'Baru', '2019-08-26'), ('Kabel UTP2019040', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276000', 'Gudang', 'Baru', '2019-08-26'), ('KU2019047', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276900', 'Gudang', 'Baru', '2019-08-26'), ('KU2019048', 31, 'Tidak Habis Pakai', 'Vascolink', 'UTP Cat 5e', '100m', '276900', 'Gudang', 'Baru', '2019-08-26'); -- -------------------------------------------------------- -- -- Struktur dari tabel `data_barang` -- CREATE TABLE `data_barang` ( `id_barang` int(11) NOT NULL, `nama_barang` varchar(255) NOT NULL, `jumlah` int(11) NOT NULL, `harga_pokok` int(11) NOT NULL, `harga_jual` int(11) NOT NULL, `kadaluwarsa` date NOT NULL, `tanggal_masuk` date NOT NULL, `keterangan` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `data_barang` -- INSERT INTO `data_barang` (`id_barang`, `nama_barang`, `jumlah`, `harga_pokok`, `harga_jual`, `kadaluwarsa`, `tanggal_masuk`, `keterangan`) VALUES (1, 'susu frisian flag', 4, 15000, 17000, '2020-09-01', '2020-03-16', ''); -- -------------------------------------------------------- -- -- Struktur dari tabel `data_pembelian` -- CREATE TABLE `data_pembelian` ( `id_pembelian` int(11) NOT NULL, `nama_barang` varchar(255) NOT NULL, `jumlah` int(11) NOT NULL, `harga_pokok` int(11) NOT NULL, `harga_jual` int(11) NOT NULL, `total_harga` int(11) NOT NULL, `kadaluwarsa` date NOT NULL, `tanggal_masuk` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Struktur dari tabel `detail_aset` -- CREATE TABLE `detail_aset` ( `no_detail` int(11) NOT NULL, `nama_aset` varchar(255) NOT NULL, `stok` int(50) NOT NULL, `minimal_stok` int(50) NOT NULL, `akumulasi_nilai` int(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `detail_aset` -- INSERT INTO `detail_aset` (`no_detail`, `nama_aset`, `stok`, `minimal_stok`, `akumulasi_nilai`) VALUES (26, 'Router', 10, 10, 2390000), (27, 'Receiver', 1, 5, 1640000), (28, 'Antena', 4, 5, 3150000), (30, 'Lan Tester', 8, 0, 1380000), (31, 'Kabel UTP', 10, 10, 3762600); -- -------------------------------------------------------- -- -- Struktur dari tabel `detail_mutasi` -- CREATE TABLE `detail_mutasi` ( `id_detail_mutasi` int(11) NOT NULL, `id_mutasi` int(11) NOT NULL, `no_aset` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `detail_mutasi` -- INSERT INTO `detail_mutasi` (`id_detail_mutasi`, `id_mutasi`, `no_aset`) VALUES (58, 31, 'BR5006'), (59, 31, 'BR5027'), (60, 32, 'BR5007'), (61, 32, 'BR5028'), (62, 33, 'BR5010'), (63, 33, 'BR5018'), (64, 33, 'BR5027'), (65, 34, 'BR5006'), (66, 34, 'BR5017'), (67, 34, 'BR5026'), (68, 35, 'BR5008'), (69, 35, 'BR5025'); -- -------------------------------------------------------- -- -- Struktur dari tabel `mutasi` -- CREATE TABLE `mutasi` ( `id_mutasi` int(11) NOT NULL, `nama_pelanggan` varchar(20) NOT NULL, `alamat` varchar(255) NOT NULL, `status` varchar(50) NOT NULL, `tanggal_keluar` date NOT NULL, `tanggal_selesai` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `mutasi` -- INSERT INTO `mutasi` (`id_mutasi`, `nama_pelanggan`, `alamat`, `status`, `tanggal_keluar`, `tanggal_selesai`) VALUES (31, 'Agus Permata', 'Kp.Rawa Pojok, Rt.06/03, Komp.Permata\r\n', 'Selesai', '2019-08-08', '2019-08-08'), (32, 'Agus Dian', 'Kebon Manggu, no. 56 Rt05/21 Padasuka-Cimahi.\r\n', 'Aktif', '2019-08-08', '0000-00-00'), (33, 'Ahmad Widodo', 'Perum.Graha Bukit Raya 1 Blok.E6 No.1 Cilame-Ngamprah\r\n', 'Aktif', '2019-08-08', '0000-00-00'), (34, 'Ahmad Hikmat', 'PCI-2 Blok C6 No.55 Rt.04/20 Tanimulya, Ngamprah\r\n', 'Aktif', '2019-08-08', '0000-00-00'), (35, 'Edi Nurochman', 'Kp.Cijerah RT.05/04 No.30 Tanimulya, Ngamprah\r\n', 'Aktif', '2019-08-08', '0000-00-00'); -- -------------------------------------------------------- -- -- Struktur dari tabel `pemeliharaan` -- CREATE TABLE `pemeliharaan` ( `no_pemeliharaan` varchar(11) NOT NULL, `no_aset` varchar(50) NOT NULL, `tanggal_pemeliharaan` date NOT NULL, `kondisi_pemeliharaan` varchar(50) NOT NULL, `biaya` int(50) NOT NULL, `keterangan` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `pemeliharaan` -- INSERT INTO `pemeliharaan` (`no_pemeliharaan`, `no_aset`, `tanggal_pemeliharaan`, `kondisi_pemeliharaan`, `biaya`, `keterangan`) VALUES ('3', 'BR5023', '2019-08-09', 'Rusak Ringan', 150000, 'ganti motherboard'), ('PM2019004', 'BR5009', '2019-08-26', 'Rusak Ringan', 150000, 'ganti motherboard'); -- -------------------------------------------------------- -- -- Struktur dari tabel `pengadaan` -- CREATE TABLE `pengadaan` ( `no_pengadaan` varchar(11) NOT NULL, `no_perencanaan` varchar(11) NOT NULL, `tanggal` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `pengadaan` -- INSERT INTO `pengadaan` (`no_pengadaan`, `no_perencanaan`, `tanggal`) VALUES ('', 'PR2019002', '2019-10-18'); -- -------------------------------------------------------- -- -- Struktur dari tabel `pengaduan` -- CREATE TABLE `pengaduan` ( `id_pengaduan` varchar(11) NOT NULL, `id_pengguna` int(11) NOT NULL, `no_aset` varchar(50) NOT NULL, `keterangan` varchar(255) NOT NULL, `info` varchar(100) NOT NULL, `tanggal` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `pengaduan` -- INSERT INTO `pengaduan` (`id_pengaduan`, `id_pengguna`, `no_aset`, `keterangan`, `info`, `tanggal`) VALUES ('11', 6, 'BR5023', 'tidak bisa diaktifkan', 'keluhan-190808-26ea53695f.jpg', '2019-08-08'); -- -------------------------------------------------------- -- -- Struktur dari tabel `pengajuan` -- CREATE TABLE `pengajuan` ( `no_pengajuan` varchar(11) NOT NULL, `id_pengguna` int(11) NOT NULL, `nama_barang` varchar(255) NOT NULL, `jenis_aset` varchar(20) NOT NULL, `merek` varchar(30) NOT NULL, `tipe` varchar(30) NOT NULL, `spesifikasi` varchar(255) NOT NULL, `harga_satuan` int(20) NOT NULL, `jumlah` int(20) NOT NULL, `harga_total` int(20) NOT NULL, `keterangan` varchar(255) NOT NULL, `status` varchar(20) NOT NULL, `tanggal_masuk` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `pengajuan` -- INSERT INTO `pengajuan` (`no_pengajuan`, `id_pengguna`, `nama_barang`, `jenis_aset`, `merek`, `tipe`, `spesifikasi`, `harga_satuan`, `jumlah`, `harga_total`, `keterangan`, `status`, `tanggal_masuk`) VALUES ('18', 1, 'Laptop', 'Tidak Habis Pakai', 'Asus', 'A442U', '8th Core I5-8250u', 6700000, 1, 6700000, 'untuk keperluan operasional', 'Diproses', '2019-08-08'), ('19', 1, 'HVS A4 70g', 'Habis Pakai', '-', '-', '-', 219000, 3, 657000, 'kebutuhan operasional', 'Belum diproses', '2019-08-08'), ('20', 6, 'Lan Tester', 'Tidak Habis Pakai', 'JW-360', 'MKT006', 'UTP STP RJ45 RJ11', 172500, 2, 345000, 'untuk keperluan operasional', 'Diproses', '2019-08-08'), ('PJ2019021', 3, 'Laptop', 'Tidak Habis Pakai', 'Asus', 'ROG', 'intel ci7 hdd 1tb ram 8gb', 10500000, 1, 10500000, 'untuk keperluan instalasi jaringan', 'Belum diproses', '2019-08-26'); -- -------------------------------------------------------- -- -- Struktur dari tabel `pengguna` -- CREATE TABLE `pengguna` ( `id_pengguna` int(11) NOT NULL, `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `nama` varchar(255) NOT NULL, `level` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `pengguna` -- INSERT INTO `pengguna` (`id_pengguna`, `username`, `password`, `nama`, `level`) VALUES (1, 'bendahara', '1234', 'Maqbul Arif Latama', 'Bendahara'), (2, 'direktur', '1234', 'Adra', 'Direktur'), (3, 'admin', '1234', 'lusi', 'Sekretaris'), (4, 'admin_system', '1234', 'Sigit Pratama', 'Admin_System'), (6, 'staff', '1234', 'Rendy', 'Staff'); -- -------------------------------------------------------- -- -- Struktur dari tabel `penyusutan` -- CREATE TABLE `penyusutan` ( `id_penyusutan` int(11) NOT NULL, `no_aset` varchar(50) NOT NULL, `umur_ekonomis` int(11) NOT NULL, `biaya_penyusutan` int(50) NOT NULL, `akumulasi_penyusutan` int(50) NOT NULL, `tahun_penggunaan` int(11) NOT NULL, `nilai_aset` int(30) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `penyusutan` -- INSERT INTO `penyusutan` (`id_penyusutan`, `no_aset`, `umur_ekonomis`, `biaya_penyusutan`, `akumulasi_penyusutan`, `tahun_penggunaan`, `nilai_aset`) VALUES (196, 'BR5006', 5, 34000, 0, 1, 170000), (197, 'BR5007', 5, 34000, 0, 1, 170000), (198, 'BR5008', 5, 34000, 0, 1, 170000), (199, 'BR5009', 5, 34000, 0, 1, 170000), (200, 'BR5010', 5, 34000, 0, 1, 170000), (201, 'BR5011', 5, 34000, 0, 1, 170000), (202, 'BR5012', 5, 34000, 0, 1, 170000), (203, 'BR5013', 5, 34000, 0, 1, 170000), (204, 'BR5014', 5, 34000, 0, 1, 170000), (205, 'BR5015', 5, 34000, 0, 1, 170000), (206, 'BR5016', 5, 164000, 0, 1, 820000), (207, 'BR5017', 5, 164000, 0, 1, 820000), (208, 'BR5018', 5, 126000, 0, 1, 630000), (209, 'BR5019', 5, 126000, 0, 1, 630000), (210, 'BR5020', 5, 126000, 0, 1, 630000), (211, 'BR5021', 5, 126000, 0, 1, 630000), (212, 'BR5022', 5, 126000, 0, 1, 630000), (213, 'BR5023', 5, 34500, 0, 1, 172500), (214, 'BR5024', 5, 34500, 0, 1, 172500), (215, 'BR5025', 5, 55380, 0, 1, 276900), (216, 'BR5026', 5, 55380, 0, 1, 276900), (217, 'BR5027', 5, 51000, 0, 1, 255000), (218, 'BR5028', 5, 51000, 0, 1, 255000), (219, 'BR5029', 5, 51000, 0, 1, 255000), (220, 'BR5030', 5, 51000, 0, 1, 255000), (221, 'BR5031', 5, 51000, 0, 1, 255000), (222, 'BR5032', 1, 172500, 0, 1, 172500), (223, 'BR5033', 1, 172500, 0, 1, 172500), (224, 'BR5034', 1, 172500, 0, 1, 172500), (225, 'BR5035', 1, 172500, 0, 1, 172500), (226, 'Kabel UTP2019036', 5, 55200, 0, 1, 276000), (227, 'Kabel UTP2019037', 5, 55200, 0, 1, 276000), (228, 'Kabel UTP2019038', 5, 55200, 0, 1, 276000), (229, 'Kabel UTP2019039', 5, 55200, 0, 1, 276000), (230, 'Kabel UTP2019040', 5, 55200, 0, 1, 276000), (231, '2019041', 5, 34500, 0, 1, 172500), (232, '2019042', 5, 34500, 0, 1, 172500), (233, '2019043', 5, 34500, 0, 1, 172500), (234, '2019044', 5, 34500, 0, 1, 172500), (235, '2019LT045', 5, 34500, 0, 1, 172500), (236, '2019LT046', 5, 34500, 0, 1, 172500), (237, 'KU2019047', 5, 55380, 0, 1, 276900), (238, 'KU2019048', 5, 55380, 0, 1, 276900); -- -------------------------------------------------------- -- -- Struktur dari tabel `perencanaan_pengadaan` -- CREATE TABLE `perencanaan_pengadaan` ( `no_perencanaan` varchar(11) NOT NULL, `nama_aset` varchar(50) NOT NULL, `jenis_aset` varchar(50) NOT NULL, `merek` varchar(50) NOT NULL, `tipe` varchar(50) NOT NULL, `spesifikasi` varchar(50) NOT NULL, `harga_satuan` int(20) NOT NULL, `jumlah` int(20) NOT NULL, `harga_total` int(20) NOT NULL, `keterangan` varchar(50) NOT NULL, `Status` varchar(20) NOT NULL, `tanggal` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `perencanaan_pengadaan` -- INSERT INTO `perencanaan_pengadaan` (`no_perencanaan`, `nama_aset`, `jenis_aset`, `merek`, `tipe`, `spesifikasi`, `harga_satuan`, `jumlah`, `harga_total`, `keterangan`, `Status`, `tanggal`) VALUES ('PER2019001', 'Router', 'Tidak Habis Pakai', 'D-Link', 'DIR-612', '10/100mbps', 172500, 2, 345000, 'untuk keperluan pemenuhan stok', 'Belum Diajukan', '2019-08-26'), ('PR2019002', 'Router', 'Tidak Habis Pakai', 'Vascolink', 'NS LOCO M5', '10/100mbps', 120000, 3, 360000, 'asdasd', 'Disetujui', '2019-10-18'); -- -------------------------------------------------------- -- -- Struktur dari tabel `tmp` -- CREATE TABLE `tmp` ( `no_tmp` int(11) NOT NULL, `no_aset` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `tmp` -- INSERT INTO `tmp` (`no_tmp`, `no_aset`) VALUES (189, 'KU2019047'), (190, 'KU2019048'); -- -- Indexes for dumped tables -- -- -- Indeks untuk tabel `aset_habis_pakai` -- ALTER TABLE `aset_habis_pakai` ADD PRIMARY KEY (`no_aset`); -- -- Indeks untuk tabel `aset_tidak_habis_pakai` -- ALTER TABLE `aset_tidak_habis_pakai` ADD PRIMARY KEY (`no_aset`), ADD KEY `no_detail` (`no_detail`); -- -- Indeks untuk tabel `data_barang` -- ALTER TABLE `data_barang` ADD PRIMARY KEY (`id_barang`); -- -- Indeks untuk tabel `data_pembelian` -- ALTER TABLE `data_pembelian` ADD PRIMARY KEY (`id_pembelian`); -- -- Indeks untuk tabel `detail_aset` -- ALTER TABLE `detail_aset` ADD PRIMARY KEY (`no_detail`); -- -- Indeks untuk tabel `detail_mutasi` -- ALTER TABLE `detail_mutasi` ADD PRIMARY KEY (`id_detail_mutasi`), ADD KEY `no_aset` (`no_aset`), ADD KEY `id_mutasi` (`id_mutasi`); -- -- Indeks untuk tabel `mutasi` -- ALTER TABLE `mutasi` ADD PRIMARY KEY (`id_mutasi`); -- -- Indeks untuk tabel `pemeliharaan` -- ALTER TABLE `pemeliharaan` ADD PRIMARY KEY (`no_pemeliharaan`), ADD KEY `no_aset` (`no_aset`); -- -- Indeks untuk tabel `pengadaan` -- ALTER TABLE `pengadaan` ADD PRIMARY KEY (`no_pengadaan`), ADD KEY `no_perencanaan` (`no_perencanaan`); -- -- Indeks untuk tabel `pengaduan` -- ALTER TABLE `pengaduan` ADD PRIMARY KEY (`id_pengaduan`), ADD KEY `id_pengguna` (`id_pengguna`), ADD KEY `no_aset` (`no_aset`); -- -- Indeks untuk tabel `pengajuan` -- ALTER TABLE `pengajuan` ADD PRIMARY KEY (`no_pengajuan`), ADD KEY `id_pengguna` (`id_pengguna`); -- -- Indeks untuk tabel `pengguna` -- ALTER TABLE `pengguna` ADD PRIMARY KEY (`id_pengguna`); -- -- Indeks untuk tabel `penyusutan` -- ALTER TABLE `penyusutan` ADD PRIMARY KEY (`id_penyusutan`), ADD KEY `no_aset` (`no_aset`); -- -- Indeks untuk tabel `perencanaan_pengadaan` -- ALTER TABLE `perencanaan_pengadaan` ADD PRIMARY KEY (`no_perencanaan`); -- -- Indeks untuk tabel `tmp` -- ALTER TABLE `tmp` ADD PRIMARY KEY (`no_tmp`), ADD KEY `no_aset` (`no_aset`); -- -- AUTO_INCREMENT untuk tabel yang dibuang -- -- -- AUTO_INCREMENT untuk tabel `aset_habis_pakai` -- ALTER TABLE `aset_habis_pakai` MODIFY `no_aset` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT untuk tabel `data_barang` -- ALTER TABLE `data_barang` MODIFY `id_barang` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT untuk tabel `data_pembelian` -- ALTER TABLE `data_pembelian` MODIFY `id_pembelian` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT untuk tabel `detail_aset` -- ALTER TABLE `detail_aset` MODIFY `no_detail` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32; -- -- AUTO_INCREMENT untuk tabel `detail_mutasi` -- ALTER TABLE `detail_mutasi` MODIFY `id_detail_mutasi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=70; -- -- AUTO_INCREMENT untuk tabel `mutasi` -- ALTER TABLE `mutasi` MODIFY `id_mutasi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36; -- -- AUTO_INCREMENT untuk tabel `pengguna` -- ALTER TABLE `pengguna` MODIFY `id_pengguna` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; -- -- AUTO_INCREMENT untuk tabel `penyusutan` -- ALTER TABLE `penyusutan` MODIFY `id_penyusutan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=239; -- -- AUTO_INCREMENT untuk tabel `tmp` -- ALTER TABLE `tmp` MODIFY `no_tmp` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=191; -- -- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables) -- -- -- Ketidakleluasaan untuk tabel `aset_tidak_habis_pakai` -- ALTER TABLE `aset_tidak_habis_pakai` ADD CONSTRAINT `aset_tidak_habis_pakai_ibfk_1` FOREIGN KEY (`no_detail`) REFERENCES `detail_aset` (`no_detail`); -- -- Ketidakleluasaan untuk tabel `detail_mutasi` -- ALTER TABLE `detail_mutasi` ADD CONSTRAINT `detail_mutasi_ibfk_2` FOREIGN KEY (`no_aset`) REFERENCES `aset_tidak_habis_pakai` (`no_aset`), ADD CONSTRAINT `detail_mutasi_ibfk_3` FOREIGN KEY (`id_mutasi`) REFERENCES `mutasi` (`id_mutasi`); -- -- Ketidakleluasaan untuk tabel `pemeliharaan` -- ALTER TABLE `pemeliharaan` ADD CONSTRAINT `pemeliharaan_ibfk_1` FOREIGN KEY (`no_aset`) REFERENCES `aset_tidak_habis_pakai` (`no_aset`); -- -- Ketidakleluasaan untuk tabel `pengadaan` -- ALTER TABLE `pengadaan` ADD CONSTRAINT `pengadaan_ibfk_1` FOREIGN KEY (`no_perencanaan`) REFERENCES `perencanaan_pengadaan` (`no_perencanaan`); -- -- Ketidakleluasaan untuk tabel `pengaduan` -- ALTER TABLE `pengaduan` ADD CONSTRAINT `pengaduan_ibfk_1` FOREIGN KEY (`id_pengguna`) REFERENCES `pengguna` (`id_pengguna`), ADD CONSTRAINT `pengaduan_ibfk_2` FOREIGN KEY (`no_aset`) REFERENCES `aset_tidak_habis_pakai` (`no_aset`); -- -- Ketidakleluasaan untuk tabel `pengajuan` -- ALTER TABLE `pengajuan` ADD CONSTRAINT `pengajuan_ibfk_1` FOREIGN KEY (`id_pengguna`) REFERENCES `pengguna` (`id_pengguna`); -- -- Ketidakleluasaan untuk tabel `penyusutan` -- ALTER TABLE `penyusutan` ADD CONSTRAINT `penyusutan_ibfk_1` FOREIGN KEY (`no_aset`) REFERENCES `aset_tidak_habis_pakai` (`no_aset`); -- -- Ketidakleluasaan untuk tabel `tmp` -- ALTER TABLE `tmp` ADD CONSTRAINT `tmp_ibfk_1` FOREIGN KEY (`no_aset`) REFERENCES `aset_tidak_habis_pakai` (`no_aset`); 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
0f52c058a3b57069c801b65d6deb0da112442061
SQL
omar-1999/codeigniter-test
/scripts.sql
UTF-8
465
3.109375
3
[ "MIT" ]
permissive
CREATE TABLE empleado ( id int primary key not null AUTO_INCREMENT, fecha_ingreso date not null, nombre varchar(50) not null, salario numeric(10.5) not null ); CREATE TABLE solicitud ( id int primary key not null AUTO_INCREMENT, codigo varchar(50) not null, descripcion varchar(50) not null, resumen varchar(50) not null, id_empleado int not null ); ALTER TABLE solicitud ADD FOREIGN KEY (id_empleado) REFERENCES empleado (id);
true
ee1954a3c3ac53bff0dd9b4423f2d5288516eeab
SQL
yh1008/DoodleMeet
/schema.sql
UTF-8
3,932
4.21875
4
[]
no_license
drop table if exists users; create table users( userid int primary key, firstname text, lastname text, fund numeric check (fund > 0) , gender text, age int ); drop table if exists friendship; create table friendship( fid int primary key, usr int, friend int, foreign key (usr) references users(userid), foreign key (friend) references users(userid) ); drop table if exists activitycategory; create table activitycategory( aid int, name text, primary key(aid) ); drop table if exists activity; create table activity( aid int, aaid int, name text, primary key(aid, aaid), foreign key(aid) references activitycategory(aid) ); drop table if exists interest; create table interest( usr int, activity_category int, activity_subcategory int, pid int, start_time timestamp, end_time timestamp, budget int check (budget >= 0), primary key (usr, activity_category, activity_subcategory, pid, start_time, end_time), foreign key (usr) references users(userid), foreign key(pid, activity_category, activity_subcategory) references location(pid, aid, aaid) ); drop table if exists rate; create table rate( rid int, usr int not null, activity_category int not null, activity_subcategory int not null, pid int, comment1 text, score int not null, primary key (rid), foreign key (usr) references users(userid), foreign key (pid, activity_category, activity_subcategory) references location(pid, aid, aaid) ); drop table if exists location; create table location( pid int, --"think of pid as Arizona State Park" aid int, --"climbing" aaid int, --"rock climbing" open_time timestamp, close_time timestamp, state text, city text, name text, primary key(pid, aid, aaid), foreign key(aid, aaid) references activity(aid, aaid) --"pid, aid, aaid uniquely identifies an activity" ); drop table if exists ticketrequired; create table ticketrequired( tid int, pid int, aid int, aaid int, price numeric check (price >= 0), name text, primary key (tid), foreign key(pid, aid, aaid) references location(pid, aid, aaid) on delete CASCADE ); drop table if exists modeoftransport; create table modeoftransport ( route_number int, pid int, aid int, aaid int, primary key(route_number, pid, aid, aaid), foreign key(pid, aid, aaid) references location(pid, aid, aaid) ); drop table if exists ratefunroute; create table ratefunroute( rid int, usr int, pid int, aid int, aaid int, route_number int, score int check (score = 1), --"constrained on only 1! as the indicator of it being chosen!" primary key(rid), foreign key(usr) references users(userid), foreign key (route_number, pid, aid, aaid) references modeoftransport(route_number, pid, aid, aaid) ); drop table if exists route; create table route( rid int, name text, primary key(rid) ); drop table if exists orderhistory; create table orderhistory( oid int, usr int, tid int, time timestamp, primary key (oid), foreign key (usr) references users(userid), foreign key(tid) references ticketrequired(tid) ); drop table if exists gearstocarry; create table gearstocarry( gid int, aid int, primary key(gid, aid), foreign key (aid) references activitycategory(aid) ); drop table if exists gears; create table gears( gid int, name text, primary key(gid) ); drop table if exists shops; create table shops ( sid int, name text not null, city text not null, primary key(sid) ); drop table if exists travelitemshop; create table travelitemshop ( sid int, gear int, price numeric check(price >= 0), primary key(sid, gear), foreign key (sid) references shops(sid), foreign key (gear) references gears(gid) );
true