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
3a01ad7bbcb1e1b2110420fd54ca86d092b870bb
SQL
mtikoian/km-all-projects
/UAS/Databases/UAS/UAS_DB/dbo/Stored Procedures/e_ClientFTP_Save.sql
UTF-8
1,278
3.3125
3
[]
no_license
CREATE PROCEDURE e_ClientFTP_Save @FTPID int, @ClientID int, @Server varchar(100), @UserName varchar(100), @Password varchar(100), @Folder varchar(100), @IsDeleted bit, @IsExternal bit, @IsActive bit, @FTPConnectionValidated bit, @DateCreated datetime, @DateUpdated datetime, @CreatedByUserID int, @UpdatedByUserID int AS BEGIN set nocount on IF @FTPID > 0 BEGIN IF @DateUpdated IS NULL BEGIN SET @DateUpdated = GETDATE(); END UPDATE ClientFTP SET ClientID = @ClientID, Server = @Server, UserName = @UserName, Password = @Password, Folder = @Folder, IsDeleted = @IsDeleted, IsExternal = @IsExternal, IsActive = @IsActive, FTPConnectionValidated = @FTPConnectionValidated, DateUpdated = @DateUpdated, UpdatedByUserID = @UpdatedByUserID WHERE FTPID = @FTPID; SELECT @FTPID; END ELSE BEGIN IF @DateCreated IS NULL BEGIN SET @DateCreated = GETDATE(); END INSERT INTO ClientFTP (ClientID,Server,UserName,Password,Folder,IsDeleted,IsExternal,IsActive,FTPConnectionValidated,DateCreated,CreatedByUserID) VALUES(@ClientID,@Server,@UserName,@Password,@Folder,@IsDeleted,@IsExternal,@IsActive,@FTPConnectionValidated,@DateCreated,@CreatedByUserID);SELECT @@IDENTITY; END END
true
97226601272e2a1dcf7a9c1b5673ab4a69449ea0
SQL
Shaita-KrZ/Plateforme_telechargement
/SQL/profit_max_editeur.sql
UTF-8
1,039
4.21875
4
[]
no_license
SELECT E.nom AS Editeur, CA_2.CA_app AS Apps, CA_1.CA_res AS Res, CA_3.CA_Ab AS Abonnement, SUM(CA_2.CA_app + CA_1.CA_res + coalesce(CA_3.CA_Ab,0)) AS CA FROM Editeur E LEFT OUTER JOIN ( SELECT sum(R.prix) as CA_res, E.nom as Nom FROM Editeur E, Transaction T, Ressource R, Achat_simple_ressource ASR WHERE R.editeur = E.id AND ASR.ressource = R.nom AND ASR.achat = T.id GROUP BY E.nom ORDER BY CA_res DESC ) AS CA_1 ON E.nom = CA_1.Nom LEFT OUTER JOIN ( SELECT sum(A.prix) as CA_app, E.nom as Nom FROM Editeur E, Application A, Achat_simple_app ASA, Transaction T WHERE A.editeur = E.id AND ASA.achat = T.id AND ASA.app = A.nom GROUP BY E.nom ORDER BY CA_app DESC ) AS CA_2 ON E.nom = CA_2.Nom LEFT OUTER JOIN ( SELECT SUM(Ab.prixabonnement*Ab.nbmois) AS CA_Ab, E.nom as Nom FROM Abonnement Ab, application A, Editeur E, Transaction T WHERE Ab.app = A.Nom AND T.id = Ab.achat AND A.editeur = E.id GROUP BY E.nom ORDER BY CA_Ab DESC ) AS CA_3 ON E.nom = CA_3.nom GROUP BY E.nom, CA_2.CA_app, CA_1.CA_res, CA_3.CA_Ab;
true
30c3f3b6d65201b2603dde4a856975f97bb77f11
SQL
dinap18/PLSQL_Database_Systems_Project
/part3/queriesParameters.sql
UTF-8
1,614
4.03125
4
[]
no_license
-- Query1 : list, ifempty, type select pr.pid, pr.pname, p.salary from hospital_staff h inner join person pr on h.pid = pr.pid inner join hiredas hr on h.pid = hr.pid inner join position p on hr.positionid = p.positionid where p.positionname = &<name="PositionName" list= "InternDoctor, Doctor, InternNurse, Nurse" type= string ifempty="Doctor">; -- Query2 : default, hint, orderby select m.fever, round(avg(TRUNC(MONTHS_BETWEEN(sysdate, birthdate)/12)),2) age from person p inner join medical_record m on p.pid = m.pid where m.fever >= &<name="fever" type="float" hint="Enter the minimum value of fever (between 35C to 42C) that you want to see"> and p.birthdate >= &<name="birthdate" type=date default="1/1/1950"> group by m.fever order by &<name="orderby" list="fever, age" default="fever" ifempty="fever"> ; -- Query3 : multiselect select p.room, m.status, count(*) as patient_count from patient p inner join medical_record m on p.pid = m.pid where p.room in (&<name=room list="select distinct room from patient order by room" multiselect="yes">) group by p.room, m.status order by p.room,count(*) desc; -- Query4 : multiselect select w.department, p.pid, p.pname, h.workpercantageincurrentmonth from person p inner join worker w on p.pid = w.pid inner join hiredas h on w.pid = h.pid inner join position po on po.positionid = h.positionid where po.positionname in (&<name="positionname" list="select positionname from position" type=string multiselect="yes">) and h.workpercantageincurrentmonth > &<name="maximum hours" type=integer> select * from uses select * from medical_record
true
ba633ff9e36b6dfed50eac24e93d9722a1463cd2
SQL
ClickHouse/ClickHouse
/tests/queries/0_stateless/01453_fixsed_string_sort.sql
UTF-8
1,563
2.875
3
[ "Apache-2.0", "BSL-1.0" ]
permissive
drop table if exists badFixedStringSort; CREATE TABLE IF NOT EXISTS badFixedStringSort (uuid5_old FixedString(16), subitem String) engine=MergeTree order by tuple(); INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '1'); INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '2'); INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '1'); INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '2'); INSERT INTO badFixedStringSort values (UUIDStringToNum('8ad8fc5e-a49e-544c-98e6-1140afd79f80'), '2'); INSERT INTO badFixedStringSort values (UUIDStringToNum('8ad8fc5e-a49e-544c-98e6-1140afd79f80'), '1'); INSERT INTO badFixedStringSort values (UUIDStringToNum('8ad8fc5e-a49e-544c-98e6-1140afd79f80'), '2'); INSERT INTO badFixedStringSort values (UUIDStringToNum('8ad8fc5e-a49e-544c-98e6-1140afd79f80'), '1'); INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '1'); INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '2'); INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '1'); INSERT INTO badFixedStringSort values (UUIDStringToNum('999e1140-66ef-5610-9c3a-b3fb33e0fda9'), '2'); optimize table badFixedStringSort final; select hex(uuid5_old), subitem from badFixedStringSort ORDER BY uuid5_old, subitem; drop table if exists badFixedStringSort;
true
b41d0d388ce24a569891f83721d797b3725ea815
SQL
519984307/qt_cppmaster
/19_qsqlquerymodel/sql/pedidos.sql
UTF-8
1,582
3.109375
3
[ "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.6.5.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: 19-Nov-2017 às 00:34 -- Versão do servidor: 10.1.21-MariaDB -- PHP Version: 5.6.30 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `pedidos` -- CREATE DATABASE IF NOT EXISTS `pedidos` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; USE `pedidos`; -- -------------------------------------------------------- -- -- Estrutura da tabela `produtos` -- CREATE TABLE `produtos` ( `id` int(11) NOT NULL, `titulo` varchar(20) COLLATE utf8_bin NOT NULL, `valor_un` double NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -- -- Extraindo dados da tabela `produtos` -- INSERT INTO `produtos` (`id`, `titulo`, `valor_un`) VALUES (1, 'Maça', 0.95), (2, 'Pêra', 1.05), (3, 'Abacaxi', 1.75); -- -- Indexes for dumped tables -- -- -- Indexes for table `produtos` -- ALTER TABLE `produtos` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `produtos` -- ALTER TABLE `produtos` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; /*!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
21dd70af0fdb9de330f47bd975f2190ca8e94afe
SQL
caoyang0014/project_test
/database/erd.sql
GB18030
2,500
3.578125
4
[]
no_license
SET SESSION FOREIGN_KEY_CHECKS=0; /* Drop Tables */ DROP TABLE IF EXISTS t_baidu_insight; DROP TABLE IF EXISTS t_crowd; DROP TABLE IF EXISTS t_crowd_keywords; DROP TABLE IF EXISTS t_monthly_active_user; DROP TABLE IF EXISTS t_monthly_mac_duplicate_removal; DROP TABLE IF EXISTS t_other_app_account; DROP TABLE IF EXISTS t_user; DROP TABLE IF EXISTS t_weekly_mac_duplicate_removal; /* Create Tables */ CREATE TABLE t_baidu_insight ( id int NOT NULL AUTO_INCREMENT, crowd_id int, schedule_id int, schedule_status int, json_result varchar(2000) BINARY, excel_result varchar(2000) BINARY, user_id int, PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE TABLE t_crowd ( id int NOT NULL AUTO_INCREMENT, -- ʱ -- create_time datetime COMMENT 'ʱ ', crowd_name varchar(255) BINARY, crowd_source int, query_type varchar(10) BINARY, app_name varchar(255) BINARY, mobile_brand varchar(255) BINARY, quantity bigint(20), vitality int, time_begin datetime, time_end datetime, description varchar(255) BINARY, upload_file varchar(2000) BINARY, user_id int, generate_file varchar(2000) BINARY, crowd_status int, PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE TABLE t_crowd_keywords ( crowd_id int NOT NULL, keyword varchar(255) NOT NULL, PRIMARY KEY (crowd_id, keyword) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE TABLE t_monthly_active_user ( id int NOT NULL AUTO_INCREMENT, year int, month int, user_count bigint(20), PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE TABLE t_monthly_mac_duplicate_removal ( id int NOT NULL AUTO_INCREMENT, year int, month int, mac_count bigint(20), PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE TABLE t_other_app_account ( id int NOT NULL AUTO_INCREMENT, app_name varchar(255) BINARY, total_account bigint(20), PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE TABLE t_user ( id int NOT NULL AUTO_INCREMENT, username varchar(255) BINARY, password varchar(255) BINARY, nickname varchar(255) BINARY, gender int, company varchar(255) BINARY, email varchar(255) BINARY, birth_year int, birth_month int, birth_day int, PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE TABLE t_weekly_mac_duplicate_removal ( id bigint(20) NOT NULL, count_date datetime, mac_count bigint(20), PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
true
1cc3abde5c6296095fb785a0748c1a256545a84e
SQL
cornelioroyer/abaco-design
/d_rela_afi_cglposteo.sql
UTF-8
376
2.640625
3
[]
no_license
delete from rela_afi_cglposteo where not exists (select * from afi_depreciacion where afi_depreciacion.compania = rela_afi_cglposteo.compania and afi_depreciacion.codigo = rela_afi_cglposteo.codigo and afi_depreciacion.aplicacion = rela_afi_cglposteo.aplicacion and afi_depreciacion.year = rela_afi_cglposteo.year and afi_depreciacion.periodo = rela_afi_cglposteo.periodo);
true
75ea7a41f00f13ee90d0a6d80cb371c20004437d
SQL
vlzhr/corp-messager
/workbench-create-chat-db.sql
UTF-8
8,329
3.203125
3
[]
no_license
-- MySQL Script generated by MySQL Workbench -- Tue Jun 5 12:54:35 2018 -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- -- Schema mydb -- ----------------------------------------------------- -- ----------------------------------------------------- -- Schema mydb -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ; USE `mydb` ; -- ----------------------------------------------------- -- Table `mydb`.`company` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`company` ; CREATE TABLE IF NOT EXISTS `mydb`.`company` ( `id` INT NOT NULL, `name` VARCHAR(45) NOT NULL, `password` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`department` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`department` ; CREATE TABLE IF NOT EXISTS `mydb`.`department` ( `id` INT NOT NULL, `name` VARCHAR(45) NOT NULL, `company_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `fk_department_company1_idx` (`company_id` ASC), CONSTRAINT `fk_department_company1` FOREIGN KEY (`company_id`) REFERENCES `mydb`.`company` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`collaborator` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`collaborator` ; CREATE TABLE IF NOT EXISTS `mydb`.`collaborator` ( `id` INT NOT NULL, `name` VARCHAR(45) NOT NULL, `login` VARCHAR(45) NOT NULL, `password` VARCHAR(45) NOT NULL, `department_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `fk_collaborator_department_idx` (`department_id` ASC), CONSTRAINT `fk_collaborator_department` FOREIGN KEY (`department_id`) REFERENCES `mydb`.`department` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`chat` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`chat` ; CREATE TABLE IF NOT EXISTS `mydb`.`chat` ( `id` INT NOT NULL, `name` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`agent` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`agent` ; CREATE TABLE IF NOT EXISTS `mydb`.`agent` ( `id` INT NOT NULL, `name` VARCHAR(45) NOT NULL, `login` VARCHAR(45) NOT NULL, `password` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`agent_has_chat` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`agent_has_chat` ; CREATE TABLE IF NOT EXISTS `mydb`.`agent_has_chat` ( `chat_id` INT NOT NULL, `agent_id` INT NOT NULL, PRIMARY KEY (`chat_id`, `agent_id`), INDEX `fk_chat_has_agent_agent1_idx` (`agent_id` ASC), INDEX `fk_chat_has_agent_chat1_idx` (`chat_id` ASC), CONSTRAINT `fk_chat_has_agent_chat1` FOREIGN KEY (`chat_id`) REFERENCES `mydb`.`chat` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_chat_has_agent_agent1` FOREIGN KEY (`agent_id`) REFERENCES `mydb`.`agent` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`topic` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`topic` ; CREATE TABLE IF NOT EXISTS `mydb`.`topic` ( `id` INT NOT NULL, `name` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`message` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`message` ; CREATE TABLE IF NOT EXISTS `mydb`.`message` ( `id` INT NOT NULL, `text` VARCHAR(45) NOT NULL, `chat_id` INT NOT NULL, `topic_id` INT NULL, PRIMARY KEY (`id`), INDEX `fk_message_chat1_idx` (`chat_id` ASC), INDEX `fk_message_topic1_idx` (`topic_id` ASC), CONSTRAINT `fk_message_chat1` FOREIGN KEY (`chat_id`) REFERENCES `mydb`.`chat` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_message_topic1` FOREIGN KEY (`topic_id`) REFERENCES `mydb`.`topic` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`attachment` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`attachment` ; CREATE TABLE IF NOT EXISTS `mydb`.`attachment` ( `id` INT NOT NULL, `link` VARCHAR(45) NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`message_has_attachment` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`message_has_attachment` ; CREATE TABLE IF NOT EXISTS `mydb`.`message_has_attachment` ( `message_id` INT NOT NULL, `attachment_id` INT NOT NULL, PRIMARY KEY (`message_id`, `attachment_id`), INDEX `fk_message_has_attachment_attachment1_idx` (`attachment_id` ASC), INDEX `fk_message_has_attachment_message1_idx` (`message_id` ASC), CONSTRAINT `fk_message_has_attachment_message1` FOREIGN KEY (`message_id`) REFERENCES `mydb`.`message` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_message_has_attachment_attachment1` FOREIGN KEY (`attachment_id`) REFERENCES `mydb`.`attachment` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`table1` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`table1` ; CREATE TABLE IF NOT EXISTS `mydb`.`table1` ( ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`view` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`view` ; CREATE TABLE IF NOT EXISTS `mydb`.`view` ( `message_id` INT NOT NULL, `collaborator_id` INT NULL, `agent_id` INT NULL, PRIMARY KEY (`message_id`, `collaborator_id`, `agent_id`), INDEX `fk_message_has_collaborator_collaborator1_idx` (`collaborator_id` ASC), INDEX `fk_message_has_collaborator_message1_idx` (`message_id` ASC), INDEX `fk_view_agent1_idx` (`agent_id` ASC), CONSTRAINT `fk_message_has_collaborator_message1` FOREIGN KEY (`message_id`) REFERENCES `mydb`.`message` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_message_has_collaborator_collaborator1` FOREIGN KEY (`collaborator_id`) REFERENCES `mydb`.`collaborator` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_view_agent1` FOREIGN KEY (`agent_id`) REFERENCES `mydb`.`agent` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`department_has_chat` -- ----------------------------------------------------- DROP TABLE IF EXISTS `mydb`.`department_has_chat` ; CREATE TABLE IF NOT EXISTS `mydb`.`department_has_chat` ( `department_id` INT NOT NULL, `chat_id` INT NOT NULL, PRIMARY KEY (`department_id`, `chat_id`), INDEX `fk_department_has_chat_chat1_idx` (`chat_id` ASC), INDEX `fk_department_has_chat_department1_idx` (`department_id` ASC), CONSTRAINT `fk_department_has_chat_department1` FOREIGN KEY (`department_id`) REFERENCES `mydb`.`department` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_department_has_chat_chat1` FOREIGN KEY (`chat_id`) REFERENCES `mydb`.`chat` (`id`) 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
260ee67caee9a90a27367b1d6dc2c91d19ec3f8b
SQL
KanishkaDewSandaruwan/info
/Database/atendance.sql
UTF-8
13,762
3.09375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.8.4 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Feb 20, 2019 at 08:46 PM -- Server version: 10.1.37-MariaDB -- PHP Version: 7.3.0 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: `atendance` -- -- -------------------------------------------------------- -- -- Table structure for table `batch` -- CREATE TABLE `batch` ( `batch_code` int(11) NOT NULL, `start_year` int(11) NOT NULL, `end_year` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `batch` -- INSERT INTO `batch` (`batch_code`, `start_year`, `end_year`) VALUES (1, 15, 16), (3, 16, 17); -- -------------------------------------------------------- -- -- Table structure for table `department` -- CREATE TABLE `department` ( `department_id` int(11) NOT NULL, `department` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `department` -- INSERT INTO `department` (`department_id`, `department`) VALUES (1, 'ICT'), (3, 'BST'); -- -------------------------------------------------------- -- -- Table structure for table `editor` -- CREATE TABLE `editor` ( `editor_id` int(11) NOT NULL, `full_name` varchar(50) NOT NULL, `address` varchar(50) NOT NULL, `phone_number` int(10) NOT NULL, `email` varchar(50) NOT NULL, `gender` varchar(10) NOT NULL, `password` varchar(50) NOT NULL, `username` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `editor` -- INSERT INTO `editor` (`editor_id`, `full_name`, `address`, `phone_number`, `email`, `gender`, `password`, `username`) VALUES (5, '', '', 0, '', '', '827ccb0eea8a706c4c34a16891f84e7b', 'admin'); -- -------------------------------------------------------- -- -- Table structure for table `lecture` -- CREATE TABLE `lecture` ( `lecture_id` int(11) NOT NULL, `full_name` varchar(50) NOT NULL, `address` varchar(50) NOT NULL, `phone_number` int(10) NOT NULL, `email` varchar(50) NOT NULL, `gender` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, `lec_username` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `lecture` -- INSERT INTO `lecture` (`lecture_id`, `full_name`, `address`, `phone_number`, `email`, `gender`, `password`, `lec_username`) VALUES (11, 'Rifai Kariapper', 'Kalmunai, Sri Lanka', 718080883, 'rifaikariapper@gmail.com', 'Male', '827ccb0eea8a706c4c34a16891f84e7b', 'rifai'), (12, 'Ahamad Sabani', 'Akkareipaththu, Sri Lanka', 783293949, 'sabani@gmail.com', 'Male', '827ccb0eea8a706c4c34a16891f84e7b', 'sabani'), (13, 'Abdul Haleem', 'Karthiv, Kalmunai', 772248250, 'haleem123@gmail.com', 'Male', '827ccb0eea8a706c4c34a16891f84e7b', 'haleem'), (14, 'Wasanthapriyan', 'Colombo, Sri Lanka', 772598634, 'wasantha@gmail.com', 'Male', '827ccb0eea8a706c4c34a16891f84e7b', 'wasantha'), (15, 'Naja Musthafa', 'Akkareipaththu, Sri Lanka', 712548789, 'naja@gmail.com', 'Male', '827ccb0eea8a706c4c34a16891f84e7b', 'naja'), (16, 'Prof. Ismail', 'Akkareipaththu, Sri Lanka', 714578963, 'ismail@gmail.com', 'Male', '827ccb0eea8a706c4c34a16891f84e7b', 'ismail'); -- -------------------------------------------------------- -- -- Table structure for table `lec_attend` -- CREATE TABLE `lec_attend` ( `lec_id` int(11) NOT NULL, `reg_number` varchar(50) NOT NULL, `cal_date` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `lec_attend` -- INSERT INTO `lec_attend` (`lec_id`, `reg_number`, `cal_date`) VALUES (44, 'SEU/IS/15/ICT/045', '2019/02/13_CIS22012'), (46, 'SEU/IS/15/ICT/045', '2019/02/13_CIS22022'), (57, 'SEU/IS/15/ICT/018', '2019/02/14_SWT22022'), (58, 'SEU/IS/15/ICT/018', '2018/02/14_CIS12012'), (59, 'SEU/IS/15/ICT/018', '2019/02/14_CIS22032'), (60, 'SEU/IS/15/ICT/012', '2019/02/14_SWT22022'), (61, 'SEU/IS/15/ICT/012', '2019/02/14_CIS22012'), (62, 'SEU/IS/15/ICT/012', '2019/02/13_CIS22012'), (63, 'SEU/IS/15/ICT/034', '2019/02/19_CIS22032'), (64, 'SEU/IS/15/ICT/045', '2019/02/19_CIS22032'), (65, 'SEU/IS/15/ICT/018', '2019/02/19_CIS22032'), (66, 'SEU/IS/15/ICT/034', '2019/02/20_SWT22022'), (67, 'SEU/IS/15/ICT/045', '2019/02/20_SWT22022'), (68, 'SEU/IS/15/ICT/018', '2019/02/20_SWT22022'), (69, 'SEU/IS/16/ICT/034', '2019/02/20_CIS12012'), (70, 'SEU/IS/16/ICT/031', '2019/02/20_CIS12012'), (71, 'SEU/IS/16/ICT/034', '2019/02/20_SWT12012'), (72, 'SEU/IS/16/ICT/031', '2019/02/19_CIS22032'); -- -------------------------------------------------------- -- -- Table structure for table `lec_calander` -- CREATE TABLE `lec_calander` ( `cal_date` varchar(255) NOT NULL, `date` date NOT NULL, `subject_code` varchar(255) NOT NULL, `batch_code` int(50) NOT NULL, `lec_time` int(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `lec_calander` -- INSERT INTO `lec_calander` (`cal_date`, `date`, `subject_code`, `batch_code`, `lec_time`) VALUES ('2019/02/19_CIS22032', '2019-02-19', 'CIS22032', 15, 4), ('2019/02/20_SWT22022', '2019-02-20', 'SWT22022', 15, 3), ('2019/02/20_SWT12012', '2019-02-20', 'SWT12012', 15, 4), ('2019/02/20_CIS12012', '2019-02-20', 'CIS12012', 15, 3); -- -------------------------------------------------------- -- -- Table structure for table `sem` -- CREATE TABLE `sem` ( `id` int(11) NOT NULL, `semester` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `sem` -- INSERT INTO `sem` (`id`, `semester`) VALUES (1, '1st Year 1st Sem'), (2, '1st Year 2nd Sem'), (3, '2nd Year 1st Sem'), (4, '2nd Year 2nd Sem'), (5, '3rd Year 1st Sem'), (6, '3rd Year 2nd Sem'), (7, '4th Year 1st Sem'), (8, '4th Year 2nd Sem'); -- -------------------------------------------------------- -- -- Table structure for table `shedule` -- CREATE TABLE `shedule` ( `subject_code` varchar(50) NOT NULL, `semester` varchar(50) NOT NULL, `lec_name` varchar(50) NOT NULL, `department` varchar(10) NOT NULL, `shedul_code` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `shedule` -- INSERT INTO `shedule` (`subject_code`, `semester`, `lec_name`, `department`, `shedul_code`) VALUES ('CIS12012', '1st Year 2nd Sem', 'Naja Musthafa', 'ICT', 13), ('CIS22012', '2nd Year 2nd Sem', 'Abdul Haleem', 'ICT', 14), ('CIS22022', '2nd Year 2nd Sem', 'Ahamad Sabani', 'ICT', 15), ('CIS22032', '2nd Year 2nd Sem', 'Rifai Kariapper', 'ICT', 16), ('CIS22042', '2nd Year 2nd Sem', 'Abdul Haleem', 'ICT', 17), ('CMS12013', '1st Year 2nd Sem', 'Naja Musthafa', 'ICT', 18), ('CMS22012', '2nd Year 2nd Sem', 'Prof. Ismail', 'ICT', 19), ('MGT12021', '1st Year 2nd Sem', 'Rifai Kariapper', 'ICT', 20), ('MGT1211', '1st Year 2nd Sem', 'Rifai Kariapper', 'ICT', 21), ('NST1202', '1st Year 2nd Sem', 'Ahamad Sabani', 'ICT', 22), ('SWT12012', '1st Year 2nd Sem', 'Abdul Haleem', 'ICT', 23), ('SWT12032', '1st Year 2nd Sem', 'Abdul Haleem', 'ICT', 24), ('SWT12041', '1st Year 2nd Sem', 'Naja Musthafa', 'ICT', 25), ('SWT12041', '1st Year 2nd Sem', 'Naja Musthafa', 'ICT', 26), ('SWT1221', '1st Year 2nd Sem', 'Naja Musthafa', 'ICT', 27), ('SWT22012', '2nd Year 2nd Sem', 'Wasanthapriyan', 'ICT', 28), ('SWT22022', '2nd Year 2nd Sem', 'Wasanthapriyan', 'ICT', 29), ('UTC22011', '2nd Year 2nd Sem', 'Abdul Haleem', 'ICT', 30), ('UTC22022', '2nd Year 2nd Sem', 'Abdul Haleem', 'ICT', 31); -- -------------------------------------------------------- -- -- Table structure for table `std_pass` -- CREATE TABLE `std_pass` ( `id` int(11) NOT NULL, `reg_number` varchar(100) NOT NULL, `password` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `std_pass` -- INSERT INTO `std_pass` (`id`, `reg_number`, `password`) VALUES (3, 'SEU/IS/15/ICT/034', '827ccb0eea8a706c4c34a16891f84e7b'); -- -------------------------------------------------------- -- -- Table structure for table `student` -- CREATE TABLE `student` ( `std_id` int(11) NOT NULL, `full_name` varchar(50) NOT NULL, `address` varchar(100) NOT NULL, `phone_number` int(10) NOT NULL, `email` varchar(50) NOT NULL, `gender` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `student` -- INSERT INTO `student` (`std_id`, `full_name`, `address`, `phone_number`, `email`, `gender`) VALUES (54, 'Kanishka Dew Sandaruwan', 'Banvalgodalla, Kosmulla', 713664071, 'kanishkadewsandaruwan@gmail.com', 'Male'), (55, 'Daksthitha Disanataka', 'Anuradhapura, Sri Lanka', 713664071, 'dakshithadissanayaka96@gmail.com', 'Male'), (56, 'Tharindu Tharaka', 'Polonnaruwa, Sri Lanka', 711995141, 'tharindu@gmail.com', 'Male'), (57, 'Dananji Widanarachchi', 'Avissawella, Sri Lanka', 719485011, 'dana@gmail.com', 'Male'), (58, 'Madara Maduvanthi', 'Horana, Sri Lanka', 716802519, 'madara@gmail.com', 'Male'), (59, 'Shashini Uthpala Kumari', 'Madamahanuwara, Theldeniya', 715878456, 'shashi@gmail.com', 'Male'), (60, 'Hariths Udana', 'Colombo, Sri Lanka', 716578485, 'hari@gmail.com', 'Male'), (61, 'Udara Dimuthu', 'Galle', 774578547, 'udara@gmail.com', 'Male'); -- -------------------------------------------------------- -- -- Table structure for table `student_reg` -- CREATE TABLE `student_reg` ( `reg_number` varchar(50) NOT NULL, `sid` int(11) NOT NULL, `department` varchar(20) NOT NULL, `batch` int(11) NOT NULL, `date` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `student_reg` -- INSERT INTO `student_reg` (`reg_number`, `sid`, `department`, `batch`, `date`) VALUES ('SEU/IS/15/ICT/034', 54, 'ICT', 15, '2019-02-20 20:30:25'), ('SEU/IS/15/ICT/045', 55, 'ICT', 15, '2019-02-20 20:31:49'), ('SEU/IS/15/ICT/018', 56, 'ICT', 15, '2019-02-20 20:32:59'), ('SEU/IS/15/bsT/034', 57, 'BST', 15, '2019-02-20 20:34:34'), ('SEU/IS/15/bst/035', 58, 'BST', 15, '2019-02-20 20:35:58'), ('SEU/IS/15/bst/036', 59, 'BST', 15, '2019-02-20 20:37:18'), ('SEU/IS/16/ICT/031', 60, 'ICT', 16, '2019-02-20 20:39:05'), ('SEU/IS/16/ICT/034', 61, 'ICT', 16, '2019-02-20 20:41:20'); -- -------------------------------------------------------- -- -- Table structure for table `subject` -- CREATE TABLE `subject` ( `sub_code` varchar(50) NOT NULL, `sub_name` varchar(50) NOT NULL, `credits` int(10) NOT NULL, `lec_hours` int(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `subject` -- INSERT INTO `subject` (`sub_code`, `sub_name`, `credits`, `lec_hours`) VALUES ('CIS12012', 'Social Computing', 2, 30), ('CIS22012', 'Distributed and Cloud Computing', 2, 30), ('CIS22022', 'Information Assuarance and Forensics', 2, 60), ('CIS22032', 'E-Commers Strategies and Architecher', 2, 30), ('CIS22042', 'Practical for Distributed and Cloud Computing', 2, 60), ('CMS12013', 'Mathamatics', 2, 30), ('CMS22012', 'Leadership and Communication Skils', 2, 60), ('MGT12021', 'Practical for Multimedia & Computer Graphics', 2, 60), ('MGT1211', 'Multimedia & Computer Graphics', 2, 30), ('NST1202', 'Computer Network & Data Communication', 2, 30), ('SWT12012', 'Object Oriented Programming', 2, 30), ('SWT12032', 'Practical for Object Oriented Programming', 2, 60), ('SWT12041', 'Practical for Web System And Technology', 2, 60), ('SWT1221', 'Web System & Technology', 2, 30), ('SWT22012', 'Internet Application Devolopment', 2, 30), ('SWT22022', 'Practical for Internet Application Devolopment', 2, 60), ('UTC22011', 'Microcontroller System Programming', 2, 30), ('UTC22022', 'Practical for Microcontroller System Programming', 2, 60); -- -- Indexes for dumped tables -- -- -- Indexes for table `batch` -- ALTER TABLE `batch` ADD PRIMARY KEY (`batch_code`); -- -- Indexes for table `department` -- ALTER TABLE `department` ADD PRIMARY KEY (`department_id`); -- -- Indexes for table `editor` -- ALTER TABLE `editor` ADD PRIMARY KEY (`editor_id`); -- -- Indexes for table `lecture` -- ALTER TABLE `lecture` ADD PRIMARY KEY (`lecture_id`); -- -- Indexes for table `lec_attend` -- ALTER TABLE `lec_attend` ADD PRIMARY KEY (`lec_id`); -- -- Indexes for table `sem` -- ALTER TABLE `sem` ADD PRIMARY KEY (`id`); -- -- Indexes for table `shedule` -- ALTER TABLE `shedule` ADD PRIMARY KEY (`shedul_code`); -- -- Indexes for table `std_pass` -- ALTER TABLE `std_pass` ADD PRIMARY KEY (`id`); -- -- Indexes for table `student` -- ALTER TABLE `student` ADD PRIMARY KEY (`std_id`); -- -- Indexes for table `subject` -- ALTER TABLE `subject` ADD PRIMARY KEY (`sub_code`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `batch` -- ALTER TABLE `batch` MODIFY `batch_code` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `department` -- ALTER TABLE `department` MODIFY `department_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `editor` -- ALTER TABLE `editor` MODIFY `editor_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; -- -- AUTO_INCREMENT for table `lecture` -- ALTER TABLE `lecture` MODIFY `lecture_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; -- -- AUTO_INCREMENT for table `lec_attend` -- ALTER TABLE `lec_attend` MODIFY `lec_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=73; -- -- AUTO_INCREMENT for table `sem` -- ALTER TABLE `sem` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; -- -- AUTO_INCREMENT for table `shedule` -- ALTER TABLE `shedule` MODIFY `shedul_code` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32; -- -- AUTO_INCREMENT for table `std_pass` -- ALTER TABLE `std_pass` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `student` -- ALTER TABLE `student` MODIFY `std_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=62; 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
73a955cb13cdfe929e7b9861f45d8ffc01de04d5
SQL
zulyang/Webservices
/SQL/sector_SQL.sql
UTF-8
1,296
2.90625
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.5.5.1 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Mar 31, 2017 at 06:12 AM -- Server version: 5.7.11 -- PHP Version: 5.6.19 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: `sector` -- -- -------------------------------------------------------- CREATE DATABASE /*!32312 IF NOT EXISTS*/ `sector` /*!40100 DEFAULT CHARACTER SET latin1 */; USE `sector`; -- -- Table structure for table `area` -- CREATE TABLE `area` ( `areacode` int(11) NOT NULL, `topic` varchar(100) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `area` -- INSERT INTO `area` (`areacode`, `topic`) VALUES (188065, 'SMU'), (530308, 'HOUGANG'); -- -- Indexes for dumped tables -- -- -- Indexes for table `area` -- ALTER TABLE `area` ADD PRIMARY KEY (`areacode`); /*!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
b45c9a9fdc7799accbf4cf4c3eb78bf7470ded0a
SQL
furnathan/SQL-queries
/Find columns named.....sql
UTF-8
144
2.640625
3
[]
no_license
SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('language_id') AND TABLE_SCHEMA='THE_DB_NAME';
true
8fb911385738930d9391335dad6d71d03d2e4f5e
SQL
shenjunwei/neurobjects
/resources/results.sql
UTF-8
2,181
3.1875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 3.4.3.2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Nov 21, 2011 at 05:12 PM -- Server version: 5.1.57 -- PHP Version: 5.3.5 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: `neurobjects_new` -- -- -------------------------------------------------------- -- -- Table structure for table `results` -- CREATE TABLE IF NOT EXISTS `results` ( `id` int(11) NOT NULL AUTO_INCREMENT, `animal` varchar(25) NOT NULL, `area` varchar(25) NOT NULL, `object` varchar(25) NOT NULL, `round` int(11) NOT NULL, `cv_fold` int(11) DEFAULT NULL, `model` varchar(40) NOT NULL, `bin_size` double NOT NULL, `window_size` int(11) NOT NULL, `neuron_drop` int(11) DEFAULT NULL, `surrogate` enum('uniform','poisson','col_swap','neuron_swap','matrix_swap','col_swap_d','poisson_d','uniform_d','spike_jitter','mean_d','contact_swap','contact_shift','contact_split','exposition_split') DEFAULT NULL, `num_surrogate` int(11) DEFAULT NULL, `pct_surrogate` double DEFAULT NULL, `dist_surrogate` double DEFAULT NULL, `num_instances` int(11) NOT NULL, `correct_instances` int(11) NOT NULL, `auroc` double NOT NULL, `kappa` double NOT NULL, `yes_fmeasure` double NOT NULL, `yes_fp` int(11) NOT NULL, `yes_fn` int(11) NOT NULL, `no_fmeasure` double NOT NULL, `no_fp` int(11) NOT NULL, `no_fn` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `CONTEXT` (`animal`,`area`,`object`,`round`,`cv_fold`,`model`,`bin_size`,`window_size`,`neuron_drop`,`surrogate`,`num_surrogate`,`pct_surrogate`,`dist_surrogate`), KEY `MAIN` (`animal`,`area`,`object`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Reference table, never changes.' AUTO_INCREMENT=1 ; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
7bda2d7cfe33b50c18d356c3af9b11eee61dcc3d
SQL
techTutorial/es-sb-hibernate-fetchtype
/src/main/resources/schema.sql
UTF-8
1,032
3.859375
4
[]
no_license
-- h2 Database DROP TABLE IF EXISTS ES_PRODUCT; create table ES_PRODUCT ( ID_PRODUCT BIGINT AUTO_INCREMENT PRIMARY KEY, NAME_PRODUCT varchar(100) NOT NULL ); DROP TABLE IF EXISTS ES_ACCESSORIES; create table ES_ACCESSORIES ( ID_ACCESSORIES BIGINT AUTO_INCREMENT PRIMARY KEY, ID_PRODUCT_ACCESSORIES BIGINT, NAME_ACCESSORIES varchar(100) NOT NULL, --PRICE_ACCESSORIES NUMBER(6), --DATE_CREATION_ACCESSORIES DATE, -- FOREIGN KEY definition is optional for hibernate mapping; FOREIGN KEY (ID_PRODUCT_ACCESSORIES) REFERENCES ES_PRODUCT (ID_PRODUCT) ); --COMMENT ON COLUMN ES_ACCESSORIES.ID_ACCESSORIES IS 'Preferred way to contact with employee'; -- drop table ES_ACCESSORIES; -- select * from ES_ACCESSORIES; DROP TABLE IF EXISTS ES_REVIEW; CREATE TABLE ES_REVIEW ( ID_REVIEW NUMBER(10) NOT NULL, ID_PRODUCT_REVIEW NUMBER(10) NOT NULL references ES_PRODUCT, STAR_REVIEW INT, --COMMENT_REVIEW varchar(100), --AUTHOR_REVIEW varchar(100), CONSTRAINT REVIEW_PK PRIMARY KEY (ID_REVIEW) );
true
87d4ee7f8d00c41573599bc7a024ec52ce304575
SQL
catgoing/mystudy
/00SQL/04TableColligation.sql
UHC
6,573
3.921875
4
[]
no_license
/* Table row, column ɾ create drop ٲٱ alter Data insert delete select update */ CREATE TABLE TB_TEST01( COL1 VARCHAR2(10), COL2 VARCHAR2(10), COL3 VARCHAR2(10) ); CREATE TABLE TB_TEST02( COL1 VARCHAR2(10), COL2 NUMBER(5, 1), COL3 DATE ); -- TABLE COPY( ) CREATE TABLE TB_TEST03 AS SELECT * FROM employees; -- DROP TABLE TB_TEST03; CREATE TABLE TB_TEST03(EMPNO, ENAME, SAL) -- ϴ ÷ AS SELECT employee_id, first_name, salary -- ϴ ͸ FROM employees; CREATE TABLE TB_DEPTGROUP(DNUM, DCOUNT) AS SELECT department_id, COUNT(*) FROM employees GROUP BY department_id; -- TABLE COPY( ) CREATE TABLE TB_TEST04 AS SELECT * FROM departments WHERE 1 = 2; CREATE TABLE DEPT_EMP(EMPNO, SAL, DNAME, LOC) AS SELECT e.employee_id, e.salary, d.department_name, d.location_id FROM employees E, departments D WHERE e.department_id = d.department_id; -- AND 1 = 2; -- ͱ κ /* ̺ */ -- ̺ ALTER TABLE TB_TEST04 RENAME TO TB_TEST99; -- ÷ ߰ ALTER TABLE TB_TEST99 -- ϳ ÷ ߰ ADD NEWCOL VARCHAR2(20); ALTER TABLE TB_TEST99 -- ټ ÷ ߰ ADD (COLNEW1 NUMBER, COLNEW2 DATE); -- ÷ ALTER TABLE TB_TEST99 MODIFY NEWCOL VARCHAR(30); ALTER TABLE TB_TEST99 MODIFY (COLNEW1 VARCHAR(20), COLNEW2 NUMBER); -- ÷ ALTER TABLE TB_TEST99 DROP COLUMN NEWCOL; ALTER TABLE TB_TEST99 DROP (COLNEW1, COLNEW2); -- ÷ ALTER TABLE TB_TEST99 RENAME COLUMN DEPARTMENT_ID TO DEPTNO; DROP TABLE TB_TEST99; -- --- ̰ --PURGE RECYCLEBIN; -- INSERT INSERT INTO TB_TEST04(department_id, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID) VALUES(100, 'ȹ', 20, 200); INSERT INTO TB_TEST04(department_id, DEPARTMENT_NAME) VALUES(100, 'ȹ'); INSERT INTO TB_TEST04 VALUES(101, '', 30, 400); INSERT INTO TB_TEST04(MANAGER_ID, LOCATION_ID, department_id, DEPARTMENT_NAME) VALUES(50, 500, 102, ''); SELECT * FROM TB_TEST04; -- DELETE DELETE FROM tb_test04 WHERE manager_id = 20; -- UPDATE UPDATE tb_test04 SET MANAGER_ID = 40 WHERE department_name = ''; UPDATE tb_test04 SET MANAGER_ID = 10, location_id = 100, department_id = 1000 WHERE department_name = ''; /* Ἲ: column column ϴ Primary Key: ⺻Ű. Null̳ ߺ X UNIQUE KEY: Ű, ߺ X, NULL O FOREIGN KEY: ܷŰ, JOIN ܷŰ ÷ ̺ PK, UK Ǿ ־ CHECK: . NULL O NOT NULL */ -- NOT NUMM CREATE TABLE TBTEST( COL1 VARCHAR2(10) NOT NULL, COL2 VARCHAR2(20) ); INSERT INTO TBTEST(COL1, COL2) VALUES('AAA', '111'); INSERT INTO TBTEST(COL1) VALUES('BBB'); INSERT INTO TBTEST(COL2) -- , COL1 Ͱ ROW̱ VALUES('222'); INSERT INTO TBTEST(COL1, COL2) -- VALUES('', '111'); DROP TABLE TBTEST CASCADE CONSTRAINTS; -- Ἲ ־ -- PRIMARY KEY = NOT NULL + UNIQUE CREATE TABLE TBTEST( COLP VARCHAR2(10) CONSTRAINT PK_TEST PRIMARY KEY, -- = COLP VARCHAR2(10) PRIMARY KEY COL1 VARCHAR2(20), COL2 VARCHAR2(30) ); INSERT INTO TBTEST(COLP, COL1, COL2) VALUES('AAA','111','aaa'); INSERT INTO TBTEST(COLP, COL1, COL2) -- COLP ߺ VALUES('AAA','112','aaa'); INSERT INTO TBTEST(COLP, COL1, COL2) VALUES('BBB','111','aaa'); INSERT INTO TBTEST(COL1, COL2) VALUES('111','aaa'); -- COLP NULL INSERT INTO TBTEST(COLP, COL1, COL2) VALUES('', '111','aaa'); -- COLP NULL SELECT * FROM TBTEST; DROP TABLE TBTEST; -- UNIQUE: ÷ ߺ X, NULL O CREATE TABLE TBTEST( COLU VARCHAR2(10) CONSTRAINT UK_TEST UNIQUE, -- = COLU VARCHAR2(10) UNIQUE COL1 VARCHAR2(20), COL2 VARCHAR2(20) ); INSERT INTO TBTEST(COLU, COL1, COL2) VALUES('AAA','111','222'); INSERT INTO TBTEST(COLU, COL1, COL2) -- , COLU Է Ұ VALUES('AAA','112','222'); INSERT INTO TBTEST(COL1, COL2) -- COLU NULL VALUES('111','222'); ALTER TABLE TBTEST DROP CONSTRAINT UK_TEST; -- COLU UNIQUE -- FOREIGN KEY CREATE TABLE TBPARENT( COL_PK VARCHAR2(10) CONSTRAINT PK_PARENT PRIMARY KEY, COL1 VARCHAR2(20), COL2 VARCHAR2(20) ); CREATE TABLE TBCHILD( KEY1 VARCHAR2(10), KEY2 VARCHAR2(10), COL_PK VARCHAR2(10), -- ܷŰ κ, PRIMARY KEY ĺ ũų Ǿ CONSTRAINT FK_CHILD FOREIGN KEY(COL_PK) REFERENCES TBPARENT(COL_PK) ); INSERT INTO TBPARENT(COL_PK, COL1, COL2) VALUES('AAA', '11', '222'); INSERT INTO TBPARENT(COL_PK, COL1, COL2) VALUES('AA1', '22', '333'); INSERT INTO TBPARENT(COL_PK, COL1, COL2) VALUES('AA2', '33', '444'); INSERT INTO TBCHILD(KEY1, KEY2, COL_PK) VALUES('55', '555', 'AAA'); INSERT INTO TBCHILD(KEY1, KEY2, COL_PK) VALUES('55', '555', 'AA3'); -- , FOREIGN KEY PRIMARY KEY Ǿ , Ȥ NULL̰ų INSERT INTO TBCHILD(KEY1, KEY2) VALUES('55', '555'); -- FOREIGN KEY NULL SELECT * FROM TBCHILD; -- CHECK : ܿ , NULL O CREATE TABLE TBCHECK( COL1 VARCHAR2(10), KEY1 VARCHAR2(10), CONSTRAINT TB_CHK1 CHECK( COL1 IN('', '', 'ٳ') ), CONSTRAINT TB_CHK2 CHECK( KEY1 > 0 AND KEY1 <= 100) ); INSERT INTO TBCHECK(COL1, KEY1) VALUES('', 12); INSERT INTO TBCHECK(COL1, KEY1) VALUES('', 0); -- KEY1 INSERT INTO TBCHECK(COL1, KEY1) VALUES('', 25); -- NULL INSERT INTO TBCHECK(COL1, KEY1) VALUES('', ''); -- NULL SELECT * FROM TBCHECK;
true
b3c2f1cb9748d6503a3eb790b0601157f735ef75
SQL
mnorelli/BasicSQLwebinterface
/commands.sql
UTF-8
722
3.09375
3
[]
no_license
#\c mnorelli DROP DATABASE IF EXISTS cafewifi; CREATE DATABASE cafewifi; \l \c cafewifi DROP TABLE IF EXISTS site, address; CREATE TABLE site ( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, ADDRESS TEXT, NETWORK TEXT, PASSWORD CHAR(50), NOTE TEXT, BATHRMCODE TEXT, UPDATED DATE ); CREATE TABLE address ( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, ADDRESS TEXT NOT NULL ); \d COPY site (id, name, address, network, password, note, bathrmcode) FROM '/Users/mnorelli/dev/xxBasicSQLinterface/data2load.csv' csv NULL AS '' ; ALTER TABLE site ADD geoid SERIAL; ALTER TABLE site ADD geom GEOMETRY(Point, 26910); ALTER TABLE site ADD name VARCHAR(128); CREATE INDEX site_gix ON site USING GIST (geom);
true
cf4b0ed910c0704cbb1640ad93fcc810e09ff7cc
SQL
mucollabo/SQL200
/example/sql/p142.sql
UHC
570
2.984375
3
[]
no_license
set serveroutput on set verify off accept p_ename prompt ' ̸ Էϼ ~ ' declare v_ename emp.ename%type := upper('&p_ename'); v_sal emp.sal%type; begin select sal into v_sal from emp where ename = v_ename; if v_sal >= 3000 then dbms_output.put_line('ҵ Դϴ.'); elsif v_sal >= 2000 then dbms_output.put_line('߰ ҵ Դϴ.'); else dbms_output.put_line('ҵ Դϴ.'); end if; end; /
true
6f35d53f21605f838b2bd1c509e8d7111045183a
SQL
QuintLeusink/Sprint-4
/scrum/sprint 4/SQL/SQLQuery3.sql
UTF-8
216
3.015625
3
[]
no_license
SELECT tblEvent.EventName, tblEvent.EventDate, tblCategory.CategoryName FROM tblEvent RIGHT JOIN tblCategory ON tblEvent.CategoryID = tblCategory.CategoryID ORDER BY tblEvent.EventDate desc
true
8f2ef9955d205bf60503401d057bdcfb7d5d17d9
SQL
Mgesche/microsoftbi_framework
/Ressources/SSAS/CroisementsNN/Validation _MatrixCle.sql
UTF-8
1,047
3.21875
3
[]
no_license
select 'IDT_Classe_Temps' AS Domaine, FAC.IDT_Classe_Temps as MATRIX_KEY, COUNT(*) as NB from dimclient FAC left join MTX.FactClasseClient_Temps_WRK WRK ON WRK.MATRIX_KEY = coalesce(FAC.IDT_Classe_Temps, -1) where WRK.MATRIX_KEY is null group by FAC.IDT_Classe_Temps union select 'IDT_Classe' AS Domaine, FAC.IDT_Classe as MATRIX_KEY, COUNT(*) as NB from dimclient FAC left join MTX.FactClasseClient_Classe_WRK WRK ON WRK.MATRIX_KEY = coalesce(FAC.IDT_Classe, -1) where WRK.MATRIX_KEY is null group by FAC.IDT_Classe union select 'IDT_Profil_Temps' AS Domaine, FAC.IDT_Profil_Temps as MATRIX_KEY, COUNT(*) as NB from dimclient FAC left join MTX.FactProfilClient_Temps_WRK WRK ON WRK.MATRIX_KEY = coalesce(FAC.IDT_Profil_Temps, -1) where WRK.MATRIX_KEY is null group by FAC.IDT_Profil_Temps union select 'IDT_Profil' AS Domaine, FAC.IDT_Profil as MATRIX_KEY, COUNT(*) as NB from dimclient FAC left join MTX.FactProfilClient_Profil_WRK WRK ON WRK.MATRIX_KEY = coalesce(FAC.IDT_Profil, -1) where WRK.MATRIX_KEY is null group by FAC.IDT_Profil
true
63cc68a30ad7846dcf66d99ee26795b65a9b4408
SQL
AlexWuDDD/SelfSQL
/MySQL/DDL语言/constraint.sql
UTF-8
4,789
4.65625
5
[]
no_license
#常见约束 /* 含义:一种限制,用于限制表中的数据,为了保证表中的数据的准确和可靠性 分类: 六大约束 NOT NULL: 非空 用于保证该字段的值不能为空,比如姓名,学号 等 DEFAULT: 默认 用于保证该字段有默认值,比如性别 PRIMARY KEY: 主键,用于保证该字段的值具有唯一性,并且非空,比如学号,员工编号 UNIQUE: 唯一,用于保证该字段的值具有唯一性,可以为空,比如座位号 CHECK: 检查约束[MYSQL 不支持]比如年龄,性别 FOREIGN KEY:外键,用于限制两个表的关系,用于保证该字段的值必须来自与住表的关联列的值 在我们的从表添加外键约束,用于引用主表中某列的值 比如学生表的专业编号,员工表的部门编号,员工表的工种编号 添加约束的时机: 1. 创建表时 2. 修改表时 约束的添加分类: - 列级约束 六大约束语法上都支持,但外键约束没有效果 - 表级约束 除了非空、默认,其他的都支持 主键和唯一的大对比: 保证唯一性 是否允许为空 一个表中可以有多少个 是否允许组合 主键 是 否 至多1个 是,但不推荐 唯一 是 是 可以有多个 是,但不推荐 insert into major values(1, 'java'); insert into major values(2, 'h5'); insert into stuinfo values(1,'john', '男', null, 19, 1); insert into stuinfo values(2,'lily', '男', null, 19, 2); 外键: 1. 要求在从表设置外键关系 2. 从表的外键列的类型和主表的关联列的类型要求一直或兼容,名称无所谓 3. 主表中的关联列必须是一个key(一般是主键或唯一) 4. 插入数据时,先插入主表再插入从表,删除数据时,先删除从表,再删除主表 */ /* CREATE TABLE 表民( 字段名 字段类型 列级约束, 字段名 字段类型 列级约束, 表级约束 ) */ CREATE DATABASE student; #一、创建表时添加约束 #1.添加列级约束 /* 语法: 直接在字段名和类型后面追加 约束类型即可 只支持 默认 非空 主键 唯一 */ USE student; CREATE TABLE IF NOT EXISTS major( id INT PRIMARY KEY, majorName VARCHAR(20) ); CREATE TABLE stuinfo( id INT PRIMARY KEY, stuName VARCHAR(20) NOT NULL, gender CHAR(1) CHECK(gender='男' OR gender='女'), seat INT UNIQUE, age INT DEFAULT 18, majorId INT REFERENCES major(id) ); DESC stuinfo; #查看stuinfo表中所有的索引,包括主键,外键,唯一 SHOW INDEX FROM stuinfo; #2、添加表级约束 /* 语法:在各个字段的最下面 [constraint 约束名] 约束类型(字段名) */ DROP TABLE IF EXISTS stuinfo; CREATE TABLE stuinfo( id INT, stuname VARCHAR(20), gender CHAR(1), seat INT, age INT, majorid INT, CONSTRAINT pk PRIMARY KEY(id), CONSTRAINT uq UNIQUE(seat), CONSTRAINT ck CHECK(gender='男' OR gender= '女'), CONSTRAINT fk_stuinfo_major FOREIGN KEY(majorid) REFERENCES major(id) ); DESC stuinfo; SHOW INDEX FROM stuinfo; #通用的写法: DROP TABLE IF EXISTS stuinfo; CREATE TABLE IF NOT EXISTS stuinfo( id INT PRIMARY KEY, stuname VARCHAR(20) NOT NULL, gender CHAR(1), age INT DEFAULT 18, seat INT UNIQUE, majorid INT, CONSTRAINT fk_stuinfo_majorid FOREIGN KEY(majorid) REFERENCES major(id) ); #二、修改表时添加约束 /* 1、添加列级约束 alter table 表民 modify column 字段名 字段类型 新约束 2、添加表级约束 alter table 表民 add [constraint 约束名] 约束类型(字段名) [外键的引用]; */ DROP TABLE IF EXISTS stuinfo; CREATE TABLE stuinfo( id INT, stuname VARCHAR(20), gender CHAR(1), seat INT, age INT, majorid INT ); #1. 添加非空约束 ALTER TABLE stuinfo MODIFY COLUMN stuname VARCHAR(20) NOT NULL; #2. 添加默认约束 ALTER TABLE stuinfo MODIFY COLUMN age INT DEFAULT 18; #3. 添加主键 #列级约束 ALTER TABLE stuinfo MODIFY COLUMN id INT PRIMARY KEY; #表级约束 ALTER TABLE stuinfo ADD PRIMARY KEY(id); #4.添加唯一 ALTER TABLE stuinfo MODIFY COLUMN seat INT UNIQUE; ALTER TABLE stuinfo ADD UNIQUE(seat); #5.添加外键 ALTER TABLE stuinfo ADD CONSTRAINT fk_stuinfo_majorid FOREIGN KEY (majorid) REFERENCES major(id); DESC stuinfo; #三、修改表时删除约束 #1.删除非空约束 ALTER TABLE stuinfo MODIFY COLUMN stuname VARCHAR(20) NULL; #2.删除默认约束 ALTER TABLE stuinfo MODIFY COLUMN age INT; #3.删除主键 ALTER TABLE stuinfo DROP PRIMARY KEY; #4.删除唯一 ALTER TABLE stuinfo DROP INDEX seat; #5.删除外键 ALTER TABLE stuinfo DROP FOREIGN KEY fk_stuinfo_majorid;
true
3a0ac6854eb5cb04bddbb08fd7fee8cc40fc02ed
SQL
razanHamzeh/Test2
/CONSTRAINTS/PHR_PACKAGE_TYPE.sql
UTF-8
1,084
2.765625
3
[]
no_license
-------------------------------------------------------- -- Constraints for Table PHR_PACKAGE_TYPE -------------------------------------------------------- ALTER TABLE "HISRHAMZEH"."PHR_PACKAGE_TYPE" ADD CONSTRAINT "PHR_PACKAGE_TYPE_PK" PRIMARY KEY ("ITEM_ID", "PACKAGE_TYPE_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ENABLE; ALTER TABLE "HISRHAMZEH"."PHR_PACKAGE_TYPE" MODIFY ("CREATED_DATE" NOT NULL ENABLE); ALTER TABLE "HISRHAMZEH"."PHR_PACKAGE_TYPE" MODIFY ("CREATED_BY" NOT NULL ENABLE); ALTER TABLE "HISRHAMZEH"."PHR_PACKAGE_TYPE" MODIFY ("UPDT_CNT" NOT NULL ENABLE); ALTER TABLE "HISRHAMZEH"."PHR_PACKAGE_TYPE" MODIFY ("PACKAGE_TYPE_ID" NOT NULL ENABLE); ALTER TABLE "HISRHAMZEH"."PHR_PACKAGE_TYPE" MODIFY ("ITEM_ID" NOT NULL ENABLE); ALTER TABLE "HISRHAMZEH"."PHR_PACKAGE_TYPE" MODIFY ("ACTIVE_IND" NOT NULL ENABLE);
true
f037ee246f469ddee19af21df5b523bc18c6123b
SQL
jackliuc/zot-team-jxing
/t_zot_cost.sql
UTF-8
313
2.90625
3
[]
no_license
USE ZOT; DROP TABLE T_ZOT_COST; CREATE TABLE T_ZOT_COST ( COST_ID VARCHAR(50) NOT NULL PRIMARY KEY, COST_TYPE VARCHAR(20) NOT NULL, COST_SUBTYPE VARCHAR(20) NOT NULL, REMARK VARCHAR(512), COST_AMOUNT FLOAT(10,1), COST_OPERATOR VARCHAR(20), COST_TIME TIMESTAMP, CREATE_TIME TIMESTAMP ); COMMIT;
true
289665d2c286877fc53d74d59764d2f8d2869fcd
SQL
8ova/TA-PBW
/inventory/inventory.sql
UTF-8
3,983
3.203125
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.0.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Waktu pembuatan: 13 Jan 2021 pada 11.37 -- Versi server: 10.4.14-MariaDB -- Versi PHP: 7.4.10 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: `inventory` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `notes` -- CREATE TABLE `notes` ( `id` int(11) NOT NULL, `contents` text NOT NULL, `admin` varchar(20) NOT NULL, `status` varchar(8) NOT NULL DEFAULT 'aktif' ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Struktur dari tabel `sbrg_keluar` -- CREATE TABLE `sbrg_keluar` ( `id` int(11) NOT NULL, `idx` int(11) NOT NULL, `tgl` date NOT NULL, `jumlah` int(11) NOT NULL, `penerima` varchar(35) NOT NULL, `keterangan` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Struktur dari tabel `sbrg_masuk` -- CREATE TABLE `sbrg_masuk` ( `id` int(11) NOT NULL, `idx` int(11) NOT NULL, `tgl` date NOT NULL, `jumlah` int(11) NOT NULL, `keterangan` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Struktur dari tabel `slogin` -- CREATE TABLE `slogin` ( `id` int(11) NOT NULL, `username` varchar(30) NOT NULL, `password` varchar(255) NOT NULL, `nickname` varchar(20) NOT NULL, `role` varchar(10) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `slogin` -- INSERT INTO `slogin` (`id`, `username`, `password`, `nickname`, `role`) VALUES (7, 'superadmin', '01c92d3c5e470cbc71b8a461b0ecff53', 'Super Admin', 'stock'), (9, 'Food', '01c92d3c5e470cbc71b8a461b0ecff53', 'food Engginer', 'kitchen'), (13, 'Coffe', '01c92d3c5e470cbc71b8a461b0ecff53', 'Coffe Guide', 'bar'); -- -------------------------------------------------------- -- -- Struktur dari tabel `sstock_brg` -- CREATE TABLE `sstock_brg` ( `idx` int(11) NOT NULL, `nama` varchar(55) NOT NULL, `divisi` varchar(20) NOT NULL, `berat` varchar(20) NOT NULL, `jenis` varchar(30) NOT NULL, `merk` varchar(40) NOT NULL, `stock` int(12) NOT NULL, `satuan` varchar(10) NOT NULL, `lokasi` varchar(55) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Indexes for dumped tables -- -- -- Indeks untuk tabel `notes` -- ALTER TABLE `notes` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `sbrg_keluar` -- ALTER TABLE `sbrg_keluar` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `sbrg_masuk` -- ALTER TABLE `sbrg_masuk` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `slogin` -- ALTER TABLE `slogin` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `sstock_brg` -- ALTER TABLE `sstock_brg` ADD PRIMARY KEY (`idx`); -- -- AUTO_INCREMENT untuk tabel yang dibuang -- -- -- AUTO_INCREMENT untuk tabel `notes` -- ALTER TABLE `notes` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=57; -- -- AUTO_INCREMENT untuk tabel `sbrg_keluar` -- ALTER TABLE `sbrg_keluar` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21; -- -- AUTO_INCREMENT untuk tabel `sbrg_masuk` -- ALTER TABLE `sbrg_masuk` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19; -- -- AUTO_INCREMENT untuk tabel `slogin` -- ALTER TABLE `slogin` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14; -- -- AUTO_INCREMENT untuk tabel `sstock_brg` -- ALTER TABLE `sstock_brg` MODIFY `idx` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=252; 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
f6ee82d3b167d567a87ffa06160b006e98c46fe3
SQL
JLGallardoV/animalia-despliegue-ZEIT
/public/BD/registros.sql
UTF-8
4,763
3
3
[]
no_license
--REGISTROS PRUEBA *NOTA SI SE ACABA DE EJECUTAR EL QUERY DE CREACION, DESHABILITAR EL DELIMITER : --PREMIOS: INSERT INTO premios (idPremio,premio,descripcionPremio) VALUES (NULL, 'envio gratis', 'unicamente republica mexicana'), (NULL, '15% descuento', 'unicamente en mascotas'); --TIPOS DE CLIENTES: INSERT INTO tiposDeClientes (idTipoCliente,tipoCliente,descripcionTipoCliente) VALUES (NULL, 'premium', 'descuentos unicos, envios gratis'), (NULL, 'premiado', 'segun sea el premio'), (NULL, 'normal', 'usuario ordinario'); --TIPOS DE PROBLEMAS: INSERT INTO tiposDeProblemas (idTipoProblema,tipoProblema) VALUES (NULL, 'caducado'), (NULL, 'mal estado'); --TIPOS DE USUARIOS INSERT INTO tiposDeUsuarios (idTipoUsuario,tipoUsuario,descripcionTipoUsuario) VALUES (NULL, 'gerente','opciones completas'), (NULL, 'vendedor', 'opciones limitadas'); --TIPOS DE PAGO: INSERT INTO tiposDePagos (idTipoPago,tipoPago,viaTipoPago, descripcionTipoPago) VALUES (NULL, 'tarjeta','visa', '12 meses s/intereses'), (NULL, 'efectivo', 'caja', 'sin descripcion'); --MEDIO DE ENTREGA: INSERT INTO mediosDeEntrega (idMedioEntrega,viaMedioEntrega, descripcionMedioEntrega) VALUES (NULL, 'DHL', 'sucursal'), (NULL, 'fedex', 'domicilio'); --ALMACENES: INSERT INTO almacenes (idAlmacen,ciudadAlmacen,estadoAlmacen,paisAlmacen,direccionAlmacen,referenciaAlmacen,telefonoAlmacen) VALUES (NULL, 'abasolo', 'gto', 'mexico', 'primavera 217','cerca de aurrera', '234211'), (NULL, 'irapuato', 'gto', 'mexico', 'las fresas 219', 'esquina hidalgo','4409245'); --CATEGORIAS: INSERT INTO categorias (idCategoria,nombreCategoria,subCategoria,descripcionCategoria) VALUES (NULL, 'articulos', 'correas', 'tambien se incluyen pecheras'), (NULL, 'alimentos', 'alimento humedo', 'productos unicamente enlatados'); --VENDEDORES: INSERT INTO vendedores (idVendedor,nombreVendedor,ciudadVendedor,estadoVendedor,direccionVendedor,telefonoVendedor,emailVendedor,fechaNacimientoVendedor,rfcVendedor,numeroSeguroSocialVendedor,antiguedadVendedor) VALUES (NULL, 'vendedor1', 'abasolo', 'gto', 'primavera 217', '4291226929', 'vendedor1@vendedor1.com', '2019-08-13', 'JKSLEOR', '234211','4'), (NULL, 'vendedor2', 'irapuato', 'gto', 'las fresas 219', '4621226929', 'vendedor2@vendedor2.com', '2019-08-15', 'FGRFDSG', '4409245','3'); --USUARIOS: INSERT INTO usuarios (idUsuario,nombreUsuario,emailUsuario,contraseniaUsuario,idVendedor,idTipoUsuario) VALUES (NULL, 'prueba1', 'prueba1@prueba1.com', '5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5',NULL, '1'); --PROVEEDORES: INSERT INTO proveedores (idProveedor,nombreProveedor,ciudadProveedor,estadoProveedor,paisProveedor,direccionProveedor,telefonoProveedor,emailProveedor,descripcionProveedor) VALUES (NULL, 'proveedor1', 'abdul', 'guato', 'india','alaa 210','2121230987','proveedor1@proveedor1.com','croquetas premium baratas'), (NULL, 'proveedor2', 'irapuato', 'gto', 'mexico','fresas 123','2121230987','proveedor2@proveedor2.com','proteina premium baratas'); --CLIENTES: INSERT INTO clientes (idCliente,nombreCliente,apellidoPaternoCliente,apellidoMaternoCliente,ciudadCliente,estadoCliente,paisCliente,direccionCliente,coloniaCliente,cpCliente,telefonoCliente,emailCliente, contraseniaCliente, puntuajeCliente,fechaRegistroCliente,fechaActualizacionCliente,idTipoCliente) VALUES (NULL, 'cliente1', 'perez', 'figueroa', 'abasolo','gto','mexico','juarez 101','colonia juarez','36970','4291093589','cliente1@cliente1.com','1234','1200',NULL,NULL,1), (NULL, 'cliente2', 'conde', 'jimenez', 'leon','gto','mexico','juarez 201','colonia juarez','36970','4291093589','cliente2@cliente2.com','1234','1200',NULL,NULL,2); --CARRITOS: INSERT INTO carritos (numeroProductosCarrito,montoTotalCarrito,idCliente) VALUES ('10', '100.00','1'); --PRODUCTOS: INSERT INTO productos (idProducto,nombreProducto,detalleProducto,contenidoProducto,fechaCaducidadProducto,paisOrigenProducto,stockProducto,puntosProducto,precioUnitarioProducto,precioCompraProducto,idCategoria,idAlmacen) VALUES (NULL, 'collar de castigo', 'marca granpet','1 corrar de castigo mediano',NULL,'e.u.','20','100','30.00','20','1','1'), (NULL, 'collar de entrenar', 'marca grandog','1 corrar de entrenamiento mediano',NULL,'e.u.','20','100','30.00','20','1','1'), (NULL, 'bulto croqueta adulto', 'marca pedigrie','25 kg','2020-02-10','mexico.','20','100','30.00','20','1','1'); --COMPENSACIONES: INSERT INTO compensaciones (idCompensacion,tipoCompensacion,descripcionCompensacion) VALUES (NULL, 'regreso dinero','devolucion total efectivo'), (NULL, 'cambio producto','otro producto del mismo precio'); --DEVOLUCIONES: INSERT INTO devoluciones (idDevolucion,motivoDevolucion,idCliente,idTipoProblema,idCompensacion,idProducto,idTransaccion) VALUES (NULL,'mal estado, oxidado','1','1','1','1','1'), (NULL,'caducada','1','2','1','2','1');
true
92ef62a23d3f16e670eb5171be410f2af87337f6
SQL
BlueSun288/OrderUpDatabase
/Documentation/Presentation/querys.sql
UTF-8
1,221
4.15625
4
[ "Apache-2.0" ]
permissive
-- Use Case Querys select distinct tablearea.name as `Table Area`, fname as `First Name`, lname as `Last Name` from employees natural join manages join tablearea where employees.ID = manages.Employees_ID and tablearea.ID=manages.TableArea_ID; select tables.ID as `Table ID`, orders.ID as `Order ID`, orders.status as `Order Status` from tables join orders where tables.ID = orders.Tables_ID; select orders.Tables_ID as "Table", contains.Orders_ID as "Order #", orderables.name as "Item Name", price as "Item Price" from contains join orders join orderables where orders.Tables_ID = "1" and orders.ID = contains.Orders_ID and orderables.ID = contains.Orderables_ID; lock table orders WRITE; insert into orders values (51, 1, "Placed"); lock table contains WRITE; insert into contains values (51, 3), (51, 21), (51, 39); unlock tables; select contains.orders_ID as "Order #", orderables.name as "Item Name", price as "Price" from contains join orderables where contains.orders_ID = "1" and contains.orderables_ID = orderables.ID; select contains.orders_ID as "Order #", sum(price) as "Total Price" from contains join orderables where contains.orders_ID = "1" and contains.orderables_ID = orderables.ID;
true
957e56af7ac90c06f4a08acdf04bd482b527b801
SQL
jakiichu/practiuc2
/mydatabase.sql
UTF-8
3,363
3.421875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.0.1 -- https://www.phpmyadmin.net/ -- -- Хост: 127.0.0.1 -- Время создания: Апр 06 2021 г., 17:57 -- Версия сервера: 10.3.16-MariaDB -- Версия PHP: 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 */; -- -- База данных: `mydatabase` -- -- -------------------------------------------------------- -- -- Структура таблицы `coment` -- CREATE TABLE `coment` ( `id` smallint(5) UNSIGNED NOT NULL, `name` varchar(50) NOT NULL, `coments` varchar(300) NOT NULL, `id_news` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Дамп данных таблицы `coment` -- INSERT INTO `coment` (`id`, `name`, `coments`, `id_news`) VALUES (17, 'zxc', 'zxczxczxc', 16), (18, 'zxc', 'gsdsdgsdg', 16); -- -------------------------------------------------------- -- -- Структура таблицы `news` -- CREATE TABLE `news` ( `id` smallint(5) UNSIGNED NOT NULL, `headline` text CHARACTER SET latin1 NOT NULL, `story` text CHARACTER SET latin1 NOT NULL, `name` varchar(255) CHARACTER SET latin1 DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `news` -- INSERT INTO `news` (`id`, `headline`, `story`, `name`) VALUES (16, 'asfasfaasfasassfasf', 'fasfasfasf', 'zxc'); -- -------------------------------------------------------- -- -- Структура таблицы `portfolio` -- CREATE TABLE `portfolio` ( `id` smallint(5) UNSIGNED NOT NULL, `name` varchar(255) DEFAULT NULL, `Site` varchar(255) DEFAULT NULL, `Description` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Дамп данных таблицы `portfolio` -- INSERT INTO `portfolio` (`id`, `name`, `Site`, `Description`) VALUES (11, 'qewegwegww', 'wegwegweg', 'wegwegwergsdgsdegwg'), (12, 'fafgafasdgsdgsdgsdfgdfgd', 'asfasdf', 'edrtghrtdghrtdfghdfrgrtdfgrtdfgrtdfg'), (15, 'wadawd', 'awdasd', 'awdasd'); -- -- Индексы сохранённых таблиц -- -- -- Индексы таблицы `coment` -- ALTER TABLE `coment` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `news` -- ALTER TABLE `news` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `portfolio` -- ALTER TABLE `portfolio` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT для сохранённых таблиц -- -- -- AUTO_INCREMENT для таблицы `coment` -- ALTER TABLE `coment` MODIFY `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19; -- -- AUTO_INCREMENT для таблицы `news` -- ALTER TABLE `news` MODIFY `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; -- -- AUTO_INCREMENT для таблицы `portfolio` -- ALTER TABLE `portfolio` MODIFY `id` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; 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
1cbbcdaf858e54c097e91a7465c430b911007a64
SQL
postgres/postgres
/src/test/regress/sql/tsearch.sql
UTF-8
37,664
3.578125
4
[ "PostgreSQL" ]
permissive
-- directory paths are passed to us in environment variables \getenv abs_srcdir PG_ABS_SRCDIR -- -- Sanity checks for text search catalogs -- -- NB: we assume the oidjoins test will have caught any dangling links, -- that is OID or REGPROC fields that are not zero and do not match some -- row in the linked-to table. However, if we want to enforce that a link -- field can't be 0, we have to check it here. -- Find unexpected zero link entries SELECT oid, prsname FROM pg_ts_parser WHERE prsnamespace = 0 OR prsstart = 0 OR prstoken = 0 OR prsend = 0 OR -- prsheadline is optional prslextype = 0; SELECT oid, dictname FROM pg_ts_dict WHERE dictnamespace = 0 OR dictowner = 0 OR dicttemplate = 0; SELECT oid, tmplname FROM pg_ts_template WHERE tmplnamespace = 0 OR tmpllexize = 0; -- tmplinit is optional SELECT oid, cfgname FROM pg_ts_config WHERE cfgnamespace = 0 OR cfgowner = 0 OR cfgparser = 0; SELECT mapcfg, maptokentype, mapseqno FROM pg_ts_config_map WHERE mapcfg = 0 OR mapdict = 0; -- Look for pg_ts_config_map entries that aren't one of parser's token types SELECT * FROM ( SELECT oid AS cfgid, (ts_token_type(cfgparser)).tokid AS tokid FROM pg_ts_config ) AS tt RIGHT JOIN pg_ts_config_map AS m ON (tt.cfgid=m.mapcfg AND tt.tokid=m.maptokentype) WHERE tt.cfgid IS NULL OR tt.tokid IS NULL; -- Load some test data CREATE TABLE test_tsvector( t text, a tsvector ); \set filename :abs_srcdir '/data/tsearch.data' COPY test_tsvector FROM :'filename'; ANALYZE test_tsvector; -- test basic text search behavior without indexes, then with SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'; SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}'); SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'; create index wowidx on test_tsvector using gist (a); SET enable_seqscan=OFF; SET enable_indexscan=ON; SET enable_bitmapscan=OFF; explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'; SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}'); SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'; SET enable_indexscan=OFF; SET enable_bitmapscan=ON; explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'; SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}'); SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'; -- Test siglen parameter of GiST tsvector_ops CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(foo=1)); CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=0)); CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=2048)); CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=100,foo='bar')); CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=100, siglen = 200)); CREATE INDEX wowidx2 ON test_tsvector USING gist (a tsvector_ops(siglen=1)); \d test_tsvector DROP INDEX wowidx; EXPLAIN (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'; SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}'); SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'; DROP INDEX wowidx2; CREATE INDEX wowidx ON test_tsvector USING gist (a tsvector_ops(siglen=484)); \d test_tsvector EXPLAIN (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'; SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}'); SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'; RESET enable_seqscan; RESET enable_indexscan; RESET enable_bitmapscan; DROP INDEX wowidx; CREATE INDEX wowidx ON test_tsvector USING gin (a); SET enable_seqscan=OFF; -- GIN only supports bitmapscan, so no need to test plain indexscan explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'; SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'; SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}'); SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'; SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'; SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'; SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'; SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'; -- Test optimization of non-empty GIN_SEARCH_MODE_ALL queries EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ '!qh'; SELECT count(*) FROM test_tsvector WHERE a @@ '!qh'; EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr' AND a @@ '!qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr' AND a @@ '!qh'; RESET enable_seqscan; INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH'); SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10; SELECT * FROM ts_stat('SELECT a FROM test_tsvector', 'AB') ORDER BY ndoc DESC, nentry DESC, word; --dictionaries and to_tsvector SELECT ts_lexize('english_stem', 'skies'); SELECT ts_lexize('english_stem', 'identity'); SELECT * FROM ts_token_type('default'); SELECT * FROM ts_parse('default', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>"> /usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 <i <b> wow < jqw <> qwerty'); SELECT to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>"> /usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 <i <b> wow < jqw <> qwerty'); SELECT length(to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>"> /usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 <i <b> wow < jqw <> qwerty')); -- ts_debug SELECT * from ts_debug('english', '<myns:foo-bar_baz.blurfl>abc&nm1;def&#xa9;ghi&#245;jkl</myns:foo-bar_baz.blurfl>'); -- check parsing of URLs SELECT * from ts_debug('english', 'http://www.harewoodsolutions.co.uk/press.aspx</span>'); SELECT * from ts_debug('english', 'http://aew.wer0c.ewr/id?ad=qwe&dw<span>'); SELECT * from ts_debug('english', 'http://5aew.werc.ewr:8100/?'); SELECT * from ts_debug('english', '5aew.werc.ewr:8100/?xx'); SELECT token, alias, dictionaries, dictionaries is null as dnull, array_dims(dictionaries) as ddims, lexemes, lexemes is null as lnull, array_dims(lexemes) as ldims from ts_debug('english', 'a title'); -- to_tsquery SELECT to_tsquery('english', 'qwe & sKies '); SELECT to_tsquery('simple', 'qwe & sKies '); SELECT to_tsquery('english', '''the wether'':dc & '' sKies '':BC '); SELECT to_tsquery('english', 'asd&(and|fghj)'); SELECT to_tsquery('english', '(asd&and)|fghj'); SELECT to_tsquery('english', '(asd&!and)|fghj'); SELECT to_tsquery('english', '(the|and&(i&1))&fghj'); SELECT plainto_tsquery('english', 'the and z 1))& fghj'); SELECT plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd'); SELECT plainto_tsquery('english', 'foo bar') || plainto_tsquery('english', 'asd fg'); SELECT plainto_tsquery('english', 'foo bar') || !!plainto_tsquery('english', 'asd fg'); SELECT plainto_tsquery('english', 'foo bar') && 'asd | fg'; -- Check stop word deletion, a and s are stop-words SELECT to_tsquery('english', '!(a & !b) & c'); SELECT to_tsquery('english', '!(a & !b)'); SELECT to_tsquery('english', '(1 <-> 2) <-> a'); SELECT to_tsquery('english', '(1 <-> a) <-> 2'); SELECT to_tsquery('english', '(a <-> 1) <-> 2'); SELECT to_tsquery('english', 'a <-> (1 <-> 2)'); SELECT to_tsquery('english', '1 <-> (a <-> 2)'); SELECT to_tsquery('english', '1 <-> (2 <-> a)'); SELECT to_tsquery('english', '(1 <-> 2) <3> a'); SELECT to_tsquery('english', '(1 <-> a) <3> 2'); SELECT to_tsquery('english', '(a <-> 1) <3> 2'); SELECT to_tsquery('english', 'a <3> (1 <-> 2)'); SELECT to_tsquery('english', '1 <3> (a <-> 2)'); SELECT to_tsquery('english', '1 <3> (2 <-> a)'); SELECT to_tsquery('english', '(1 <3> 2) <-> a'); SELECT to_tsquery('english', '(1 <3> a) <-> 2'); SELECT to_tsquery('english', '(a <3> 1) <-> 2'); SELECT to_tsquery('english', 'a <-> (1 <3> 2)'); SELECT to_tsquery('english', '1 <-> (a <3> 2)'); SELECT to_tsquery('english', '1 <-> (2 <3> a)'); SELECT to_tsquery('english', '((a <-> 1) <-> 2) <-> s'); SELECT to_tsquery('english', '(2 <-> (a <-> 1)) <-> s'); SELECT to_tsquery('english', '((1 <-> a) <-> 2) <-> s'); SELECT to_tsquery('english', '(2 <-> (1 <-> a)) <-> s'); SELECT to_tsquery('english', 's <-> ((a <-> 1) <-> 2)'); SELECT to_tsquery('english', 's <-> (2 <-> (a <-> 1))'); SELECT to_tsquery('english', 's <-> ((1 <-> a) <-> 2)'); SELECT to_tsquery('english', 's <-> (2 <-> (1 <-> a))'); SELECT to_tsquery('english', '((a <-> 1) <-> s) <-> 2'); SELECT to_tsquery('english', '(s <-> (a <-> 1)) <-> 2'); SELECT to_tsquery('english', '((1 <-> a) <-> s) <-> 2'); SELECT to_tsquery('english', '(s <-> (1 <-> a)) <-> 2'); SELECT to_tsquery('english', '2 <-> ((a <-> 1) <-> s)'); SELECT to_tsquery('english', '2 <-> (s <-> (a <-> 1))'); SELECT to_tsquery('english', '2 <-> ((1 <-> a) <-> s)'); SELECT to_tsquery('english', '2 <-> (s <-> (1 <-> a))'); SELECT to_tsquery('english', 'foo <-> (a <-> (the <-> bar))'); SELECT to_tsquery('english', '((foo <-> a) <-> the) <-> bar'); SELECT to_tsquery('english', 'foo <-> a <-> the <-> bar'); SELECT phraseto_tsquery('english', 'PostgreSQL can be extended by the user in many ways'); SELECT ts_rank_cd(to_tsvector('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) '), to_tsquery('english', 'paint&water')); SELECT ts_rank_cd(to_tsvector('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) '), to_tsquery('english', 'breath&motion&water')); SELECT ts_rank_cd(to_tsvector('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) '), to_tsquery('english', 'ocean')); SELECT ts_rank_cd(to_tsvector('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) '), to_tsquery('english', 'painted <-> Ship')); SELECT ts_rank_cd(strip(to_tsvector('both stripped')), to_tsquery('both & stripped')); SELECT ts_rank_cd(to_tsvector('unstripped') || strip(to_tsvector('stripped')), to_tsquery('unstripped & stripped')); --headline tests SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'paint&water')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'breath&motion&water')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'ocean')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'day & drink')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'day | drink')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'day | !drink')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'painted <-> Ship & drink')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'painted <-> Ship | drink')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'painted <-> Ship | !drink')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', phraseto_tsquery('english', 'painted Ocean')); SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', phraseto_tsquery('english', 'idle as a painted Ship')); SELECT ts_headline('english', 'Lorem ipsum urna. Nullam nullam ullamcorper urna.', to_tsquery('english','Lorem') && phraseto_tsquery('english','ullamcorper urna'), 'MaxWords=100, MinWords=1'); SELECT ts_headline('english', 'Lorem ipsum urna. Nullam nullam ullamcorper urna.', phraseto_tsquery('english','ullamcorper urna'), 'MaxWords=100, MinWords=5'); SELECT ts_headline('english', ' <html> <!-- some comment --> <body> Sea view wow <u>foo bar</u> <i>qq</i> <a href="http://www.google.com/foo.bar.html" target="_blank">YES &nbsp;</a> ff-bg <script> document.write(15); </script> </body> </html>', to_tsquery('english', 'sea&foo'), 'HighlightAll=true'); SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 <-> 3', 'MaxWords=2, MinWords=1'); SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 & 3', 'MaxWords=4, MinWords=1'); SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 <-> 3', 'MaxWords=4, MinWords=1'); --Check if headline fragments work SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'ocean'), 'MaxFragments=1'); --Check if more than one fragments are displayed SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2'); --Fragments when there all query words are not in the document SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'ocean & seahorse'), 'MaxFragments=1'); --FragmentDelimiter option SELECT ts_headline('english', ' Day after day, day after day, We stuck, nor breath nor motion, As idle as a painted Ship Upon a painted Ocean. Water, water, every where And all the boards did shrink; Water, water, every where, Nor any drop to drink. S. T. Coleridge (1772-1834) ', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2,FragmentDelimiter=***'); --Fragments with phrase search SELECT ts_headline('english', 'Lorem ipsum urna. Nullam nullam ullamcorper urna.', to_tsquery('english','Lorem') && phraseto_tsquery('english','ullamcorper urna'), 'MaxFragments=100, MaxWords=100, MinWords=1'); -- Edge cases with empty query SELECT ts_headline('english', '', to_tsquery('english', '')); SELECT ts_headline('english', 'foo bar', to_tsquery('english', '')); --Rewrite sub system CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT); \set ECHO none \copy test_tsquery from stdin 'New York' new <-> york | big <-> apple | nyc Moscow moskva | moscow 'Sanct Peter' Peterburg | peter | 'Sanct Peterburg' foo & bar & qq foo & (bar | qq) & city 1 & (2 <-> 3) 2 <-> 4 5 <-> 6 5 <-> 7 \. \set ECHO all ALTER TABLE test_tsquery ADD COLUMN keyword tsquery; UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword); ALTER TABLE test_tsquery ADD COLUMN sample tsquery; UPDATE test_tsquery SET sample = to_tsquery('english', txtsample::text); SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new <-> york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new <-> york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new <-> york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new <-> york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new <-> york'; CREATE UNIQUE INDEX bt_tsq ON test_tsquery (keyword); SET enable_seqscan=OFF; SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new <-> york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new <-> york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new <-> york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new <-> york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new <-> york'; RESET enable_seqscan; SELECT ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big & apple | nyc | new & york & city'); SELECT ts_rewrite(ts_rewrite('new & !york ', 'york', '!jersey'), 'jersey', 'mexico'); SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text ); SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text ); SELECT ts_rewrite('bar & qq & foo & (new <-> york)', 'SELECT keyword, sample FROM test_tsquery'::text ); SELECT ts_rewrite( 'moscow', 'SELECT keyword, sample FROM test_tsquery'); SELECT ts_rewrite( 'moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'); SELECT ts_rewrite( 'bar & qq & foo & (new <-> york)', 'SELECT keyword, sample FROM test_tsquery'); SELECT ts_rewrite('1 & (2 <-> 3)', 'SELECT keyword, sample FROM test_tsquery'::text ); SELECT ts_rewrite('1 & (2 <2> 3)', 'SELECT keyword, sample FROM test_tsquery'::text ); SELECT ts_rewrite('5 <-> (1 & (2 <-> 3))', 'SELECT keyword, sample FROM test_tsquery'::text ); SELECT ts_rewrite('5 <-> (6 | 8)', 'SELECT keyword, sample FROM test_tsquery'::text ); -- Check empty substitution SELECT ts_rewrite(to_tsquery('5 & (6 | 5)'), to_tsquery('5'), to_tsquery('')); SELECT ts_rewrite(to_tsquery('!5'), to_tsquery('5'), to_tsquery('')); SELECT keyword FROM test_tsquery WHERE keyword @> 'new'; SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'new'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow'; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query; CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops); SET enable_seqscan=OFF; SELECT keyword FROM test_tsquery WHERE keyword @> 'new'; SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'new'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow'; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query; SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query; SELECT ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz'); SELECT to_tsvector('foo bar') @@ ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz'); SELECT to_tsvector('bar baz') @@ ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz'); RESET enable_seqscan; --test GUC SET default_text_search_config=simple; SELECT to_tsvector('SKIES My booKs'); SELECT plainto_tsquery('SKIES My booKs'); SELECT to_tsquery('SKIES & My | booKs'); SET default_text_search_config=english; SELECT to_tsvector('SKIES My booKs'); SELECT plainto_tsquery('SKIES My booKs'); SELECT to_tsquery('SKIES & My | booKs'); --trigger CREATE TRIGGER tsvectorupdate BEFORE UPDATE OR INSERT ON test_tsvector FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(a, 'pg_catalog.english', t); SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); INSERT INTO test_tsvector (t) VALUES ('345 qwerty'); SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); UPDATE test_tsvector SET t = null WHERE t = '345 qwerty'; SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); INSERT INTO test_tsvector (t) VALUES ('345 qwerty'); SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); -- Test inlining of immutable constant functions -- to_tsquery(text) is not immutable, so it won't be inlined explain (costs off) select * from test_tsquery, to_tsquery('new') q where txtsample @@ q; -- to_tsquery(regconfig, text) is an immutable function. -- That allows us to get rid of using function scan and join at all. explain (costs off) select * from test_tsquery, to_tsquery('english', 'new') q where txtsample @@ q; -- test finding items in GIN's pending list create temp table pendtest (ts tsvector); create index pendtest_idx on pendtest using gin(ts); insert into pendtest values (to_tsvector('Lore ipsam')); insert into pendtest values (to_tsvector('Lore ipsum')); select * from pendtest where 'ipsu:*'::tsquery @@ ts; select * from pendtest where 'ipsa:*'::tsquery @@ ts; select * from pendtest where 'ips:*'::tsquery @@ ts; select * from pendtest where 'ipt:*'::tsquery @@ ts; select * from pendtest where 'ipi:*'::tsquery @@ ts; --check OP_PHRASE on index create temp table phrase_index_test(fts tsvector); insert into phrase_index_test values ('A fat cat has just eaten a rat.'); insert into phrase_index_test values (to_tsvector('english', 'A fat cat has just eaten a rat.')); create index phrase_index_test_idx on phrase_index_test using gin(fts); set enable_seqscan = off; select * from phrase_index_test where fts @@ phraseto_tsquery('english', 'fat cat'); set enable_seqscan = on; -- test websearch_to_tsquery function select websearch_to_tsquery('simple', 'I have a fat:*ABCD cat'); select websearch_to_tsquery('simple', 'orange:**AABBCCDD'); select websearch_to_tsquery('simple', 'fat:A!cat:B|rat:C<'); select websearch_to_tsquery('simple', 'fat:A : cat:B'); select websearch_to_tsquery('simple', 'fat*rat'); select websearch_to_tsquery('simple', 'fat-rat'); select websearch_to_tsquery('simple', 'fat_rat'); -- weights are completely ignored select websearch_to_tsquery('simple', 'abc : def'); select websearch_to_tsquery('simple', 'abc:def'); select websearch_to_tsquery('simple', 'a:::b'); select websearch_to_tsquery('simple', 'abc:d'); select websearch_to_tsquery('simple', ':'); -- these operators are ignored select websearch_to_tsquery('simple', 'abc & def'); select websearch_to_tsquery('simple', 'abc | def'); select websearch_to_tsquery('simple', 'abc <-> def'); select websearch_to_tsquery('simple', 'abc (pg or class)'); -- NOT is ignored in quotes select websearch_to_tsquery('english', 'My brand new smartphone'); select websearch_to_tsquery('english', 'My brand "new smartphone"'); select websearch_to_tsquery('english', 'My brand "new -smartphone"'); -- test OR operator select websearch_to_tsquery('simple', 'cat or rat'); select websearch_to_tsquery('simple', 'cat OR rat'); select websearch_to_tsquery('simple', 'cat "OR" rat'); select websearch_to_tsquery('simple', 'cat OR'); select websearch_to_tsquery('simple', 'OR rat'); select websearch_to_tsquery('simple', '"fat cat OR rat"'); select websearch_to_tsquery('simple', 'fat (cat OR rat'); select websearch_to_tsquery('simple', 'or OR or'); -- OR is an operator here ... select websearch_to_tsquery('simple', '"fat cat"or"fat rat"'); select websearch_to_tsquery('simple', 'fat or(rat'); select websearch_to_tsquery('simple', 'fat or)rat'); select websearch_to_tsquery('simple', 'fat or&rat'); select websearch_to_tsquery('simple', 'fat or|rat'); select websearch_to_tsquery('simple', 'fat or!rat'); select websearch_to_tsquery('simple', 'fat or<rat'); select websearch_to_tsquery('simple', 'fat or>rat'); select websearch_to_tsquery('simple', 'fat or '); -- ... but not here select websearch_to_tsquery('simple', 'abc orange'); select websearch_to_tsquery('simple', 'abc OR1234'); select websearch_to_tsquery('simple', 'abc or-abc'); select websearch_to_tsquery('simple', 'abc OR_abc'); -- test quotes select websearch_to_tsquery('english', '"pg_class pg'); select websearch_to_tsquery('english', 'pg_class pg"'); select websearch_to_tsquery('english', '"pg_class pg"'); select websearch_to_tsquery('english', '"pg_class : pg"'); select websearch_to_tsquery('english', 'abc "pg_class pg"'); select websearch_to_tsquery('english', '"pg_class pg" def'); select websearch_to_tsquery('english', 'abc "pg pg_class pg" def'); select websearch_to_tsquery('english', ' or "pg pg_class pg" or '); select websearch_to_tsquery('english', '""pg pg_class pg""'); select websearch_to_tsquery('english', 'abc """"" def'); select websearch_to_tsquery('english', 'cat -"fat rat"'); select websearch_to_tsquery('english', 'cat -"fat rat" cheese'); select websearch_to_tsquery('english', 'abc "def -"'); select websearch_to_tsquery('english', 'abc "def :"'); select websearch_to_tsquery('english', '"A fat cat" has just eaten a -rat.'); select websearch_to_tsquery('english', '"A fat cat" has just eaten OR !rat.'); select websearch_to_tsquery('english', '"A fat cat" has just (+eaten OR -rat)'); select websearch_to_tsquery('english', 'this is ----fine'); select websearch_to_tsquery('english', '(()) )))) this ||| is && -fine, "dear friend" OR good'); select websearch_to_tsquery('english', 'an old <-> cat " is fine &&& too'); select websearch_to_tsquery('english', '"A the" OR just on'); select websearch_to_tsquery('english', '"a fat cat" ate a rat'); select to_tsvector('english', 'A fat cat ate a rat') @@ websearch_to_tsquery('english', '"a fat cat" ate a rat'); select to_tsvector('english', 'A fat grey cat ate a rat') @@ websearch_to_tsquery('english', '"a fat cat" ate a rat'); -- cases handled by gettoken_tsvector() select websearch_to_tsquery(''''); select websearch_to_tsquery('''abc''''def'''); select websearch_to_tsquery('\abc'); select websearch_to_tsquery('\');
true
8f8720d4f550bd5bdf04528a4630909d9d11e178
SQL
MengFree/vue-express
/todo.sql
UTF-8
1,762
3.15625
3
[]
no_license
/* SQLyog v12.2.6 (64 bit) MySQL - 5.5.53 : Database - todo ********************************************************************* */ /*!40101 SET NAMES utf8 */; /*!40101 SET SQL_MODE=''*/; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/`todo` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `todo`; /*Table structure for table `action` */ DROP TABLE IF EXISTS `action`; CREATE TABLE `action` ( `id` int(64) NOT NULL AUTO_INCREMENT, `content` varchar(250) NOT NULL, `title` varchar(100) DEFAULT NULL, `creatTime` bigint(64) NOT NULL, `updateTime` bigint(64) DEFAULT NULL, `userId` int(32) NOT NULL, `time` int(20) DEFAULT NULL, `status` int(2) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=59 DEFAULT CHARSET=utf8; /*Table structure for table `user` */ DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `userName` varchar(100) NOT NULL COMMENT '用户名', `email` varchar(150) NOT NULL COMMENT '邮箱地址', `userId` int(32) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户id', `password` varchar(200) NOT NULL COMMENT '密码', `modi_ver` int(11) NOT NULL DEFAULT '1' COMMENT '修改标记', PRIMARY KEY (`userId`) ) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
true
26cc60e25fe85dad0af62b72228a36da61a5b496
SQL
s3444261/picnic
/admin/createDB/createDb.sql
UTF-8
5,205
3.875
4
[]
no_license
/* Authors: * Derrick, Troy - s3202752@student.rmit.edu.au * Foster, Diane - s3387562@student.rmit.edu.au * Goodreds, Allen - s3492264@student.rmit.edu.au * Kinkead, Grant - s3444261@student.rmit.edu.au * Putro, Edwan - s3418650@student.rmit.edu.au */ DROP TABLE IF EXISTS `Comments`; DROP TABLE IF EXISTS `Category_items`; DROP TABLE IF EXISTS `User_ratings`; DROP TABLE IF EXISTS `Item_matches`; DROP TABLE IF EXISTS `Items`; DROP TABLE IF EXISTS `Categories`; DROP TABLE IF EXISTS `Users`; CREATE TABLE `Users` ( `userID` int(11) NOT NULL AUTO_INCREMENT, `user` varchar(45) NOT NULL, `email` varchar(90) NOT NULL, `password` varchar(45) NULL, `status` varchar(45) NOT NULL, `activate` varchar(32) DEFAULT NULL, `blocked` tinyint(1) DEFAULT 0, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`userID`), UNIQUE KEY `email_UNIQUE` (`email`), UNIQUE KEY `user_UNIQUE` (`user`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `Categories` ( `categoryID` int(11) NOT NULL AUTO_INCREMENT, `parentID` int(11), `category` varchar(90) NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`categoryID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER TABLE Categories ADD CONSTRAINT FK_Categories_Categories FOREIGN KEY (`parentID`) REFERENCES `Categories` (`categoryID`) ON DELETE CASCADE ON UPDATE CASCADE; CREATE TABLE `Items` ( `itemID` bigint(11) NOT NULL AUTO_INCREMENT, `type` ENUM('ForSale', 'Wanted') NOT NULL, `owningUserID` int(11) NOT NULL, `title` text NOT NULL, `description` text NOT NULL, `quantity` varchar(12) NOT NULL, `itemcondition` ENUM('New', 'Used') NOT NULL, `price` varchar(16) NOT NULL, `status` ENUM('Active', 'Deleted', 'Completed') NOT NULL DEFAULT 'Active', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, CHECK (quantity > 0), PRIMARY KEY (`itemID`), CONSTRAINT `FK_Items_Users` FOREIGN KEY (`owningUserID`) REFERENCES `Users` (`userID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `Item_matches` ( `lhsItemID` bigint(11) NOT NULL, `rhsItemID` bigint(11) NOT NULL, `lhsStatus` ENUM('None', 'Accepted', 'Rejected') NOT NULL DEFAULT 'None', `rhsStatus` ENUM('None', 'Accepted', 'Rejected') NOT NULL DEFAULT 'None', PRIMARY KEY (`lhsItemID`, `rhsItemID`), KEY `FK_Item_matches_Items_idx` (`lhsItemID`), KEY `FK_Item_matches_Items_idx2` (`rhsItemID`), CHECK (lhsItemID < rhsItemID), CONSTRAINT `FK_Item_matches_Items` FOREIGN KEY (`lhsItemID`) REFERENCES `Items` (`itemID`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FK_Item_matches_Items2` FOREIGN KEY (`rhsItemID`) REFERENCES `Items` (`itemID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `User_ratings` ( `sourceItemID` bigint(11) NOT NULL, `targetItemID` bigint(11) NOT NULL, `rating` int(11) NULL, `accessCode` varchar(32), `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `rating_left_at` timestamp NULL, PRIMARY KEY ( `sourceItemID`, `targetItemID`), CHECK (rating > 0), CHECK (rating <= 5), KEY `FK_User_ratings_Items_idx` (`sourceItemID`), KEY `FK_User_ratings_Items_idx2`(`targetItemID`), CONSTRAINT `FK_User_ratings_Item_matches` FOREIGN KEY (`sourceItemID`, `targetItemID`) REFERENCES `Item_matches` (`lhsItemID`, `rhsItemID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `Category_items` ( `itemID` bigint(11) NOT NULL, `categoryID` int(11) NOT NULL, PRIMARY KEY (`itemID`,`categoryID`), UNIQUE KEY `UQ_categoryID_itemID` (`itemID`,`categoryID`), KEY `FK_Item_idx` (`itemID`), KEY `FK_Category_idx` (`categoryID`), CONSTRAINT `FK_Item` FOREIGN KEY (`itemID`) REFERENCES `Items` (`itemID`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FK_Category` FOREIGN KEY (`categoryID`) REFERENCES `Categories` (`categoryID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `Comments` ( `commentID` int(11) NOT NULL AUTO_INCREMENT, `toUserID` int(11) NOT NULL, `fromUserID` int(11) NOT NULL, `itemID` bigint(11) NOT NULL, `comment` text NOT NULL, `status` varchar(16) NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`commentID`), KEY `FK_Comments_ToUser_idx` (`toUserID`), KEY `FK_Comments_FromUser_idx` (`fromUserID`), CONSTRAINT `FK_Comments_Item` FOREIGN KEY (`itemID`) REFERENCES `Items` (`itemID`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FK_Comments_ToUser` FOREIGN KEY (`toUserID`) REFERENCES `Users` (`userID`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FK_Comments_FromUser` FOREIGN KEY (`fromUserID`) REFERENCES `Users` (`userID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
true
9a036b7afdfb533bfe1f5c5d64c3df91744a4544
SQL
PawelPeczek/ConferencesDatabase
/StoredProcedures/ManagingParticipantsAtConfDay/AssignParticipantsAtConfDay.sql
UTF-8
306
2.78125
3
[]
no_license
CREATE TYPE PARTICIPANTS_BATCH AS TABLE( ParticipantID INT ) DROP PROCEDURE AssignParticipantsAtConfDay CREATE PROCEDURE AssignParticipantsAtConfDay( @OrdOnConfDayID INT, @data PARTICIPANTS_BATCH READONLY ) AS BEGIN INSERT INTO ParticipAtConfDay SELECT ParticipantID, @OrdOnConfDayID FROM @data END
true
b64d48d91be244b3bde59f67dd35d27d876a6226
SQL
georgetown-cset/contending-frames
/data/world_without_work_frame.sql
UTF-8
5,463
3.390625
3
[]
no_license
with ln as ( -- Select analytic corpus select title, subTitle, content, source.category as source_category, source.editorialRank as editorialRank, matchingKeywords, extract(year from publishedDate) as year, source.name as source_name, url, lower(coalesce(title, "") || " " || coalesce(subTitle, "") || " " || coalesce(content, "")) as text from gcp_cset_lexisnexis.raw_news where extract(year from publishedDate) >= 2012 and extract(year from publishedDate) <= 2020 and (source.category = 'Press Wire' or source.category = 'National' or source.category = 'Trade') -- I excluded rank 3 here in an attempt to cut down on low-quality hits and source.editorialRank in (1, 2) and language = 'English' and source.location.country = 'United States' ), keywords as ( -- Add columns indicating whether text matched various patterns select title, url, source_category, editorialRank, matchingKeywords, year, source_name, REGEXP_CONTAINS(LOWER(text), r'(displace.{0,20}job.{0,20}\bai\b)') AS displace_job_ai, REGEXP_CONTAINS(LOWER(text), r'(\bai\b.{0,20}displace.*job)') AS ai_displace_job, REGEXP_CONTAINS(LOWER(text), r'(replace.{0,20}job.{0,20}\bai\b)') AS replace_job_ai, REGEXP_CONTAINS(LOWER(text), r'(\bai\b.{0,20}replace.{0,20}job)') AS ai_replace_job, REGEXP_CONTAINS(LOWER(text), r'(obsolete.{0,20}\bai\b)') AS obsolete_ai, REGEXP_CONTAINS(LOWER(text), r'(\bai\b.{0,20}obsolete)') AS ai_obsolete, REGEXP_CONTAINS(LOWER(text), r'(automation.{0,20}job)') AS automation_job, REGEXP_CONTAINS(LOWER(text), r'(automate.{0,20}job)') AS automate_job, REGEXP_CONTAINS(LOWER(text), r'(job.{0,20}automation)') AS job_automation, REGEXP_CONTAINS(LOWER(text), r'(job.{0,20}automate)') AS job_automate, REGEXP_CONTAINS(LOWER(text), r'(global useless class)') AS global_useless_class, REGEXP_CONTAINS(LOWER(text), r'(employment.?polarization)') AS employment_polarization, REGEXP_CONTAINS(LOWER(text), r'(livelihoods)') AS livelihoods, REGEXP_CONTAINS(LOWER(text), r'(compensation)') AS compensation, REGEXP_CONTAINS(LOWER(text), r'(mass joblessness)') AS mass_joblessness, REGEXP_CONTAINS(LOWER(text), r'(out of a job)') AS out_of_job, REGEXP_CONTAINS(LOWER(text), r'(robot apocalypse)') AS robot_apocalypse, REGEXP_CONTAINS(LOWER(text), r'(unemploy)') AS unemploy, REGEXP_CONTAINS(LOWER(text), r'(fourth.?industrial.?revolution)') AS fourth_industrial_revolution, REGEXP_CONTAINS(LOWER(text), r'(unions?)') AS unions, REGEXP_CONTAINS(LOWER(text), r'(jobless.?recovery)') AS jobless_recovery, REGEXP_CONTAINS(LOWER(text), r'(reskill)') AS reskill, REGEXP_CONTAINS(LOWER(text), r'(winners and losers)') AS winners_losers, REGEXP_CONTAINS(LOWER(text), r'(blue.?collar)') AS blue_collar, REGEXP_CONTAINS(LOWER(text), r'(white.?collar)') AS white_collar, REGEXP_CONTAINS(LOWER(text), r'(jobs.?eliminated)') AS jobs_eliminated, REGEXP_CONTAINS(LOWER(text), r'(steal.?jobs?)') AS steal_jobs, REGEXP_CONTAINS(LOWER(text), r'(coming for y?our job)') AS coming_for_job, REGEXP_CONTAINS(LOWER(text), r'(take y?our job)') AS take_job, REGEXP_CONTAINS(LOWER(text), r'(job killer)') AS job_killer, REGEXP_CONTAINS(LOWER(text), r'(threaten.{0,20}jobs?)') AS threaten_jobs, REGEXP_CONTAINS(LOWER(text), r'(job.{0,20}extinct)') AS job_extinct, text from ln -- Require a mention of AI somewhere where regexp_contains(lower(ln.text), r"\bai\b|artificial intelligence\b") ), hits as ( -- Select docs with matches from the analytic corpus select * from keywords where keywords.global_useless_class or keywords.employment_polarization or keywords.take_job or keywords.job_killer or (keywords.displace_job_ai or keywords.ai_displace_job or keywords.replace_job_ai or keywords.ai_replace_job or keywords.obsolete_ai or keywords.ai_obsolete or keywords.automation_job or keywords.automate_job or keywords.job_automation or keywords.job_automate or keywords.mass_joblessness or keywords.out_of_job or keywords.unemploy or keywords.jobless_recovery or keywords.jobs_eliminated or keywords.steal_jobs or keywords.threaten_jobs or keywords.job_extinct or keywords.coming_for_job) and ( keywords.livelihoods or keywords.compensation or keywords.robot_apocalypse or keywords.fourth_industrial_revolution or keywords.reskill or keywords.winners_losers or keywords.blue_collar or keywords.white_collar) ) select -- Summarize the results title, url, source_category, editorialRank, (global_useless_class or employment_polarization) as inequality, (take_job or job_killer) as job_killer, (displace_job_ai or ai_displace_job or ai_replace_job or replace_job_ai or jobs_eliminated or job_extinct or out_of_job or unemploy) as job_loss, (obsolete_ai or ai_obsolete or automate_job or automation_job or job_automate or job_automation) as automation, (steal_jobs or threaten_jobs or coming_for_job) as steal_jobs, (mass_joblessness or jobless_recovery) as joblessness, (livelihoods or compensation) as career, reskill, (blue_collar or white_collar) as collar, robot_apocalypse, fourth_industrial_revolution as industrial_rev, winners_losers from hits
true
c0bc2bad421783a06199c5ae6cea4632cf981ea9
SQL
saskatchuwan/W3D2
/import_db.sql
UTF-8
2,626
3.6875
4
[]
no_license
PRAGMA foreign_keys = ON; CREATE TABLE users ( id INTEGER PRIMARY KEY, fname TEXT NOT NULL, lname TEXT NOT NULL ); CREATE TABLE questions ( id INTEGER PRIMARY KEY, title TEXT NOT NULL, body TEXT NOT NULL, author_id INTEGER NOT NULL, FOREIGN KEY (author_id) REFERENCES users(id) ); CREATE TABLE questions_follows ( id INTEGER PRIMARY KEY, author_id INTEGER NOT NULL, question_id INTEGER, FOREIGN KEY (author_id) REFERENCES users(id), FOREIGN KEY (question_id) REFERENCES questions(id) ); CREATE TABLE replies ( id INTEGER PRIMARY KEY, body TEXT NOT NULL, author_id INTEGER NOT NULL, question_id INTEGER NOT NULL, parent_reply_id INTEGER, FOREIGN KEY (parent_reply_id) REFERENCES replies(id), FOREIGN KEY (question_id) REFERENCES questions(id), FOREIGN KEY (author_id) REFERENCES users(id) ); CREATE TABLE question_likes ( id INTEGER PRIMARY KEY, author_id INTEGER NOT NULL, question_id INTEGER, FOREIGN KEY (author_id) REFERENCES users(id), FOREIGN KEY (question_id) REFERENCES questions(id) ); INSERT INTO questions_follows ("id", "author_id", "question_id") VALUES (2, 25, 112); INSERT INTO questions_follows ("id", "author_id", "question_id") VALUES (1, 11, 112); INSERT INTO questions_follows ("id", "author_id", "question_id") VALUES (3, 26, 112); -- INSERT INTO users ("id", "fname", "lname") VALUES (1, "Demetri","Sakellaropoulos"); -- INSERT INTO users ("id", "fname", "lname") VALUES (2, "Kathryn","Chu"); -- INSERT INTO questions ("id", "title", "body", "author_id") VALUES (0, "yo waddup??","just checking in not really tho", 0); -- INSERT INTO replies ("id", "body", "author_id", "question_id","parent_reply_id") VALUES (0, "i like puppies", 1, 0, NULL); -- INSERT INTO replies ("id", "body", "author_id", "question_id","parent_reply_id") VALUES (1, "just got back from lunch", 2, 0, NULL); -- INSERT INTO questions ("id", "title", "body", "author_id") VALUES (112, "Please feed me","woof woof", 11); -- INSERT INTO users ("id", "fname", "lname") VALUES (25, "Eustace","Bagge"); -- INSERT INTO replies ("id", "body", "author_id", "question_id","parent_reply_id") VALUES (3, "frank, i already fed you! you animal", 25, 112, NULL); -- INSERT INTO replies ("id", "body", "author_id", "question_id","parent_reply_id") VALUES (4, "eustace (aka) dad, i hate you", 11, 112, 3); -- UPDATE replies SET parent_reply_id = 3 WHERE id = 4 -- INSERT INTO users ("id", "fname", "lname") VALUES (26, "Muriel", "Bagge"); INSERT INTO questions_follows ("id", "author_id", "question_id") VALUES (4,26,113);
true
5229b98e45bc15201908fd8d4861fe98641480fe
SQL
kurena/QATracker
/database/QATracker2014-03-16.sql
UTF-8
7,118
3.140625
3
[]
no_license
CREATE DATABASE IF NOT EXISTS `qa_tracker` /*!40100 DEFAULT CHARACTER SET latin1 */; USE `qa_tracker`; -- MySQL dump 10.13 Distrib 5.5.35, for debian-linux-gnu (x86_64) -- -- Host: 127.0.0.1 Database: qa_tracker -- ------------------------------------------------------ -- Server version 5.5.35-0ubuntu0.13.10.2 /*!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 `issue` -- DROP TABLE IF EXISTS `issue`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `issue` ( `idissue` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) DEFAULT NULL, `description` varchar(45) DEFAULT NULL, `issuecol` varchar(45) DEFAULT NULL, PRIMARY KEY (`idissue`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `issue` -- LOCK TABLES `issue` WRITE; /*!40000 ALTER TABLE `issue` DISABLE KEYS */; /*!40000 ALTER TABLE `issue` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `issuetask` -- DROP TABLE IF EXISTS `issuetask`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `issuetask` ( `idissuetask` int(11) NOT NULL AUTO_INCREMENT, `idissue` int(11) NOT NULL, `idtask` int(11) NOT NULL, PRIMARY KEY (`idissuetask`), KEY `fk_issuetask_1_idx` (`idtask`), KEY `fk_issuetask_2_idx` (`idissue`), CONSTRAINT `fk_issuetask_1` FOREIGN KEY (`idtask`) REFERENCES `task` (`idtask`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_issuetask_2` FOREIGN KEY (`idissue`) REFERENCES `issue` (`idissue`) 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 `issuetask` -- LOCK TABLES `issuetask` WRITE; /*!40000 ALTER TABLE `issuetask` DISABLE KEYS */; /*!40000 ALTER TABLE `issuetask` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `proyect` -- DROP TABLE IF EXISTS `proyect`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `proyect` ( `idproyect` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) DEFAULT NULL, `description` varchar(45) DEFAULT NULL, PRIMARY KEY (`idproyect`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `proyect` -- LOCK TABLES `proyect` WRITE; /*!40000 ALTER TABLE `proyect` DISABLE KEYS */; /*!40000 ALTER TABLE `proyect` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `task` -- DROP TABLE IF EXISTS `task`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `task` ( `idtask` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) DEFAULT NULL, `description` varchar(45) DEFAULT NULL, `image` varchar(45) DEFAULT NULL, PRIMARY KEY (`idtask`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `task` -- LOCK TABLES `task` WRITE; /*!40000 ALTER TABLE `task` DISABLE KEYS */; /*!40000 ALTER TABLE `task` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `taskproyect` -- DROP TABLE IF EXISTS `taskproyect`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `taskproyect` ( `idtaskproyect` int(11) NOT NULL AUTO_INCREMENT, `idproyect` int(11) NOT NULL, `idtask` int(11) NOT NULL, PRIMARY KEY (`idtaskproyect`), KEY `fk_taskproyect_1_idx` (`idproyect`), KEY `fk_taskproyect_2_idx` (`idtask`), CONSTRAINT `fk_taskproyect_1` FOREIGN KEY (`idproyect`) REFERENCES `proyect` (`idproyect`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_taskproyect_2` FOREIGN KEY (`idtask`) REFERENCES `task` (`idtask`) 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 `taskproyect` -- LOCK TABLES `taskproyect` WRITE; /*!40000 ALTER TABLE `taskproyect` DISABLE KEYS */; /*!40000 ALTER TABLE `taskproyect` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `user` -- DROP TABLE IF EXISTS `user`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `user` ( `iduser` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(45) DEFAULT NULL, `name` varchar(45) DEFAULT NULL, `password` varchar(45) DEFAULT NULL, `age` varchar(45) DEFAULT NULL, `role` varchar(45) DEFAULT NULL, `lastname` varchar(45) DEFAULT NULL, PRIMARY KEY (`iduser`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `user` -- LOCK TABLES `user` WRITE; /*!40000 ALTER TABLE `user` DISABLE KEYS */; INSERT INTO `user` VALUES (1,'kurena','Kevin','admin123','19',NULL,NULL),(2,'sdf','sdf','123','12',NULL,NULL),(3,'asd','asd','123','12',NULL,NULL),(4,'kaut94','kaut94','123','12',NULL,NULL),(5,'rquesada','Raiam','admin123','19','desarrollador','Quesada'); /*!40000 ALTER TABLE `user` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `userproyect` -- DROP TABLE IF EXISTS `userproyect`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `userproyect` ( `iduserproyect` int(11) NOT NULL AUTO_INCREMENT, `iduser` int(11) NOT NULL, `idproyect` int(11) NOT NULL, PRIMARY KEY (`iduserproyect`), KEY `fk_proyectStructure_1_idx` (`iduser`), KEY `fk_proyectStructure_2_idx` (`idproyect`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `userproyect` -- LOCK TABLES `userproyect` WRITE; /*!40000 ALTER TABLE `userproyect` DISABLE KEYS */; /*!40000 ALTER TABLE `userproyect` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2014-03-16 16:46:02
true
85cb5ad0c697bc69794a2e900873bb6188bea2d2
SQL
Felino7727/SQL-Oracle-
/Запрос- DAS для ЛокБриг (Гринберг).sql
UTF-8
2,927
2.84375
3
[]
no_license
SELECT w.B_DEPO_OBL, w.B_NOM_MM, nvl(w.PR_MASH,1)PR_MASH, w.B_TAB_NOM, w.B_FAM, w.B_NAME, w.B_MID_NAME, w.B_DEPO_PRIP, w.B_VID_ROB, w.DATE_JAVKA, e.ID_SER, e.nom, e.ID_DEPO, e.DATE_PRIJOM, r.DATE_VUHID_KP, t.DATE_ZAHID_KP, u.DATE_ZDACHA, DATE_VIDPOCH FROM (select Q.B_DEPO_OBL, Q.B_NOM_MM, Q.CODE_OP as JAVKA, Q.DATE_OP as DATE_JAVKA, Q.B_TAB_NOM, Q.B_FAM, Q.B_NAME, Q.B_MID_NAME, Q.B_DEPO_PRIP, Q.PR_MASH, Q.B_VID_ROB from rktme.ro_lok q where Q.CODE_OP in (28,31,35)) w left join (select Q.B_DEPO_OBL, Q.B_NOM_MM, Q.CODE_OP as PRIJOM, Q.ID_SER, q.nom, Q.ID_DEPO, Q.DATE_OP AS DATE_PRIJOM, q.B_TIME_YAVKA from rktme.ro_lok q where Q.CODE_OP in (24,43,124,114)) e on (w.B_NOM_MM=e.B_NOM_MM and w.B_DEPO_OBL=e.B_DEPO_OBL and w.DATE_JAVKA=e.B_TIME_YAVKA ) left join (select Q.B_DEPO_OBL, Q.B_NOM_MM, Q.CODE_OP as VUHID_KP, Q.DATE_OP AS DATE_VUHID_KP, q.B_TIME_YAVKA from rktme.ro_lok q where Q.CODE_OP in (902)) r on (w.B_NOM_MM=r.B_NOM_MM and w.B_DEPO_OBL=r.B_DEPO_OBL and w.DATE_JAVKA=r.B_TIME_YAVKA ) left join (select Q.B_DEPO_OBL, Q.B_NOM_MM, Q.CODE_OP as ZAHID_KP, Q.DATE_OP AS DATE_ZAHID_KP, q.B_TIME_YAVKA from rktme.ro_lok q where Q.CODE_OP in (901)) t on (w.B_NOM_MM=t.B_NOM_MM and w.B_DEPO_OBL=t.B_DEPO_OBL and w.DATE_JAVKA=t.B_TIME_YAVKA ) left join (select Q.B_DEPO_OBL, Q.B_NOM_MM, Q.CODE_OP as ZDACHA, Q.DATE_OP AS DATE_ZDACHA, Q.B_TAB_NOM, q.B_TIME_YAVKA from rktme.ro_lok q where Q.CODE_OP in (25, 41, 125, 115,141)) u on (w.B_NOM_MM=u.B_NOM_MM and w.B_DEPO_OBL=u.B_DEPO_OBL and w.DATE_JAVKA=u.B_TIME_YAVKA ) left join (select Q.B_DEPO_OBL, Q.B_NOM_MM, Q.CODE_OP as VIDPOCH, Q.DATE_OP AS DATE_VIDPOCH, Q.B_TAB_NOM, q.B_TIME_YAVKA from rktme.ro_lok q where Q.CODE_OP in (31, 37, 131, 137)) p on (w.B_NOM_MM=p.B_NOM_MM and w.B_DEPO_OBL=p.B_DEPO_OBL and w.DATE_JAVKA=p.B_TIME_YAVKA and w.B_TAB_NOM=p.B_TAB_NOM) where w.B_NOM_MM=:mnum and w.DATE_JAVKA<=to_date(:d1,'dd.mm.yyyy')and w.DATE_JAVKA>=to_date(:d0,'dd.mm.yyyy') SELECT SRC, CODE_OP, B_DEPO_OBL, B_NOM_MM, nvl(PR_MASH,1)PR_MASH, B_TAB_NOM, B_FAM, B_NAME, B_MID_NAME, B_DEPO_PRIP, B_VID_ROB,DATE_OP, B_TIME_YAVKA, ID_SER, nom, ID_DEPO from rktme.ro_lok where B_NOM_MM=:mnum and B_TIME_YAVKA<=to_date(:d1,'dd.mm.yyyy') and B_TIME_YAVKA>=to_date(:d0,'dd.mm.yyyy') and SRC in (0,2) --CODE_OP in (28, 31, 35, 128, 24, 43, 124, 114, 902, 901, 25, 41, 125, 115, 141, 31, 37, 131, 137) --not in (1,2,3, 201) order by date_op
true
a3f4a4bb5d3cf3e2fcad95ebbaf74e0bb2a51cc9
SQL
Etimo/diamonds2
/backend/prisma/migrations/20230227230421_init/migration.sql
UTF-8
4,206
3.375
3
[ "MIT" ]
permissive
-- CreateTable CREATE TABLE "BoardConfig" ( "id" UUID NOT NULL DEFAULT gen_random_uuid(), "inventorySize" INTEGER NOT NULL DEFAULT 5, "canTackle" BOOLEAN NOT NULL DEFAULT false, "teleporters" INTEGER NOT NULL DEFAULT 1, "teleportRelocation" INTEGER NOT NULL DEFAULT 10, "height" INTEGER NOT NULL DEFAULT 15, "width" INTEGER NOT NULL DEFAULT 15, "minimumDelayBetweenMoves" INTEGER NOT NULL DEFAULT 100, "sessionLength" INTEGER NOT NULL DEFAULT 60, "createTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updateTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "PK_1636b437b1255b668e371bc8e23" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Bot" ( "id" UUID NOT NULL DEFAULT gen_random_uuid(), "name" VARCHAR(300) NOT NULL, "email" VARCHAR(300) NOT NULL, "createTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updateTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "password" VARCHAR(300), "teamId" UUID NOT NULL, CONSTRAINT "PK_9ada6b90026027b7d2f75c4d3d8" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Highscore" ( "id" UUID NOT NULL DEFAULT gen_random_uuid(), "score" INTEGER NOT NULL, "createTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updateTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "seasonId" UUID NOT NULL, "botId" UUID NOT NULL, CONSTRAINT "PK_da1bb900eb93df2f2d5103d8545" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Recording" ( "id" UUID NOT NULL DEFAULT gen_random_uuid(), "score" INTEGER NOT NULL, "board" INTEGER NOT NULL, "createTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "recording" TEXT NOT NULL, "seasonId" UUID NOT NULL, "botId" UUID NOT NULL, CONSTRAINT "PK_8c3247d5ee4551d59bb2115a484" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Season" ( "id" UUID NOT NULL DEFAULT gen_random_uuid(), "name" VARCHAR(300) NOT NULL, "startDate" TIMESTAMPTZ(6) NOT NULL, "endDate" TIMESTAMPTZ(6) NOT NULL, "createTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updateTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "boardConfigId" UUID NOT NULL, CONSTRAINT "PK_cb8ed53b5fe109dcd4a4449ec9d" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Team" ( "id" UUID NOT NULL DEFAULT gen_random_uuid(), "name" VARCHAR(300) NOT NULL, "abbreviation" VARCHAR(20) NOT NULL, "logotypeUrl" VARCHAR(1000) NOT NULL, "createTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updateTimeStamp" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "PK_7e5523774a38b08a6236d322403" PRIMARY KEY ("id") ); -- CreateIndex CREATE UNIQUE INDEX "Bot_name_key" ON "Bot"("name"); -- CreateIndex CREATE UNIQUE INDEX "Bot_email_key" ON "Bot"("email"); -- CreateIndex CREATE INDEX "Highscore_seasonId_botId_idx" ON "Highscore"("seasonId", "botId"); -- CreateIndex CREATE UNIQUE INDEX "Highscore_seasonId_botId_key" ON "Highscore"("seasonId", "botId"); -- CreateIndex CREATE UNIQUE INDEX "Season_name_key" ON "Season"("name"); -- AddForeignKey ALTER TABLE "Bot" ADD CONSTRAINT "Bot_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Highscore" ADD CONSTRAINT "Highscore_botId_fkey" FOREIGN KEY ("botId") REFERENCES "Bot"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Highscore" ADD CONSTRAINT "Highscore_seasonId_fkey" FOREIGN KEY ("seasonId") REFERENCES "Season"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Recording" ADD CONSTRAINT "Recording_botId_fkey" FOREIGN KEY ("botId") REFERENCES "Bot"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Recording" ADD CONSTRAINT "Recording_seasonId_fkey" FOREIGN KEY ("seasonId") REFERENCES "Season"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Season" ADD CONSTRAINT "Season_boardConfigId_fkey" FOREIGN KEY ("boardConfigId") REFERENCES "BoardConfig"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
true
7fa54acfc6bea72888ac7ea61899bd330b104945
SQL
jayse45/alx-higher_level_programming-1
/0x0D-SQL_introduction/7-insert_value.sql
UTF-8
229
2.546875
3
[]
no_license
-- a script that inserts a new row in the table first_table (database hbtn_0c_0) in your MySQL server -- New row should be id = 89 and name = Holberton School INSERT INTO first_table(id, name) VALUES ('89', 'Holberton School');
true
80e064927169760c678a9f464187087d85e79322
SQL
HARPgroup/vahydro
/sql/ann_ne_monthly.sql
UTF-8
756
3.984375
4
[]
no_license
select * from ( select a.hydroid, a.name, extract(year from to_timestamp(b.tstime)), b.tsvalue as annual, sum(c.tsvalue) as monthly from dh_feature as a left outer join dh_timeseries as b on ( a.hydroid = b.featureid and b.entity_type = 'dh_feature' and b.varid = 305 ) left outer join dh_timeseries as c on ( a.hydroid = c.featureid and c.entity_type = 'dh_feature' and c.varid = 1021 ) where a.bundle in ('well', 'intake') and extract(year from to_timestamp(b.tstime)) = 2021 and extract(year from to_timestamp(c.tstime)) = 2021 group by a.hydroid, a.name, b.tsvalue, extract(year from to_timestamp(b.tstime)) ) as foo where ( (annual > 1.01 * monthly ) or (annual < 0.99 * monthly ) ) ;
true
6bbe1196bba4dbeb348962d769e3821a9ad9e23c
SQL
naoya7076/sql-lessons-from-zero
/chapter-5/5-4.sql
UTF-8
258
2.96875
3
[]
no_license
CREATE VIEW AngTankaByBunrui ( shohin_id, shohin_mei, shohin_bunrui, hanbai_tanka, avg_hanbai_tanka ) AS SELECT shohin_id, shohin_mei, shohin_bunrui, hanbai_tanka, (SELECT AVG(hanbai_tanka) as hanbai_tanka_all FROM shohin) FROM shohin;
true
539f192101949cc18086b4852a19b71a03d6244c
SQL
MoonlightKosmos7/Week-7-MySQL
/MySQLWeek1Assignment.sql
UTF-8
881
3.453125
3
[]
no_license
1. mysql> SELECT * from employees where birth_date < '1965-01-01' limit 5; 2. SELECT * from employees where hire_date > '1991-01-01' limit 5; 3. SELECT * from employees where last_name LIKE 'f%'; 4. INSERT INTO employees VALUES (100,'1994-09-12', 'Joon', 'Kim', 'M', '2013-10-01'), (101, '1995-12-30','Tae', 'Kim', 'M', '2013-11-01'), (102, '1993-03-09', 'Yoongi', 'Min', 'M', '2013-10-01'); 5. UPDATE employees SET first_name = 'Bob' WHERE emp_no =10023; To show: SELECT * FROM employees where emp_no = 10023; 6. UPDATE employees SET hire_date = '2002-01-01' where last_name LIKE 'p%'; 7. SELECT * from employees where emp_no <103; Delete from employees where emp_no <103; 8. SELECT * from employees where emp_no = 10048 or emp_no= 10099 or emp_no= 10234 or emp_no= 20089; Delete from employees where emp_no = 10048 or emp_no= 10099 or emp_no= 10234 or emp_no= 20089;
true
37c419e35d3eeb74e262e4d929726ab78013e955
SQL
meenakshik-optimus/SQL-INDUCTION
/SQL-INDUCTION-MEENAKSHI/ASSIGNMENT TWO.sql
UTF-8
7,020
3.71875
4
[]
no_license
---Question 1:- Create three tables as follows: (i) Product Table: t_product_master (ii)User Table: t_user_master (iii)Transaction Table: t_transaction CREATE TABLE t_product_master(Product_ID varchar(25) PRIMARY KEY,Product_Name varchar(25),Cost_Per_Item int); INSERT INTO t_product_master VALUES('P1','Pen',10); INSERT INTO t_product_master VALUES('P2','Scale',15); INSERT INTO t_product_master VALUES('P3','Note Book',25); CREATE TABLE t_user_master(User_ID varchar(25) PRIMARY KEY,User_Name varchar(60)); INSERT INTO t_user_master VALUES('U1','Alfred Lawrence'); INSERT INTO t_user_master VALUES('U2','William Paul'); INSERT INTO t_user_master VALUES('U3','Edward Fillip'); SELECT * FROM t_product_master; SELECT * FROM t_user_master; CREATE TABLE t_transaction(User_ID varchar(25) FOREIGN KEY REFERENCES t_user_master(User_ID), Product_ID varchar(25) FOREIGN KEY REFERENCES t_product_master(Product_ID),Transaction_Date DATE, Transaction_Type varchar(25),Transaction_Amount int); INSERT INTO t_transaction VALUES('U1','P1','2010-10-25','Order',150); INSERT INTO t_transaction VALUES('U1','P1','2010-11-20','Payment',750); INSERT INTO t_transaction VALUES('U1','P1','2010-11-20','Order',200); INSERT INTO t_transaction VALUES('U1','P3','2010-11-25','Order',50); INSERT INTO t_transaction VALUES('U3','P2','2010-11-26','Order',100); INSERT INTO t_transaction VALUES('U2','P1','2010-12-15','Order',75); INSERT INTO t_transaction VALUES('U3','P2','2011-01-15','Payment',250); SELECT * FROM t_transaction; --Question 2:- QUERY SELECT t_user_master.User_Name, t_product_master.Product_Name, SUM(CASE WHEN Transaction_Type='Order'THEN t_transaction.Transaction_Amount ELSE 0 END) AS Ordered_Quantity, SUM(CASE WHEN Transaction_Type='Payment'THEN t_transaction.Transaction_Amount ELSE 0 END) AS Amount_Paid, MAX(t_transaction.Transaction_Date) AS Last_Target_Date, (SUM(CASE WHEN Transaction_Type='Order'THEN t_transaction.Transaction_Amount* t_product_master.Cost_Per_Item ELSE 0 END)- SUM(CASE WHEN Transaction_Type='Payment'THEN t_transaction.Transaction_Amount ELSE 0 END)) AS Balance FROM ((t_transaction LEFT JOIN t_user_master ON t_transaction.User_ID=t_user_master.User_ID) LEFT JOIN t_product_master ON t_transaction.Product_ID=t_product_master.Product_ID) group by t_user_master.User_Name,t_product_master.Product_Name; --Question 3:- Creation of required tables CREATE TABLE t_emp(EMP_id int IDENTITY(1001,2) NOT NULL PRIMARY KEY,Emp_Code varchar(25),Emp_f_name varchar(25) NOT NULL,Emp_m_name varchar(25),Emp_l_name varchar(25),Emp_DOB DATE,Emp_DOJ DATE NOT NULL); INSERT INTO t_emp(Emp_Code,Emp_f_name,Emp_l_name,Emp_DOB,Emp_DOJ) VALUES('OPT20110105','Manmohan','Singh','1983-02-10','2010-05-25'); INSERT INTO t_emp(Emp_Code,Emp_f_name,Emp_m_name,Emp_l_name,Emp_DOB,Emp_DOJ) VALUES('OPT20100915','Alfred','Joseph','Lawrence','1988-02-28','2009-03-24'); INSERT INTO t_emp(Emp_Code,Emp_f_name,Emp_m_name,Emp_l_name,Emp_DOB,Emp_DOJ) VALUES('OPT20100916','Adam','Hilary','wiliam','1988-02-29','2009-04-25'); INSERT INTO t_emp(Emp_Code,Emp_f_name,Emp_l_name,Emp_DOB,Emp_DOJ) VALUES('OPT20110106','Meenakshi','kumari','1993-02-28','2010-05-25'); SELECT * FROM t_emp; CREATE TABLE t_activity(Activity_id int PRIMARY KEY,Activity_Description varchar(255)); INSERT INTO t_activity VALUES(1,'Code Analysis'); INSERT INTO t_activity VALUES(2,'Lunch'); INSERT INTO t_activity VALUES(3,'Coding'); INSERT INTO t_activity VALUES(4,'Knowledge Transition'); INSERT INTO t_activity VALUES(5,'Database'); SELECT * FROM t_activity; CREATE table t_atten_det(Atten_id int IDENTITY(1001,1), Emp_id int FOREIGN KEY REFERENCES t_emp(Emp_id), Activity_id int FOREIGN KEY REFERENCES t_activity(Activity_id), Atten_Start_Datetime DATETIME,Atten_end_hrs int); INSERT INTO t_atten_det VALUES(1001,5,'2011-02-13 10:00:00',2); INSERT INTO t_atten_det VALUES(1001,1,'2011-01-14 10:00:00',3); INSERT INTO t_atten_det VALUES(1001,3,'2011-01-14 13:00:00',5); INSERT INTO t_atten_det VALUES(1003,5,'2011-02-16 10:00:00',8); INSERT INTO t_atten_det VALUES(1003,5,'2011-02-17 10:00:00',8); INSERT INTO t_atten_det VALUES(1003,5,'2011-02-19 10:00:00',7); SELECT * FROM t_atten_det; CREATE TABLE t_salary(Salary_id int PRIMARY KEY,Emp_Id int,Changed_date DATE,New_Salary float); INSERT INTO t_salary VALUES(1001,1003,'2011-01-14',20000.00); INSERT INTO t_salary VALUES(1002,1003,'2011-02-16',25000.00); INSERT INTO t_salary VALUES(1003,1001,'2011-02-16',26000.00); --Question 4.1:- SELECT Emp_f_name +' '+ CASE WHEN Emp_m_name IS NULL THEN '' ELSE Emp_m_name END+' '+ Emp_l_name AS Name,Emp_DOB FROM t_emp where Emp_DOB=CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,t_emp.Emp_DOB))), DATEADD(mm,1,t_emp.Emp_DOB)),101); --Question 4.2:- SELECT * FROM ( SELECT DISTINCT s.Emp_id, year(s.Atten_Start_Datetime) AS [year], datename(month,s.Atten_Start_Datetime) AS [month], datename(day,s.Atten_Start_Datetime) d,t_emp.Emp_f_name +' '+ CASE WHEN t_emp.Emp_m_name IS NULL THEN '' ELSE t_emp.Emp_m_name END+' '+ t_emp.Emp_l_name AS Name, s.atten_end_hrs AS hrs FROM t_emp INNER JOIN t_atten_det s ON t_emp.emp_id= s.Emp_id )t PIVOT ( SUM(t.hrs) FOR t.d IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16], [17],[18],[19],[20],[21],[22],[23],[24],[25],[26],[27],[28],[29],[30,[31]) )AS pivot_table; --Question 4.3:- SELECT t_emp.Emp_f_name +' '+ CASE WHEN t_emp.Emp_m_name IS NULL THEN '' ELSE t_emp.Emp_m_name END+' '+ t_emp.Emp_l_name AS Name, t_atten_det.Emp_id, (CASE WHEN (max(t_salary.New_Salary)-min(t_salary.New_Salary))>0 THEN 'YES' ELSE 'NO' END) AS got_increment_in_salary, min(t_salary.New_Salary) AS previous_salary, max(t_salary.New_Salary) AS current_salary , s.ss AS total_worked_hours, f.ff AS last_worked_activity, f.hh AS hours_worked_in_that FROM t_salary LEFT JOIN t_emp ON t_salary.Emp_Id=t_emp.EMP_id LEFT JOIN t_atten_det ON t_salary.Emp_Id=t_atten_det.Emp_id LEFT JOIN t_activity ON t_activity.Activity_id=t_atten_det.Activity_id LEFT JOIN (SELECT Emp_id, sum(atten_end_hrs) ss FROM t_atten_det GROUP BY Emp_id) s ON s.Emp_id=t_emp.EMP_id LEFT JOIN (SELECT atten_end_hrs hh,ACTivity_id ff,z.Emp_id FROM t_atten_det z LEFT OUTER JOIN (SELECT Emp_id, MAX(Atten_Start_Datetime) g FROM t_atten_det GROUP BY Emp_id) w ON z.Emp_id=w.Emp_id WHERE z.Atten_Start_Datetime=w.g) f ON f.Emp_id=t_emp.EMP_id GROUP BY t_emp.Emp_f_name,t_emp.Emp_m_name,t_emp.Emp_l_name,t_atten_det.Emp_Id,s.ss,f.ff,f.hh; SELECT * FROM ( SELECT year(Atten_Start_Datetime) as [year], datename(month,Atten_Start_Datetime) as [month], datename(day,Atten_Start_Datetime) [day], atten_end_hrs as hrs FROM t_atten_det) s PIVOT ( SUM(hrs) FOR [day] IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20]) )AS pivottable;
true
579207c96909da9a0b6e2dac78fd0082d45ccf04
SQL
trojal/SeAr-mirror
/sql-files/upgrade_logs_r1.5.126.sql
UTF-8
495
2.984375
3
[]
no_license
#CashLog types (C)ash Points,(K)afra Points #Database: log #Table: cashlog CREATE TABLE `cashlog` ( `id` int(11) NOT NULL auto_increment, `time` datetime NOT NULL default '0000-00-00 00:00:00', `char_id` int(11) NOT NULL default '0', `type` enum('C','K') NOT NULL default 'C', `amount` int(11) NOT NULL default '0', `remain` int(11) NOT NULL default '0', `map` varchar(11) NOT NULL default '', PRIMARY KEY (`id`), INDEX (`type`) ) ENGINE=MyISAM AUTO_INCREMENT=1 ;
true
f2cb1716a3767f97e8558a318cb546f6b05ea5ea
SQL
dannyhz/mpayrecon
/src/main/resources/sql/SP_BANK_MCH_TOTAL.SQL
GB18030
3,424
3.921875
4
[]
no_license
CREATE OR REPLACE PROCEDURE "MPOS"."SP_BANK_MCH_TOTAL" ( IN "I_BATID" DECIMAL(20,0), IN "I_CKDT" CHARACTER(10), IN "I_CHLNO" VARCHAR(50),--05 ΢Ŷ壬10 ֧壬20 ٸ OUT "O_ERRMSG" VARCHAR(128) ) LANGUAGE SQL BEGIN /*=====================================================================+ ƶյн׻嵥 1Ŀǰ֧̻ͨܣ дԱLINYQ ڣ2017/04/26 ޸ʷ ޸ ޸Ա ޸ԭ ======================================================================*/ --------------------------ñ-------------------------- DECLARE IRET INT DEFAULT 0 ; --SQL쳣Ϣ׽ DECLARE SQLCODE INT DEFAULT 0 ; --SQLش DECLARE SQLSTATE CHAR(5) DEFAULT '00000' ;--SQLĬϷش'00000'سɹ --------------------------Ӧñ--------------------------- DECLARE V_SMDT CHAR(8); DECLARE V_BATID DEC(20); DECLARE V_CKDT DATE; ----------------------------------쳣־------------------------- --SQLķ쳣Ĵ DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN SET O_ERRMSG = O_ERRMSG ||',SQLCODE = '|| TRIM(CHAR(SQLCODE)) || ',SQLSTATE = '||SQLSTATE; --ROLLBACK ; END; SET O_ERRMSG = '-1'; --ȷ\κ SET V_SMDT = TO_CHAR(CURRENT DATE, 'YYYYMMDD'); SET V_CKDT = TO_DATE(I_CKDT, 'YYYY-MM-DD'); IF I_BATID = 0 THEN SELECT MAX(BATID) INTO V_BATID FROM MPOS.BAT2_CMP_RESULT WHERE CHANNEL_NO = I_CHLNO AND CKDT = V_CKDT; IF V_BATID IS NULL THEN RETURN; END IF; ELSE SET V_BATID = I_BATID; END IF; SET O_ERRMSG = '-2'; --̻Ψһ IF EXISTS (SELECT SUB_ZX_MCHT_NO, COUNT(1) FROM IMP_SECD_SUB_INFO WHERE SUB_ZX_MCHT_NO <> '' GROUP BY SUB_ZX_MCHT_NO HAVING COUNT(1) > 1) THEN RETURN; END IF; SET O_ERRMSG = '-3'; --̻ͨ MCHTP = 1 INSERT INTO MPOS.BAT2_BANK_MCH_TOTAL(BATID, SMDT, BANK_CODE, CHANNEL_NO, MY_MCH_NO, MY_SEC_MCH_NO, MY_SEC_MCH_NM, ACNT, ATRAM, RCNT, RTRAM, TOTAL_FEE, TTRAM, RZAMT, TCNT, MCHTP) SELECT A.V_BATID, A.V_SMDT, A.BANK_CODE, A.CHANNEL_NO, A.MY_MCH_NO, A.MY_SEC_MCH_NO, B.MCHT_NM, --B A.ACNT, A.ATRAM, A.RCNT, A.RTRAM, A.TOTAL_FEE, A.TTRAM, A.RZAMT, A.TCNT, A.MCHTP FROM (SELECT V_BATID AS V_BATID, V_SMDT AS V_SMDT, BANK_CODE, CHANNEL_NO, MY_MCH_NO, MY_SEC_MCH_NO, SUM(CASE WHEN TRTP = '01' THEN 1 ELSE 0 END) AS ACNT, --ױ SUM(CASE WHEN TRTP = '01' THEN TRAM ELSE 0 END) AS ATRAM, --ܽ SUM(CASE WHEN TRTP IN ('04','21') THEN 1 ELSE 0 END) AS RCNT, --ױ SUM(CASE WHEN TRTP IN ('04','21') THEN TRAM ELSE 0 END) AS RTRAM, --ܽ COALESCE(SUM(TOTAL_FEE), 0) AS TOTAL_FEE, -- COALESCE(SUM(TRAM), 0) AS TTRAM, -- COALESCE(SUM(RZAMT), 0) AS RZAMT, --̻˽ COUNT(1) AS TCNT, --ܱ 1 AS MCHTP FROM BAT2_CMP_RESULT WHERE CKDT = V_CKDT AND BATID = V_BATID AND CKFG = 0 AND FZFG = 'N' GROUP BY BANK_CODE, CHANNEL_NO, MY_MCH_NO, MY_SEC_MCH_NO) AS A --бţ, һ̻(Ӧ̻), ̻ LEFT JOIN IMP_SECD_SUB_INFO B ON A.MY_SEC_MCH_NO = B.SUB_ZX_MCHT_NO; COMMIT; SET O_ERRMSG = '0'; END;
true
04fb348cf24b785e9866f17f71255f01a622fc7c
SQL
hannank/simple-etl
/create_info_tables.sql
UTF-8
1,579
3.3125
3
[]
no_license
DROP TABLE IF EXISTS raw_to_clean_medicine; DROP TABLE IF EXISTS clean_medicine_to_dosage; DROP TABLE IF EXISTS medicine_purpose; DROP TABLE IF EXISTS protocol_step_definition; CREATE TABLE raw_to_clean_medicine ( raw_name VARCHAR, raw_dosage VARCHAR, rxcui INTEGER, PRIMARY KEY (raw_name, raw_dosage) ); CREATE TABLE clean_medicine_to_dosage ( id serial PRIMARY KEY, rxcui INTEGER , medicine VARCHAR, dosage float ); CREATE TABLE medicine_purpose ( name VARCHAR PRIMARY KEY, hypertension BOOL, diabetes BOOL ); CREATE TABLE protocol_step_definition ( id serial PRIMARY KEY, protocol_id UUID, step INTEGER, amlodipine FLOAT, telmisartan FLOAT, losartan FLOAT, atenolol FLOAT, enalapril FLOAT, chlorthalidone FLOAT, hydrochlorothiazide FLOAT, other_bp_medications FLOAT ); COPY raw_to_clean_medicine(raw_name, raw_dosage, rxcui) FROM '/PATH/simple-etl/informational_tables/raw_to_clean_medicine.csv' DELIMITER ',' CSV HEADER; COPY clean_medicine_to_dosage(rxcui, medicine, dosage) FROM '/PATH/simple-etl/informational_tables/clean_medicine_to_dosage.csv' DELIMITER ',' CSV HEADER; COPY medicine_purpose(name, hypertension, diabetes) FROM '/PATH/simple_etl/informational_tables/medicine_purpose.csv' DELIMITER ',' CSV HEADER; COPY protocol_step_definition (protocol_id, step, amlodipine, telmisartan, losartan, atenolol, enalapril, chlorthalidone, hydrochlorothiazide, other_bp_medications ) FROM '/PATH/simple-etl/informational_tables/protocol_step_definition.csv' DELIMITER ',' CSV HEADER;
true
7be496e6a3cb4e785dc563ea094f059ac5cc71bc
SQL
s1m0nB/apex-plugin-tradingview
/region_type_plugin_sba_tradingview.sql
UTF-8
10,666
2.96875
3
[ "Apache-2.0" ]
permissive
prompt --application/set_environment set define off verify off feedback off whenever sqlerror exit sql.sqlcode rollback -------------------------------------------------------------------------------- -- -- ORACLE Application Express (APEX) export file -- -- You should run the script connected to SQL*Plus as the Oracle user -- APEX_200100 or as the owner (parsing schema) of the application. -- -- NOTE: Calls to apex_application_install override the defaults below. -- -------------------------------------------------------------------------------- begin wwv_flow_api.import_begin ( p_version_yyyy_mm_dd=>'2020.03.31' ,p_release=>'20.1.0.00.13' ,p_default_workspace_id=>12391180323004392729 ,p_default_application_id=>85382 ,p_default_id_offset=>0 ,p_default_owner=>'SB_DEV' ); end; / prompt APPLICATION 85382 - Tradingview widget -- -- Application Export: -- Application: 85382 -- Name: Tradingview widget -- Date and Time: 14:05 Friday October 2, 2020 -- Exported By: SIMON.BOORSMA@GMAIL.COM -- Flashback: 0 -- Export Type: Component Export -- Manifest -- PLUGIN: 43230395099574900093 -- Manifest End -- Version: 20.1.0.00.13 -- Instance ID: 63113759365424 -- begin -- replace components wwv_flow_api.g_mode := 'REPLACE'; end; / prompt --application/shared_components/plugins/region_type/sba_tradingview begin wwv_flow_api.create_plugin( p_id=>wwv_flow_api.id(43230395099574900093) ,p_plugin_type=>'REGION TYPE' ,p_name=>'SBA_TRADINGVIEW' ,p_display_name=>'TradingViewWidget' ,p_supported_ui_types=>'DESKTOP' ,p_plsql_code=>wwv_flow_string.join(wwv_flow_t_varchar2( 'function addTradingViewRegion( p_region in apex_plugin.t_region', ' , p_plugin in apex_plugin.t_plugin', ' , p_is_printer_friendly in boolean )', 'return apex_plugin.t_region_render_result', 'is', ' -- plugin attributes', ' l_symbol varchar2(32676) := p_region.attribute_01;', ' l_interval varchar2(32676) := p_region.attribute_02;', ' l_interval_tabs varchar2(32676) := p_region.attribute_03;', ' l_show_footer varchar2(32676) := p_region.attribute_04;', ' l_transparant varchar2(32676) := p_region.attribute_05;', ' l_color_theme varchar2(32676) := p_region.attribute_06; ', ' l_width varchar2(32676) := p_region.attribute_07;', ' l_height varchar2(32676) := p_region.attribute_08; ', ' l_autosize varchar2(32676) := p_region.attribute_09; ', ' -- ', ' l_display_symbol varchar2(32676) := substr(l_symbol,instr(l_symbol,'':'')+1);', ' -- dummy result', ' l_result apex_plugin.t_region_render_result;', 'begin', ' -- check atributes ', ' l_interval_tabs := case when l_interval_tabs = ''Y'' then ''true'' else ''false'' end;', ' l_transparant := case when l_transparant = ''Y'' then ''true'' else ''false'' end;', ' -- check autosize', ' if nvl(l_autosize,''N'') = ''Y'' then l_width := ''100%''; l_height := ''100%''; end if;', ' -- render the html', ' htp.prn(''<div class="tradingview-widget-container">'');', ' htp.prn(''<div class="tradingview-widget-container__widget"></div>'');', ' if l_show_footer = ''Y''', ' then', ' htp.prn(''<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/''||l_symbol||''/technicals/" rel="noopener" target="_blank">'');', ' htp.prn(''<span class="blue-text">Technical Analysis for ''||l_display_symbol||''</span></a> by TradingView</div>'');', ' end if;', ' htp.prn(''<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-technical-analysis.js" async>'');', ' htp.p(''{'');', ' htp.p('' "interval": "''||l_interval||''",'');', ' htp.p('' "width": "''||l_width||''",'');', ' htp.p('' "isTransparent": ''||l_transparant||'','');', ' htp.p('' "height": "''||l_height||''",'');', ' htp.p('' "symbol": "''||l_symbol||''",'');', ' htp.p('' "showIntervalTabs": ''||l_interval_tabs||'','');', ' htp.p('' "locale": "en",'');', ' htp.p('' "colorTheme": "''||l_color_theme||''"'');', ' htp.p(''}'');', ' htp.prn('' </script>''); ', ' htp.prn(''</div>''); ', ' return l_result;', ' --', 'end addTradingViewRegion;')) ,p_api_version=>2 ,p_render_function=>'addTradingViewRegion' ,p_substitute_attributes=>true ,p_subscribe_plugin_settings=>true ,p_help_text=>wwv_flow_string.join(wwv_flow_t_varchar2( 'Technical Analysis Widget', 'The Technical Analysis Widget is an advanced tool that displays ratings based on technical indicators. ', 'Our beautifully designed gauge lets you see the summary based on all indicators at a quick glance. ', 'You no longer have to apply multiple indicators to analyze a financial instrument since our widget does that for you.', ' On top of that, all ratings are shown in real time.')) ,p_version_identifier=>'1.0' ,p_about_url=>'https://www.tradingview.com/widget/technical-analysis/' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43232304703467957518) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>1 ,p_display_sequence=>10 ,p_prompt=>'Symbol' ,p_attribute_type=>'TEXT' ,p_is_required=>true ,p_supported_ui_types=>'DESKTOP' ,p_is_translatable=>false ,p_help_text=>'Select stock or asset to be displayed , using the symbols as used in TradingView (eg. NYSE:ORCL)' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43233092345840960272) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>2 ,p_display_sequence=>20 ,p_prompt=>'Interval' ,p_attribute_type=>'SELECT LIST' ,p_is_required=>true ,p_default_value=>'1D' ,p_is_translatable=>false ,p_lov_type=>'STATIC' ,p_help_text=>'Select for which interval the technical analysis widget will be displayed, eg daily, weekly, monthly' ); wwv_flow_api.create_plugin_attr_value( p_id=>wwv_flow_api.id(43233244981967973069) ,p_plugin_attribute_id=>wwv_flow_api.id(43233092345840960272) ,p_display_sequence=>10 ,p_display_value=>'1 hour' ,p_return_value=>'1h' ); wwv_flow_api.create_plugin_attr_value( p_id=>wwv_flow_api.id(43233247433312975735) ,p_plugin_attribute_id=>wwv_flow_api.id(43233092345840960272) ,p_display_sequence=>20 ,p_display_value=>'1 day' ,p_return_value=>'1D' ); wwv_flow_api.create_plugin_attr_value( p_id=>wwv_flow_api.id(43233249234245976928) ,p_plugin_attribute_id=>wwv_flow_api.id(43233092345840960272) ,p_display_sequence=>30 ,p_display_value=>'1 week' ,p_return_value=>'1W' ); wwv_flow_api.create_plugin_attr_value( p_id=>wwv_flow_api.id(43233252708162978043) ,p_plugin_attribute_id=>wwv_flow_api.id(43233092345840960272) ,p_display_sequence=>40 ,p_display_value=>'1 month' ,p_return_value=>'1M' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43233511270801991221) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>3 ,p_display_sequence=>30 ,p_prompt=>'showIntervalTabs' ,p_attribute_type=>'CHECKBOX' ,p_is_required=>false ,p_default_value=>'N' ,p_is_translatable=>false ,p_help_text=>'Show the interval tabs so the user can change the interval technical analysis' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43237346288075246971) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>4 ,p_display_sequence=>40 ,p_prompt=>'showFooter' ,p_attribute_type=>'CHECKBOX' ,p_is_required=>false ,p_default_value=>'N' ,p_is_translatable=>false ,p_help_text=>'Optional show the copyright footer of TradingView' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43237728861204259595) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>5 ,p_display_sequence=>50 ,p_prompt=>'Transparant background' ,p_attribute_type=>'CHECKBOX' ,p_is_required=>false ,p_default_value=>'Y' ,p_is_translatable=>false ,p_help_text=>'Use of transparant background' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43239255452821327455) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>6 ,p_display_sequence=>60 ,p_prompt=>'Color theme' ,p_attribute_type=>'SELECT LIST' ,p_is_required=>true ,p_default_value=>'light' ,p_is_translatable=>false ,p_lov_type=>'STATIC' ); wwv_flow_api.create_plugin_attr_value( p_id=>wwv_flow_api.id(43239443086667330115) ,p_plugin_attribute_id=>wwv_flow_api.id(43239255452821327455) ,p_display_sequence=>10 ,p_display_value=>'Light' ,p_return_value=>'light' ); wwv_flow_api.create_plugin_attr_value( p_id=>wwv_flow_api.id(43238534701655678340) ,p_plugin_attribute_id=>wwv_flow_api.id(43239255452821327455) ,p_display_sequence=>20 ,p_display_value=>'Dark' ,p_return_value=>'dark' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43240470258611375182) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>7 ,p_display_sequence=>80 ,p_prompt=>'Custom width' ,p_attribute_type=>'NUMBER' ,p_is_required=>false ,p_is_translatable=>false ,p_depending_on_attribute_id=>wwv_flow_api.id(43240979088736726254) ,p_depending_on_has_to_exist=>true ,p_depending_on_condition_type=>'NULL' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43240882146753376352) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>8 ,p_display_sequence=>90 ,p_prompt=>'Custom height' ,p_attribute_type=>'NUMBER' ,p_is_required=>false ,p_is_translatable=>false ,p_depending_on_attribute_id=>wwv_flow_api.id(43240979088736726254) ,p_depending_on_has_to_exist=>true ,p_depending_on_condition_type=>'NULL' ); wwv_flow_api.create_plugin_attribute( p_id=>wwv_flow_api.id(43240979088736726254) ,p_plugin_id=>wwv_flow_api.id(43230395099574900093) ,p_attribute_scope=>'COMPONENT' ,p_attribute_sequence=>9 ,p_display_sequence=>70 ,p_prompt=>'autosize' ,p_attribute_type=>'CHECKBOXES' ,p_is_required=>false ,p_is_translatable=>false ,p_lov_type=>'STATIC' ,p_help_text=>'Autosize will set the custom width and height on 100%' ); wwv_flow_api.create_plugin_attr_value( p_id=>wwv_flow_api.id(43240769651155380787) ,p_plugin_attribute_id=>wwv_flow_api.id(43240979088736726254) ,p_display_sequence=>10 ,p_display_value=>' ' ,p_return_value=>'Y' ); end; / prompt --application/end_environment begin wwv_flow_api.import_end(p_auto_install_sup_obj => nvl(wwv_flow_application_install.get_auto_install_sup_obj, false)); commit; end; / set verify on feedback on define on prompt ...done
true
f54b75ac248eebf5af2646cbb688f9e56a75fbd5
SQL
yj-smart/DotNetClub
/database/tables-sqlserver.sql
UTF-8
1,401
3.28125
3
[ "Artistic-2.0" ]
permissive
create table [User] ( ID bigint identity primary key, UserName nvarchar(20) not null unique, Password nvarchar(32) not null, Email nvarchar(100) not null unique, WebSite nvarchar(100), Location nvarchar(100), Signature nvarchar(200), CreateDate datetime not null, Status tinyint not null ) create table Topic ( ID bigint identity primary key, Category nvarchar(50) not null, Title nvarchar(100) not null, Content nvarchar(max) not null, CreateUser bigint not null, CreateDate datetime not null, UpdateDate datetime, IsLock bit not null, IsRecommand bit not null, IsTop bit not null, IsDelete bit not null, LastReplyDate datetime, LastReplyUserID bigint ) create table Comment ( ID bigint identity primary key, TopicID bigint not null, ReplyID bigint, Content nvarchar(max) not null, IsDelete bit not null, Createuser bigint not null, CreateDate datetime not null ) create table TopicCollect ( UserID bigint not null, TopicID bigint not null, CreateDate datetime not null primary key(UserID, TopicID) ) create table CommentVote ( UserID bigint not null, CommentID bigint not null, CreateDate datetime not null primary key(UserID, CommentID) ) create table Message ( ID bigint identity primary key, Type tinyint not null, TopicID bigint, CommentID bigint, FromUserID bigint, ToUserID bigint not null, CreateDate datetime not null, IsRead bit not null )
true
66db39522d34f1fe9df718ac8b709f25b9a551db
SQL
christineton/Extract_Transform_Load_Project
/christine/Project 2 Examples/ETL-examples/02-example_ETL_Pandas_Local/demo/query.sql
UTF-8
241
3.46875
3
[ "MIT" ]
permissive
-- Query to check successful load SELECT * FROM premise; SELECT * FROM county; -- Join tables on county_id SELECT premise.id, premise.premise_name, county.county_name FROM premise INNER JOIN county ON premise.county_id = county.county_id;
true
f38e4710a8a9708c08a873dc102886b450b05c33
SQL
JameChen/shopping
/quicksale/app_nahuo_v3.3_ali_release_sign/res/raw/sql.sql
UTF-8
2,997
2.78125
3
[]
no_license
create table upload_tasklist ( id INTEGER not null, create_time TIMESTAMP, title VARCHAR(500), intro VARCHAR(5000), price DEC(10,2), products VARCHAR(5000), cover char(250), images char(500), old_image char(500), is_add INTEGER, item_id INTEGER, group_ids char(500), is_only_4_agent INTEGER, retail_price DEC(10,2), upload_counter INTEGER default 0, notified INTEGER default 0, category VARCHAR(100), styles VARCHAR(100), shop_cats VARCHAR(100), attrs VARCHAR(50), is_top INTEGER, user_id INTEGER, login_user_id INTEGER, item_source_type INTEGER, user_name VARCHAR(200), source_id INTEGER, unique_tag VARCHAR(200), primary key (id) ); create table all_item_list ( id INTEGER not null, name VARCHAR(500), intro VARCHAR(5000), username VARCHAR(200), create_date TIMESTAMP, cover VARCHAR(250), price DEC(10,2), is_source INTEGER, images char(500), item_id INTEGER, item_item_id INTEGER, my_id INTEGER, page_index INTEGER, user_id INTEGER, retail_price DEC(10,2), org_user_id INTEGER, address VARCHAR(500), backup_address VARCHAR(500), mobile VARCHAR(500), wx_name VARCHAR(500), wx_num VARCHAR(500), apply_statu_id INTEGER, primary key (id) ); create table shop_item_list ( id INTEGER not null, name VARCHAR(500), intro VARCHAR(5000), username VARCHAR(200), create_date TIMESTAMP, cover VARCHAR(250), price DEC(10,2), is_source INTEGER, images char(500), user_id INTEGER, item_id INTEGER, item_item_id INTEGER, my_id INTEGER, page_index INTEGER, retail_price DEC(10,2), primary key (user_id,page_index,id) ); create table my_item_list ( id INTEGER not null, name VARCHAR(500), intro VARCHAR(5000), username VARCHAR(200), create_date TIMESTAMP, cover VARCHAR(250), price DEC(10,2), is_source INTEGER, images char(500), item_id INTEGER, item_item_id INTEGER, my_id INTEGER, page_index INTEGER, group_ids char(500), group_names char(500), is_only_4_agent INTEGER, user_id INTEGER, retail_price DEC(10,2), org_user_id INTEGER, address VARCHAR(500), backup_address VARCHAR(500), mobile VARCHAR(500), wx_name VARCHAR(500), wx_num VARCHAR(500), org_user_name VARCHAR(200), primary key (id) );
true
e99d17e70389e70247b9c0812bd61344dded4482
SQL
BoboDuluYaa/penjualan
/susipos (1).sql
UTF-8
7,837
3.015625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.5.2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jun 02, 2016 at 10:23 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: `susipos` -- -- -------------------------------------------------------- -- -- Table structure for table `barang` -- CREATE TABLE `barang` ( `barang_id` int(11) NOT NULL, `kategori_id` int(11) NOT NULL, `nama_barang` varchar(25) NOT NULL, `prod_unit` varchar(20) NOT NULL, `harga` int(11) NOT NULL, `stok` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `barang` -- INSERT INTO `barang` (`barang_id`, `kategori_id`, `nama_barang`, `prod_unit`, `harga`, `stok`) VALUES (3, 2, 'kolor firaun', 'lusin', 1000, 80), (5, 3, 'mukena putih', 'pcs', 85000, 69), (6, 2, 'coba', 'kodi', 7000, 92), (7, 1, 'dsfsdf', 'dfdsf', 20000, -46), (8, 3, 'alo', 'batang', 23444, 0), (9, 1, 'dfdf', 'dfdf', 4545, 0), (10, 3, 'kolor', 'kain', 230000, 0); -- -------------------------------------------------------- -- -- Table structure for table `customer` -- CREATE TABLE `customer` ( `cust_id` int(11) NOT NULL, `nama_customer` varchar(30) NOT NULL, `alamat` text NOT NULL, `kota` varchar(20) NOT NULL, `phone` varchar(20) NOT NULL, `no_hp` varchar(20) NOT NULL, `ket` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `customer` -- INSERT INTO `customer` (`cust_id`, `nama_customer`, `alamat`, `kota`, `phone`, `no_hp`, `ket`) VALUES (1001, 'sinar agung empat', 'ditempat bae gaes ', '9999', '838338', 'coba', 'saja'), (1004, 'PT.abcccc', 'jl. kodau no 76', 'bekasi', '5555', '9999', '-'), (1005, 'tonoris', 'jl.ampera no 10', 'cilacap', '0786778', '087765', '-'); -- -------------------------------------------------------- -- -- Table structure for table `history_bayar` -- CREATE TABLE `history_bayar` ( `transaksi_id` int(11) NOT NULL, `tgl_bayar` date NOT NULL, `jumlah_bayar` int(11) NOT NULL, `sisa_bayar` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `history_bayar` -- INSERT INTO `history_bayar` (`transaksi_id`, `tgl_bayar`, `jumlah_bayar`, `sisa_bayar`) VALUES (48, '2016-05-12', 50000, 140000), (48, '2016-05-04', 130000, 10000), (48, '2016-05-04', 10000, 0), (49, '2016-05-31', 0, 255000), (49, '2016-06-08', 100000, 155000), (49, '2016-06-09', 20000, 135000), (48, '2016-06-01', 135000, -65000), (50, '2016-06-08', 0, 99000), (50, '2016-06-01', 90000, 9000), (50, '2016-06-02', 9000, 0), (51, '2016-06-01', 0, 14000), (51, '2016-06-08', 1000, 13000), (51, '2016-06-08', 10000, 3000), (51, '2016-06-02', 3000, 0), (52, '2016-06-16', 1000, 27000), (53, '2016-06-15', 3000, 337000), (52, '2016-06-03', 27000, 0); -- -------------------------------------------------------- -- -- Table structure for table `kategori_barang` -- CREATE TABLE `kategori_barang` ( `kategori_id` int(11) NOT NULL, `nama_kategori` varchar(25) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `kategori_barang` -- INSERT INTO `kategori_barang` (`kategori_id`, `nama_kategori`) VALUES (1, 'sepatu bocah'), (2, 'sepatu import'), (3, 'baju muslimah'), (4, 'karung'); -- -------------------------------------------------------- -- -- Table structure for table `operator` -- CREATE TABLE `operator` ( `operator_id` int(11) NOT NULL, `nama_lengkap` varchar(30) NOT NULL, `foto` text NOT NULL, `username` varchar(30) NOT NULL, `password` varchar(100) NOT NULL, `last_login` date NOT NULL, `level` enum('1','2') NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `operator` -- INSERT INTO `operator` (`operator_id`, `nama_lengkap`, `foto`, `username`, `password`, `last_login`, `level`) VALUES (3, 'susi darmawanti', 'avatar.png', 'susi', '536931d80decb18c33db9612bdd004d4', '2016-06-01', '1'), (4, 'dadi', 'index-1_img-21.jpg', '123', '202cb962ac59075b964b07152d234b70', '2016-06-01', '2'); -- -------------------------------------------------------- -- -- Table structure for table `transaksi_jual` -- CREATE TABLE `transaksi_jual` ( `transaksi_id` int(11) NOT NULL, `tgl_transaksi` date NOT NULL, `operator_id` int(11) NOT NULL, `cust_id` varchar(20) NOT NULL, `total` int(11) NOT NULL, `jumlah_bayar` int(11) NOT NULL, `piutang` int(11) NOT NULL, `tgl_jatuh_tempo` date NOT NULL, `tgl_input` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `transaksi_jual` -- INSERT INTO `transaksi_jual` (`transaksi_id`, `tgl_transaksi`, `operator_id`, `cust_id`, `total`, `jumlah_bayar`, `piutang`, `tgl_jatuh_tempo`, `tgl_input`) VALUES (50, '2016-06-08', 3, '1004', 99000, 99000, 0, '2016-06-23', '2016-06-01 19:37:29'), (51, '2016-06-01', 3, '1004', 14000, 14000, 0, '2016-06-11', '2016-06-01 19:42:13'), (52, '2016-06-16', 3, '1004', 28000, 28000, 0, '2016-06-26', '2016-06-01 19:57:41'), (53, '2016-06-15', 3, '1001', 340000, 3000, 337000, '2016-07-05', '2016-06-01 20:27:13'); -- -------------------------------------------------------- -- -- Table structure for table `transaksi_jual_detail` -- CREATE TABLE `transaksi_jual_detail` ( `t_detail_id` int(11) NOT NULL, `barang_id` int(11) NOT NULL, `qty` int(11) NOT NULL, `transaksi_id` int(11) NOT NULL, `harga` int(11) NOT NULL, `status` enum('0','1') NOT NULL COMMENT '1=sudah diproses 0=belum diproses', `prod_unit` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `transaksi_jual_detail` -- INSERT INTO `transaksi_jual_detail` (`t_detail_id`, `barang_id`, `qty`, `transaksi_id`, `harga`, `status`, `prod_unit`) VALUES (88, 6, 2, 50, 7000, '1', 'kodi'), (89, 5, 1, 50, 85000, '1', 'pcs'), (90, 6, 2, 51, 7000, '1', 'kodi'), (91, 6, 4, 52, 7000, '1', 'kodi'), (92, 5, 4, 53, 85000, '1', 'pcs'), (94, 7, 4, 0, 20000, '0', 'dfdsf'); -- -- Indexes for dumped tables -- -- -- Indexes for table `barang` -- ALTER TABLE `barang` ADD PRIMARY KEY (`barang_id`); -- -- Indexes for table `customer` -- ALTER TABLE `customer` ADD PRIMARY KEY (`cust_id`); -- -- Indexes for table `kategori_barang` -- ALTER TABLE `kategori_barang` ADD PRIMARY KEY (`kategori_id`); -- -- Indexes for table `operator` -- ALTER TABLE `operator` ADD PRIMARY KEY (`operator_id`); -- -- Indexes for table `transaksi_jual` -- ALTER TABLE `transaksi_jual` ADD PRIMARY KEY (`transaksi_id`); -- -- Indexes for table `transaksi_jual_detail` -- ALTER TABLE `transaksi_jual_detail` ADD PRIMARY KEY (`t_detail_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `barang` -- ALTER TABLE `barang` MODIFY `barang_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT for table `kategori_barang` -- ALTER TABLE `kategori_barang` MODIFY `kategori_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `operator` -- ALTER TABLE `operator` MODIFY `operator_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `transaksi_jual` -- ALTER TABLE `transaksi_jual` MODIFY `transaksi_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=54; -- -- AUTO_INCREMENT for table `transaksi_jual_detail` -- ALTER TABLE `transaksi_jual_detail` MODIFY `t_detail_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=95; /*!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
21dd8f1663121d41fc9d5ad5b92579f202457c0b
SQL
calvin-and-smit/ds-interview-qs
/sql/snapchat_liked_pages.sql
UTF-8
872
3.8125
4
[]
no_license
/*************************************************************************************************** Liked Pages This question was asked by: Snapchat `friends` table column type user_id integer friend_user_id integer `page_likes` table column type user_id integer page_id integer Let's say we want to build a naive recommender. We're given two tables, one table called `friends` with a user_id and friend_user_id columns representing each user's friends, and another table called `page_likes` with a user_id and a page_id representing the page each user liked. Write an SQL query to create a metric to recommend pages for each user based on recommendations from their friends liked pages. Note: It shouldn't recommend pages that the user already likes. ***************************************************************************************************/
true
b187e955bb45c9074fabeb02a4b677d2bc882a18
SQL
bodoiquadi123/thuchanhwebphp
/fashi/db/linhkien.sql
UTF-8
13,902
3.109375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1:3308 -- Generation Time: Nov 26, 2020 at 01:09 PM -- Server version: 5.7.28 -- PHP Version: 7.3.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: `linhkien` -- -- -------------------------------------------------------- -- -- Table structure for table `chitietdonhang` -- DROP TABLE IF EXISTS `chitietdonhang`; CREATE TABLE IF NOT EXISTS `chitietdonhang` ( `machitietdonhang` varchar(20) NOT NULL, `madonhang` varchar(20) NOT NULL, `masanpham` varchar(20) NOT NULL, `soluong` int(11) NOT NULL, `gia` float NOT NULL, `giamgia` float NOT NULL, PRIMARY KEY (`machitietdonhang`), KEY `madonhang` (`madonhang`), KEY `masanpham` (`masanpham`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `chitietphieunhap` -- DROP TABLE IF EXISTS `chitietphieunhap`; CREATE TABLE IF NOT EXISTS `chitietphieunhap` ( `machitietphieunhap` varchar(20) NOT NULL, `maphieunhap` varchar(20) NOT NULL, `masanpham` varchar(20) NOT NULL, `soluong` int(11) NOT NULL, `gia` float NOT NULL, PRIMARY KEY (`machitietphieunhap`), KEY `maphieunhap` (`maphieunhap`), KEY `masanpham` (`masanpham`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `danhmuc` -- DROP TABLE IF EXISTS `danhmuc`; CREATE TABLE IF NOT EXISTS `danhmuc` ( `madanhmuc` varchar(20) NOT NULL, `tendanhmuc` varchar(50) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`madanhmuc`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `danhmuc` -- INSERT INTO `danhmuc` (`madanhmuc`, `tendanhmuc`) VALUES ('case', 'Case-Thùng máy tính'), ('cpu', 'CPU-Bộ vi xử lý'), ('hdd', 'Ổ cứng HDD'), ('main', 'Mainboard'), ('power', 'Nguồn máy tính'), ('ram', 'RAM-Bộ nhớ'), ('ssd', 'Ổ cứng SSD'), ('vga', 'Card màn hình'); -- -------------------------------------------------------- -- -- Table structure for table `donhang` -- DROP TABLE IF EXISTS `donhang`; CREATE TABLE IF NOT EXISTS `donhang` ( `madonhang` varchar(20) NOT NULL, `makhachhang` varchar(20) NOT NULL, `ngaydat` date NOT NULL, `ngaygiao` date NOT NULL, `diachi` varchar(100) CHARACTER SET utf8 NOT NULL, `ghichu` varchar(100) CHARACTER SET utf8 NOT NULL, `hinhthucthanhtoan` tinyint(1) NOT NULL, `trangthaidonhang` tinyint(1) DEFAULT NULL, PRIMARY KEY (`madonhang`), KEY `makhachhang` (`makhachhang`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `khachhang` -- DROP TABLE IF EXISTS `khachhang`; CREATE TABLE IF NOT EXISTS `khachhang` ( `makhachhang` varchar(20) NOT NULL, `tendangnhap` varchar(50) NOT NULL, `matkhau` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `hoten` varchar(50) CHARACTER SET utf8 NOT NULL, `gioitinh` tinyint(1) NOT NULL, `diachi` varchar(100) CHARACTER SET utf8 NOT NULL, `sodienthoai` int(11) NOT NULL, `madonhang` varchar(20) NOT NULL, PRIMARY KEY (`makhachhang`), KEY `madonhang` (`madonhang`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `nhacungcap` -- DROP TABLE IF EXISTS `nhacungcap`; CREATE TABLE IF NOT EXISTS `nhacungcap` ( `manhacungcap` varchar(20) NOT NULL, `tennhacungcap` varchar(50) NOT NULL, `diachi` varchar(150) CHARACTER SET utf8mb4 NOT NULL, `email` varchar(20) NOT NULL, `sodienthoai` int(11) NOT NULL, PRIMARY KEY (`manhacungcap`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `nhacungcap` -- INSERT INTO `nhacungcap` (`manhacungcap`, `tennhacungcap`, `diachi`, `email`, `sodienthoai`) VALUES ('antech', 'ANTECH', '175 Nguyễn Thị Minh Khai, Phường 7, Quận 3, Thành phố Hồ Chí Minh', 'antechvn@gmail.com', -4250449), ('asrock', 'ASROCK', '146 Nguyễn Tri Phương, Phường 8, Quận 5, Thành phố Hồ Chí Minh', 'asrockvn@gmail.com', -34445679), ('asus', 'ASUS', '134 Lý Thường Kiệt, Phường 7, Quận 10, Thành phố Hồ Chí Minh', 'asusvn@gmail.com', -39250679), ('ggbyte', 'GYGABYTE', '175 Nguyễn Thị Minh Khai, Phường Phạm Ngũ Lão, Quận 1, Thành phố Hồ Chí Minh', 'gygabytevn@gmail.com', -4250679), ('int', 'Intel', ' Lô I2, đường D1, khu công nghệ cao, Phường Tân Phú, Quận 9', 'intelvn@gmail.com', 30429984), ('kmax', 'KINGMAX', '29 Gò Dầu, Tân Sơn Nhì, Tân Phú, Thành phố Hồ Chí Minh', 'kingmaxvn@gmail.com', -39250719), ('kton', 'KINGSTON', '146 Nguyễn Văn Trỗi, Phường 8, Phú Nhuận, Thành phố Hồ Chí Minh', 'kingstonvn@gmail.com', -39245679), ('msi', 'MSI', '13T Dương Bá Trạc, Phường 1, Quận 8, Thành phố Hồ Chí Minh', 'msivn@gmail.com', -39250399); -- -------------------------------------------------------- -- -- Table structure for table `phieunhap` -- DROP TABLE IF EXISTS `phieunhap`; CREATE TABLE IF NOT EXISTS `phieunhap` ( `maphieunhap` varchar(20) NOT NULL, `manhacungcap` varchar(20) NOT NULL, `ngaynhap` date NOT NULL, PRIMARY KEY (`maphieunhap`), KEY `manhacungcap` (`manhacungcap`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `sanpham` -- DROP TABLE IF EXISTS `sanpham`; CREATE TABLE IF NOT EXISTS `sanpham` ( `masanpham` varchar(20) NOT NULL, `madanhmuc` varchar(20) NOT NULL, `manhacungcap` varchar(20) NOT NULL, `tensanpham` varchar(100) CHARACTER SET utf8 NOT NULL, `motasanpham` varchar(400) CHARACTER SET utf8 NOT NULL, `gia` float NOT NULL, `hinhanh` varchar(20) NOT NULL, PRIMARY KEY (`masanpham`), KEY `madanhmuc` (`madanhmuc`), KEY `manhacungcap` (`manhacungcap`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `sanpham` -- INSERT INTO `sanpham` (`masanpham`, `madanhmuc`, `manhacungcap`, `tensanpham`, `motasanpham`, `gia`, `hinhanh`) VALUES ('sp1', 'case', 'int', 'Case Jetek Space X - G9326', 'Giao tiếp: 1x USB 3.0 + 2x USB 2.0 Chất liệu: Mặc hông kính cường lực 4mm; Mặt trước nhựa kết hợp bar Led RGB; Thép dày 0.5mm sơn tĩnh điện Fan: Đỉnh 2x 120mm - Trước : 3x 120mm - Sau : 1x 120mm - Cover nguồn 2x120mm (Không kèm fan)', 550, 'imgs/case_3.png'), ('sp10', 'cpu', 'int', 'CPU INTEL Core i7-1700', 'Socket: LGA 1151 , Intel Core thế hệ thứ 7\r\n- Tốc độ xử lý: 3.0 GHz - 3.5 GHz ( 4 nhân, 4 luồng)\r\n- Bộ nhớ đệm: 6MB\r\n- Đồ họa tích hợp: Intel HD Graphics 630', 7600000, 'imgs/cpu_3.jpg'), ('sp11', 'cpu', 'int', 'CPU INTEL Core i7-9700', 'Socket: 1151-v2, Intel Core thế hệ thứ 9\r\nTốc độ: 3.00 GHz up to 4.70 GHz (8nhân, 8 luồng)\r\nBộ nhớ đệm: 12MB\r\nChip đồ họa tích hợp: Intel 630', 4600000, 'imgs/cpu_4.jpg'), ('sp12', 'cpu', 'asrock', 'CPU Intel Core I7-7700K (4.2GHz)', '- Socket: LGA 1151 , Intel Core thế hệ thứ 7\r\n- Tốc độ xử lý: 4.2 GHz ( 4 nhân, 8 luồng)\r\n- Bộ nhớ đệm: 8MB\r\n- Đồ họa tích hợp: Intel HD Graphics 630', 5690000, 'imgs/cpu_5.jpg'), ('sp13', 'cpu', 'int', 'CPU INTEL Core i7-4700', 'Socket: 1151-v2, Intel Core thế hệ thứ 9\r\nTốc độ: 3.00 GHz up to 4.70 GHz (8nhân, 8 luồng)\r\nBộ nhớ đệm: 12MB\r\nChip đồ họa tích hợp: Intel UHD Graphics 630', 8500000, 'imgs/cpu_6.jpg'), ('sp14', 'main', 'asus', 'Mainboard ASUS Rog Strix B460-F GAMINGG', '- Chuẩn mainboard: ATX\r\n- Socket: 1200 , Chipset: B460\r\n- Hỗ trợ RAM: 4 khe DDR4, tối đa 128GB\r\n- Lưu trữ: 1 x M.2 NVMe, Hỗ trợ Intel Optane, 1 x M.2 SATA/NVMe, 6 x SATA 3 6Gb/s\r\n- Cổng xuất hình: 1 x HDMI, 1 x DisplayPort', 3970000, 'imgs/main_2.jpg'), ('sp15', 'main', 'asus', 'Mainboard ASUS STRIX B460-G GAMING', '- Chuẩn mainboard: Micro-ATX\r\n- Socket: 1200 ,\r\n- Hỗ trợ RAM: 4 khe DDR4, tối đa 128GB\r\n- Lưu trữ: 1 x M.2 NVMe, Hỗ trợ Intel Optane, 1 x M.2 SATA/NVMe, 6 x SATA 3 6Gb/s\r\n- Cổng xuất hình: 1 x HDMI, 1 x DisplayPort', 4870000, 'imgs/main_3.jpg'), ('sp16', 'main', 'msi', 'Mainboard MSI A320M-A PRO MAX', '- Chuẩn mainboard: Micro-ATX\r\n- Socket: AM4 , Chipset: A320\r\n- Hỗ trợ RAM: 2 khe DDR4, tối đa 32GB\r\n- Lưu trữ: 4 x SATA 3 6Gb/s, 1 x M.2 SATA/NVMe\r\n- Cổng xuất hình: 1 x HDMI, 1 x DVI-D', 1870000, 'imgs/main_4.jpg'), ('sp17', 'main', 'msi', 'Mainboard MSI B450M-A PRO MAX', '- Chuẩn mainboard: Micro-ATX\r\n- Socket: AM4 , Chipset: B450\r\n- Hỗ trợ RAM: 2 khe DDR4, tối đa 32GB\r\n- Lưu trữ: 4 x SATA 3 6Gb/s, 1 x M.2 SATA/NVMe\r\n- Cổng xuất hình: 1 x HDMI, 1 x DVI-D', 1870000, 'imgs/main_5.jpg'), ('sp18', 'main', 'ggbyte', 'Mainboard GIGABYTE C246-WU4', '- Chuẩn mainboard: ATX\r\n- Socket: 1151-v2 , Chipset: C246\r\n- Hỗ trợ RAM: 4 khe DDR4, tối đa 128GB\r\n- Lưu trữ: 1 x M.2 NVMe, Hỗ trợ Intel Optane, 1 x M.2 SATA/NVMe, 10 x SATA 3 6Gb/s\r\n- Cổng xuất hình: 2 x DisplayPort', 3870000, 'imgs/main_6.jpg'), ('sp19', 'main', 'ggbyte', 'Mainboard GIGABYTE AB350-Gaming 3', '- Chuẩn mainboard: ATX\r\n- Socket: AM4 , Chipset: B350\r\n- Hỗ trợ RAM: DDR4 , tối đa 64GB\r\n- Cổng cắm lưu trữ: 1 x M.2 SATA/NVMe; 6 x SATA 3 6Gb/s\r\n- Cổng xuất hình: 1 x DVI-D; 1 x HDMI', 3670000, 'imgs/main_7.jpg'), ('sp2', 'case', 'asus', 'Case Deepcool Matrexx 50 ADD-RGB 4F', '- Hỗ trợ mainboard: Mini-ITX, Micro-ATX, ATX, Extended-ATX\r\n- Khay mở rộng tối đa: 2 x 3.5, 4 x 2.5\r\n- USB: , 1 x USB 3.0, 2 x USB 2.0\r\n- Quạt tặng kèm: 4 x 120 mm RGB', 319000, 'imgs/case_2.png'), ('sp20', 'main', 'asus', 'Mainboard ASUS ROG STRIX B460-G GAMING', '- Chuẩn mainboard: Micro-ATX\r\n- Socket: 1200 , Chipset: B460\r\n- Hỗ trợ RAM: 4 khe DDR4, tối đa 128GB\r\n- Lưu trữ: 1 x M.2 NVMe, Hỗ trợ Intel Optane, 1 x M.2 SATA/NVMe, 6 x SATA 3 6Gb/s\r\n- Cổng xuất hình: 1 x HDMI, 1 x DisplayPort', 3870000, 'imgs/main_1.jpg'), ('sp3', 'case', 'asus', 'Case Deepcool Matrexx 60 ADD-RGB', '- Hỗ trợ mainboard: Mini-ITX, Micro-ATX, ATX, Extended-ATX\r\n- Khay mở rộng tối đa: 2 x 3.5, 4 x 2.5\r\n- USB: , 1 x USB 3.0, 2 x USB 2.0\r\n- Quạt tặng kèm: 4 x 120 mm RGB', 333000, 'imgs/case_4.png'), ('sp4', 'case', 'antech', 'Case máy tính DEEPCOOL ADD-RGB 3F', '- Hỗ trợ mainboard: Mini-ITX, Micro-ATX, ATX, Extended-ATX\r\n- Khay mở rộng tối đa: 2 x 3.5, 4 x 2.5\r\n- USB: , 1 x USB 3.0, 2 x USB 2.0\r\n- Quạt tặng kèm: 4 x 120 mm RGB', 510000, 'imgs/case_5.png'), ('sp5', 'case', 'antech', 'Case máy tính DEEPCOOL Matrexx 70-RGB 3F - Mid Tower (Đen)', '- Hỗ trợ mainboard: Mini-ITX, Micro-ATX, ATX, Extended-ATX\r\n- Khay mở rộng tối đa: 2 x 3.5, 4 x 2.5\r\n- USB: , 1 x USB 3.0, 2 x USB 2.0\r\n- Quạt tặng kèm: 4 x 120 mm RGB', 319000, 'imgs/case_6.png'), ('sp6', 'case', 'int', 'Thùng máy/ Case 60 ADD-RGB', '- Hỗ trợ mainboard: Mini-ITX, Micro-ATX, ATX, Extended-ATX\r\n- Khay mở rộng tối đa: 2 x 3.5, 4 x 2.5\r\n- USB: , 1 x USB 3.0, 2 x USB 2.0\r\n- Quạt tặng kèm: 4 x 120 mm RGB', 433000, 'imgs/case_7.png'), ('sp7', 'case', 'int', 'Case máy tính DEEPCOOL Matrexx 30(Đen)', '- Hỗ trợ mainboard: Mini-ITX, Micro-ATX, ATX, Extended-ATX\r\n- Khay mở rộng tối đa: 2 x 3.5, 4 x 2.5\r\n- USB: , 1 x USB 3.0, 2 x USB 2.0\r\n- Quạt tặng kèm: 4 x 120 mm RGB', 470000, 'imgs/case_8.png'), ('sp8', 'cpu', 'int', 'CPU INTEL Core i7-9700', 'Socket: 1151-v2, Intel Core thế hệ thứ 9\r\nTốc độ: 3.00 GHz up to 4.70 GHz (8nhân, 8 luồng)\r\nBộ nhớ đệm: 12MB\r\nChip đồ họa tích hợp: Intel UHD Graphics 630', 7600000, 'imgs/cpu_1.jpg'), ('sp9', 'cpu', 'int', 'CPU INTEL Core i7-900', 'Socket: 1151-v2, Intel Core thế hệ thứ 9\r\nTốc độ: 3.00 GHz up to 4.70 GHz (8nhân, 8 luồng)\r\nBộ nhớ đệm: 12MB', 8600000, 'imgs/cpu_2.jpg'); -- -- Constraints for dumped tables -- -- -- Constraints for table `chitietdonhang` -- ALTER TABLE `chitietdonhang` ADD CONSTRAINT `chitietdonhang_ibfk_1` FOREIGN KEY (`madonhang`) REFERENCES `donhang` (`madonhang`), ADD CONSTRAINT `chitietdonhang_ibfk_2` FOREIGN KEY (`masanpham`) REFERENCES `sanpham` (`masanpham`); -- -- Constraints for table `chitietphieunhap` -- ALTER TABLE `chitietphieunhap` ADD CONSTRAINT `chitietphieunhap_ibfk_1` FOREIGN KEY (`maphieunhap`) REFERENCES `phieunhap` (`maphieunhap`), ADD CONSTRAINT `chitietphieunhap_ibfk_2` FOREIGN KEY (`masanpham`) REFERENCES `sanpham` (`masanpham`); -- -- Constraints for table `donhang` -- ALTER TABLE `donhang` ADD CONSTRAINT `donhang_ibfk_1` FOREIGN KEY (`makhachhang`) REFERENCES `khachhang` (`makhachhang`); -- -- Constraints for table `khachhang` -- ALTER TABLE `khachhang` ADD CONSTRAINT `khachhang_ibfk_1` FOREIGN KEY (`madonhang`) REFERENCES `donhang` (`madonhang`); -- -- Constraints for table `phieunhap` -- ALTER TABLE `phieunhap` ADD CONSTRAINT `phieunhap_ibfk_1` FOREIGN KEY (`manhacungcap`) REFERENCES `nhacungcap` (`manhacungcap`); -- -- Constraints for table `sanpham` -- ALTER TABLE `sanpham` ADD CONSTRAINT `sanpham_ibfk_1` FOREIGN KEY (`madanhmuc`) REFERENCES `danhmuc` (`madanhmuc`), ADD CONSTRAINT `sanpham_ibfk_2` FOREIGN KEY (`manhacungcap`) REFERENCES `nhacungcap` (`manhacungcap`); 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
f4140d5bd28d24e6eb2b39f89c8e727f3b79cb2b
SQL
moutainhigh/tz
/ms/sql/biz/T_CONTENT_TYPE.sql
UTF-8
459
2.71875
3
[]
no_license
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `T_CONTENTTYPE` -- ---------------------------- DROP TABLE IF EXISTS `T_CONTENT_TYPE`; CREATE TABLE `T_CONTENT_TYPE` ( `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID', `TYPE_KEY` varchar(20) NOT NULL COMMENT '网站内容KEY', `TYPE_DES` varchar(20) NOT NULL COMMENT '网站内容类型描述', PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
true
ae462d78f6ad20173b0ac7b05b48a7cdfd4b04dc
SQL
evfurio/scripts
/Doc/system_queries/GScom user openID.sql
UTF-8
292
3.265625
3
[]
no_license
--SELECT COUNT(*) --3617443 SELECT TOP 1000 uo.dt_date_created, uo.i_customer_id, uo.u_email_address , mu.OpenIDClaimedIdentifier FROM Gamestop_profiles.dbo.userobject uo WITH(NOLOCK) JOIN Gamestop_profiles.dbo.stage_MultipassUsers mu WITH(NOLOCK) ON uo.u_email_address = mu.UserName
true
a0a2c2f0415197dc4d800ed63d825fb518f2ccc0
SQL
kbevers/FIRE-DDL
/QA/Statistics.sql
UTF-8
2,716
3.359375
3
[ "MIT" ]
permissive
SELECT 'PUNKT' AS TABLENAME, NULL AS INFOTYPE, SUM(CASE WHEN REGISTRERINGTIL IS NULL THEN 1 ELSE 0 END) AS CURRENTINSTANSES, SUM(CASE WHEN REGISTRERINGTIL IS NOT NULL THEN 1 ELSE 0 END) AS PREVIOUSINSTANSES, COUNT(REGISTRERINGFRA) AS TOTALINSTANSES FROM PUNKT GROUP BY 1 UNION ALL SELECT 'GEOMETRIOBJEKT' AS TABLENAME, NULL AS INFOTYPE, SUM(CASE WHEN REGISTRERINGTIL IS NULL THEN 1 ELSE 0 END) AS CURRENTINSTANSES, SUM(CASE WHEN REGISTRERINGTIL IS NOT NULL THEN 1 ELSE 0 END) AS PREVIOUSINSTANSES, COUNT(REGISTRERINGFRA) AS TOTALINSTANSES FROM GEOMETRIOBJEKT GROUP BY 1 UNION ALL SELECT 'KOORDINAT' AS TABLENAME, SRID AS INFOTYPE, SUM(CASE WHEN REGISTRERINGTIL IS NULL THEN 1 ELSE 0 END) AS CURRENTINSTANSES, SUM(CASE WHEN REGISTRERINGTIL IS NOT NULL THEN 1 ELSE 0 END) AS PREVIOUSINSTANSES, COUNT(REGISTRERINGFRA) AS TOTALINSTANSES FROM KOORDINAT GROUP BY SRID UNION ALL SELECT 'PUNKTINFO' AS TABLENAME, INFOTYPE AS INFOTYPE, SUM(CASE WHEN REGISTRERINGTIL IS NULL THEN 1 ELSE 0 END) AS CURRENTINSTANSES, SUM(CASE WHEN REGISTRERINGTIL IS NOT NULL THEN 1 ELSE 0 END) AS PREVIOUSINSTANSES, COUNT(REGISTRERINGFRA) AS TOTALINSTANSES FROM PUNKTINFO GROUP BY INFOTYPE UNION ALL SELECT 'OBSERVATION' AS TABLENAME, OBSERVATIONSTYPE AS INFOTYPE, SUM(CASE WHEN REGISTRERINGTIL IS NULL THEN 1 ELSE 0 END) AS CURRENTINSTANSES, SUM(CASE WHEN REGISTRERINGTIL IS NOT NULL THEN 1 ELSE 0 END) AS PREVIOUSINSTANSES, COUNT(REGISTRERINGFRA) AS TOTALINSTANSES FROM OBSERVATION GROUP BY OBSERVATIONSTYPE UNION ALL SELECT 'BEREGNING' AS TABLENAME, NULL AS INFOTYPE, SUM(CASE WHEN REGISTRERINGTIL IS NULL THEN 1 ELSE 0 END) AS CURRENTINSTANSES, SUM(CASE WHEN REGISTRERINGTIL IS NOT NULL THEN 1 ELSE 0 END) AS PREVIOUSINSTANSES, COUNT(REGISTRERINGFRA) AS TOTALINSTANSES FROM BEREGNING GROUP BY 1 UNION ALL SELECT 'BEREGNING_KOORDINAT' AS TABLENAME, NULL AS INFOTYPE, COUNT(*), 0 AS PREVIOUSINSTANSES, COUNT(*) AS TOTALINSTANSES FROM BEREGNING_KOORDINAT GROUP BY 1 UNION ALL SELECT 'BEREGNING_OBSERVATION' AS TABLENAME, NULL AS INFOTYPE, COUNT(*), 0 AS PREVIOUSINSTANSES, COUNT(*) AS TOTALINSTANSES FROM BEREGNING_OBSERVATION GROUP BY 1 UNION ALL SELECT 'SAG' AS TABLENAME, NULL AS INFOTYPE, COUNT(REGISTRERINGFRA), 0 AS PREVIOUSINSTANSES, COUNT(REGISTRERINGFRA) AS TOTALINSTANSES FROM SAG GROUP BY 1 UNION ALL SELECT 'SAGSEVENT' AS TABLENAME, EVENT AS INFOTYPE, COUNT(REGISTRERINGFRA), 0 AS PREVIOUSINSTANSES, COUNT(REGISTRERINGFRA) AS TOTALINSTANSES FROM SAGSEVENT GROUP BY EVENT ORDER BY TABLENAME, INFOTYPE ;
true
aff8b7fac9a8f4308db7515e9b230268273fbd68
SQL
marmikp/Book-My-Garage
/charlie_db (1).sql
UTF-8
4,146
3.078125
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.5.2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jan 24, 2019 at 04:50 PM -- Server version: 10.1.13-MariaDB -- PHP Version: 5.6.20 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: `charlie_db` -- -- -------------------------------------------------------- -- -- Table structure for table `garage_location` -- CREATE TABLE `garage_location` ( `id` int(5) NOT NULL, `username` varchar(50) NOT NULL, `location` varchar(100) DEFAULT NULL, `status` int(2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `garage_location` -- INSERT INTO `garage_location` (`id`, `username`, `location`, `status`) VALUES (1, 'jinali@gmail.com', '23.755535893465865,72.54202388226987', 1); -- -------------------------------------------------------- -- -- Table structure for table `garage_temp_location` -- CREATE TABLE `garage_temp_location` ( `id` int(10) NOT NULL, `username` varchar(50) NOT NULL, `location` varchar(50) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `garage_temp_location` -- INSERT INTO `garage_temp_location` (`id`, `username`, `location`) VALUES (1, 'jinali@gmail.com', '23.7623704,72.5609652'); -- -------------------------------------------------------- -- -- Table structure for table `login` -- CREATE TABLE `login` ( `id` int(5) NOT NULL, `username` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, `status` int(2) NOT NULL, `name` varchar(50) NOT NULL, `mobile` varchar(12) NOT NULL, `img_name` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `login` -- INSERT INTO `login` (`id`, `username`, `password`, `status`, `name`, `mobile`, `img_name`) VALUES (1, 'chirag@gmail.com', 'chirag', 0, 'Chirag Joshi', '8141642183', 'IMG-20190122-WA0014.jpg'), (2, 'jinali@gmail.com', 'jinali', 1, 'Jinali Raval', '8849739018', 'IMG-20190122-WA0011.jpg'); -- -------------------------------------------------------- -- -- Table structure for table `request` -- CREATE TABLE `request` ( `id` int(100) NOT NULL, `username` varchar(50) NOT NULL, `location` varchar(100) NOT NULL, `message` varchar(500) NOT NULL, `work_status` int(2) NOT NULL, `flag` int(2) NOT NULL, `work_by` varchar(50) NOT NULL, `distance` varchar(5) NOT NULL, `ask_complete` int(2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `request` -- INSERT INTO `request` (`id`, `username`, `location`, `message`, `work_status`, `flag`, `work_by`, `distance`, `ask_complete`) VALUES (1, 'chirag@gmail.com', '23.7552885,72.5416631', 'My car stopped', 0, 0, 'jinali@gmail.com', '0.045', 0); -- -- Indexes for dumped tables -- -- -- Indexes for table `garage_location` -- ALTER TABLE `garage_location` ADD PRIMARY KEY (`id`); -- -- Indexes for table `garage_temp_location` -- ALTER TABLE `garage_temp_location` ADD PRIMARY KEY (`id`); -- -- Indexes for table `login` -- ALTER TABLE `login` ADD PRIMARY KEY (`id`,`username`); -- -- Indexes for table `request` -- ALTER TABLE `request` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `garage_location` -- ALTER TABLE `garage_location` MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `garage_temp_location` -- ALTER TABLE `garage_temp_location` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `login` -- ALTER TABLE `login` MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `request` -- ALTER TABLE `request` MODIFY `id` int(100) 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
6fb19c9249a87f24a1017bd8bde9b0bf7c6d4c0b
SQL
OsamuYabuta/wuhan
/db/create.sql
UTF-8
941
3.390625
3
[]
no_license
create table tweets ( id bigint(20) unsigned not null primary key, lang char(2) not null , tweet text not null , username varchar(100) not null, created_at datetime not null, since_id int(11) unsigned default 0, screen_name varchar(255) default null, key idx_lang(lang), key idx_username(username) ) engine=innodb default charset utf8mb4; create table tweet_topics ( id int(11) unsigned not null auto_increment primary key, lang char(2) not null, topic varchar(255) not null , score double default 0.0, calculated_date date default null, key idx_lang(lang) ) engine=innodb default charset utf8mb4; create table tweet_pickup_users ( id int(11) unsigned not null auto_increment primary key, screen_name varchar(255) not null, lang char(2) not null, score double, calculated_date date default null, key idx_lang(lang) ) engine=innodb default charset utf8mb4;
true
de9735a3af2857f2d1cb42768304bfb9f9fc965a
SQL
quedacoder/Capstone
/import.sql
UTF-8
2,801
3.890625
4
[]
no_license
CREATE TABLE `project` ( `project_id` bigint(20) NOT NULL AUTO_INCREMENT, `changed_by` varchar(255) DEFAULT NULL, `changed_date` datetime(6) NOT NULL, `created_by` varchar(255) DEFAULT NULL, `created_date` datetime(6) NOT NULL, `description` varchar(255) DEFAULT NULL, `process_area` int(11) DEFAULT NULL, `project_name` varchar(255) DEFAULT NULL, `project_owner` varchar(255) DEFAULT NULL, PRIMARY KEY (`project_id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE `task` ( `task_id` bigint(20) NOT NULL AUTO_INCREMENT, `changed_by` varchar(255) DEFAULT NULL, `changed_date` datetime(6) DEFAULT NULL, `comments` varchar(255) DEFAULT NULL, `created_by` varchar(255) DEFAULT NULL, `created_date` datetime(6) DEFAULT NULL, `start_date` datetime(6) DEFAULT NULL, `status` varchar(15) DEFAULT NULL, `description` varchar(255) DEFAULT NULL, `task_name` varchar(255) DEFAULT NULL, `task_type` varchar(15) DEFAULT NULL, `ticket_number` varchar(255) DEFAULT NULL, `project_id` bigint(20) NOT NULL, PRIMARY KEY (`task_id`), KEY `FK_task_project` (`project_id`), CONSTRAINT `FK_task_project` FOREIGN KEY (`project_id`) REFERENCES `project` (`project_id`) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE `task_replicated_data` ( `task_replicated_id` bigint(20) NOT NULL AUTO_INCREMENT, `changed_by` varchar(255) DEFAULT NULL, `changed_date` datetime(6) DEFAULT NULL, `comments` varchar(255) DEFAULT NULL, `created_by` varchar(255) DEFAULT NULL, `created_date` datetime(6) DEFAULT NULL, `start_date` datetime(6) DEFAULT NULL, `status` varchar(15) DEFAULT NULL, `description` varchar(255) DEFAULT NULL, `task_name` varchar(255) DEFAULT NULL, `task_type` varchar(15) DEFAULT NULL, `ticket_number` varchar(255) DEFAULT NULL, `task_id` bigint(20) NOT NULL, PRIMARY KEY (`task_replicated_id`), KEY `FKk8qrwowg31kx7hp93sru1pdqa` (`task_id`), CONSTRAINT `TASK_CHANDED_DATA_TB` FOREIGN KEY (`task_id`) REFERENCES `task` (`task_id`) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `GET_RECENT_TASK_UPDATES`(IN pTask_id BIGINT(20)) BEGIN SELECT task_replicated_id, task_name, task_type, ticket_number, status, description, comments, changed_by, changed_date FROM task_replicated_data INNER JOIN ( SELECT MAX(task_replicated_id) as max_task_id FROM task_replicated_data GROUP BY task_replicated_id ) trd ON task_replicated_data.task_replicated_id = trd.max_task_id WHERE task_id = pTask_id ORDER BY task_replicated_id desc LIMIT 4; END$$ DELIMITER ;
true
71d8631daa8e53615a5cb022fb816a82c1c65be7
SQL
jayesh25parab/Entity-Relationship-Diagram
/My_Query_A3.sql
UTF-8
15,388
3.203125
3
[]
no_license
DROP TABLE Audit_Log CASCADE CONSTRAINTS ; DROP TABLE Configuration CASCADE CONSTRAINTS ; DROP TABLE Connection CASCADE CONSTRAINTS ; DROP TABLE Device CASCADE CONSTRAINTS ; DROP TABLE Download CASCADE CONSTRAINTS ; DROP TABLE Media_Player CASCADE CONSTRAINTS ; DROP TABLE Member CASCADE CONSTRAINTS ; DROP TABLE Physical_Dvd CASCADE CONSTRAINTS ; DROP TABLE Rent CASCADE CONSTRAINTS ; DROP TABLE Review CASCADE CONSTRAINTS ; DROP TABLE Serve CASCADE CONSTRAINTS ; DROP TABLE Title CASCADE CONSTRAINTS ; DROP TABLE Video CASCADE CONSTRAINTS ; DROP TABLE Video_Quality CASCADE CONSTRAINTS ; DROP TABLE Warehouse CASCADE CONSTRAINTS ; CREATE TABLE Audit_Log ( Audit_Log_Id NUMBER (6) NOT NULL , Log_Time_Date TIMESTAMP NOT NULL , Is_Suspended CHAR (1) NOT NULL , Mofified_By_User VARCHAR2 (20) NOT NULL , Membership_Number NUMBER (7) NOT NULL ) ; ALTER TABLE Audit_Log ADD CONSTRAINT Suspended_Constraint CHECK ( Is_Suspended IN ('Y','N')) ; COMMENT ON COLUMN Audit_Log.Membership_Number IS 'Membership Number' ; ALTER TABLE Audit_Log ADD CONSTRAINT Audit_Log_PK PRIMARY KEY ( Audit_Log_Id ) ; CREATE TABLE Configuration ( DeliveryConfigNo NUMBER (7) NOT NULL , MediaPlayer VARCHAR2 (20) NOT NULL , Media_Player_Version VARCHAR2 (20) NOT NULL , Device_Name VARCHAR2 (20) NOT NULL , Device_Memory_Size NUMBER (7) NOT NULL , Video_Quality_Code CHAR (3) NOT NULL , Connection_Code VARCHAR2 (6) NOT NULL ) ; COMMENT ON COLUMN Configuration.DeliveryConfigNo IS 'Delivery Configuration Number' ; COMMENT ON COLUMN Configuration.MediaPlayer IS 'Media Player Name' ; COMMENT ON COLUMN Configuration.Media_Player_Version IS 'Version Of Media Player' ; COMMENT ON COLUMN Configuration.Device_Name IS 'Name Of Device' ; COMMENT ON COLUMN Configuration.Device_Memory_Size IS 'Memory Size Of Device' ; COMMENT ON COLUMN Configuration.Connection_Code IS 'Connection Code' ; ALTER TABLE Configuration ADD CONSTRAINT Configuration_PK PRIMARY KEY ( DeliveryConfigNo ) ; CREATE TABLE Connection ( Connection_Code VARCHAR2 (6) NOT NULL , Connection_Type VARCHAR2 (20) NOT NULL ) ; COMMENT ON COLUMN Connection.Connection_Code IS 'Connection Code' ; COMMENT ON COLUMN Connection.Connection_Type IS 'Type of Connection' ; ALTER TABLE Connection ADD CONSTRAINT Connection_PK PRIMARY KEY ( Connection_Code ) ; CREATE TABLE Device ( Device_Name VARCHAR2 (20) NOT NULL , Device_Memory_Size NUMBER (7) NOT NULL ) ; COMMENT ON COLUMN Device.Device_Name IS 'Name Of Device' ; COMMENT ON COLUMN Device.Device_Memory_Size IS 'Memory Size Of Device' ; ALTER TABLE Device ADD CONSTRAINT Device_PK PRIMARY KEY ( Device_Name, Device_Memory_Size ) ; CREATE TABLE Download ( Download_ID NUMBER (7) NOT NULL , Download_Start_Date DATE NOT NULL , Download_Complete_Date DATE NOT NULL , Title_id NUMBER (7) NOT NULL , Server_ID NUMBER (7) NOT NULL , Membership_Number NUMBER (7) NOT NULL , DeliveryConfigNo NUMBER (7) NOT NULL ) ; COMMENT ON COLUMN Download.Download_ID IS 'Warehouse Identifier' ; COMMENT ON COLUMN Download.Download_Start_Date IS 'Download Start Date' ; COMMENT ON COLUMN Download.Download_Complete_Date IS 'Download End Date' ; COMMENT ON COLUMN Download.Title_id IS 'Unique Title Identifier' ; COMMENT ON COLUMN Download.Server_ID IS 'Server Identifier' ; COMMENT ON COLUMN Download.Membership_Number IS 'Membership Number' ; COMMENT ON COLUMN Download.DeliveryConfigNo IS 'Delivery Configuration Number' ; ALTER TABLE Download ADD CONSTRAINT Download_PK PRIMARY KEY ( Download_ID ) ; CREATE TABLE Media_Player ( MediaPlayer VARCHAR2 (20) NOT NULL , Media_Player_Version VARCHAR2 (20) NOT NULL ) ; COMMENT ON COLUMN Media_Player.MediaPlayer IS 'Media Player Name' ; COMMENT ON COLUMN Media_Player.Media_Player_Version IS 'Version Of Media Player' ; ALTER TABLE Media_Player ADD CONSTRAINT Media_Player_PK PRIMARY KEY ( MediaPlayer, Media_Player_Version ) ; CREATE TABLE Member ( Membership_Number NUMBER (7) NOT NULL , Member_Name VARCHAR2 (50) NOT NULL , Member_Delivery_Address VARCHAR2 (50) NOT NULL , Member_Phone_Number NUMBER (10) , Member_Email_Address VARCHAR2 (20) , Membership_Level CHAR (1) NOT NULL , Membership_Start_Date DATE NOT NULL , Membership_Status CHAR (1) ) ; ALTER TABLE Member ADD CONSTRAINT membership_level_constraint CHECK ( Membership_Level IN ('G', 'S', 'B')) ; ALTER TABLE Member ADD CONSTRAINT membership_status_constraint CHECK ( Membership_Status IN ('C', 'S', 'I')) ; COMMENT ON COLUMN Member.Membership_Number IS 'Membership Number' ; COMMENT ON COLUMN Member.Member_Name IS 'Member Name' ; COMMENT ON COLUMN Member.Member_Delivery_Address IS 'DVD Delivery Address' ; COMMENT ON COLUMN Member.Member_Phone_Number IS 'Member Contact Number' ; COMMENT ON COLUMN Member.Member_Email_Address IS 'Member Email Address' ; COMMENT ON COLUMN Member.Membership_Level IS 'Level of Membership' ; COMMENT ON COLUMN Member.Membership_Start_Date IS 'Starting Date of Membership' ; COMMENT ON COLUMN Member.Membership_Status IS 'Status of Membership' ; ALTER TABLE Member ADD CONSTRAINT Member_PK PRIMARY KEY ( Membership_Number ) ; CREATE TABLE Physical_Dvd ( DVD_ID NUMBER (7) NOT NULL , DVD_Format VARCHAR2 (50) NOT NULL , Warehouse_ID NUMBER (7) NOT NULL , Title_id NUMBER (7) NOT NULL ) ; COMMENT ON COLUMN Physical_Dvd.DVD_ID IS 'DVD_ID Identifier' ; COMMENT ON COLUMN Physical_Dvd.DVD_Format IS 'Format of DVD' ; COMMENT ON COLUMN Physical_Dvd.Warehouse_ID IS 'Warehouse Identifier' ; COMMENT ON COLUMN Physical_Dvd.Title_id IS 'Unique Title Identifier' ; ALTER TABLE Physical_Dvd ADD CONSTRAINT Physical_Dvd_PK PRIMARY KEY ( DVD_ID ) ; CREATE TABLE Rent ( Rent_Id NUMBER (7) NOT NULL , Dispatch_Date DATE NOT NULL , Receive_Date DATE NOT NULL , DVD_ID NUMBER (7) NOT NULL , Membership_Number NUMBER (7) NOT NULL ) ; COMMENT ON COLUMN Rent.Rent_Id IS 'Rent Identifier' ; COMMENT ON COLUMN Rent.Dispatch_Date IS 'Dispatch Date Of Dvd' ; COMMENT ON COLUMN Rent.Receive_Date IS 'Receive Date Of Date' ; COMMENT ON COLUMN Rent.DVD_ID IS 'DVD_ID Identifier' ; COMMENT ON COLUMN Rent.Membership_Number IS 'Membership Number' ; ALTER TABLE Rent ADD CONSTRAINT Rent_PK PRIMARY KEY ( Rent_Id ) ; CREATE TABLE Review ( Review_Rating NUMBER (1) NOT NULL , Review_Comment VARCHAR2 (50) NOT NULL , Membership_Number NUMBER (7) NOT NULL , Title_id NUMBER (7) NOT NULL ) ; ALTER TABLE Review ADD CONSTRAINT rating_between_1_to5 CHECK ( Review_Rating >=1 AND Review_Rating<=5) ; COMMENT ON COLUMN Review.Review_Rating IS 'Review Rating' ; COMMENT ON COLUMN Review.Review_Comment IS 'Review Comment for Title' ; COMMENT ON COLUMN Review.Membership_Number IS 'Membership Number' ; COMMENT ON COLUMN Review.Title_id IS 'Unique Title Identifier' ; ALTER TABLE Review ADD CONSTRAINT Review_PK PRIMARY KEY ( Membership_Number, Title_id ) ; CREATE TABLE Serve ( Server_ID NUMBER (7) NOT NULL , Server_Ip_Address VARCHAR2 (20) NOT NULL , Server_Os VARCHAR2 (20) NOT NULL , Server_Location VARCHAR2 (20) NOT NULL , Server_Disk_Capacity VARCHAR2 (20) NOT NULL , Server_Max_Bandwidth VARCHAR2 (20) NOT NULL ) ; COMMENT ON COLUMN Serve.Server_ID IS 'Server Identifier' ; COMMENT ON COLUMN Serve.Server_Ip_Address IS 'Server IP Address' ; COMMENT ON COLUMN Serve.Server_Os IS 'Server Operating System' ; COMMENT ON COLUMN Serve.Server_Location IS 'Server Location' ; COMMENT ON COLUMN Serve.Server_Disk_Capacity IS 'Server Disk Capacity' ; COMMENT ON COLUMN Serve.Server_Max_Bandwidth IS 'Server Max Bandwidth' ; ALTER TABLE Serve ADD CONSTRAINT Serve_PK PRIMARY KEY ( Server_ID ) ; CREATE TABLE Title ( Title_id NUMBER (7) NOT NULL , Title_Name VARCHAR2 (50) NOT NULL , Title_Classification CHAR (2) NOT NULL , Number_Of_Minutes NUMBER (3) NOT NULL , Title_Director VARCHAR2 (50) , Title_Actor VARCHAR2 (50) , Title_Actress VARCHAR2 (50) , Title_Genre VARCHAR2 (50) NOT NULL , Title_Language VARCHAR2 (50) NOT NULL ) ; COMMENT ON COLUMN Title.Title_id IS 'Unique Title Identifier' ; COMMENT ON COLUMN Title.Title_Name IS 'Title Name' ; COMMENT ON COLUMN Title.Title_Classification IS 'Classification Of Title' ; COMMENT ON COLUMN Title.Number_Of_Minutes IS 'Length Of Title in Minutes' ; COMMENT ON COLUMN Title.Title_Director IS 'Director Of Title' ; COMMENT ON COLUMN Title.Title_Actor IS 'Lead Actor of Title' ; COMMENT ON COLUMN Title.Title_Genre IS 'Genre of Title' ; COMMENT ON COLUMN Title.Title_Language IS 'Language Of Title' ; ALTER TABLE Title ADD CONSTRAINT Title_PK PRIMARY KEY ( Title_id ) ; CREATE TABLE Video ( Title_id NUMBER (7) NOT NULL , Server_ID NUMBER (7) NOT NULL , File_Size NUMBER (7) NOT NULL , DeliveryConfigNo NUMBER (7) NOT NULL ) ; COMMENT ON COLUMN Video.Title_id IS 'Unique Title Identifier' ; COMMENT ON COLUMN Video.Server_ID IS 'Server Identifier' ; COMMENT ON COLUMN Video.File_Size IS 'Size Of File' ; COMMENT ON COLUMN Video.DeliveryConfigNo IS 'Delivery Configuration Number' ; ALTER TABLE Video ADD CONSTRAINT Video_PK PRIMARY KEY ( Title_id, Server_ID, DeliveryConfigNo ) ; CREATE TABLE Video_Quality ( Video_Quality_Code CHAR (3) NOT NULL , Video_Quality VARCHAR2 (20) NOT NULL ) ; COMMENT ON COLUMN Video_Quality.Video_Quality IS 'Video Quality' ; ALTER TABLE Video_Quality ADD CONSTRAINT Video_Quality_PK PRIMARY KEY ( Video_Quality_Code ) ; CREATE TABLE Warehouse ( Warehouse_ID NUMBER (7) NOT NULL , Warehouse_Location VARCHAR2 (50) ) ; COMMENT ON COLUMN Warehouse.Warehouse_ID IS 'Warehouse Identifier' ; COMMENT ON COLUMN Warehouse.Warehouse_Location IS 'Warehouse location' ; ALTER TABLE Warehouse ADD CONSTRAINT Warehouse_PK PRIMARY KEY ( Warehouse_ID ) ; ALTER TABLE Audit_Log ADD CONSTRAINT Audit_Log_Member_FK FOREIGN KEY ( Membership_Number ) REFERENCES Member ( Membership_Number ) ; ALTER TABLE Configuration ADD CONSTRAINT Configuration_Connection_FK FOREIGN KEY ( Connection_Code ) REFERENCES Connection ( Connection_Code ) ; ALTER TABLE Configuration ADD CONSTRAINT Configuration_Device_FK FOREIGN KEY ( Device_Name, Device_Memory_Size ) REFERENCES Device ( Device_Name, Device_Memory_Size ) ; ALTER TABLE Configuration ADD CONSTRAINT Configuration_Media_Player_FK FOREIGN KEY ( MediaPlayer, Media_Player_Version ) REFERENCES Media_Player ( MediaPlayer, Media_Player_Version ) ; ALTER TABLE Configuration ADD CONSTRAINT Configuration_Video_Quality_FK FOREIGN KEY ( Video_Quality_Code ) REFERENCES Video_Quality ( Video_Quality_Code ) ; ALTER TABLE Download ADD CONSTRAINT Download_Member_FK FOREIGN KEY ( Membership_Number ) REFERENCES Member ( Membership_Number ) ; ALTER TABLE Download ADD CONSTRAINT Download_Video_FK FOREIGN KEY ( Title_id, Server_ID, DeliveryConfigNo ) REFERENCES Video ( Title_id, Server_ID, DeliveryConfigNo ) ; ALTER TABLE Physical_Dvd ADD CONSTRAINT Physical_Dvd_Title_FK FOREIGN KEY ( Title_id ) REFERENCES Title ( Title_id ) ; ALTER TABLE Physical_Dvd ADD CONSTRAINT Physical_Dvd_Warehouse_FK FOREIGN KEY ( Warehouse_ID ) REFERENCES Warehouse ( Warehouse_ID ) ; ALTER TABLE Rent ADD CONSTRAINT Rent_Member_FK FOREIGN KEY ( Membership_Number ) REFERENCES Member ( Membership_Number ) ; ALTER TABLE Rent ADD CONSTRAINT Rent_Physical_Dvd_FK FOREIGN KEY ( DVD_ID ) REFERENCES Physical_Dvd ( DVD_ID ) ; ALTER TABLE Review ADD CONSTRAINT Review_Member_FK FOREIGN KEY ( Membership_Number ) REFERENCES Member ( Membership_Number ) ; ALTER TABLE Review ADD CONSTRAINT Review_Title_FK FOREIGN KEY ( Title_id ) REFERENCES Title ( Title_id ) ; ALTER TABLE Video ADD CONSTRAINT Video_Configuration_FK FOREIGN KEY ( DeliveryConfigNo ) REFERENCES Configuration ( DeliveryConfigNo ) ; ALTER TABLE Video ADD CONSTRAINT Video_Serve_FK FOREIGN KEY ( Server_ID ) REFERENCES Serve ( Server_ID ) ; ALTER TABLE Video ADD CONSTRAINT Video_Title_FK FOREIGN KEY ( Title_id ) REFERENCES Title ( Title_id ) ; CREATE SEQUENCE Audit_Log_Audit_Log_Id_SEQ START WITH 1 NOCACHE ORDER ; CREATE SEQUENCE Configuration_DeliveryConfigNo START WITH 1 NOCACHE ORDER ; CREATE SEQUENCE Download_Download_ID_SEQ START WITH 1 NOCACHE ORDER ; CREATE SEQUENCE Member_Membership_Number_SEQ START WITH 1 NOCACHE ORDER ; CREATE SEQUENCE Physical_Dvd_DVD_ID_SEQ START WITH 1 NOCACHE ORDER ; CREATE SEQUENCE Rent_Rent_Id_SEQ START WITH 1 NOCACHE ORDER ; CREATE SEQUENCE Serve_Server_ID_SEQ START WITH 1 NOCACHE ORDER ; CREATE SEQUENCE Title_Title_id_SEQ START WITH 1 NOCACHE ORDER ; CREATE SEQUENCE Warehouse_Warehouse_ID_SEQ START WITH 1 NOCACHE ORDER ; -- Oracle SQL Developer Data Modeler Summary Report: -- -- CREATE TABLE 15 -- CREATE INDEX 0 -- ALTER TABLE 35 -- CREATE VIEW 0 -- ALTER VIEW 0 -- CREATE PACKAGE 0 -- CREATE PACKAGE BODY 0 -- CREATE PROCEDURE 0 -- CREATE FUNCTION 0 -- CREATE TRIGGER 0 -- ALTER TRIGGER 0 -- CREATE COLLECTION TYPE 0 -- CREATE STRUCTURED TYPE 0 -- CREATE STRUCTURED TYPE BODY 0 -- CREATE CLUSTER 0 -- CREATE CONTEXT 0 -- CREATE DATABASE 0 -- CREATE DIMENSION 0 -- CREATE DIRECTORY 0 -- CREATE DISK GROUP 0 -- CREATE ROLE 0 -- CREATE ROLLBACK SEGMENT 0 -- CREATE SEQUENCE 9 -- CREATE MATERIALIZED VIEW 0 -- CREATE SYNONYM 0 -- CREATE TABLESPACE 0 -- CREATE USER 0 -- -- DROP TABLESPACE 0 -- DROP DATABASE 0 -- -- REDACTION POLICY 0 -- -- ORDS DROP SCHEMA 0 -- ORDS ENABLE SCHEMA 0 -- ORDS ENABLE OBJECT 0 -- -- ERRORS 0 -- WARNINGS 0
true
8fe4a88c6faf408404ec16d17499105a8af250bb
SQL
kylenielebeck/Simple-CD-Management-System
/PROJECT 4.sql
UTF-8
1,069
4.34375
4
[]
no_license
USE disk_inventory; /*creates view*/ CREATE VIEW View_Individual_Artist AS SELECT ArtistID, ArtistName FROM Artist; /*Select only individual artist, in my case most of mine are bands*/ SELECT * FROM View_Individual_Artist WHERE ArtistName = 'Bon Jovi', 'Phil Collins', 'Ed Sheeran', 'John Legend'; /* Select everyone else */ SELECT * FROM View_Individual_Artist WHERE ArtistName <> 'Bon Jovi', 'Phil Collins', 'Ed Sheeran', 'John Legend'; /*Adds DiskName to Disk table*/ ALTER TABLE Disk ADD DiskName varchar(255); /*Selects the artist name and disk name (most of mine don't have a disk name*/ SELECT ArtistName, DiskName FROM Artist FULL OUTER JOIN Disk ON Artist.ArtistName = Disk.DiskName; /*Who borrowed what disk, by last name*/ SELECT BorrowerFN, BorrowerLN, DiskNo FROM DiskHasBorrower ORDER BY BorrowerLN; /*show how many times a disk has been borrowed*/ SELECT COUNT(*) FROM DiskHasBorrower WHERE BorrowedDate <> NULL; /*Show who borrowed what disk and when*/ SELECT DiskNo, BorrowedDate, ReturnedDate, BorrowerLN FROM DiskHasBorrower ORDER BY DiskNo;
true
b26d1f8046fc82f6b332a6d3cbfd27451b108ed2
SQL
baiyu2683/sql
/SQL基础教程/outerjoin_cases.sql
UTF-8
411
3.53125
4
[]
no_license
select sp.shop_id, sp.shop_name,sp.product_id, p.product_name, p.sale_price from shopproduct as sp right outer join product as p on sp.product_id = p.product_id; -- 使用不确定代替为null的字段 select coalesce(sp.shop_id, '不确定'), coalesce(sp.shop_name,'不确定'),p.product_id, p.product_name, p.sale_price from shopproduct as sp right outer join product as p on sp.product_id = p.product_id;
true
86d8739b36aa6b5f2ed22ae39ccb2fc313486d85
SQL
alayonx4/negocio-web-con-bulma-css-laravel-axios
/juegos.sql
UTF-8
3,487
3.046875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.2 -- https://www.phpmyadmin.net/ -- -- Servidor: 127.0.0.1 -- Tiempo de generación: 27-05-2020 a las 18:33:26 -- Versión del servidor: 10.4.11-MariaDB -- Versión de PHP: 7.4.1 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de datos: `juegos` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `friends` -- CREATE TABLE `friends` ( `user` varchar(16) DEFAULT NULL, `friend` varchar(16) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `members` -- CREATE TABLE `members` ( `user` varchar(16) DEFAULT NULL, `pass` varchar(16) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Volcado de datos para la tabla `members` -- INSERT INTO `members` (`user`, `pass`) VALUES ('alayonx4', '12345678'), ('fue kevin', '12345678'), ('ultra gay diego', 'simio'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `messages` -- CREATE TABLE `messages` ( `id` int(10) UNSIGNED NOT NULL, `auth` varchar(16) DEFAULT NULL, `recip` varchar(16) DEFAULT NULL, `pm` char(1) DEFAULT NULL, `time` int(10) UNSIGNED DEFAULT NULL, `message` varchar(4096) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Volcado de datos para la tabla `messages` -- INSERT INTO `messages` (`id`, `auth`, `recip`, `pm`, `time`, `message`) VALUES (1, 'fue kevin', 'fue kevin', '0', 1587576531, 'sedaces xool es gey'), (2, 'alayonx4', 'alayonx4', '0', 1587576606, 'sedaces'), (3, 'alayonx4', 'fue kevin', '0', 1587581752, 'eyden gey pelon'), (4, 'ultra gay diego', 'ultra gay diego', '0', 1587584000, 'soy diegote simiote'), (5, 'alayonx4', 'alayonx4', '0', 1590269484, 'me guchta mucho pokemonch'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `profiles` -- CREATE TABLE `profiles` ( `user` varchar(16) DEFAULT NULL, `text` varchar(4096) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Volcado de datos para la tabla `profiles` -- INSERT INTO `profiles` (`user`, `text`) VALUES ('alayonx4', 'gamesx4'), ('fue kevin', 'i dont have fucking uno'); -- -- Índices para tablas volcadas -- -- -- Indices de la tabla `friends` -- ALTER TABLE `friends` ADD KEY `user` (`user`(6)), ADD KEY `friend` (`friend`(6)); -- -- Indices de la tabla `members` -- ALTER TABLE `members` ADD KEY `user` (`user`(6)); -- -- Indices de la tabla `messages` -- ALTER TABLE `messages` ADD PRIMARY KEY (`id`), ADD KEY `auth` (`auth`(6)), ADD KEY `recip` (`recip`(6)); -- -- Indices de la tabla `profiles` -- ALTER TABLE `profiles` ADD KEY `user` (`user`(6)); -- -- AUTO_INCREMENT de las tablas volcadas -- -- -- AUTO_INCREMENT de la tabla `messages` -- ALTER TABLE `messages` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; 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
5e1f0c57f53d2d2793b22771cfed6f751e5016ac
SQL
HideOne/Learn
/jing_dong.sql
UTF-8
5,275
2.78125
3
[]
no_license
/* Navicat MySQL Data Transfer Source Server : evil Source Server Version : 50561 Source Host : 192.168.0.113:3306 Source Database : jing_dong Target Server Type : MYSQL Target Server Version : 50561 File Encoding : 65001 Date: 2018-10-10 16:15:48 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for goods -- ---------------------------- DROP TABLE IF EXISTS `goods`; CREATE TABLE `goods` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(150) NOT NULL, `cate_id` int(10) unsigned NOT NULL, `brand_id` int(10) unsigned NOT NULL, `price` decimal(10,3) NOT NULL DEFAULT '0.000', `is_show` bit(1) NOT NULL DEFAULT b'1', `is_saleoff` bit(1) NOT NULL DEFAULT b'0', PRIMARY KEY (`id`), KEY `cate_id` (`cate_id`), CONSTRAINT `goods_ibfk_1` FOREIGN KEY (`cate_id`) REFERENCES `goods_cates` (`id`), CONSTRAINT `goods_ibfk_2` FOREIGN KEY (`cate_id`) REFERENCES `goods_cates` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of goods -- ---------------------------- INSERT INTO `goods` VALUES ('1', 'r510vc 15.6英寸笔记本', '5', '2', '3399.000', '', '\0'); INSERT INTO `goods` VALUES ('2', 'y400n 14.0英寸笔记本电脑', '5', '7', '4999.000', '', '\0'); INSERT INTO `goods` VALUES ('3', 'g150th 15.6英寸游戏本', '4', '9', '8499.000', '', '\0'); INSERT INTO `goods` VALUES ('4', 'x550cc 15.6英寸笔记本', '5', '2', '2799.000', '', '\0'); INSERT INTO `goods` VALUES ('5', 'x240 超极本', '7', '7', '4880.000', '', '\0'); INSERT INTO `goods` VALUES ('6', 'u330p 13.3英寸超极本', '7', '7', '4299.000', '', '\0'); INSERT INTO `goods` VALUES ('7', 'svp13226scb 触控超极本', '7', '6', '7999.000', '', '\0'); INSERT INTO `goods` VALUES ('8', 'ipad mini 7.9英寸平板电脑', '2', '8', '1998.000', '', '\0'); INSERT INTO `goods` VALUES ('9', 'ipad air 9.7英寸平板电脑', '2', '8', '3388.000', '', '\0'); INSERT INTO `goods` VALUES ('10', 'ipad mini 配备 retina 显示屏', '2', '8', '2788.000', '', '\0'); INSERT INTO `goods` VALUES ('11', 'ideacentre c340 20英寸一体电脑 ', '1', '7', '3499.000', '', '\0'); INSERT INTO `goods` VALUES ('12', 'vostro 3800-r1206 台式电脑', '1', '5', '2899.000', '', '\0'); INSERT INTO `goods` VALUES ('13', 'imac me086ch/a 21.5英寸一体电脑', '1', '8', '9188.000', '', '\0'); INSERT INTO `goods` VALUES ('14', 'at7-7414lp 台式电脑 linux )', '1', '3', '3699.000', '', '\0'); INSERT INTO `goods` VALUES ('15', 'z220sff f4f06pa工作站', '3', '4', '4288.000', '', '\0'); INSERT INTO `goods` VALUES ('16', 'poweredge ii服务器', '3', '5', '5388.000', '', '\0'); INSERT INTO `goods` VALUES ('17', 'mac pro专业级台式电脑', '3', '8', '28888.000', '', '\0'); INSERT INTO `goods` VALUES ('18', 'hmz-t3w 头戴显示设备', '6', '6', '6999.000', '', '\0'); INSERT INTO `goods` VALUES ('19', '商务双肩背包', '6', '6', '99.000', '', '\0'); INSERT INTO `goods` VALUES ('20', 'x3250 m4机架式服务器', '3', '1', '6888.000', '', '\0'); INSERT INTO `goods` VALUES ('21', '商务双肩背包', '6', '6', '99.000', '', '\0'); INSERT INTO `goods` VALUES ('22', 'adk10英寸笔记本', '5', '2', '4399.000', '', '\0'); -- ---------------------------- -- Table structure for goods_brands -- ---------------------------- DROP TABLE IF EXISTS `goods_brands`; CREATE TABLE `goods_brands` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(40) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of goods_brands -- ---------------------------- INSERT INTO `goods_brands` VALUES ('1', 'ibm'); INSERT INTO `goods_brands` VALUES ('2', '华硕'); INSERT INTO `goods_brands` VALUES ('3', '宏碁'); INSERT INTO `goods_brands` VALUES ('4', '惠普'); INSERT INTO `goods_brands` VALUES ('5', '戴尔'); INSERT INTO `goods_brands` VALUES ('6', '索尼'); INSERT INTO `goods_brands` VALUES ('7', '联想'); INSERT INTO `goods_brands` VALUES ('8', '苹果'); INSERT INTO `goods_brands` VALUES ('9', '雷神'); INSERT INTO `goods_brands` VALUES ('16', '海尔'); INSERT INTO `goods_brands` VALUES ('17', '清华同方'); INSERT INTO `goods_brands` VALUES ('18', '神舟'); -- ---------------------------- -- Table structure for goods_cates -- ---------------------------- DROP TABLE IF EXISTS `goods_cates`; CREATE TABLE `goods_cates` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(40) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of goods_cates -- ---------------------------- INSERT INTO `goods_cates` VALUES ('1', '台式机'); INSERT INTO `goods_cates` VALUES ('2', '平板电脑'); INSERT INTO `goods_cates` VALUES ('3', '服务器/工作站'); INSERT INTO `goods_cates` VALUES ('4', '游戏本'); INSERT INTO `goods_cates` VALUES ('5', '笔记本'); INSERT INTO `goods_cates` VALUES ('6', '笔记本配件'); INSERT INTO `goods_cates` VALUES ('7', '超级本'); INSERT INTO `goods_cates` VALUES ('8', '路由器'); INSERT INTO `goods_cates` VALUES ('9', '交换机'); INSERT INTO `goods_cates` VALUES ('10', '网卡');
true
9ce1342269544b7aa6f3c3f747a595792638fc83
SQL
mkoscak/koberce
/Koberce/Queries/example.sql
UTF-8
150
2.6875
3
[]
no_license
-- Tu pride nazov, ktory sa zobrazi ako text tlacitka (musi zacinat //) select * from sold s join arena a on s.code = a.code where code = 101102
true
7550802f00e25399668c194d8f048d22c2a2b638
SQL
dzvonari/firmapp23
/Script-7.sql
UTF-8
494
3.203125
3
[]
no_license
drop database if exists firmapp23; create database firmapp23; use firmapp23; create table projekt( sifra int not null primary key auto_increment, naziv varchar(50) not null, cijena decimal(18.2) ); create table programer( sifra int not null primary key auto_increment, ime varchar(50) not null, prezime varchar(50) not null, datumrodjenja datetime, placa decimal(18.2) ); create table sudjeluje( projekt int, programer varchar(50), datumpocetka datetime, datumkraja datetime );
true
ba084715341daf5e04871c21e0a5bd1fe0da3cf1
SQL
radtek/abs3
/sql/mmfo/bars/Trigger/tai_tmp_priocom_nbs_list.sql
UTF-8
948
2.609375
3
[]
no_license
PROMPT ===================================================================================== PROMPT *** Run *** ========== Scripts /Sql/BARS/Trigger/TAI_TMP_PRIOCOM_NBS_LIST.sql ======= PROMPT ===================================================================================== PROMPT *** Create trigger TAI_TMP_PRIOCOM_NBS_LIST *** CREATE OR REPLACE TRIGGER BARS.TAI_TMP_PRIOCOM_NBS_LIST AFTER INSERT ON "BARS"."TMP_PRIOCOM_NBS_LIST" REFERENCING FOR EACH ROW begin priocom_audit.trace('insert into tmp_priocom_nbs_list(nbs) values('''||nvl(:new.nbs,'NULL')||''')'); end; / ALTER TRIGGER BARS.TAI_TMP_PRIOCOM_NBS_LIST ENABLE; PROMPT ===================================================================================== PROMPT *** End *** ========== Scripts /Sql/BARS/Trigger/TAI_TMP_PRIOCOM_NBS_LIST.sql ======= PROMPT =====================================================================================
true
f65a648e3b5cbe2401a13ded9e31b1bbad3a07fd
SQL
SviatlanaJavaHTP/TAT6_Library_create_book
/sql_test.sql
UTF-8
2,330
3.09375
3
[]
no_license
-- -------------------------------------------------------- -- Host: 127.0.0.1 -- Server version: 5.7.16-log - MySQL Community Server (GPL) -- Server OS: Win64 -- HeidiSQL Version: 9.4.0.5125 -- -------------------------------------------------------- /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET NAMES utf8 */; /*!50503 SET NAMES utf8mb4 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -- Dumping database structure for tat6library DROP DATABASE IF EXISTS `tat6library`; CREATE DATABASE IF NOT EXISTS `tat6library` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `tat6library`; -- Dumping structure for table tat6library.author DROP TABLE IF EXISTS `author`; CREATE TABLE IF NOT EXISTS `author` ( `name` varchar(50) NOT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `surname` varchar(50) NOT NULL, `birthDate` date DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- Dumping data for table tat6library.author: ~2 rows (approximately) DELETE FROM `author`; /*!40000 ALTER TABLE `author` DISABLE KEYS */; INSERT INTO `author` (`name`, `id`, `surname`, `birthDate`) VALUES ('Author1', 1, 'Author1', '2018-01-27'), ('Author2', 2, 'Author1', '2018-01-27'); /*!40000 ALTER TABLE `author` ENABLE KEYS */; -- Dumping structure for table tat6library.book DROP TABLE IF EXISTS `book`; CREATE TABLE IF NOT EXISTS `book` ( `title` varchar(50) NOT NULL, `author` int(11) NOT NULL, `year` date DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -- Dumping data for table tat6library.book: ~0 rows (approximately) DELETE FROM `book`; /*!40000 ALTER TABLE `book` DISABLE KEYS */; INSERT INTO `book` (`title`, `author`, `year`, `id`) VALUES ('bbb', 12, '1970-01-01', 4); /*!40000 ALTER TABLE `book` ENABLE KEYS */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
true
43ac1719532b1d4de59ff06c95f2c916c29cd543
SQL
nilenso/postgresql-monitoring
/monitor.sql
UTF-8
12,875
3.796875
4
[]
no_license
-- Cache PREPARE cache_tables AS SELECT relname AS "relation", heap_blks_read AS heap_read, heap_blks_hit AS heap_hit, ( (heap_blks_hit*100) / NULLIF((heap_blks_hit + heap_blks_read), 0)) AS ratio FROM pg_statio_user_tables; PREPARE cache_total AS SELECT sum(heap_blks_read) AS heap_read, sum(heap_blks_hit) AS heap_hit, (sum(heap_blks_hit)*100 / NULLIF((sum(heap_blks_hit) + sum(heap_blks_read)),0)) AS ratio FROM pg_statio_user_tables; -- Disk usage PREPARE table_sizes AS SELECT relname AS "relation", pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') AND C.relkind <> 'i' AND nspname ='public' ORDER BY pg_total_relation_size(C.oid) DESC; PREPARE relation_sizes AS SELECT relname AS "relation", pg_size_pretty(pg_relation_size(C.oid)) AS "size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname = 'public' ORDER BY pg_relation_size(C.oid) DESC; PREPARE db_size AS SELECT pg_size_pretty(pg_database_size(current_database())); -- Bloat PREPARE table_bloat AS SELECT tblname as "relation", pg_size_pretty((bs*tblpages)::bigint) AS real_size, pg_size_pretty(((tblpages-est_tblpages)*bs)::bigint) AS extra_size, CASE WHEN tblpages - est_tblpages > 0 THEN 100 * (tblpages - est_tblpages)/tblpages::float ELSE 0 END AS extra_ratio, fillfactor, pg_size_pretty(((tblpages-est_tblpages_ff)*bs)::bigint) AS bloat_size, CASE WHEN tblpages - est_tblpages_ff > 0 THEN 100 * (tblpages - est_tblpages_ff)/tblpages::float ELSE 0 END AS bloat_ratio, is_na::varchar -- , (pst).free_percent + (pst).dead_tuple_percent AS real_frag FROM ( SELECT ceil( reltuples / ( (bs-page_hdr)/tpl_size ) ) + ceil( toasttuples / 4 ) AS est_tblpages, ceil( reltuples / ( (bs-page_hdr)*fillfactor/(tpl_size*100) ) ) + ceil( toasttuples / 4 ) AS est_tblpages_ff, tblpages, fillfactor, bs, tblid, schemaname, tblname, heappages, toastpages, is_na -- , stattuple.pgstattuple(tblid) AS pst FROM ( SELECT ( 4 + tpl_hdr_size + tpl_data_size + (2*ma) - CASE WHEN tpl_hdr_size%ma = 0 THEN ma ELSE tpl_hdr_size%ma END - CASE WHEN ceil(tpl_data_size)::int%ma = 0 THEN ma ELSE ceil(tpl_data_size)::int%ma END ) AS tpl_size, bs - page_hdr AS size_per_block, (heappages + toastpages) AS tblpages, heappages, toastpages, reltuples, toasttuples, bs, page_hdr, tblid, schemaname, tblname, fillfactor, is_na FROM ( SELECT tbl.oid AS tblid, ns.nspname AS schemaname, tbl.relname AS tblname, tbl.reltuples, tbl.relpages AS heappages, coalesce(toast.relpages, 0) AS toastpages, coalesce(toast.reltuples, 0) AS toasttuples, coalesce(substring( array_to_string(tbl.reloptions, ' ') FROM '%fillfactor=#"__#"%' FOR '#')::smallint, 100) AS fillfactor, current_setting('block_size')::numeric AS bs, CASE WHEN version()~'mingw32' OR version()~'64-bit|x86_64|ppc64|ia64|amd64' THEN 8 ELSE 4 END AS ma, 24 AS page_hdr, 23 + CASE WHEN MAX(coalesce(null_frac,0)) > 0 THEN ( 7 + count(*) ) / 8 ELSE 0::int END + CASE WHEN tbl.relhasoids THEN 4 ELSE 0 END AS tpl_hdr_size, sum( (1-coalesce(s.null_frac, 0)) * coalesce(s.avg_width, 1024) ) AS tpl_data_size, bool_or(att.atttypid = 'pg_catalog.name'::regtype) AS is_na FROM pg_attribute AS att JOIN pg_class AS tbl ON att.attrelid = tbl.oid JOIN pg_namespace AS ns ON ns.oid = tbl.relnamespace JOIN pg_stats AS s ON s.schemaname=ns.nspname AND ns.nspname = 'public' AND s.tablename = tbl.relname AND s.inherited=false AND s.attname=att.attname LEFT JOIN pg_class AS toast ON tbl.reltoastrelid = toast.oid WHERE att.attnum > 0 AND NOT att.attisdropped AND tbl.relkind = 'r' GROUP BY 1,2,3,4,5,6,7,8,9,10, tbl.relhasoids ORDER BY 2,3 ) AS s ) AS s2 ) AS s3; PREPARE table_and_index_bloat AS SELECT tablename AS "relation", reltuples::bigint AS tups, relpages::bigint AS pages, otta, ROUND(CASE WHEN otta=0 OR sml.relpages=0 OR sml.relpages=otta THEN 0.0 ELSE sml.relpages/otta::numeric END,1) AS tbloat, CASE WHEN relpages < otta THEN 0 ELSE relpages::bigint - otta END AS wastedpages, CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::bigint END AS wastedbytes, CASE WHEN relpages < otta THEN 0 ELSE (bs*(relpages-otta))::bigint END AS wastedsize, iname, ituples::bigint AS itups, ipages::bigint AS ipages, iotta, ROUND(CASE WHEN iotta=0 OR ipages=0 OR ipages=iotta THEN 0.0 ELSE ipages/iotta::numeric END,1) AS ibloat, CASE WHEN ipages < iotta THEN 0 ELSE ipages::bigint - iotta END AS wastedipages, CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) END AS wastedibytes, CASE WHEN ipages < iotta THEN 0 ELSE (bs*(ipages-iotta))::bigint END AS wastedisize, CASE WHEN relpages < otta THEN CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta::bigint) END ELSE CASE WHEN ipages < iotta THEN bs*(relpages-otta::bigint) ELSE bs*(relpages-otta::bigint + ipages-iotta::bigint) END END AS totalwastedbytes FROM ( SELECT nn.nspname AS schemaname, cc.relname AS tablename, COALESCE(cc.reltuples,0) AS reltuples, COALESCE(cc.relpages,0) AS relpages, COALESCE(bs,0) AS bs, COALESCE(CEIL((cc.reltuples*((datahdr+ma- (CASE WHEN datahdr%ma=0 THEN ma ELSE datahdr%ma END))+nullhdr2+4))/(bs-20::float)),0) AS otta, COALESCE(c2.relname,'?') AS iname, COALESCE(c2.reltuples,0) AS ituples, COALESCE(c2.relpages,0) AS ipages, COALESCE(CEIL((c2.reltuples*(datahdr-12))/(bs-20::float)),0) AS iotta -- very rough approximation, assumes all cols FROM pg_class cc JOIN pg_namespace nn ON cc.relnamespace = nn.oid AND nn.nspname = 'public' LEFT JOIN ( SELECT ma,bs,foo.nspname,foo.relname, (datawidth+(hdr+ma-(case when hdr%ma=0 THEN ma ELSE hdr%ma END)))::numeric AS datahdr, (maxfracsum*(nullhdr+ma-(case when nullhdr%ma=0 THEN ma ELSE nullhdr%ma END))) AS nullhdr2 FROM ( SELECT ns.nspname, tbl.relname, hdr, ma, bs, SUM((1-coalesce(null_frac,0))*coalesce(avg_width, 2048)) AS datawidth, MAX(coalesce(null_frac,0)) AS maxfracsum, hdr+( SELECT 1+count(*)/8 FROM pg_stats s2 WHERE null_frac<>0 AND s2.schemaname = ns.nspname AND s2.tablename = tbl.relname ) AS nullhdr FROM pg_attribute att JOIN pg_class tbl ON att.attrelid = tbl.oid JOIN pg_namespace ns ON ns.oid = tbl.relnamespace LEFT JOIN pg_stats s ON s.schemaname=ns.nspname AND s.tablename = tbl.relname AND s.inherited=false AND s.attname=att.attname, ( SELECT (SELECT current_setting('block_size')::numeric) AS bs, CASE WHEN SUBSTRING(SPLIT_PART(v, ' ', 2) FROM '#"[0-9]+.[0-9]+#"%' for '#') IN ('8.0','8.1','8.2') THEN 27 ELSE 23 END AS hdr, CASE WHEN v ~ 'mingw32' OR v ~ '64-bit' THEN 8 ELSE 4 END AS ma FROM (SELECT version() AS v) AS foo ) AS constants WHERE att.attnum > 0 AND tbl.relkind='r' GROUP BY 1,2,3,4,5 ) AS foo ) AS rs ON cc.relname = rs.relname AND nn.nspname = rs.nspname AND nn.nspname = 'public' LEFT JOIN pg_index i ON indrelid = cc.oid LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid ) AS sml; -- Indexes PREPARE index_usage AS SELECT t.tablename AS "relation", indexname, c.reltuples AS num_rows, pg_size_pretty(pg_relation_size(quote_ident(t.tablename)::text)) AS table_size, pg_size_pretty(pg_relation_size(quote_ident(indexrelname)::text)) AS index_size, idx_scan AS number_of_scans, idx_tup_read AS tuples_read, idx_tup_fetch AS tuples_fetched FROM pg_tables t LEFT OUTER JOIN pg_class c ON t.tablename=c.relname LEFT OUTER JOIN ( SELECT c.relname AS ctablename, ipg.relname AS indexname, x.indnatts AS number_of_columns, idx_scan, idx_tup_read, idx_tup_fetch, indexrelname, indisunique FROM pg_index x JOIN pg_class c ON c.oid = x.indrelid JOIN pg_class ipg ON ipg.oid = x.indexrelid JOIN pg_stat_all_indexes psai ON x.indexrelid = psai.indexrelid ) AS foo ON t.tablename = foo.ctablename WHERE t.schemaname='public' ORDER BY 1,2; -- Tuples PREPARE tuple_info AS SELECT relname as "relation", EXTRACT (EPOCH FROM current_timestamp-last_autovacuum) as since_last_av, autovacuum_count as av_count, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup FROM pg_stat_all_tables WHERE schemaname = 'public' ORDER BY relname; -- queries PREPARE current_queries_status AS SELECT count(pid), query, waiting from pg_stat_activity group by query, waiting; PREPARE queries AS SELECT LEFT(query,50) AS query, calls, total_time, rows, shared_blks_hit, local_blks_hit, blk_read_time, blk_write_time FROM pg_stat_statements WHERE EXISTS(SELECT * FROM pg_available_extensions WHERE name = 'pg_stat_statements') ORDER BY calls DESC; PREPARE current_queries_status_with_locks AS SELECT count(pg_stat_activity.pid) AS number_of_queries, substring(trim(LEADING FROM regexp_replace(pg_stat_activity.query, '[\n\r]+'::text, ' '::text, 'g'::text)) FROM 0 FOR 200) AS query_name, max(age(CURRENT_TIMESTAMP, query_start)) AS max_wait_time, waiting, usename, locktype, mode, granted FROM pg_stat_activity LEFT JOIN pg_locks ON pg_stat_activity.pid = pg_locks.pid WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_%' AND query NOT ILIKE '%application_name%' AND query NOT ILIKE '%inet%' AND age(CURRENT_TIMESTAMP, query_start) > '5 milliseconds'::interval GROUP BY query_name, waiting, usename, locktype, mode, granted ORDER BY max_wait_time DESC; PREPARE current_queries_status_with_locks_pg10 AS SELECT count(pg_stat_activity.pid) AS number_of_queries, substring(trim(LEADING FROM regexp_replace(pg_stat_activity.query, '[\n\r]+'::text, ' '::text, 'g'::text)) FROM 0 FOR 200) AS query_name, max(age(CURRENT_TIMESTAMP, query_start)) AS max_wait_time, wait_event, usename, locktype, mode, granted FROM pg_stat_activity LEFT JOIN pg_locks ON pg_stat_activity.pid = pg_locks.pid WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_%' AND query NOT ILIKE '%application_name%' AND query NOT ILIKE '%inet%' AND age(CURRENT_TIMESTAMP, query_start) > '5 milliseconds'::interval GROUP BY query_name, wait_event, usename, locktype, mode, granted ORDER BY max_wait_time DESC; -- replication PREPARE replication_status_9 AS SELECT application_name,client_addr,state,sent_location,write_location,replay_location, (sent_offset - (replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ))::text AS byte_lag FROM (SELECT application_name,client_addr,state,sync_state,sent_location,write_location,replay_location, ('x' || lpad(split_part(sent_location::text, '/', 1), 8, '0'))::bit(32)::bigint AS sent_xlog, ('x' || lpad(split_part(replay_location::text, '/', 1), 8, '0'))::bit(32)::bigint AS replay_xlog, ('x' || lpad(split_part(sent_location::text, '/', 2), 8, '0'))::bit(32)::bigint AS sent_offset, ('x' || lpad(split_part(replay_location::text, '/', 2), 8, '0'))::bit(32)::bigint AS replay_offset FROM pg_stat_replication) AS s; PREPARE replication_status_10 AS SELECT application_name,client_addr,state, \\ (sent_offset - (replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ))::text AS byte_lag \\ FROM (SELECT \\ application_name,client_addr,state,sync_state,sent_lsn,write_lsn,replay_lsn, \\ ('x' || lpad(split_part(sent_lsn::text, '/', 1), 8, '0'))::bit(32)::bigint AS sent_xlog, \\ ('x' || lpad(split_part(replay_lsn::text, '/', 1), 8, '0'))::bit(32)::bigint AS replay_xlog, \\ ('x' || lpad(split_part(sent_lsn::text, '/', 2), 8, '0'))::bit(32)::bigint AS sent_offset, \\ ('x' || lpad(split_part(replay_lsn::text, '/', 2), 8, '0'))::bit(32)::bigint AS replay_offset \\ FROM pg_stat_replication) \\ AS s;
true
bfa9cf3dea6ebf829c2c4536d12ad2968b24efa2
SQL
elfachruz/sip_guru
/UASplatform/sipguru.sql
UTF-8
2,519
3.328125
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 3.4.5 -- http://www.phpmyadmin.net -- -- Host: localhost -- Waktu pembuatan: 18. Juli 2017 jam 08:42 -- Versi Server: 5.5.16 -- Versi PHP: 5.3.8 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: `sipguru` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `admin` -- CREATE TABLE IF NOT EXISTS `admin` ( `user` varchar(20) NOT NULL, `pass` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data untuk tabel `admin` -- INSERT INTO `admin` (`user`, `pass`) VALUES ('admin', '21232f297a57a5a743894a0e4a801fc3'); -- -------------------------------------------------------- -- -- Struktur dari tabel `guru` -- CREATE TABLE IF NOT EXISTS `guru` ( `id_guru` int(11) NOT NULL AUTO_INCREMENT, `nip` varchar(12) NOT NULL, `nama` varchar(25) NOT NULL, `email` text NOT NULL, `id_mapel` int(11) NOT NULL, PRIMARY KEY (`id_guru`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ; -- -- Dumping data untuk tabel `guru` -- INSERT INTO `guru` (`id_guru`, `nip`, `nama`, `email`, `id_mapel`) VALUES (1, '1011101011', 'Ahmad bakri', 'ahmad.i@sipguru.com', 1), (4, '1023400122', 'Supardi Nasir', 's.nasir@sipguru.com', 2), (5, '1001123343', 'Sakinah', 'sakinah@sipguru.com', 3), (6, '1020304012', 'ahmad munawir', 'ahmadmunawir83@gmail.com', 2), (7, '1013455432', 'Suratman handoyo', 'suratman_h@sipguru.com', 6), (8, '1003443781', 'Yusuf ismail', 'yusuf_is@sipguru.com', 12), (9, '1012234681', 'Suryana Saputra', 'suryana_ss@sipguru.com', 4); -- -------------------------------------------------------- -- -- Struktur dari tabel `mtpelajaran` -- CREATE TABLE IF NOT EXISTS `mtpelajaran` ( `id_mapel` int(11) NOT NULL AUTO_INCREMENT, `mapel` varchar(30) NOT NULL, PRIMARY KEY (`id_mapel`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ; -- -- Dumping data untuk tabel `mtpelajaran` -- INSERT INTO `mtpelajaran` (`id_mapel`, `mapel`) VALUES (1, 'Pendidikan Agama Islam'), (2, 'Matematika'), (3, 'Fisika'), (4, 'Kimia'), (5, 'Biologi'), (6, 'Pancasila'), (7, 'Sejarah'), (8, 'Sosiologi'), (9, 'Ekonomi'), (10, 'Wirausaha'), (11, 'Bahasa Inggris'), (12, 'Bahasa Indonesia'); /*!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
cc46a0bbc96b9ebc46efa656147174ca9dedd40f
SQL
ngocbinh123/java_hcmus
/cookmanagement.sql
UTF-8
6,431
3.984375
4
[]
no_license
/* DROP DATABASE IF EXISTS cookingmanagement_v1 CREATE DATABASE cookingmanagement_v1 WITH OWNER = postgres ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'C' LC_CTYPE = 'C' CONNECTION LIMIT = -1; */ CREATE DATABASE cookingmanagement_v1 WITH ENCODING='UTF8' OWNER=postgres CONNECTION LIMIT=-1; ------------------------ Creating tables ------------------------ DROP TABLE IF EXISTS STAFFTYPE; CREATE TABLE STAFFTYPE( id serial primary key not null, name character(50) ); DROP TABLE IF EXISTS WORKINGSTATUS; CREATE TABLE WORKINGSTATUS( id serial primary key not null, name character(50) ); DROP TABLE IF EXISTS WORKINGTIME; CREATE TABLE WORKINGTIME( id serial primary key not null, startHour int, endHour int ); DROP TABLE IF EXISTS STAFF; CREATE TABLE STAFF( id serial primary key not null, fullName text, image text, sex boolean default true, -- true: man | false: women birthday date, startWorking date, baseSalary int, note text, id_staffType int not null references STAFFTYPE(id), id_workingStatus int not null references WORKINGSTATUS(id) ); DROP TABLE IF EXISTS FOODTYPE; CREATE TABLE FOODTYPE( id serial primary key not null, name text ); DROP TABLE IF EXISTS FOOD; CREATE TABLE FOOD( id serial primary key not null, "name" text, image text, id_foodType int not null references FOODTYPE(id), "number" int default 100, price float check(price >= 0) default 0, status boolean default true, note text ); DROP TABLE IF EXISTS FOODTABLE; CREATE TABLE FOODTABLE( id serial primary key not null, "name" text UNIQUE ); DROP TABLE IF EXISTS COOKEDSTATUS; CREATE TABLE COOKEDSTATUS( id serial primary key not null, "name" text ); DROP TABLE IF EXISTS USERTYPE; CREATE TABLE USERTYPE( id serial primary key not null, name character(50) ); DROP TABLE IF EXISTS USERSTATUS; CREATE TABLE USERSTATUS( id serial primary key not null, name character(50) ); DROP TABLE IF EXISTS "user"; CREATE TABLE "user"( id serial primary key not null, fullName text, name text, -- user name email text, password text, image text, sex boolean default true, -- true: man | false: women birthday date, id_userType int not null references USERTYPE(id), id_userStatus int not null references USERSTATUS(id) ) DROP TABLE IF EXISTS HISTORYORDER; CREATE TABLE HISTORYORDER( id_foodeTable int not null, id_food int not null, id_staff int not null, "numberOfCustomer" int not null, "startDate" Date not null, "customerName" text, primary key(id_foodeTable, id_food, id_staff, "startDate") ); ------------------------ insert data ------------------------ /* 1. STAFFTYPE data */ INSERT INTO STAFFTYPE (name) VALUES ('Service personnel'); INSERT INTO STAFFTYPE (name) VALUES ('Bartender'); INSERT INTO STAFFTYPE (name) VALUES ('Receptionist'); INSERT INTO STAFFTYPE (name) VALUES ('Manager'); /* 2. WORKINGSTATUS data */ INSERT INTO WORKINGSTATUS (name) VALUES ('working'); INSERT INTO WORKINGSTATUS (name) VALUES ('leaving'); /* 3. WORKINGTIME data */ INSERT INTO WORKINGTIME (startHour,endHour) VALUES (8,12); INSERT INTO WORKINGTIME (startHour,endHour) VALUES (12,17); INSERT INTO WORKINGTIME (startHour,endHour) VALUES (17,22); /* 4. FOOTYPE data */ INSERT INTO FOODTYPE (name) VALUES ('Chiên'); INSERT INTO FOODTYPE (name) VALUES ('Kho'); INSERT INTO FOODTYPE (name) VALUES ('Canh'); INSERT INTO FOODTYPE (name) VALUES ('Xào'); INSERT INTO FOODTYPE (name) VALUES ('Chay'); INSERT INTO FOODTYPE (name) VALUES ('Nướng'); INSERT INTO FOODTYPE (name) VALUES ('Hấp luộc'); INSERT INTO FOODTYPE (name) VALUES ('Other'); /* 5. FOOTYPE data */ INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Cơm chiên cá mặn', '',1,100, 30000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Gà chiên nước mắm', '',1,100, 30000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('cá bóng kho tộ', '',2,100, 25000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('mắm kho quẹt', '',2,100, 25000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Canh khổ qua', '',3,100, 20000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Canh chua ca lóc', '',3,100, 30000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Cơm xào thịt bò', '',4,100, 45000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Thịt heo xào cải chua', '',4,100, 25000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Rau cải sốt nấm', '',5,100, 20000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Hủ tiếu chay', '',5,100, 20000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Gà nướng lu', '',6,100, 170000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Thịt nướng kiểu Nga', '',6,100, 50000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Thịt luộc', '',7,100, 25000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Gà luộc nguyên con', '',7,50, 160000,true, ''); INSERT INTO FOOD (name,image,id_foodType,number,price,status,note) VALUES ('Hủ tiếu Sườn', '',5,100, 35000,true, ''); /* 6. FOOTYPE data */ INSERT INTO FOODTABLE (name) VALUES ('1'); INSERT INTO FOODTABLE (name) VALUES ('2'); INSERT INTO FOODTABLE (name) VALUES ('3'); INSERT INTO FOODTABLE (name) VALUES ('4'); INSERT INTO FOODTABLE (name) VALUES ('5'); INSERT INTO FOODTABLE (name) VALUES ('6'); INSERT INTO FOODTABLE (name) VALUES ('7'); INSERT INTO FOODTABLE (name) VALUES ('8'); INSERT INTO FOODTABLE (name) VALUES ('9'); INSERT INTO FOODTABLE (name) VALUES ('10'); /* 7. USERSTATUS data */ INSERT INTO USERSTATUS (name) VALUES ('Enable'); INSERT INTO USERSTATUS (name) VALUES ('Disable'); /* 8. USERTYPE data */ INSERT INTO USERTYPE (name) VALUES ('Customer'); INSERT INTO USERTYPE (name) VALUES ('Admin'); INSERT INTO USERTYPE (name) VALUES ('Boss'); INSERT INTO USERTYPE (name) VALUES ('Service staff'); INSERT INTO USERTYPE (name) VALUES ('Chief staff');
true
f5609573ff461d3eb6e106f5fa1947234c57ed33
SQL
DaniilPavlov/PostgreSQLCourse
/ScriptsSQL/select_subquerry.sql
UTF-8
409
2.984375
3
[]
no_license
SELECT * FROM personal_data WHERE personal_data_id = (SELECT personal_data_id FROM player WHERE player_id = (SELECT player_id FROM transfer_cost WHERE season_finish = (SELECT max(season_finish) FROM transfer_cost)));
true
c0b554313ca2c20bbae3c3eb3fb1999f9b29284d
SQL
nikhilkeshava/online-course-registration-
/SQL File/onlinecourse.sql
UTF-8
9,760
3.1875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.0.1 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Feb 11, 2022 at 02:35 AM -- Server version: 10.3.15-MariaDB -- PHP Version: 7.2.19 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: `onlinecourse` -- -- -------------------------------------------------------- -- -- Table structure for table `admin` -- CREATE TABLE `admin` ( `id` int(11) NOT NULL, `username` varchar(255) DEFAULT NULL, `password` varchar(255) DEFAULT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `updationDate` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `admin` -- INSERT INTO `admin` (`id`, `username`, `password`, `creationDate`, `updationDate`) VALUES (1, 'admin', 'f925916e2754e5e03f75dd58a5733251', '2022-01-31 16:21:18', '2022-01-31 16:21:18'); -- -------------------------------------------------------- -- -- Table structure for table `course` -- CREATE TABLE `course` ( `id` int(11) NOT NULL, `courseCode` varchar(255) DEFAULT NULL, `courseName` varchar(255) DEFAULT NULL, `courseUnit` varchar(255) DEFAULT NULL, `noofSeats` int(11) DEFAULT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `updationDate` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `course` -- INSERT INTO `course` (`id`, `courseCode`, `courseName`, `courseUnit`, `noofSeats`, `creationDate`, `updationDate`) VALUES (1, 'PHP01', 'PHP', '5', 10, '2022-02-10 17:23:28', NULL), (2, 'C001', 'C++', '12', 25, '2022-02-11 00:52:46', '11-02-2022 06:23:06 AM'); -- -------------------------------------------------------- -- -- Table structure for table `courseenrolls` -- CREATE TABLE `courseenrolls` ( `id` int(11) NOT NULL, `studentRegno` varchar(255) DEFAULT NULL, `pincode` varchar(255) DEFAULT NULL, `session` int(11) DEFAULT NULL, `department` int(11) DEFAULT NULL, `level` int(11) DEFAULT NULL, `semester` int(11) DEFAULT NULL, `course` int(11) DEFAULT NULL, `enrollDate` timestamp NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `courseenrolls` -- INSERT INTO `courseenrolls` (`id`, `studentRegno`, `pincode`, `session`, `department`, `level`, `semester`, `course`, `enrollDate`) VALUES (1, '10806121', '822894', 1, 1, 2, 3, 1, '2022-02-11 00:59:33'), (2, '10806121', '822894', 1, 1, 1, 2, 2, '2022-02-11 01:01:07'); -- -------------------------------------------------------- -- -- Table structure for table `department` -- CREATE TABLE `department` ( `id` int(11) NOT NULL, `department` varchar(255) DEFAULT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `department` -- INSERT INTO `department` (`id`, `department`, `creationDate`) VALUES (1, 'IT', '2022-02-10 17:23:04'), (2, 'HR', '2022-02-10 17:23:09'); -- -------------------------------------------------------- -- -- Table structure for table `level` -- CREATE TABLE `level` ( `id` int(11) NOT NULL, `level` varchar(255) DEFAULT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `level` -- INSERT INTO `level` (`id`, `level`, `creationDate`) VALUES (1, '1', '2022-02-11 00:59:02'), (2, '2', '2022-02-11 00:59:02'), (3, '3', '2022-02-11 00:59:09'); -- -------------------------------------------------------- -- -- Table structure for table `news` -- CREATE TABLE `news` ( `id` int(11) NOT NULL, `newstitle` varchar(255) DEFAULT NULL, `newsDescription` mediumtext DEFAULT NULL, `postingDate` timestamp NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `news` -- INSERT INTO `news` (`id`, `newstitle`, `newsDescription`, `postingDate`) VALUES (2, 'Test News', 'This is for testing. This is for testing.This is for testing.This is for testing.This is for testing.This is for testing.This is for testing.This is for testing.This is for testing.This is for testing.', '2022-02-10 17:36:50'), (3, 'New Course Started C#', 'This is sample text for testing.', '2022-02-11 00:54:38'); -- -------------------------------------------------------- -- -- Table structure for table `semester` -- CREATE TABLE `semester` ( `id` int(11) NOT NULL, `semester` varchar(255) DEFAULT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `updationDate` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `semester` -- INSERT INTO `semester` (`id`, `semester`, `creationDate`, `updationDate`) VALUES (1, '1', '2022-02-10 17:22:49', NULL), (2, '2', '2022-02-10 17:22:55', NULL), (3, '3', '2022-02-11 00:51:43', NULL); -- -------------------------------------------------------- -- -- Table structure for table `session` -- CREATE TABLE `session` ( `id` int(11) NOT NULL, `session` varchar(255) DEFAULT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `session` -- INSERT INTO `session` (`id`, `session`, `creationDate`) VALUES (1, '2022', '2022-02-10 17:10:59'); -- -------------------------------------------------------- -- -- Table structure for table `students` -- CREATE TABLE `students` ( `StudentRegno` varchar(255) NOT NULL, `studentPhoto` varchar(255) DEFAULT NULL, `password` varchar(255) DEFAULT NULL, `studentName` varchar(255) DEFAULT NULL, `pincode` varchar(255) DEFAULT NULL, `session` varchar(255) DEFAULT NULL, `department` varchar(255) DEFAULT NULL, `semester` varchar(255) DEFAULT NULL, `cgpa` decimal(10,2) DEFAULT NULL, `creationdate` timestamp NULL DEFAULT current_timestamp(), `updationDate` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `students` -- INSERT INTO `students` (`StudentRegno`, `studentPhoto`, `password`, `studentName`, `pincode`, `session`, `department`, `semester`, `cgpa`, `creationdate`, `updationDate`) VALUES ('10806121', '', 'f925916e2754e5e03f75dd58a5733251', 'Anuj kumar', '822894', NULL, NULL, NULL, '7.10', '2022-02-11 00:53:31', NULL); -- -------------------------------------------------------- -- -- Table structure for table `userlog` -- CREATE TABLE `userlog` ( `id` int(11) NOT NULL, `studentRegno` varchar(255) DEFAULT NULL, `userip` binary(16) DEFAULT NULL, `loginTime` timestamp NULL DEFAULT current_timestamp(), `logout` varchar(255) DEFAULT NULL, `status` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `userlog` -- INSERT INTO `userlog` (`id`, `studentRegno`, `userip`, `loginTime`, `logout`, `status`) VALUES (1, '10806121', 0x3a3a3100000000000000000000000000, '2022-02-11 00:55:07', NULL, 1), (2, '10806121', 0x3a3a3100000000000000000000000000, '2022-02-11 00:57:00', NULL, 1), (3, '10806121', 0x3a3a3100000000000000000000000000, '2022-02-11 00:57:22', '11-02-2022 06:31:26 AM', 1); -- -- Indexes for dumped tables -- -- -- Indexes for table `admin` -- ALTER TABLE `admin` ADD PRIMARY KEY (`id`); -- -- Indexes for table `course` -- ALTER TABLE `course` ADD PRIMARY KEY (`id`); -- -- Indexes for table `courseenrolls` -- ALTER TABLE `courseenrolls` ADD PRIMARY KEY (`id`); -- -- Indexes for table `department` -- ALTER TABLE `department` ADD PRIMARY KEY (`id`); -- -- Indexes for table `level` -- ALTER TABLE `level` ADD PRIMARY KEY (`id`); -- -- Indexes for table `news` -- ALTER TABLE `news` ADD PRIMARY KEY (`id`); -- -- Indexes for table `semester` -- ALTER TABLE `semester` ADD PRIMARY KEY (`id`); -- -- Indexes for table `session` -- ALTER TABLE `session` ADD PRIMARY KEY (`id`); -- -- Indexes for table `students` -- ALTER TABLE `students` ADD PRIMARY KEY (`StudentRegno`); -- -- Indexes for table `userlog` -- ALTER TABLE `userlog` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `admin` -- ALTER TABLE `admin` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `course` -- ALTER TABLE `course` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `courseenrolls` -- ALTER TABLE `courseenrolls` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `department` -- ALTER TABLE `department` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `level` -- ALTER TABLE `level` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `news` -- ALTER TABLE `news` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `semester` -- ALTER TABLE `semester` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `session` -- ALTER TABLE `session` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `userlog` -- ALTER TABLE `userlog` 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
fd2333e25c425fee400d753f21e4c7055866ea3b
SQL
kivitendo/kivitendo-erp
/sql/Pg-upgrade2-auth/right_productivity_as_category.sql
UTF-8
1,329
3.15625
3
[]
no_license
-- @tag: right_productivity_as_category -- @description: Rechte: Produktivität als eigene Kategorie -- @depends: master_rights_positions_fix -- @locales: Productivity (TODO list, Follow-Ups) -- make space before 'configuration' UPDATE auth.master_rights SET position = position+1000 WHERE position >= (SELECT position FROM auth.master_rights WHERE name LIKE 'configuration'); -- insert category for productivity before 'configuration' INSERT INTO auth.master_rights (position, name, description, category) VALUES ((SELECT position FROM auth.master_rights WHERE name LIKE 'configuration') - 1000, 'productivity_category', 'Productivity', TRUE); -- move productivity rights below 'productivity_category' UPDATE auth.master_rights SET position = (SELECT position FROM auth.master_rights WHERE name LIKE 'productivity_category') + 100, description = 'Productivity (TODO list, Follow-Ups)' WHERE name LIKE 'productivity'; UPDATE auth.master_rights SET position = (SELECT position FROM auth.master_rights WHERE name LIKE 'productivity_category') + 200 WHERE name LIKE 'email_journal'; UPDATE auth.master_rights SET position = (SELECT position FROM auth.master_rights WHERE name LIKE 'productivity_category') + 250 WHERE name LIKE 'email_employee_readall';
true
570a041b45b578fbf781c610c7284448665e529c
SQL
yeqizhang/helloworld
/src/main/resources/db/db.sql
UTF-8
583
2.875
3
[]
no_license
CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */; use test; SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(500) COLLATE utf8_bin DEFAULT NULL, `age` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -- ---------------------------- -- Records of users -- ---------------------------- INSERT INTO `users` VALUES ('1', 'tgc', '26'); INSERT INTO `users` VALUES ('2', 'tgc2', '18');
true
e287b2c6a334da84a2d9add53a4ff88c321128c7
SQL
syphu1993/C2021G1-lephuocsyphu
/MODULE 3/Case_Study_Database/Query_23_24.sql
UTF-8
1,496
3.578125
4
[]
no_license
-- 23. Tạo Store procedure Sp_1 Dùng để xóa thông tin của một Khách hàng nào đó với Id Khách hàng được truyền vào -- như là 1 tham số của Sp_1 DELIMITER // create procedure Xoa_khach_hang(Id_p int) begin delete from khach_hang where ID_khach_hang = Id_p; end // DELIMITER ; SET FOREIGN_KEY_CHECKS=0; SET SQL_SAFE_UPDATES = 0; call Xoa_khach_hang(2); -- 24. Tạo Store procedure Sp_2 Dùng để thêm mới vào bảng HopDong với yêu cầu Sp_2 phải thực hiện kiểm tra -- tính hợp lệ của dữ liệu bổ sung, với nguyên tắc không được trùng khóa chính và đảm bảo toàn vẹn tham chiếu -- đến các bảng liên quan. DELIMITER // create procedure Them_hop_dong(Id_hopdong_p int,Id_nhanvien_p int,Id_khachhang_p int,Id_dichvu_p int, Ngay_lam_hop_dong_p date, Ngay_ket_thuc_hop_dong_p date,Tien_dat_coc_p int, Tien_tang_p int) begin if( Id_hopdong_p not in (select Id_hop_dong from hop_dong) and Id_nhanvien_p in(select Id_nhan_vien from nhan_vien) and Id_khachhang_p in(select Id_khach_hang from khach_hang) and Id_dichvu_p in(select Id_dich_vu from dich_vu) ) then insert into hop_dong value(Id_hopdong_p,Id_nhanvien_p,Id_khachhang_p,Id_dichvu_p,Ngay_lam_hop_dong_p, Ngay_ket_thuc_hop_dong_p,Tien_dat_coc_p, Tien_tang_p); else SIGNAL SQLSTATE '02000' SET MESSAGE_TEXT = 'Loi_nhap,Nhap_lai!!'; end if ; end ; // DELIMITER ; call Them_hop_dong(10,1,1,3,'2021-05-12','2021-05-30',500000,500000);
true
d8cac5a3c2e1638da075d53ef34df75a302e4a84
SQL
andymiaomiao/framework-repositories
/spring-boot/tcc-transaction-boot/db/tcc-boot.sql
UTF-8
4,409
3.40625
3
[ "Apache-2.0" ]
permissive
/* Navicat Premium Data Transfer Source Server : localhost Source Server Type : MySQL Source Server Version : 50638 Source Host : localhost:3306 Source Schema : tcc-boot Target Server Type : MySQL Target Server Version : 50638 File Encoding : 65001 Date: 24/01/2019 09:58:04 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for tcc_transaction_cap -- ---------------------------- DROP TABLE IF EXISTS `tcc_transaction_cap`; CREATE TABLE `tcc_transaction_cap` ( `TRANSACTION_ID` int(11) NOT NULL AUTO_INCREMENT, `DOMAIN` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `GLOBAL_TX_ID` varbinary(32) NOT NULL, `BRANCH_QUALIFIER` varbinary(32) NOT NULL, `CONTENT` varbinary(8000) NULL DEFAULT NULL, `STATUS` int(11) NULL DEFAULT NULL, `TRANSACTION_TYPE` int(11) NULL DEFAULT NULL, `RETRIED_COUNT` int(11) NULL DEFAULT NULL, `CREATE_TIME` datetime(0) NULL DEFAULT NULL, `LAST_UPDATE_TIME` datetime(0) NULL DEFAULT NULL, `VERSION` int(11) NULL DEFAULT NULL, `IS_DELETE` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`TRANSACTION_ID`) USING BTREE, UNIQUE INDEX `UX_TX_BQ`(`GLOBAL_TX_ID`, `BRANCH_QUALIFIER`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Table structure for tcc_transaction_ord -- ---------------------------- DROP TABLE IF EXISTS `tcc_transaction_ord`; CREATE TABLE `tcc_transaction_ord` ( `TRANSACTION_ID` int(11) NOT NULL AUTO_INCREMENT, `DOMAIN` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `GLOBAL_TX_ID` varbinary(32) NOT NULL, `BRANCH_QUALIFIER` varbinary(32) NOT NULL, `CONTENT` varbinary(8000) NULL DEFAULT NULL, `STATUS` int(11) NULL DEFAULT NULL, `TRANSACTION_TYPE` int(11) NULL DEFAULT NULL, `RETRIED_COUNT` int(11) NULL DEFAULT NULL, `CREATE_TIME` datetime(0) NULL DEFAULT NULL, `LAST_UPDATE_TIME` datetime(0) NULL DEFAULT NULL, `VERSION` int(11) NULL DEFAULT NULL, `IS_DELETE` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`TRANSACTION_ID`) USING BTREE, UNIQUE INDEX `UX_TX_BQ`(`GLOBAL_TX_ID`, `BRANCH_QUALIFIER`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Table structure for tcc_transaction_red -- ---------------------------- DROP TABLE IF EXISTS `tcc_transaction_red`; CREATE TABLE `tcc_transaction_red` ( `TRANSACTION_ID` int(11) NOT NULL AUTO_INCREMENT, `DOMAIN` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `GLOBAL_TX_ID` varbinary(32) NOT NULL, `BRANCH_QUALIFIER` varbinary(32) NOT NULL, `CONTENT` varbinary(8000) NULL DEFAULT NULL, `STATUS` int(11) NULL DEFAULT NULL, `TRANSACTION_TYPE` int(11) NULL DEFAULT NULL, `RETRIED_COUNT` int(11) NULL DEFAULT NULL, `CREATE_TIME` datetime(0) NULL DEFAULT NULL, `LAST_UPDATE_TIME` datetime(0) NULL DEFAULT NULL, `VERSION` int(11) NULL DEFAULT NULL, `IS_DELETE` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`TRANSACTION_ID`) USING BTREE, UNIQUE INDEX `UX_TX_BQ`(`GLOBAL_TX_ID`, `BRANCH_QUALIFIER`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Table structure for tcc_transaction_ut -- ---------------------------- DROP TABLE IF EXISTS `tcc_transaction_ut`; CREATE TABLE `tcc_transaction_ut` ( `TRANSACTION_ID` int(11) NOT NULL AUTO_INCREMENT, `DOMAIN` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `GLOBAL_TX_ID` varbinary(32) NOT NULL, `BRANCH_QUALIFIER` varbinary(32) NOT NULL, `CONTENT` varbinary(8000) NULL DEFAULT NULL, `STATUS` int(11) NULL DEFAULT NULL, `TRANSACTION_TYPE` int(11) NULL DEFAULT NULL, `RETRIED_COUNT` int(11) NULL DEFAULT NULL, `CREATE_TIME` datetime(0) NULL DEFAULT NULL, `LAST_UPDATE_TIME` datetime(0) NULL DEFAULT NULL, `VERSION` int(11) NULL DEFAULT NULL, `IS_DELETE` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`TRANSACTION_ID`) USING BTREE, UNIQUE INDEX `UX_TX_BQ`(`GLOBAL_TX_ID`, `BRANCH_QUALIFIER`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; SET FOREIGN_KEY_CHECKS = 1;
true
e0d376705ff4ebd0f08a89c53a9c6e1b01e2cf2d
SQL
fatihari/Patika.dev_solutions
/SQL/03-Like-ILike/main.sql
UTF-8
352
2.890625
3
[ "MIT" ]
permissive
/** * @author Fatih ARI - 30.08.2021 */ -- Option 1: SELECT country FROM country WHERE country LIKE 'A%a'; -- Option 2: SELECT country FROM country WHERE country LIKE '_%_%_%_%_%n'; -- Option 3: SELECT title FROM film WHERE title ILIKE '%t%t%t%t%'; -- Option 4: SELECT * FROM film WHERE title LIKE 'C%' AND length >= 90 AND rental_rate = 2.99;
true
a4a57a5d44d99fe99737626b5762fa3a43102dc0
SQL
amax3002/timeentry_sql
/time_entry.sql
UTF-8
4,098
4.59375
5
[]
no_license
--Find all time entries. SELECT * FROM time_entries --Find the developer who joined most recently. SELECT * FROM developers ORDER BY created_at DESC LIMIT 1 --Find the number of projects for each client. SELECT c.name AS client_name, count(p.client_id) AS counter FROM clients AS c LEFT JOIN projects AS p ON c.id = p.client_id GROUP BY c.name ORDER BY counter DESC --Find all time entries, and show each one's client name next to it. SELECT te.*, c.name FROM time_entries AS te LEFT JOIN projects AS p ON te.project_id = p.id LEFT JOIN clients AS c ON c.id = p.client_id --Find all developers in the "Ohio sheep" group. SELECT d.*, g.name FROM developers AS d LEFT JOIN group_assignments AS ga ON ga.developer_id = d.id LEFT JOIN groups AS g ON g.id = ga.group_id WHERE g.name = 'Ohio sheep' --Find the total number of hours worked for each client. SELECT c.name, sum(te.duration) AS total_hours FROM time_entries AS te LEFT JOIN projects AS p ON te.project_id = p.id LEFT JOIN clients AS c ON c.id = p.client_id GROUP BY c.name --Find the client for whom Mrs. Lupe Schowalter (the developer) has worked the greatest number of hours. SELECT d.*, c.name, sum(te.duration) AS total_hours FROM time_entries AS te LEFT JOIN developers AS d ON te.developer_id = d.id LEFT JOIN projects AS p ON te.project_id = p.id LEFT JOIN clients AS c ON c.id = p.client_id GROUP BY c.name, c.name ORDER BY total_hours DESC LIMIT 1 -- List all client names with their project names (multiple rows for one client is fine). Make sure that clients still show up even if they have no projects. SELECT c.name, p.name FROM clients AS c LEFT JOIN projects AS p ON c.id = p.client_id --Find all developers who have written no comments. SELECT d.*, ct.comment FROM developers AS d LEFT JOIN comments AS ct ON ct.developer_id = d.id WHERE ct.comment IS NULL --HARD --Find all developers with at least five comments. SELECT d.*, count(developer_id) FROM comments as ct LEFT JOIN developers as d on d.id = ct.developer_id GROUP BY ct.developer_id HAVING count(developer_id)>= 5 --Find the developer who worked the fewest hours in January of 2015. SELECT d.*, c.name as client_name, sum(te.duration) AS total_hours FROM time_entries AS te LEFT JOIN developers AS d ON te.developer_id = d.id LEFT JOIN projects AS p ON te.project_id = p.id LEFT JOIN clients AS c ON c.id = p.client_id WHERE te.worked_on >= '2015-01-01' AND te.worked_on <= '2015-01-30' GROUP BY c.name ORDER BY total_hours asc --Find all time entries which were created by developers who were not assigned to that time entry's project. SELECT d.*, pa.project_id, te.project_id FROM time_entries AS te LEFT JOIN project_assignments AS pa ON pa.developer_id = te.developer_id AND pa.project_id = te.project_id LEFT JOIN developers AS d ON d.id = te.developer_id WHERE pa.project_id IS NULL --Find all developers with no time put towards at least one of their assigned projects. SELECT d.*, pa.project_id, te.project_id, te.duration FROM time_entries AS te LEFT JOIN project_assignments AS pa ON pa.developer_id = te.developer_id AND pa.project_id = te.project_id LEFT JOIN developers AS d ON d.id = te.developer_id WHERE pa.project_id IS NOT NULL AND te.duration = 0 --Find all pairs of developers who are in two or more different groups together. SELECT * FROM developers WHERE id IN (SELECT developer_id FROM group_assignments GROUP BY group_id HAVING count(group_id) >= 2) --For all clients, find the duration of the time entry which was entered most recently for that particular client. SELECT c.name as client_name, te.duration, max(te.worked_on) as most_recent_date FROM time_entries AS te LEFT JOIN projects AS p ON te.project_id = p.id LEFT JOIN clients AS c ON c.id = p.client_id GROUP BY c.name order by most_recent_date -* --Did this a second way to include the 3 clients that have no time entries SELECT c.name as client_name,te.duration, max(te.worked_on) as most_recent_date FROM clients as c LEFT JOIN projects AS p ON c.id = p.client_id LEFT JOIN time_entries AS te ON te.project_id = p.id GROUP BY c.name order by most_recent_date DESC
true
ed174fd88fcd799fcbbcb9b7682c49024bf71641
SQL
TheChanec/mcs.repository
/Database/Archive/Tables/Inspections.sql
UTF-8
3,021
2.515625
3
[]
no_license
CREATE TABLE [Archive].[Inspections] ( [InspectionID] BIGINT NOT NULL, [PMID] BIGINT NOT NULL, [InspectionStatusID] TINYINT NOT NULL, [VendorID] INT NOT NULL, [VendorSubID] INT NULL, [ClientInspectionTypeID] TINYINT NOT NULL, [VendorInspectionTypeID] TINYINT NOT NULL, [TimeFrameID] TINYINT NOT NULL, [WorkOrderNumber] BIGINT NOT NULL, [FormattedWorkOrderNumber] AS ('IN'+CONVERT([varchar](12),[WorkOrderNumber],(0))), [DateCreated] SMALLDATETIME NULL, [CreateUserID] INT NOT NULL, [DateOrdered] SMALLDATETIME NOT NULL, [DateRequested] SMALLDATETIME NOT NULL, [DateAssigned] SMALLDATETIME NULL, [AssignUserID] INT NULL, [DateReassigned] SMALLDATETIME NULL, [ReassignUserID] INT NULL, [DateInspectionPrinted] SMALLDATETIME NULL, [InspectionPrintUserID] INT NULL, [DateInspectBetweenStarts] SMALLDATETIME NOT NULL, [DateInspectBetweenEnds] SMALLDATETIME NOT NULL, [DatesToInspectBetween] AS ((CONVERT([char](10),[DateInspectBetweenStarts],(101))+' - ')+CONVERT([char](10),[DateInspectBetweenEnds],(101))), [DateResultsEntered] SMALLDATETIME NULL, [DateResultsFinalized] SMALLDATETIME NULL, [DateResultsSentToClient] SMALLDATETIME NULL, [DateInspectionBilled] SMALLDATETIME NULL, [Instructions] VARCHAR (MAX) NULL, [PreviousOccupancyStatusID] TINYINT NULL, [VendorAPAmount] DECIMAL (7, 2) NOT NULL, [ClientARAmount] DECIMAL (6, 2) NOT NULL, [TotalClientPhotoAmount] DECIMAL (5, 2) NOT NULL, [TotalNumberOfPhotosBilled] SMALLINT NOT NULL, [APBatchStatus] TINYINT NULL, [DamageFlag] BIT NOT NULL, [DateCancelled] SMALLDATETIME NULL, [DateLastModified] SMALLDATETIME NOT NULL, [LastModificationUserID] INT NOT NULL, [DateWorkStopCoded] SMALLDATETIME NULL, [StopWorkUserID] INT NULL, [InspectionCallbackID] SMALLINT NULL, [SalesTaxTotal] DECIMAL (7, 2) NOT NULL, [SentToAspen] BIT NULL, [MissingDateTaken] BIT NULL, [MissingGeolocation] BIT NULL, [InvalidDateTaken] BIT NULL, [ImageDataArchived] BIT NULL, [insp_date] SMALLDATETIME NULL, [ArchivedDate] SMALLDATETIME CONSTRAINT [DF_Inspections_ArchivedDate] DEFAULT (getdate()) NOT NULL, CONSTRAINT [PK_Inspections] PRIMARY KEY CLUSTERED ([InspectionID] ASC) );
true
21d8086d6e7baf7bf4987405769ce5d2b6c8cbaf
SQL
yasminmenchaca/database-exercises
/join_exercises.sql
UTF-8
2,831
4.625
5
[]
no_license
USE employees; # Using the example in the Associative Table Joins section as a guide, write a query that shows each department along with the name of the current manager for that department. SELECT d.dept_name AS 'Department Name', CONCAT(e.first_name, ' ', e.last_name) AS 'Department Manager' FROM employees as e JOIN dept_manager as dm ON e.emp_no = dm.emp_no JOIN departments d on dm.dept_no = d.dept_no where to_date > NOW() order by dept_name; # Find the name of all departments currently managed by women. SELECT d.dept_name AS 'Department Name', CONCAT(e.first_name, ' ', e.last_name) AS 'Manager Name' FROM employees AS e JOIN dept_manager dm on e.emp_no = dm.emp_no JOIN departments d on dm.dept_no = d.dept_no WHERE to_date > NOW() and e.gender = 'f' order by dept_name; # Find the current titles of employees currently working in the Customer Service department. # SELECT t.title AS 'Title', # COUNT(*) AS 'Count' # FROM titles as t # JOIN employees e on t.emp_no = e.emp_no # JOIN dept_emp de on e.emp_no = de.emp_no # WHERE t.to_date > NOW() # AND de.to_date > NOW() # and dept_no = 'd009' # group by t.title; -- or SELECT t.title AS 'Title', COUNT(*) AS 'Count' FROM departments as d JOIN dept_emp de on d.dept_no = de.dept_no JOIN titles t on t.emp_no = de.emp_no WHERE de.to_date > NOW() and t.to_date > NOW() and d.dept_name = 'Customer Service' GROUP BY t.title; # Find the current salary of all current managers. SELECT d.dept_name AS 'Department Name', CONCAT(e.first_name, ' ', e.last_name) AS 'Name', employees.salaries.salary AS 'Salary' FROM employees AS e JOIN dept_manager dm on e.emp_no = dm.emp_no JOIN dept_emp de on e.emp_no = de.emp_no JOIN salaries on dm.emp_no = salaries.emp_no JOIN departments as d ON d.dept_no = de.dept_no WHERE dm.to_date > NOW() and salaries.to_date > NOW() ORDER BY d.dept_name; # Bonus -- Find the names of all current employees, their department name, and their current manager's name. SELECT concat(employees.first_name, ' ', employees.last_name) AS 'Employee Name', d.dept_name AS 'Department Name', concat(managers.first_name, ' ', managers.last_name) AS 'Manager Name' FROM employees JOIN dept_emp AS de on de.emp_no = employees.emp_no JOIN departments AS d on de.dept_no = d.dept_no JOIN dept_manager AS m on m.dept_no = d.dept_no JOIN employees AS managers ON m.emp_no = managers.emp_no WHERE de.to_date > NOW() AND m.to_date > NOW();
true
3a4006d909a7fb57dc1da282665d0492c6bac280
SQL
SergioO21/holbertonschool-higher_level_programming
/0x0D-SQL_introduction/101-avg_temperatures.sql
UTF-8
196
3.5625
4
[]
no_license
-- Displays the top 3 of cities temperature during July and August ordered by temperature (descending). SELECT city, AVG(value) as avg_temp FROM temperatures GROUP BY city ORDER BY avg_temp DESC;
true
1111f976d8fe7c9dd21208454f42980519704d48
SQL
antonpaquin/Homulili
/src/backend/sqlmigrations/1517806519_change_pagedata_to_pagemirrors/down.sql
UTF-8
402
2.96875
3
[]
no_license
DROP TABLE pagemirrors; CREATE TABLE pagedata ( page_id SERIAL PRIMARY KEY NOT NULL, data BYTEA, time_created TIMESTAMP DEFAULT current_timestamp, time_updated TIMESTAMP, FOREIGN KEY (page_id) REFERENCES pages(page_id) ON DELETE CASCADE ); CREATE TRIGGER update_timestamp_pagedata BEFORE UPDATE ON pagedata FOR EACH ROW EXECUTE PROCEDURE update_timestamp();
true
7135f3e5a93f281aee4fada0b311cb2ab16a664e
SQL
IgorCs95/lanches-api
/src/main/resources/db/migration/V04__create_item_pedido.sql
UTF-8
299
3.03125
3
[]
no_license
CREATE TABLE item_pedido( id SERIAL PRIMARY KEY, pedido_id INTEGER, produto_id INTEGER, valor DECIMAL(10,2) NOT NULL, valor_total DECIMAL(10,2) NOT NULL, quantidade DECIMAL(10,2) NOT NULL, FOREIGN KEY(produto_id) REFERENCES produto (id), FOREIGN KEY(pedido_id) REFERENCES pedido (id) );
true
c4f2c89dc2f26e37c71d26793549bf910554dcb3
SQL
Lucas-Lameira/schema-product
/sqlScripts/inserir_dados.sql
UTF-8
3,406
3.171875
3
[]
no_license
-- date data "1980-06-25" -- usuario INSERT INTO usuario (id, nome, email, senha) VALUES (DEFAULT, "lucas lameira", "lucaslameira@gmail.com", "123456"); INSERT INTO usuario VALUES (DEFAULT, "leandro ribeiro", "leandroribeiro@gmail.com", "7891011"); -- fornecedor INSERT INTO fornecedor (id, nome, rua, cep, numero, bairro, id_usuario) VALUES (DEFAULT, "fonecedouro", "RUA", "CEP", "NUMERO", "BAIRRO", 1); INSERT INTO fornecedor VALUES (DEFAULT, "atacadinho", "passagem alves", "06123-066", "1645", "pratinha", 1), (DEFAULT, "liderezoom", "1° de abril", "05846-047", "1200", "bairro do marco", 1), (DEFAULT, "super mercaderoi", "padre julio maria", "04567-987", "985", "cruzeiro", 1), (DEFAULT, "emporio coquetel", "quinta rua", "45678-068", "465", "umarizal", 2); -- telefone INSERT INTO telefone (telefone, id_fornecedor) VALUES ("(91) 98989-8989", 2); INSERT INTO telefone VALUES ("(91) 97979-8787", 2), ("(91) 96868-8686", 1), ("(91) 98585-8585", 3), ("(91) 91212-2121", 4), ("(91) 93535-5353", 4), ("(91) 91234-5847", 5); -- produto INSERT INTO produto (cod_produto, nome, quantidade, preco_venda, quantidade_minima, id_categoria) VALUES (DEFAULT, "agua mineral marcax 20L", 20, 7.00, DEFAULT, 1); INSERT INTO produto VALUES (DEFAULT, "macarrao legal 250g", 16, 3.50, 5, 2), (DEFAULT, "cerveja skola beet", 0, 5.00, 30, 1), (DEFAULT, "papel higienio 6 rolos", 15, 4.50, 8, 4), (DEFAULT, "arroz tia joelma 1kg", 26, 6.20, 6, 2), (DEFAULT, "cortador de unha", 12, 8.88, 2, 3), (DEFAULT, "feijão galopero 500g", 17, 4.99, DEFAULT, 2), (DEFAULT, "café desunião", 4, 4.83, 6, 1); INSERT INTO produto (nome, quantidade, preco_venda, quantidade_minima, id_categoria) values ('Miojo tailandes', 0, 2.50, DEFAULT, 2); -- item compra INSERT INTO item_compra (id, data_compra, preco_compra, quantidade, inserido, lucro, id_usuario, cod_produto) VALUES (DEFAULT, "2021-05-05", 2.89, 12, false, '15', 1, 8); INSERT INTO item_compra VALUES (DEFAULT, "2021-05-06", 2.80, 12, true, '15', 1, 2), (DEFAULT, '2021-05-07', 7.40, 2, true, '15', 1, 6), (DEFAULT, '2021-05-07', 3.20, 6, false, '15', 1, 4), (DEFAULT, '2021-05-07', 4.80, 10, false, '15', 1, 5), (DEFAULT, '2021-05-09', 4.10, 28, false, '15', 1, 3), (DEFAULT, '2021-05-09', 3.20, 8, true, '15', 1, 7), (DEFAULT, '2021-05-15', 5.50, 5, true, '15', 1, 1), (DEFAULT, '2021-06-05', 3.20, 6, true, '16', 1, 4), (DEFAULT, '2021-06-06', 3.20, 8, true, '16', 1, 1); -- fornecedor item INSERT INTO fornecedor_item (id_compra, id_fornecedor) VALUES (1, 2); INSERT INTO fornecedor_item VALUES (2, 1), (3, 1), (4, 3), (5, 2), (6, 5), (7, 4), (8, 5), (9, 4), (10, 3); -- venda INSERT INTO venda (cod_venda, id_usuario) VALUES (1, 1); INSERT INTO venda values (2, 1), (3, 1), (4, 1), (5, 1), (6, 2), (7, 2), (8, 2), (9, 1), (10, 1), (11, 2), (12, 2), (13, 1), (14, 1), (15, 2), (16, 2), (17, 2), (18, 2), (19, 1), (20, 1); -- item venda INSERT INTO item_venda (id, data_venda, quantidade, cod_venda, cod_produto) VALUES (1, '2021-06-07', 1, 1, 1); INSERT INTO item_venda VALUES (2, '2021-06-07', 2, 2, 5), (3, '2021-06-07', 8, 3, 3), (4, '2021-06-07', 1, 4, 7), (5, '2021-06-07', 3, 5, 2), (6, '2021-06-08', 1, 6, 4), (7, '2021-06-08', 2, 7, 5), (8, '2021-06-08', 3, 8, 5), (9, '2021-06-09', 4, 9, 8), (10, '2021-06-09', 1, 10, 6);
true
bff91c7d73da4f09d16a0b3fea38bceab8ea9ea3
SQL
thiagosonnessogarcia/repositSites
/B2better/banco/scriptBanco.sql
UTF-8
868
3.234375
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,ALLOW_INVALID_DATES'; CREATE SCHEMA IF NOT EXISTS `db_pi` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; USE `db_pi` ; -- ----------------------------------------------------- -- Table `db_pi`.`tb_cadastro` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `db_pi`.`tb_cadastro` ( `id` INT NOT NULL AUTO_INCREMENT, `nomefunc` VARCHAR(45) NULL, `nomeemp` VARCHAR(45) NULL, `cargo` VARCHAR(45) NULL, `email` VARCHAR(45) NULL, `login` VARCHAR(45) NULL, `senha` VARCHAR(45) NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
true
89f84f21a183b6296ec10c7d60411684f0f39daf
SQL
www2388258980/rty-service
/src/main/resources/sql/rty_oa_dial_persons.sql
UTF-8
1,255
2.953125
3
[]
no_license
/* Navicat MySQL Data Transfer Source Server : localhost_3306 Source Server Version : 50553 Source Host : localhost:3306 Source Database : rty Target Server Type : MYSQL Target Server Version : 50553 File Encoding : 65001 Date: 2020-02-23 11:44:21 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for rty_oa_dial_persons -- ---------------------------- DROP TABLE IF EXISTS `rty_oa_dial_persons`; CREATE TABLE `rty_oa_dial_persons` ( `DIAL_PERSON_ID` varchar(20) NOT NULL, `FIRST_NAME` varchar(255) DEFAULT NULL, `TELECOM_NUMBER` varchar(255) DEFAULT NULL, `COUNT_NAME` varchar(255) DEFAULT NULL, `STATUS` varchar(255) DEFAULT NULL, `DESCRIPTION` varchar(255) DEFAULT NULL, `FIRST_CHAR` varchar(255) DEFAULT NULL, `DEPARTMENT_ID` varchar(255) DEFAULT NULL, `CREATED_BY` varchar(255) DEFAULT NULL, `MODIFIED_BY` varchar(255) DEFAULT NULL, `BILL_ID` varchar(255) DEFAULT NULL, `MODIFIED_BILL_ID` varchar(255) DEFAULT NULL, `VPN_TYPE_ID` varchar(20) DEFAULT NULL, `OP_TYPE` varchar(255) DEFAULT NULL, `LAST_UPDATED_STAMP` datetime DEFAULT NULL, `CREATED_STAMP` datetime DEFAULT NULL, PRIMARY KEY (`DIAL_PERSON_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
true
e0238d6f3d91ac63fedc8050e8a3377402dc4cee
SQL
srdantas/fortnight
/app/src/main/resources/db/V3__CREATE_TRANSFERS.sql
UTF-8
513
3.203125
3
[ "Apache-2.0" ]
permissive
CREATE TABLE `transfers` ( `id` bigint auto_increment, `debtor` varchar(13) NOT NULL, `creditor` varchar(13) NOT NULL, `transaction` varchar(100) NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `FK_74` FOREIGN KEY `fkIdx_74` (`debtor`) REFERENCES `customers` (`document`), CONSTRAINT `FK_75` FOREIGN KEY `fkIdx_75` (`creditor`) REFERENCES `customers` (`document`), CONSTRAINT `FK_76` FOREIGN KEY `fkIdx_76` (`transaction`) REFERENCES `transactions` (`correlation`) );
true
7ca525c8def4dcec4a959e08c5cbdb7f6ea376aa
SQL
cristobaldaw/tienda_online
/tienda.sql
UTF-8
14,052
3.390625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.0.6 -- http://www.phpmyadmin.net -- -- Servidor: localhost -- Tiempo de generación: 28-02-2017 a las 20:22:34 -- Versión del servidor: 5.5.53-0ubuntu0.14.04.1 -- Versión de PHP: 5.5.9-1ubuntu4.20 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 */; -- -- Base de datos: `2daw16_crisdo01` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `categorias` -- CREATE TABLE IF NOT EXISTS `categorias` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cod` varchar(10) DEFAULT NULL, `nombre` varchar(45) DEFAULT NULL, `descripcion` varchar(150) DEFAULT NULL, `oculto` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; -- -- Volcado de datos para la tabla `categorias` -- INSERT INTO `categorias` (`id`, `cod`, `nombre`, `descripcion`, `oculto`) VALUES (1, 'port', 'Ordenadores portátiles', 'Ordenadores portátiles para todas las necesidades. Tanto si eres un jugón empedernido, como si lo necesitas para el trabajo.', 0), (2, 'sma', 'Smartphones', 'Los smartphones son una herramienta indispensable en nuestro día a día. La cantidad de aplicaciones que abarcan nos hacen la vida mucho más fácil.', 0), (3, 'con', 'Consolas', 'No importa si eres de Sony o de Microsoft. Lo importante es que te diviertas, y que lo hagas en tu videoconsola favorita al mejor precio.', 0); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `linea_pedido` -- CREATE TABLE IF NOT EXISTS `linea_pedido` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_producto` int(11) NOT NULL, `id_pedido` int(11) NOT NULL, `cantidad` int(11) DEFAULT NULL, `precio` decimal(6,2) DEFAULT NULL, PRIMARY KEY (`id`,`id_producto`,`id_pedido`), KEY `fk_linea_pedido_productos1_idx` (`id_producto`), KEY `fk_linea_pedido_pedidos1_idx` (`id_pedido`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=74 ; -- -- Volcado de datos para la tabla `linea_pedido` -- INSERT INTO `linea_pedido` (`id`, `id_producto`, `id_pedido`, `cantidad`, `precio`) VALUES (68, 11, 65, 3, 278.00), (69, 1, 65, 1, 337.00), (70, 6, 65, 2, 319.00), (71, 6, 66, 1, 319.00), (72, 6, 67, 1, 319.00), (73, 6, 68, 1, 319.00); -- -- Disparadores `linea_pedido` -- DROP TRIGGER IF EXISTS `Reduce_Stock`; DELIMITER // CREATE TRIGGER `Reduce_Stock` AFTER INSERT ON `linea_pedido` FOR EACH ROW update productos set stock = stock - new.cantidad where id = new.id_producto // DELIMITER ; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `pedidos` -- CREATE TABLE IF NOT EXISTS `pedidos` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_usuario` int(11) NOT NULL, `nombre` varchar(45) DEFAULT NULL, `apellidos` varchar(100) DEFAULT NULL, `direccion` varchar(200) DEFAULT NULL, `email` varchar(60) DEFAULT NULL, `cp` varchar(5) DEFAULT NULL, `estado` char(2) DEFAULT NULL, `id_provincia` int(11) DEFAULT NULL, `fecha` date NOT NULL, PRIMARY KEY (`id`), KEY `fk_pedidos_usuarios1_idx` (`id_usuario`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=69 ; -- -- Volcado de datos para la tabla `pedidos` -- INSERT INTO `pedidos` (`id`, `id_usuario`, `nombre`, `apellidos`, `direccion`, `email`, `cp`, `estado`, `id_provincia`, `fecha`) VALUES (65, 4, 'nombre de prueba', 'apellidos de prueba', 'direccion de prueba', 'cristobaldominguez95@hotmail.com', '66666', 'pe', 17, '2017-02-28'), (66, 4, 'nombre de prueba', 'apellidos de prueba', 'direccion de prueba', 'cristobaldominguez95@hotmail.com', '66666', 'pe', 17, '2017-02-28'), (67, 4, 'nombre de prueba', 'apellidos de prueba', 'direccion de prueba', 'cristobaldominguez95@hotmail.com', '66666', 'ca', 17, '2017-02-28'), (68, 4, 'nombre de prueba', 'apellidos de prueba', 'direccion de prueba', 'cristobaldominguez95@hotmail.com', '66666', 'ca', 17, '2017-02-28'); -- -- Disparadores `pedidos` -- DROP TRIGGER IF EXISTS `Fecha_Pedido`; DELIMITER // CREATE TRIGGER `Fecha_Pedido` BEFORE INSERT ON `pedidos` FOR EACH ROW set new.fecha = curdate() // DELIMITER ; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `productos` -- CREATE TABLE IF NOT EXISTS `productos` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cod` varchar(10) DEFAULT NULL, `nombre` varchar(45) DEFAULT NULL, `precio` decimal(6,2) DEFAULT NULL, `descuento` int(2) DEFAULT NULL, `imagen` varchar(256) DEFAULT NULL, `iva` int(2) DEFAULT NULL, `descripcion` varchar(500) DEFAULT NULL, `id_categoria` int(11) NOT NULL, `stock` int(11) DEFAULT NULL, `fecha_ini` date DEFAULT NULL, `fecha_fin` date DEFAULT NULL, `oculto` tinyint(1) DEFAULT NULL, `destacado` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`,`id_categoria`), KEY `fk_productos_categorias2_idx` (`id_categoria`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ; -- -- Volcado de datos para la tabla `productos` -- INSERT INTO `productos` (`id`, `cod`, `nombre`, `precio`, `descuento`, `imagen`, `iva`, `descripcion`, `id_categoria`, `stock`, `fecha_ini`, `fecha_fin`, `oculto`, `destacado`) VALUES (1, 'B50-50', 'Lenovo Essential B50-50', 278.51, NULL, 'port1', 21, 'Lenovo te presenta si gama Essential B50-50, un portátil con un procesador Intel Core i3 con una resolución de pantalla de 1366 x 768 píxeles y tecnología Wifi con 500GB de almacenamiento interno, para que en un solo portátil tengas todo lo que necesitas para trabajar al alcance de tu mano.', 1, 11, NULL, NULL, 0, 0), (2, 'P259M', 'Acer TravelMate P259M', 412.40, NULL, 'port2', 21, 'Te presentamos la gama Acer TravelMate . Estos portátiles, que tienen un refinado acabado textil con una apariencia y un tacto excepcionales, incorporan los últimos procesadores Intel® Core™ y unas discretas opciones gráficas para que logre la máxima productividad en todo momento.', 1, 4, NULL, NULL, 0, 1), (3, 'GL62', 'MSI GL62 6QF-1230XES', 698.35, NULL, 'port3', 21, 'Te presentamos el GL62 6QF-1230XES de MSI, un portátil gaming con procesador Intel Core i5, 8GB de RAM, 1TB de disco duro y gráca Nvidia GeForce GTX 960M.', 1, 0, NULL, NULL, 0, 0), (4, 'RED3S', 'Xiaomi Redmi 3S Prime 4G 32Gb', 164.46, NULL, 'sma1', 21, 'Con la llegada del Xiaomi Redmi 3S ya tenemos otro smartphone barato en la gama media con un diseño fantástico y especificaciones más que interesantes. Desde que Xiaomi llegó al mercado, nuestra percepción de los teléfonos móviles baratos está cambiando, para bien, y este Redmi 3S es una prueba de ello.', 2, 9, NULL, NULL, 0, 0), (5, 'P8', 'Huawei P8 Lite', 142.15, NULL, 'sma2', 21, 'Huawei P8 Lite es sinónimo de diseño y tecnología. Este P8 Lite es un buen ejemplo de que los móviles baratos pueden combinar un diseño genial con la mejor tecnología del momento sin que el precio se resienta.', 2, 0, NULL, NULL, 0, 0), (6, 'IPH5S', 'Apple iPhone 5S', 263.64, NULL, 'sma3', 21, 'iPhone 5s coge todas las cualidades del iPhone anterior, las amplía y las mejora. Así es el nuevo móvil de Apple.\r\n\r\nApple vuelve a la carga y PcComponentes te pone en bandeja este iphone 5s barato como él solo.', 2, 14, NULL, NULL, 0, 1), (7, 'SAMJ5', 'Samsung Galaxy J5', 164.46, NULL, 'sma4', 21, 'Samsung Galaxy J5 2016 es lo nuevo en móviles Samsung. La serie J apuesta por unas especificaciones realmente atractivas a un precio muy ajustado, sobre todo en el modelo J5. Algo que parece haberle salido bien a la compañía a tenor de los resultados del Samsung J5 2016 y las opiniones tan positivas que está cosechando.', 2, 0, NULL, NULL, 0, 0), (8, 'MG4', 'Motorola Moto G4', 147.93, NULL, 'sma5', 21, 'Con 5,5 pulgadas y resolución Full HD (1920x1080), este teléfono hará las delicias de quienes disfrutan consumiendo contenido multimedia, vídeos, fotografías, animaciones y juegos, también para aquellos a los que les guste navegar y echar un rápido vistazo a una página web sin apenas hacer uso del scroll para recorrer la web.', 2, 4, NULL, NULL, 0, 1), (9, 'LGK8', 'LG K8 4G 8GB', 103.30, NULL, 'sma6', 21, 'LG presenta al LG K8, un móvil libre barato con el que pretende competir en la gama baja con un precio irresistible y unas especificaciones muy interesantes que sitúan a este teléfono como uno de los mejores en cuanto a calidad/precio.', 2, 1, NULL, NULL, 0, 0), (10, 'NEX5X', 'Google Nexus 5X 16GB', 222.31, NULL, 'sma7', 21, 'Nexus 5X es un smartphone que equilibra a la perfección diseño, especificaciones y precio. Al comprar Nexus 5X estás adquiriendo la más avanzada tecnología al mejor precio. Un dispositivo ligero y compacto que te acompañará durante todo el día ofreciéndote una experiencia de uso sin igual.', 2, 0, NULL, NULL, 0, 0), (11, 'PS4', 'PlayStation 4 Slim 500GB', 229.75, NULL, 'con1', 21, 'Disfruta de una PS4 más estilizada y compacta con la misma potencia de juego.Disfruta de colores increíblemente vivos y brillantes con asombrosos gráficos HDR.Organiza tus juegos y aplicaciones y comparte todo con tus amigos a través de una nueva interfaz intuitiva.', 3, 7, NULL, NULL, 0, 0), (12, 'XBOXFI', 'Xbox One S 500GB + Fifa 17', 247.11, NULL, 'con2', 21, 'Reserva el pack Xbox One S 1 TB: Fifa 17 , que contiene una consola Xbox One S de 500GB y el Mando Inalámbrico Xbox One y de Fifa 17, sin duda uno de los juegos más esperados del año.', 3, 6, NULL, NULL, 0, 0), (13, '3DS', 'Nintendo New 3DS XL', 161.16, NULL, 'con3', 21, 'New 3DS XL supone una vuelta de tuerca en el mundo de las consolas. Un golpe sobre la mesa de Nintendo para demostrar que, desde la Game Boy, sigue siendo la reina de la diversión portátil. Y es que la Nintendo New 3DS XL supone un gran avance con respecto a la Nintendo 3DS.', 3, 7, NULL, NULL, 0, 0), (14, 'GL752VW', 'Asus GL752VW-T4065D', 825.62, 15, 'port4', 21, 'Comprar Asus GL752VW es una sabia decisión si buscas potencia para jugar a tus videojuegos favoritos en cualquier parte. Su potente procesador Intel Core i7 a 2.6GHz overclokeable hasta 3.5 junto con la tarjeta gráfica Nvidia GTX960M aportan la potencia necesaria para mover los juegos más novedosos en calidades ultra y altísimas resoluciones.', 1, 0, NULL, NULL, 0, 0); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `provincias` -- CREATE TABLE IF NOT EXISTS `provincias` ( `id` int(11) NOT NULL, `nombre` varchar(60) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Volcado de datos para la tabla `provincias` -- INSERT INTO `provincias` (`id`, `nombre`) VALUES (0, '- Seleccione -'), (1, 'Alava'), (2, 'Albacete'), (3, 'Alicante'), (4, 'Almería'), (5, 'Ávila'), (6, 'Badajoz'), (7, 'Islas Baleares'), (8, 'Barcelona'), (9, 'Burgos'), (10, 'Cáceres'), (11, 'Cádiz'), (12, 'Castellón'), (13, 'Ciudad Real'), (14, 'Córdoba'), (15, 'A Coruña'), (16, 'Cuenca'), (17, 'Girona'), (18, 'Granada'), (19, 'Guadalajara'), (20, 'Guipzcoa'), (21, 'Huelva'), (22, 'Huesca'), (23, 'Jaén'), (24, 'León'), (25, 'Lleida'), (26, 'La Rioja'), (27, 'Lugo'), (28, 'Madrid'), (29, 'Málaga'), (30, 'Murcia'), (31, 'Navarra'), (32, 'Ourense'), (33, 'Asturias'), (34, 'Palencia'), (35, 'Las Palmas'), (36, 'Pontevedra'), (37, 'Salamanca'), (38, 'S. Cruz de Tenerife'), (39, 'Cantabria'), (40, 'Segovia'), (41, 'Sevilla'), (42, 'Soria'), (43, 'Tarragona'), (44, 'Teruel'), (45, 'Toledo'), (46, 'Valencia'), (47, 'Valladolid'), (48, 'Vizcaya'), (49, 'Zamora'), (50, 'Zaragoza'), (51, 'Ceuta'), (52, 'Melilla'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `usuarios` -- CREATE TABLE IF NOT EXISTS `usuarios` ( `id` int(11) NOT NULL AUTO_INCREMENT, `usuario` varchar(15) DEFAULT NULL, `pass` varchar(32) DEFAULT NULL, `email` varchar(60) DEFAULT NULL, `nombre` varchar(45) DEFAULT NULL, `apellidos` varchar(100) DEFAULT NULL, `dni` varchar(9) DEFAULT NULL, `direccion` varchar(200) DEFAULT NULL, `cp` varchar(5) DEFAULT NULL, `borrado` tinyint(1) DEFAULT NULL, `id_provincia` int(11) NOT NULL, PRIMARY KEY (`id`,`id_provincia`), KEY `fk_usuarios_provincias_idx` (`id_provincia`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; -- -- Volcado de datos para la tabla `usuarios` -- INSERT INTO `usuarios` (`id`, `usuario`, `pass`, `email`, `nombre`, `apellidos`, `dni`, `direccion`, `cp`, `borrado`, `id_provincia`) VALUES (1, 'cristobal', '5946db8e9b20ccb3866982fe9d9524ce', 'cristobaldominguez95@gmail.com', 'Cristóbal', 'Domínguez', '49086582M', 'Avenida de Rociana, nº 54', '21830', 0, 21), (4, 'prueba', '7ad4109292636b7498a9f5042081becf', 'cristobaldominguez95@hotmail.com', 'nombre de prueba', 'apellidos de prueba', '49086582M', 'direccion de prueba', '66666', 0, 17); -- -- Restricciones para tablas volcadas -- -- -- Filtros para la tabla `linea_pedido` -- ALTER TABLE `linea_pedido` ADD CONSTRAINT `fk_linea_pedido_pedidos1` FOREIGN KEY (`id_pedido`) REFERENCES `pedidos` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, ADD CONSTRAINT `fk_linea_pedido_productos1` FOREIGN KEY (`id_producto`) REFERENCES `productos` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; -- -- Filtros para la tabla `pedidos` -- ALTER TABLE `pedidos` ADD CONSTRAINT `fk_pedidos_usuarios1` FOREIGN KEY (`id_usuario`) REFERENCES `usuarios` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; -- -- Filtros para la tabla `productos` -- ALTER TABLE `productos` ADD CONSTRAINT `fk_productos_categorias2` FOREIGN KEY (`id_categoria`) REFERENCES `categorias` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; -- -- Filtros para la tabla `usuarios` -- ALTER TABLE `usuarios` ADD CONSTRAINT `fk_usuarios_provincias` FOREIGN KEY (`id_provincia`) REFERENCES `provincias` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; /*!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
f80210020511bccd22e4c4856798663c2350f8bb
SQL
silence-do-good/stress-test-Postgres-and-MySQL
/dump/high/day08/select1914.sql
UTF-8
267
3.15625
3
[]
no_license
SELECT sen.name FROM SENSOR sen, SENSOR_TYPE st, COVERAGE_INFRASTRUCTURE ci WHERE sen.SENSOR_TYPE_ID=st.id AND st.name='Thermometer' AND sen.id=ci.SENSOR_ID AND ci.INFRASTRUCTURE_ID=ANY(array['3056','3013','3026','4069','2211','1413','6215','6210','3206','5019'])
true
d14334f6e0153635dded63655ebb970690b4d228
SQL
shukia/WebAPI-unsafe
/src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql
UTF-8
274
3.046875
3
[ "Apache-2.0" ]
permissive
SELECT c2.concept_id AS conceptId, c2.concept_name AS conceptName, ar1.count_value AS countValue FROM @results_database_schema.ACHILLES_results ar1 INNER JOIN @vocab_database_schema.concept c2 ON CAST(ar1.stratum_1 AS INT) = c2.concept_id WHERE ar1.analysis_id = 505
true
769ba086a5f5e9fdc00827cc989e2a6fe98daf89
SQL
weinan003/TPCH
/lsp/workloads/RETAILDW/scripts/gen_facts.sql
UTF-8
10,518
3.0625
3
[]
no_license
-- gen_facts.sql -- This script uses the order_item_base table and the pre-populated dimension tables to "denormalize" and generate the fact tables. -- 7 hours \timing on -- Load the "global" variables PATH_OF_DCA_DEMO_CONF_SQL --DROP INDEX IF EXISTS order_lineitems_cust_id; TRUNCATE TABLE retail_demo.Order_LineItems; INSERT INTO retail_demo.Order_LineItems ( Order_ID , Order_Item_ID , Product_ID , Product_Name , Customer_ID , Store_ID , Item_Shipment_Status_Code , Order_Datetime , Ship_Datetime , Item_Return_Datetime , Item_Refund_Datetime , Product_Category_ID , Product_Category_Name , Payment_Method_Code , Tax_Amount , Item_Quantity , Item_Price , Discount_Amount , Coupon_Code , Coupon_Amount , Ship_Address_Line1 , Ship_Address_Line2 , Ship_Address_Line3 , Ship_Address_City , Ship_Address_State , Ship_Address_Postal_Code , Ship_Address_Country , Ship_Phone_Number , Ship_Customer_Name , Ship_Customer_Email_Address , Ordering_Session_ID , Website_URL ) SELECT Order_ID , Order_Item_ID , ols.Product_ID , prod.Product_Name , ols.Customer_ID , Store_ID , CASE WHEN Item_Shipment_Status_Code < 3 THEN 'Received' WHEN Item_Shipment_Status_Code = 3 THEN 'Prep' WHEN Item_Shipment_Status_Code = 4 THEN 'Shipper_Notified' ELSE 'Shipped' END AS Item_Shipment_Status_Code , Order_TS AS Order_Datetime , ship_ts AS Ship_Datetime , item_return_ts AS Item_Return_Datetime , item_refund_ts AS Item_Refund_Datetime , prod.Category_ID , cat.Category_Name , CASE ols.Payment_Method_ID WHEN 1 THEN 'COD' WHEN 2 THEN 'Credit' WHEN 3 THEN 'CreditCard' WHEN 4 THEN 'GiftCertificate' WHEN 5 THEN 'FreeReplacement' END AS Payment_Method_Code , CASE WHEN Item_Quantity > 12 THEN Item_Quantity-11 ELSE 1 END * prod.Price * sst.Tax_Rate/100 AS Tax_Amount , CASE WHEN Item_Quantity > 12 THEN Item_Quantity-11 ELSE 1 END Item_Quantity , prod.Price AS Item_Price , CASE Discount_Amount_Code WHEN 1 THEN .05 WHEN 2 THEN 0 ELSE .05 + .015 * Discount_Amount_Code END AS Discount_Amount , CASE Coupon_Code WHEN 1 THEN 'BOGO-PDX' WHEN 2 THEN 'None' WHEN 3 THEN 'HOLIDAY' WHEN 4 THEN 'Coupon-'||TRANSLATE(bigrand,'0123456789','AKRNCPWLQVE') ELSE 'CUST-Ret-'||TRANSLATE(ols.customer_id,'0123456789','AKRNCPWLQVE') END AS Coupon_Code , CASE Coupon_Code WHEN 1 THEN .5 WHEN 2 THEN 0 WHEN 3 THEN .15 WHEN 4 THEN .1 * Item_Quantity ELSE .05 END AS Coupon_Amount , addr.house_number ||' '|| addr.street_name AS Ship_Address_Line1 , addr.appt_suite_no AS Ship_Address_Line2 , CASE WHEN SUBSTRING(bigrand for 2) >= 76 THEN 'ATTN: '||cust.first_name||' '||cust.last_name ELSE NULL END AS Ship_Address_Line3 , addr.city AS Ship_Address_City , addr.state_code AS Ship_Address_State , addr.zip_code AS Ship_Address_Postal_Code , addr.country AS Ship_Address_Country , addr.phone_number AS Ship_Phone_Number , cust.first_name||' '||cust.last_name AS Ship_Customer_Name , eaddr.Email_Address , ols.Ordering_Session_ID , 'http://myretailsite.emc.com/product_detail/'|| TRANSLATE(cat.category_name,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ','abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_')|| '/?tps='||TRANSLATE(bigrand::VARCHAR,'0123456789','ikvurmsqlps')|| '&sessionid='||ols.Ordering_Session_ID|| '&ref='||TRANSLATE(ols.customer_id::VARCHAR,'0123456789','zmeposjxya')|| '&sku='||ols.product_id AS Website_URL FROM order_item_base ols , retail_demo.products_dim prod , retail_demo.categories_dim cat , retail_demo.customers_dim cust , retail_demo.Customer_Addresses_Dim addr , retail_demo.email_addresses_dim eaddr , retail_demo.state_sales_taxes sst WHERE ols.Product_ID = prod.Product_ID AND prod.Category_ID = cat.Category_ID AND ols.customer_id = cust.customer_id AND cust.customer_id = addr.customer_id AND cust.customer_id = eaddr.customer_id AND addr.state_code = sst.state_code -- This should be the join but the data generation doesn't take slowly changing dimensions into account yet. So, for now, we'll just use the recent address --AND addr.valid_from_timestamp <= Order_Date + (Order_Datetime_Offset||' seconds')::INTERVAL --AND COALESCE(addr.valid_from_timestamp, current_timestamp) >= Order_Date + (Order_Datetime_Offset||' seconds')::INTERVAL AND addr.valid_to_timestamp IS NULL AND ols.Order_TS < :PRELOAD_END -- Reserve ~2% for the example loads ; VACUUM ANALYZE retail_demo.Order_LineItems; TRUNCATE TABLE retail_demo.Orders; set statement_mem='125MB'; INSERT INTO retail_demo.Orders ( Order_ID , Customer_ID , Store_ID , Order_Datetime , Ship_Completion_Datetime , Return_Datetime , Refund_Datetime , Payment_Method_Code , Total_Tax_Amount , Total_Paid_Amount , Total_Item_Quantity , Total_Discount_Amount , Coupon_Code , Coupon_Amount , Order_Canceled_Flag , Has_Returned_Items_Flag , Has_Refunded_Items_Flag , Fraud_Code , Fraud_Resolution_Code , Billing_Address_Line1 , Billing_Address_Line2 , Billing_Address_Line3 , Billing_Address_City , Billing_Address_State , Billing_Address_Postal_Code , Billing_Address_Country , Billing_Phone_Number , Customer_Name , Customer_Email_Address , Ordering_Session_ID , Website_URL ) SELECT Order_ID AS Order_ID , MAX(Customer_ID) AS Customer_ID , MAX(Store_ID) AS Store_ID , MIN(Order_Datetime) AS Order_Datetime , MAX(Ship_Datetime) AS Ship_Completion_Datetime , MIN(item_Return_Datetime) AS Return_Datetime , MIN(item_Refund_Datetime) AS Refund_Datetime , MAX(Payment_Method_Code) AS Payment_Method_Code , SUM(Tax_Amount) AS Total_Tax_Amount , SUM(Item_Quantity * Item_Price) AS Total_Paid_Amount , SUM(Item_Quantity) AS Total_Item_Quantity , SUM(Discount_Amount) AS Total_Discount_Amount , MAX(Coupon_Code) AS Coupon_Code , MAX(Coupon_Amount) AS Coupon_Amount , CASE WHEN SUM(CASE WHEN item_Return_Datetime IS NOT NULL OR item_Refund_Datetime IS NOT NULL THEN 1 ELSE 0 END) = COUNT(*) THEN 'Y' ELSE 'N' END AS Order_Canceled_Flag , CASE WHEN MAX(item_Return_Datetime) IS NOT NULL THEN 'Y' ELSE 'N' END AS Has_Returned_Items_Flag , CASE WHEN MAX(item_Refund_Datetime) IS NOT NULL THEN 'Y' ELSE 'N' END AS Has_Refunded_Items_Flag , CASE SUBSTRING(order_id FOR 2 FROM 2) WHEN 96 THEN 'Stolen Card' WHEN 97 THEN 'Compromised Account' WHEN 98 THEN 'Gift Certificate Abuse' WHEN 99 THEN 'Researching' ELSE NULL END AS Fraud_Code , CASE WHEN SUBSTRING(order_id FOR 2 FROM 2) > 95 THEN CASE SUBSTRING(order_id FOR 1 FROM 6) WHEN 5 THEN 'Resolved - Account Canceled' WHEN 6 THEN 'Resolved - No Fraud' WHEN 7 THEN 'Resolved - Order Canceled' WHEN 8 THEN 'Resolved - Authorities Notified' ELSE 'In Progress' END ELSE NULL END AS Fraud_Resolution_Code , MAX(ship_Address_Line1) AS Billing_Address_Line1 -- Need to change this to a window function for first ship address as the billing address , MAX(ship_Address_Line2) AS Billing_Address_Line2 , MAX(ship_Address_Line3) AS Billing_Address_Line3 , MAX(ship_Address_City) AS Billing_Address_City , MAX(ship_Address_State) AS Billing_Address_State , MAX(ship_Address_Postal_Code) AS Billing_Address_Postal_Code , MAX(ship_Address_Country) AS Billing_Address_Country , MAX(ship_Phone_Number) AS Billing_Phone_Number , MAX(ship_Customer_Name) AS Customer_Name , MAX(ship_Customer_Email_Address) AS Customer_Email_Address , MAX(Ordering_Session_ID) AS Ordering_Session_ID , MAX(Website_URL) AS Website_URL FROM retail_demo.order_lineitems GROUP BY order_id ; set statement_mem='1999MB'; VACUUM ANALYZE retail_demo.Orders; TRUNCATE TABLE retail_demo.Shipment_LineItems; INSERT INTO retail_demo.Shipment_LineItems ( Shipment_ID , Order_ID , Order_Item_ID , Product_ID , Product_Name , Customer_ID , Order_Datetime , Ship_Datetime , Item_Ship_Quantity , Item_Price , Customer_Paid_Ship_Cost , Our_Paid_Ship_Cost , Shipper_Code , Shipment_Type_Code , Ship_Address_Line1 , Ship_Address_Line2 , Ship_Address_Line3 , Ship_Address_City , Ship_Address_State , Ship_Address_Postal_Code , Ship_Address_Country , Ship_Phone_Number , Ship_Customer_Name , Ship_Customer_Email_Address ) SELECT TO_CHAR(round(order_item_id/100000), 'FM00000') || '-' || TO_CHAR(order_item_id%100000, 'FM00000') || '-' || TO_CHAR(product_id%100, 'FM00') || '-' || TO_CHAR(round(product_id*retail_demo.box_muller(3::bigint,37::bigint)/100)::int % 1000000 , 'FM000000') AS Shipment_ID , Order_ID , Order_Item_ID , Product_ID , Product_Name , Customer_ID , Order_Datetime , Ship_Datetime , Item_Quantity AS Item_Ship_Quantity , Item_Price , .8 * (5 + (.03*Item_Price)) AS Customer_Paid_Ship_Cost -- Ship cost is $5 + 3% of the item_cost. Customer pays 80%. , .2 * (5 + (.03*Item_Price)) AS Our_Paid_Ship_Cost -- Eventually change customer/us paid ratio to "random" , CASE retail_demo.crand(1::bigint,4::bigint) WHEN 1 THEN 'UPS' WHEN 2 THEN 'USPS' WHEN 3 THEN 'FedEx' WHEN 4 THEN 'DHL' END AS Shipper_Code , CASE retail_demo.crand(1::bigint,4::bigint) WHEN 1 THEN 'Next Day Air' WHEN 2 THEN '2 Day Ground' WHEN 3 THEN '3 to 5 Day Ground' WHEN 4 THEN 'International' END AS Shipment_Type_Code , Ship_Address_Line1 , Ship_Address_Line2 , Ship_Address_Line3 , Ship_Address_City , Ship_Address_State , Ship_Address_Postal_Code , Ship_Address_Country , Ship_Phone_Number , Ship_Customer_Name , Ship_Customer_Email_Address FROM retail_demo.Order_LineItems WHERE ship_datetime IS NOT NULL ; VACUUM ANALYZE retail_demo.Shipment_LineItems; -- The following is only needed if the demo will include web_user (BI style) queries. --CREATE INDEX order_lineitems_cust_id ON retail_demo.order_lineitems (customer_id); \timing off
true
90ee5534426bb2e60c47e30928484407bc887ef7
SQL
fernando-romulo-silva/myStudies
/java/spring/pro-spring-5/pro-spring-5-chapter09-transaction-management/pro-spring-5-chapter09-part01-base-dao/src/main/resources/db/ddl.sql
UTF-8
516
2.75
3
[ "Apache-2.0" ]
permissive
CREATE USER 'prospring5_A'@'localhost' IDENTIFIED BY 'prospring5_A'; CREATE SCHEMA musicdb_a; GRANT ALL PRIVILEGES ON musicdb_a . * TO 'prospring5_A'@'localhost'; FLUSH PRIVILEGES; CREATE USER 'prospring5_B'@'localhost' IDENTIFIED BY 'prospring5_B'; CREATE SCHEMA musicdb_b; GRANT ALL PRIVILEGES ON musicdb_b . * TO 'prospring5_B'@'localhost'; FLUSH PRIVILEGES; /*in case of java.sql.SQLException: The server timezone value 'UTC' is unrecognized or represents more than one timezone. */ SET GLOBAL time_zone = '+3:00';
true
72e3af4f808219c1f3a16ae4fdbceca464387a22
SQL
J-Shine/miniDBMS
/project1/35.sql
UTF-8
113
3.3125
3
[]
no_license
SELECT name FROM Pokemon, Evolution WHERE Evolution.before_id = Pokemon.id AND before_id > after_id ORDER BY name
true
9151e6a32fc0278e259c09dd6e99be0d624ba33f
SQL
radtek/abs3
/sql/mmfo/bars/Function/f_2401_grp.sql
WINDOWS-1251
1,447
2.828125
3
[]
no_license
PROMPT ===================================================================================== PROMPT *** Run *** ========== Scripts /Sql/BARS/function/f_2401_grp.sql =========*** Run *** PROMPT ===================================================================================== CREATE OR REPLACE FUNCTION BARS.F_2401_GRP (p_nbs accounts.nbs%type, p_ob22 accounts.ob22%type) RETURN VARCHAR2 is /* 1.0 17-02-2017 ------------------------------------- */ l_grp integer; begin begin SELECT grp into l_grp FROM tmp_nbs_2401 WHERE nbs = p_nbs and ob22 = p_ob22; EXCEPTION WHEN NO_DATA_FOUND THEN l_grp := NULL; END; return(l_grp); end; / show err; PROMPT *** Create grants F_2401_GRP *** grant EXECUTE on F_2401_GRP to BARS_ACCESS_DEFROLE; grant EXECUTE on F_2401_GRP to RCC_DEAL; grant EXECUTE on F_2401_GRP to START1; PROMPT ===================================================================================== PROMPT *** End *** ========== Scripts /Sql/BARS/function/f_2401_grp.sql =========*** End *** PROMPT =====================================================================================
true
4f7106de3fd28ef4b3dbfee61b1f9fdeeade219e
SQL
KD-Secret-Family-Recipes-Cookbook/backend
/src/main/resources/data.sql
UTF-8
2,845
3.109375
3
[]
no_license
-- noinspection SqlDialectInspectionForFile -- noinspection SqlNoDataSourceInspectionForFile DELETE FROM users; DELETE FROM recipes; DELETE FROM ingredients; INSERT INTO users(userid, username, password, useremail) VALUES (1, 'user1', 'user1', 'user1@user.com'), (2, 'user2', 'user2', 'user2@user.com'), (3, 'user3', 'user3', 'user3@user.com'), (4, 'user4', 'user4', 'user4@user.com'), (5, 'user5', 'user5', 'user5@user.com'); alter sequence hibernate_sequence restart with 6; INSERT INTO recipes(recipeid, recipename, source, category, instructions, userid, imageurl) VALUES (2, 'PB & J', 'Society', 'Sandwich', '1. Spread Jelly on slice of bread 2. Spread PB on other slice of bread 3. Put slices together', 1, 'https://www.fakeurl.com'), (3, 'test2', 'test2', 'test2', 'test instructions', 2, 'https://www.fakeurl.com'), (4, 'test22', 'test2', 'test2', 'test instructions', 2, 'https://www.fakeurl.com'), (5, 'test3', 'test3', 'test3', 'test instructions', 3, 'https://www.fakeurl.com'), (6, 'test33', 'test3', 'test3', 'test instructions', 3, 'https://www.fakeurl.com'), (7, 'test4', 'test4', 'test4', 'test instructions', 4, 'https://www.fakeurl.com'), (8, 'test44', 'test4', 'test4', 'test instructions', 4, 'https://www.fakeurl.com'), (9, 'test5', 'test5', 'test5', 'test instructions', 5, 'https://www.fakeurl.com'), (10, 'test55', 'test5', 'test5', 'test instructions', 5, 'https://www.fakeurl.com'); alter sequence hibernate_sequence restart with 11; INSERT INTO ingredients(ingredientid, ingredientname, quantity, measurement, recipeid) VALUES (4, 'Peanut Butter', 3, 'tbsp', 2), (5, 'Raspberry Jelly', 2, 'tbsp', 2), (6, 'Bread', 2, 'slices', 2), (7, 'test1', 56, 'testmeasurement', 3), (8, 'test1', 56, 'testmeasurement', 3), (9, 'test1', 56, 'testmeasurement', 4), (10, 'test1', 56, 'testmeasurement', 4), (11, 'test1', 56, 'testmeasurement', 5), (12, 'test1', 56, 'testmeasurement', 5), (13, 'test1', 56, 'testmeasurement', 6), (14, 'test1', 56, 'testmeasurement', 6), (15, 'test1', 56, 'testmeasurement', 7), (16, 'test1', 56, 'testmeasurement', 7), (17, 'test1', 56, 'testmeasurement', 8), (18, 'test1', 56, 'testmeasurement', 8), (19, 'test1', 56, 'testmeasurement', 9), (20, 'test1', 56, 'testmeasurement', 9), (21, 'test1', 56, 'testmeasurement', 10), (22, 'test1', 56, 'testmeasurement', 10); alter sequence hibernate_sequence restart with 23;
true
71126985edff6c8c85f061ae38c4c4e41134b680
SQL
dotbehrens/aloud-server
/schema.sql
UTF-8
2,242
3.765625
4
[]
no_license
-- sudo -u postgres psql -f schema.sql -- delete in production ALTER USER postgres with encrypted password 'postgres'; DROP DATABASE IF EXISTS aloud; CREATE DATABASE aloud; \c aloud; CREATE TABLE users ( id INT GENERATED ALWAYS AS IDENTITY, username VARCHAR(50) NOT NULL, password CHAR(50), email VARCHAR(50) NOT NULL, name_display VARCHAR(64), bio TEXT, url_image TEXT, PRIMARY KEY (id) ); CREATE TYPE setting AS ENUM('private', 'public'); CREATE TABLE recordings ( id INT GENERATED ALWAYS AS IDENTITY, id_user INT references users(id), title VARCHAR(255) NOT NULL, description TEXT, url_recording TEXT NOT NULL, published setting, speech_to_text TEXT, created_at TIMESTAMP NOT NULL, PRIMARY KEY (id) ); CREATE TABLE collections ( id INT GENERATED ALWAYS AS IDENTITY, id_user_creator INT references users(id), title VARCHAR(255) NOT NULL, description TEXT, count_recordings INT NOT NULL, url_image TEXT, created_at TIMESTAMP NOT NULL, PRIMARY KEY (id) ); CREATE TABLE collections_recordings ( id_collection INT references collections(id), id_recording INT references recordings(id) ); CREATE TABLE users_saved_collections ( id INT GENERATED ALWAYS AS IDENTITY, id_user INT references users(id), id_collection INT references collections(id), created_at TIMESTAMP NOT NULL ); CREATE TABLE users_saved_recordings ( id INT GENERATED ALWAYS AS IDENTITY, id_user INT references users(id), id_recording INT references recordings(id), created_at TIMESTAMP NOT NULL ); /* working users insertion insert into users(bio, email, username, password, url_image, name_display) values('punk-turned-pop-turned-experimental spacescapes', 'bjork@space.io', 'bjork575', 'babyGiraffe', 'https://bit.ly/2R9TPv9', 'bjork'); working users query select * from users where username = 'bjork575'; insert into recordings(id_user, title, description, url_recording, created_at, published, speech_to_text) values('1', 'baby martian', 'newborn baby martian song', 'marsbb.cloudinary', now(), 'public', 'i am martian baby roar loud space fun bjork is great'); */ -- timestamp functions -- now() -- ex format. 2020-01-21 11:51:36.310508 -- current_date; -- current_time; -- current_timestamp;
true
a98ab8cf3323cef833cc93e259302ba1eb4f29b3
SQL
nerzhul250/DBproject
/Paquetes/Nivel3/asignacionTriggers.sql
UTF-8
2,457
2.875
3
[]
no_license
CREATE OR REPLACE TRIGGER asignacionAutomaticaSolModificar AFTER INSERT ON solmodificacionProducto FOR EACH ROW DECLARE cedula funcionario.cedula%TYPE; BEGIN cedula:=pkAsignacionNivel2.fRetornarFuncionarioDisponible; pkAsignacionNivel2.realizarAsignacion (SYSDATE,TRIM(cedula), :NEW.solicitud_codigo,NULL, NULL, NULL); EXCEPTION WHEN OTHERS THEN dbms_output.put_line( 'no se hizo la asignacion automatica' ); END; / CREATE OR REPLACE TRIGGER asignacionAutomaticaSolReporte AFTER INSERT ON solreportedanios FOR EACH ROW DECLARE cedula funcionario.cedula%TYPE; BEGIN cedula:=pkAsignacionNivel2.fRetornarFuncionarioDisponible; pkAsignacionNivel2.realizarAsignacion (SYSDATE,TRIM(cedula),:NEW.solicitud_codigo ,NULL, NULL, NULL); pkAsignacionNivel2.cambiarEstadoSolicitud (:NEW.solicitud_codigo, 'Asignado'); EXCEPTION WHEN OTHERS THEN dbms_output.put_line( 'no se hizo la asignacion automatica' ); END ; / CREATE OR REPLACE TRIGGER asignacionAutomaticaSolCancelacion AFTER INSERT ON solcancelacionproducto FOR EACH ROW DECLARE cedula funcionario.cedula%TYPE; BEGIN cedula:=pkAsignacionNivel2.fRetornarFuncionarioDisponible; pkAsignacionNivel2.realizarAsignacion (SYSDATE,TRIM(cedula), :NEW.solicitud_codigo,NULL, NULL, NULL); pkAsignacionNivel2.cambiarEstadoSolicitud (:NEW.solicitud_codigo, 'Asignado'); EXCEPTION WHEN OTHERS THEN dbms_output.put_line( 'no se hizo la asignacion automatica' ); END ; / CREATE OR REPLACE TRIGGER asignacionAutomaticaSolCreacion AFTER INSERT ON solcreacion FOR EACH ROW DECLARE cedula funcionario.cedula%TYPE; BEGIN cedula:=pkAsignacionNivel2.fRetornarFuncionarioDisponible; pkAsignacionNivel2.realizarAsignacion (SYSDATE,TRIM(cedula),:NEW.solicitud_codigo,NULL, NULL, NULL); pkAsignacionNivel2.cambiarEstadoSolicitud (:NEW.solicitud_codigo, 'Asignado'); EXCEPTION WHEN OTHERS THEN dbms_output.put_line( 'no se hizo la asignacion automatica' ); END ; / CREATE OR REPLACE TRIGGER asignacionAutomaticaSolReclamo AFTER INSERT ON solreclamo FOR EACH ROW DECLARE cedula funcionario.cedula%TYPE; BEGIN cedula:=pkAsignacionNivel2.fRetornarFuncionarioDisponible; pkAsignacionNivel2.realizarAsignacion (SYSDATE,TRIM(cedula), :NEW.solicitud_codigo,NULL, NULL, NULL); pkAsignacionNivel2.cambiarEstadoSolicitud (:NEW.solicitud_codigo, 'Asignado'); EXCEPTION WHEN OTHERS THEN dbms_output.put_line( 'no se hizo la asignacion automatica' ); END ; /
true
7299295a13d86f096ff5f2614b9edae05169fa8c
SQL
maki567/mailsystem1
/mailsystem1/src/main/resources/sql/create_table.sql
UTF-8
616
3
3
[]
no_license
USE mailsystem1; CREATE TABLE mst_user ( id int(11) PRIMARY KEY AUTO_INCREMENT, user_name VARCHAR(32) NOT NULL UNIQUE, password VARCHAR(16) NOT NULL, family_name VARCHAR(255) NOT NULL, first_name VARCHAR(255) NOT NULL, family_name_kana VARCHAR(255) NOT NULL, first_name_kana VARCHAR(255) NOT NULL, gender TINYINT DEFAULT 0, created_at TIMESTAMP NOT NULL DEFAULT current_timestamp(), updated_at TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() ); create table mail_history ( subject VARCHAR(255), created_at TIMESTAMP NOT NULL DEFAULT current_timestamp() );
true
41bca69cb0da63e8755801497ee0dca131196b5a
SQL
rhariyani/timed-calls
/docs/sql/ddl.sql
UTF-8
752
3.640625
4
[ "Apache-2.0" ]
permissive
CREATE TABLE IF NOT EXISTS `History` ( `history_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `duration` INTEGER NOT NULL, `date` INTEGER, `timer_id` INTEGER NOT NULL, FOREIGN KEY (`timer_id`) REFERENCES `Timer` (`timer_id`) ON UPDATE NO ACTION ON DELETE SET NULL ); CREATE INDEX IF NOT EXISTS `index_History_timer_id` ON `History` (`date`); CREATE TABLE IF NOT EXISTS `Timer` ( `timer_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `limit` INTEGER NOT NULL, `contact_uri` TEXT NOT NULL ); CREATE UNIQUE INDEX IF NOT EXISTS `index_Timer_contact_uri` ON `Timer` (`contact_uri`);
true
8ae742caf3b6ac4cec65e5d649a3795ba4afadd6
SQL
LahiruNE/VmiT
/database/vmit.sql
UTF-8
12,041
3.09375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.5.4.1deb2ubuntu2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Sep 21, 2017 at 09:49 PM -- Server version: 5.7.19-0ubuntu0.16.04.1 -- PHP Version: 7.0.22-0ubuntu0.16.04.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: `vmit` -- -- -------------------------------------------------------- -- -- Table structure for table `employee` -- CREATE TABLE `employee` ( `Employee_ID` int(11) NOT NULL, `Employee_Name` varchar(255) NOT NULL, `Phone_Number` int(13) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `employee` -- INSERT INTO `employee` (`Employee_ID`, `Employee_Name`, `Phone_Number`) VALUES (1, 'Jara Epz', 716482041), (2, 'Lahiru Epa', 776453212), (3, 'Epzii Jara', 716483021); -- -------------------------------------------------------- -- -- Table structure for table `project` -- CREATE TABLE `project` ( `Project_ID` int(11) NOT NULL, `Project_Name` varchar(32) NOT NULL, `Start_Date` date NOT NULL, `End_Date` date DEFAULT NULL, `Status` tinyint(2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `project` -- INSERT INTO `project` (`Project_ID`, `Project_Name`, `Start_Date`, `End_Date`, `Status`) VALUES (1, 'test', '2017-09-19', NULL, 1), (2, 'test2', '2017-09-13', '2017-09-13', 22), (3, 'Test Null', '2017-09-04', NULL, 0); -- -------------------------------------------------------- -- -- Table structure for table `reason` -- CREATE TABLE `reason` ( `Reason` int(11) NOT NULL, `Reason_Description` varchar(1024) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `reason` -- INSERT INTO `reason` (`Reason`, `Reason_Description`) VALUES (1, 'Extra work - Catchup Internal delays'), (2, 'Client Request'), (3, 'Virtusa meeting'), (4, 'other'); -- -------------------------------------------------------- -- -- Table structure for table `request` -- CREATE TABLE `request` ( `Empid` int(50) NOT NULL, `Time` varchar(50) NOT NULL, `Date` varchar(50) NOT NULL, `Route` int(50) NOT NULL, `ReqTime` int(50) NOT NULL, `ReqCode` text NOT NULL, `Destination` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `request` -- INSERT INTO `request` (`Empid`, `Time`, `Date`, `Route`, `ReqTime`, `ReqCode`, `Destination`) VALUES (0, 'time', 'date', 1, 6, 'Extra work - Catchup Internal delays ', ''), (0, 'time', 'date', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, 'time', 'date', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, 'time', 'date', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, 'time1', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, '4', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, '', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, '', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (12, 'time1', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (233, 'time1', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (23, 'time1', 'date1', 4, 6, 'Extra work - Catchup Internal delays ', ''), (233, 'time1', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', 'aaqa'), (1, 'time1', 'date1', 7, 8, 'Virtusa meeting', 'asf'), (0, 'time', 'date', 1, 6, 'Extra work - Catchup Internal delays ', ''), (0, 'time', 'date', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, 'time', 'date', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, 'time', 'date', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, 'time1', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, '4', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, '', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (1, '', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (12, 'time1', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (233, 'time1', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', ''), (23, 'time1', 'date1', 4, 6, 'Extra work - Catchup Internal delays ', ''), (233, 'time1', 'date1', 1, 6, 'Extra work - Catchup Internal delays ', 'aaqa'), (1, 'time1', 'date1', 7, 8, 'Virtusa meeting', 'asf'); -- -------------------------------------------------------- -- -- Table structure for table `reservation` -- CREATE TABLE `reservation` ( `Reservation_ID` int(11) NOT NULL, `User_ID` int(11) NOT NULL, `Route_ID` int(11) NOT NULL, `Time_ID` int(11) NOT NULL, `Reason_ID` int(11) NOT NULL, `Nearest_City` varchar(32) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `route` -- CREATE TABLE `route` ( `Route_ID` int(11) NOT NULL, `Route_Number` tinyint(3) NOT NULL, `Route_Description` varchar(1024) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `route` -- INSERT INTO `route` (`Route_ID`, `Route_Number`, `Route_Description`) VALUES (1, 1, 'Kolpetty/Punchi Borella/ Rajagiriya'), (2, 2, 'Kalutara/Panadura/ Batuwandara/ Palanwatte'), (3, 3, 'Kandana/Kelaniya/Dalugama/Weliwita'), (4, 4, 'Wellawatte/Battaramulla'), (5, 5, 'Dehiwala/Mount/Pitakotte'), (6, 6, 'Awissawella/ Kaduwela'), (7, 7, 'Horana/Matthegoda/Athurugiriya'), (8, 8, 'Kadawatha/Yakkala'), (9, 9, 'Moratuwa/ Maharagama/Hokandara'), (10, 10, 'Batakaththara/Wijerama/Pita Kotte/Malabe'), (11, 11, 'Dematagoda/Kotahena'); -- -------------------------------------------------------- -- -- Table structure for table `signup` -- CREATE TABLE `signup` ( `Empid` int(50) NOT NULL, `Name` text NOT NULL, `Contact` int(50) NOT NULL, `Project` text NOT NULL, `Username` text NOT NULL, `Password` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `signup` -- INSERT INTO `signup` (`Empid`, `Name`, `Contact`, `Project`, `Username`, `Password`) VALUES (31, 'wefg', 324, 'wef', '{username}', 'wef'), (2345, 'sdg', 2535, 'segt', 'sgg', 'sg'), (31, 'wefg', 324, 'wef', 'wef', 'wef'), (2345, 'awf', 35, 'efgf', 'agga', 'ag'), (1, 'a', 2, 'a', 'aa', '11'), (12, 'ag', 123, 'ad', 'asd', '123'), (0, '', 0, '', 'da', 'ad'), (23, 'asf', 325, 'fraf', 'aaa', 'sss'), (7676, 'wf', 23423, 'asgr', 'qqqqq', 'aaaaa'), (233, 'srg', 525, 'agr', 'asdf', '1234'), (23, 'thsh', 346, 'rdh', 'asdfg', '12345'), (31, 'wefg', 324, 'wef', '{username}', 'wef'), (2345, 'sdg', 2535, 'segt', 'sgg', 'sg'), (31, 'wefg', 324, 'wef', 'wef', 'wef'), (2345, 'awf', 35, 'efgf', 'agga', 'ag'), (1, 'a', 2, 'a', 'aa', '11'), (12, 'ag', 123, 'ad', 'asd', '123'), (0, '', 0, '', 'da', 'ad'), (23, 'asf', 325, 'fraf', 'aaa', 'sss'), (7676, 'wf', 23423, 'asgr', 'qqqqq', 'aaaaa'), (233, 'srg', 525, 'agr', 'asdf', '1234'), (23, 'thsh', 346, 'rdh', 'asdfg', '12345'); -- -------------------------------------------------------- -- -- Table structure for table `time` -- CREATE TABLE `time` ( `Time_ID` int(11) NOT NULL, `Time` time NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `time` -- INSERT INTO `time` (`Time_ID`, `Time`) VALUES (3, '18:00:00'), (4, '20:00:00'), (5, '21:30:00'), (6, '22:30:00'), (7, '23:30:00'), (8, '00:30:00'), (9, '01:30:00'); -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `User_ID` int(11) NOT NULL, `Employee_ID` int(11) NOT NULL, `Username` varchar(32) NOT NULL, `Password` varchar(32) NOT NULL, `User_Role_ID` int(11) NOT NULL, `Project_ID` int(11) DEFAULT NULL, `Is_Approved` tinyint(2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user` -- INSERT INTO `user` (`User_ID`, `Employee_ID`, `Username`, `Password`, `User_Role_ID`, `Project_ID`, `Is_Approved`) VALUES (2, 1, 'hr', 'adab7b701f23bb82014c8506d3dc784e', 2, NULL, 1), (3, 1, 'staff1', '4d7d719ac0cf3d78ea8a94701913fe47', 3, 1, 1), (4, 1, 'staff2', '8bc01711b8163ec3f2aa0688d12cdf3b', 3, 2, 1), (5, 1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 1, NULL, 1), (21, 3, 'eer', 'f38aeb65a88f50a2373643a82158c6dc', 3, 1, 0); -- -------------------------------------------------------- -- -- Table structure for table `user_role` -- CREATE TABLE `user_role` ( `User_Role_ID` int(11) NOT NULL, `User_Role_Name` varchar(32) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user_role` -- INSERT INTO `user_role` (`User_Role_ID`, `User_Role_Name`) VALUES (1, 'admin'), (2, 'admin-HR'), (3, 'staff'); -- -- Indexes for dumped tables -- -- -- Indexes for table `employee` -- ALTER TABLE `employee` ADD PRIMARY KEY (`Employee_ID`); -- -- Indexes for table `project` -- ALTER TABLE `project` ADD PRIMARY KEY (`Project_ID`); -- -- Indexes for table `reason` -- ALTER TABLE `reason` ADD PRIMARY KEY (`Reason`); -- -- Indexes for table `reservation` -- ALTER TABLE `reservation` ADD PRIMARY KEY (`Reservation_ID`), ADD KEY `Route_ID` (`Route_ID`), ADD KEY `Time_ID` (`Time_ID`), ADD KEY `Reason_ID` (`Reason_ID`), ADD KEY `User_ID` (`User_ID`); -- -- Indexes for table `route` -- ALTER TABLE `route` ADD PRIMARY KEY (`Route_ID`); -- -- Indexes for table `time` -- ALTER TABLE `time` ADD PRIMARY KEY (`Time_ID`); -- -- Indexes for table `user` -- ALTER TABLE `user` ADD PRIMARY KEY (`User_ID`), ADD KEY `Employee_ID` (`Employee_ID`), ADD KEY `User_Role_ID` (`User_Role_ID`) USING BTREE, ADD KEY `Project_ID` (`Project_ID`) USING BTREE; -- -- Indexes for table `user_role` -- ALTER TABLE `user_role` ADD PRIMARY KEY (`User_Role_ID`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `employee` -- ALTER TABLE `employee` MODIFY `Employee_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `project` -- ALTER TABLE `project` MODIFY `Project_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `reason` -- ALTER TABLE `reason` MODIFY `Reason` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `reservation` -- ALTER TABLE `reservation` MODIFY `Reservation_ID` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `route` -- ALTER TABLE `route` MODIFY `Route_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12; -- -- AUTO_INCREMENT for table `time` -- ALTER TABLE `time` MODIFY `Time_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; -- -- AUTO_INCREMENT for table `user` -- ALTER TABLE `user` MODIFY `User_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22; -- -- AUTO_INCREMENT for table `user_role` -- ALTER TABLE `user_role` MODIFY `User_Role_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- Constraints for dumped tables -- -- -- Constraints for table `reservation` -- ALTER TABLE `reservation` ADD CONSTRAINT `reservation_ibfk_1` FOREIGN KEY (`Route_ID`) REFERENCES `route` (`Route_ID`) ON UPDATE CASCADE, ADD CONSTRAINT `reservation_ibfk_2` FOREIGN KEY (`Time_ID`) REFERENCES `time` (`Time_ID`) ON UPDATE CASCADE, ADD CONSTRAINT `reservation_ibfk_3` FOREIGN KEY (`Reason_ID`) REFERENCES `reason` (`Reason`) ON UPDATE CASCADE, ADD CONSTRAINT `reservation_ibfk_4` FOREIGN KEY (`User_ID`) REFERENCES `user` (`User_ID`) ON UPDATE CASCADE; -- -- Constraints for table `user` -- ALTER TABLE `user` ADD CONSTRAINT `user_ibfk_1` FOREIGN KEY (`Employee_ID`) REFERENCES `employee` (`Employee_ID`) ON UPDATE CASCADE, ADD CONSTRAINT `user_ibfk_2` FOREIGN KEY (`User_Role_ID`) REFERENCES `user_role` (`User_Role_ID`) ON UPDATE CASCADE, ADD CONSTRAINT `user_ibfk_3` FOREIGN KEY (`Project_ID`) REFERENCES `project` (`Project_ID`) ON UPDATE CASCADE; /*!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
3da00494d31ec82c8db9571d62cd4dc764332034
SQL
dkman123/BigBrotherBot-For-UrT43
/b3/plugins/xlrstats/sql/mysql/playerbody.sql
UTF-8
612
2.75
3
[]
no_license
CREATE TABLE IF NOT EXISTS `%s` ( `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT, `bodypart_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', `player_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0', `kills` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0', `deaths` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0', `teamkills` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0', `teamdeaths` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0', `suicides` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `bodypart_id` (`bodypart_id`), KEY `player_id` (`player_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
true
915ee79c30a9355f213b378ca002fed8cb1634ca
SQL
vivek-gohil/Shared
/Assignment-1_Solution-1_Oracle10G.sql
WINDOWS-1252
26,005
3.453125
3
[]
no_license
----------------------------- --1) Create the following tables: ------------------------------- create table Client_master ( client_no varchar2 (6) constraint prmKeyCNO primary key, name varchar2 (20) not null, address1 varchar2 (30), address2 varchar2 (30), city varchar2 (15), state varchar2 (15), pincode number (6), bal_due number (10,2), constraint checkCNO check (client_no like 'C%') ); ========================================== create table product_master( product_no varchar2 (6) constraint prmKeyPNO primary key, constraint checkPNO check (product_no like 'P%'), description varchar2 (50) not null, profit_percent number (3,2) not null, unit_measure varchar2 (10) not null, qty_on_hand number (8)not null, record_lvl number (8) not null, sell_price number (8,2) not null constraint checkSELLPRICE check (sell_price>0), cost_price number (8,2) not null constraint checkCOSTPRICE check (cost_price>0) ); =============================================== create table salesman_master( salesman_no varchar2(6) constraint prmKeySNO primary key,constraint checkSNO check (salesman_no like 'S%'), salesman_name varchar2(20) not null, address1 varchar2(30) not null, address2 varchar2(30), city varchar2(20), pincode varchar2(6), state varchar2 (20), sal_amt number (8,2) not null, tgt_to_get number (6,2) not null, ytd_sales number (6,2) not null, remarks varchar2 (60) ); =============================================== create table sales_order( s_order_no varchar2(6) constraint prmKeySONO primary key, constraint checkSONO check (s_order_no like 'O%'), s_order_date date, client_no varchar2 (6) constraint fornKeyCNO references Client_master(client_no), dely_addr varchar2 (25), salesman_no varchar2 (6) constraint fornKeySNO references Salesman_master (salesman_no), dely_type char (1) default 'F', billed_yn char (1) default 'N', dely_date date, order_status varchar2 (10) constraint checkOSTATUS check (order_status in('in process','fullfilled','backOrder','canceled')), constraint checkDELYTYPE check (dely_type in('P','F')), constraint checkBILLYN check (billed_yn in('Y','N')), constraint checkDELYDATE check (dely_date >s_order_date) ); ==================================================== create table sales_order_details( s_order_no varchar2(6) constraint fornKeySONODetails references Sales_order(s_order_no), product_no varchar2(6) constraint fornKeyPNODetails references product_master(product_no), qty_ordered number (8), qty_disp number (8), product_rate number (10,2), constraint prmKeySONO_PNO primary key(s_order_no,product_no) ); ========================================= create table Challan_Header( challan_no varchar2 (6) constraint prmKey primary key, s_order_no varchar2 (6) constraint fornKey references sales_order(s_order_no), challan_date date not null, billed_yn char (1) default 'N', constraint checkCHALLAN_NO check (challan_no like 'CH%'), constraint checkBILLED_YN check (billed_yn in ('Y','N')) ); ==================================================== create table challan_details( challan_no varchar (6) constraint fornKeyCHALLANNO references Challan_header(challan_no), product_no varchar (6) constraint fornKeyPRODUCRNO references product_master(product_no), qty_disp number (4,2) not null, constraint prmKeyCHALLANNO_PRODUCTNO primary key(challan_no,product_no) ); ===================================================== ------------------------------------------------- --2 Insert the following data into their respective tables using the SQL insert statement: ---------------------------------------------- insert into client_master(client_no, name, city, pincode,state,bal_due) values('C00001','Ivan Bayross','Bombay',400054,'Maharashtra',15000); insert into client_master(client_no, name, city, pincode,state,bal_due) values('C00002','Vandana Saitwal','Madras',780001,'Tamil Nadu',0); insert into client_master(client_no, name, city, pincode,state,bal_due) values('C00003','Pramada Jaguste','Bombay',400057,'Maharashtra',5000); insert into client_master(client_no, name, city, pincode,state,bal_due) values('C00004','Basu Navindgi','Bombay',400056,'Maharashtra',0); insert into client_master(client_no, name, city, pincode,state,bal_due) values('C00005','Ravi Sreedharan','Delhi',100001,'Delhi',2000); insert into client_master(client_no, name, city, pincode,state,bal_due) values('C00006','Rukmini','Bombay',400050,'Maharashtra',0); ============================== insert into product_master values('P00001','1.44 Floppies',5,'Piece',100,20,525,500); insert into product_master values('P03453','Monitors',6,'Piece',10,3,12000,11280); insert into product_master values('P06734','Mouse',5,'Piece',20,50,1050,1000); insert into product_master values('P07865','1.22 Floppies',5,'Piece',100,20,525,500); insert into product_master values('P07868','Keyboards',2,'Piece',10,3,3150,3050); insert into product_master values('P07885','CD Drive',2.5,'Piece',10,3,5250,5100); insert into product_master values('P07965','540 HDD',4,'Piece',10,3,8400,8000); insert into product_master values('P07975','1.44 Drive',5,'Piece',10,3,1050,1000); insert into product_master values('P08865','1.22 Drive',5,'Piece',2,3,1050,1000); ================================== insert into salesman_master values('S00001','Kiran','A/14','Worli','Bombay',400002,'MAH',3000,100,50,'Good'); insert into salesman_master values('S00002','Manish','65','Nariman','Bombay',400001,'MAH',3000,200,100,'Good'); insert into salesman_master values('S00003','Ravi','P-7','Bandra','Bombay',400032,'MAH',3000,200,100,'Good'); insert into salesman_master values('S00004','Ashish','A/5','Juhu','Bombay',400044,'MAH',3500,200,150,'Good'); ====================================== insert into sales_order(s_order_no,s_order_date,client_no,dely_type,billed_Yn,salesman_no,dely_date,order_status) values('O19001','12-Jan-1996','C00001','F','N','S00001','20-Jan-1996','in process'); insert into sales_order(s_order_no,s_order_date,client_no,dely_type,billed_Yn,salesman_no,dely_date,order_status) values('O19002','25-Jan-1996','C00002','P','N','S00002','27-Jan-1996','canceled'); insert into sales_order(s_order_no,s_order_date,client_no,dely_type,billed_Yn,salesman_no,dely_date,order_status) values('O46865','18-Feb-1996','C00003','F','Y','S00003','20-Feb-1996','fullfilled'); insert into sales_order(s_order_no,s_order_date,client_no,dely_type,billed_Yn,salesman_no,dely_date,order_status) values('O19003','03-Apr-1996','C00001','F','Y','S00001','07-Apr-1996','fullfilled'); insert into sales_order(s_order_no,s_order_date,client_no,dely_type,billed_Yn,salesman_no,dely_date,order_status) values('O46866','20-May-1996','C00004','P','N','S00002','22-May-1996','canceled'); insert into sales_order(s_order_no,s_order_date,client_no,dely_type,billed_Yn,salesman_no,dely_date,order_status) values('O10008','24-May-1996','C00005','F','N','S00004','26-May-1996','in process'); ============================================ insert into sales_order_details values('O19001','P00001',4,4,525); insert into sales_order_details values('O19001','P07965',2,1,8400); insert into sales_order_details values('O19001','P07885',2,1,5250); insert into sales_order_details values('O19002','P00001',10,0,525); insert into sales_order_details values('O46865','P07868',3,3,3150); insert into sales_order_details values('O46865','P07885',3,1,5250); insert into sales_order_details values('O46865','P00001',10,10,525); insert into sales_order_details values('O46865','P03453',4,4,1050); insert into sales_order_details values('O19003','P03453',2,2,1050); insert into sales_order_details values('O19003','P06734',1,1,12000); insert into sales_order_details values('O46866','P07965',1,0,8400); insert into sales_order_details values('O46866','P07975',1,0,1050); insert into sales_order_details values('O19003','P00001',10,4,525); insert into sales_order_details values('O19003','P07975',5,3,1050); =================================================== insert into challan_header values('CH9001','O19001','12-Dec-1995','Y'); insert into challan_header values('CH6865','O46865','12-Nov-1995','Y'); insert into challan_header values('CH3965','O10008','12-Oct-1995','Y'); ================================================= insert into challan_details values('CH9001','P00001',4); insert into challan_details values('CH9001','P07965',1); insert into challan_details values('CH9001','P07885',1); insert into challan_details values('CH6865','P07868',3); insert into challan_details values('CH6865','P03453',4); insert into challan_details values('CH6865','P00001',10); insert into challan_details values('CH3965','P00001',5); insert into challan_details values('CH3965','P07975',2); ===================================================== select * from Client_master; select * from product_master; select * from salesman_master; select * from sales_order; select * from sales_order_details; select * from Challan_header; select * from Challan_details; ====================================================== drop table client_master drop table product_master drop table salesman_master drop table sales_order drop table sales_order_details drop table Challan_Details drop table challan_details ================================= ----------------------------------------- -- SIXTY SELF REVIEW SQL SENTENCE CONSTRUCTS FOR PRACTICE ----------------------------------------- --1. Single Table retrieval --------1--------------------- --Find out the names of all the clients. select name from client_master --------2----------------------- -- Print the entire client_master table. select * from client_master ---------3--------------------- --Retrieve the list of names and the cities of all the clients select name, city from client_master ----------4--------------------------- --List the various products available from the product_master table. select description "Product Name" from product_master; ----------5--------------------------- --Find the names of all clients having a as the second letter in their table. select name from client_master where name like '_a%' -----------6---------------------------- --Find the names of all clients who stay in a city whose second letter is a select name,city from client_master where city like '_a%' ------------7-------------------------- --Find out the clients who stay in a city Bombay or city Delhi or city Madras. select * from client_master where city in('Bombay','Delhi','Madras') -------------8--------------------------- --8) List all the clients who are located in Bombay. select * from client_master where city='Bombay' --------------9-------------------------- --9) Print the list of clients whose bal_due are greater than value 10000 select * from client_master where bal_due>10000 --------------10-------------------------- --10) Print the information from sales_order table of orders placed in the month of January. select s_order_no from sales_order where to_char(s_order_date,'Mon')='Jan'; ---------------11---------------------- --11) Display the order information for client_no C00001 and C00002 select * from sales_order where client_no in ('C00001', 'C00003') ---------------12---------------------- --12) Find the products with description as 1.44 Drive and 1.22 Drive select * from product_master where description in ('1.44 Drive','1.22 Drive') ---------------13------------------------ --13) Find the products whose selling price is greater than 2000 and less than or equal to 5000 select * from product_master where sell_price > 2000 and sell_price <=5000 ---------------14------------------------- --14) Find the products whose selling price is more than 1500 and also find the new selling price as original selling price * 15 select Description as "Product Name", sell_price "Selling Price ", sell_price*.15+sell_price as "New Selling Price" from product_master where sell_price>1500 ----------------15------------------------- --15) Rename the new column in the above query as new_price select Description as "Product Name", sell_price "Selling Price ", sell_price*.15+sell_price as "New Selling Price" from product_master where sell_price>1500 -------------------16------------------------ --16) Find the products whose cost price is less than 1500 select * from product_master where cost_price <1500 --------------------17------------------------- --17) List the products in sorted order of their description. select * from product_master order by DESCRIPTION select * from product_master order by 2 --------------------18----------------- --18) Calculate the square root the price of each product. select sqrt(sell_price) "Price" from product_master order by DESCRIPTION --------------------19----------------- --19) Divide the cost of product 540 HDD --by difference between its price and 100 (COSHENT) SELECT SELL_PRICE ,ROUND( SELL_PRICE / (SELL_PRICE-100),2) AS "COSHENT" FROM PRODUCT_MASTER --------------------20----------------- --20) List the names, city and state of clients not in the state of Maharashtra SELECT NAME, CITY, STATE FROM CLIENT_MASTER WHERE NOT STATE='Maharashtra'; --------------------21----------------- --21) List the product_no, description, sell_price of products --whose description begin with letter M SELECT pRODUCT_NO, DESCRIPTION, SELL_PRICE FROM PRODUCT_MASTER WHERE DESCRIPTION LIKE 'M%'; --------------------22----------------- --22) List all the orders that were canceled in the month of May. SELECT * FROM SALES_ORDER WHERE ORDER_STATUS = 'canceled' AND TO_CHAR(DELY_DATE,'MM')=05 --------------------Set Functions and Concatenation----------------- --2. Set Functions and Concatenation : --------------------23----------------- 23) Count the total number of orders. SELECT COUNT(*) FROM SALES_ORDER; --------------------24----------------- 24) Calculate the average price of all the products. SELECT AVG(SELL_PRICE) FROM PRODUCT_MASTER; --------------------25----------------- 25) Calculate the minimum price of products. select min(sell_price) "Minimum Price" from product_master --------------------26----------------- 26) Determine the maximum and minimum product prices. Rename the title as max_price and min_price respectively. SELECT MIN(SELL_PRICE) "Minimum Price", max(sell_price) "Maximum Price" from product_master; --------------------27----------------- 27) Count the number of products having price greater than or equal to 1500. select count(*) from product_master where sell_price >= 1500; --------------------28----------------- 28) Find all the products whose qty_on_hand is less than reorder level. select * from product_master where qty_on_hand < reorder_lvl; --------------------29----------------- 29) Print the information of client_master, product_master, sales_order table in the following formate for all the records {cust_name} has placed order {order_no} on {s_order_date}. select name ||' has placed order '||s_order_no||' on '||s_order_date from client_master, sales_order where client_master.client_no = sales_order.client_no; --------------------3. Having and Group by:----------------- --------------------30----------------- 30) Print the description and total qty sold for each product. select description, sum(qty_disp) "Total Quantity Sold" from product_master, sales_order_details where product_master.product_no = sales_order_details.product_no group by description; --------------------31----------------- 31) Find the value of each product sold. select description, sum(qty_disp * product_rate) "Total Worth" from product_master, sales_order_details where product_master.product_no = sales_order_details.product_no group by description; --------------------32----------------- 32) Calculate the average qty sold for each client that has a maximum order value of 15000.00 select client_master.client_no, avg(qty_disp), sum(qty_disp*product_rate) from client_master, sales_order, sales_order_details where client_master.client_no = sales_order.client_no and sales_order.s_order_no = sales_order_details.s_order_no group by client_master.client_no having sum(qty_disp * product_rate) <= 15000 --------------------33----------------- --33) Find out the total sales amount receivable for the month of jan. it will be the --sum total of all the billed orders for the month. --select s_order_date,sum(qty_dispatched*product_rate) --from sales_order, sales_order_details --where sales_order.s_order_no = sales_order_details.s_order_no --and billed_yn='y' and to_char(s_order_dt,mon)='jan'; --------------------34----------------- 34) Print the information of product_master, order_detail table in the following format for all the records {Description} worth Rs. {Total sales for the product} was sold. select description||' worth Rs.'||sum(qty_dispatched*product_rate)|| ' for the product was sold ' from client_master,sales_order, sales_order_details, product_master where client_master.client_no = sales_order.client_no and product_master.product_no = sales_ordeR_details.product_no and sales_order.s_order_no = sales_order_details.s_order_no group by description --------------------35----------------- 35) Print the information of product_master, order_detail table in the following format for all the records {Description} worth Rs. {Total sales for the product} was produced in the month of {s_order_date} in month format. select description||' worth Rs.'||to_char(sum(qty_disp*product_rate))|| ' was produced in the month'|| to_char(s_order_date,'month') from client_master,sales_order, sales_order_details, product_master where client_master.client_no = sales_order.client_no and product_master.product_no = sales_ordeR_details.product_no and sales_order.s_order_no = sales_order_details.s_order_no group by description, s_order_date; --------------------4. Joins and Correlation :----------------- --------------------36----------------- 36) Find out the products which has been sold to Ivan Bayross select name, description from client_master, product_master, sales_order, sales_order_details where client_master.client_no = sales_order.client_no and product_master.product_no = sales_order_details.product_no and sales_order.s_order_no = sales_order_details.s_order_no and name='Ivan Bayross'; --------------------37----------------- 37) Find out the products and their quantities that will have to deliver in the current month. select description, qty_disp, dely_date from product_master, sales_order_details, sales_order where product_master.product_no = sales_order_details.product_no and sales_order.s_order_no = sales_order_details.s_order_no and to_char(dely_date,'month')=to_char(sysdate,'month') --------------------38----------------- 38) Find the product_no and description of moving products. select * from product_master where product_no in(select product_no from sales_order_details); --------------------39----------------- 39) Find the names of clients who have purchased CD Drive select name, description from client_master, product_master, sales_order, sales_order_details where client_master.client_no = sales_order.client_no and product_master.product_no = sales_order_details.product_no and sales_order.s_order_no = sales_order_details.s_order_no and description ='CD Drive'; --------------------40----------------- 40) List the product_no and s_order_no of customers having qty_ordered less than 5 from the order details table for the product 1.44 floppies select p.product_no, s.s_order_no,sod.qty_ordered, c.name,p.description from client_master c, product_master p, sales_order s, sales_order_details sod where (s.client_no=c.client_no and sod.product_no=p.product_no and sod.s_order_no=s.s_order_no) and sod.qty_ordered<5 and p.description='1.44 Floppies' --------------------41----------------- 41) Find the products and their quantities for the orders placed by Vandana Saitwal and Ivan Bayross select p.description, sod.qty_ordered, c.name from client_master c, product_master p, sales_order s, sales_order_details sod where (s.client_no=c.client_no and sod.product_no=p.product_no and sod.s_order_no=s.s_order_no) and c.name in('Vandana Saitwal','Ivan Bayross') --------------------42----------------- 42) Find the products and their quantities for the orders placed by client_no C00001 and C00002 select p.description, sod.qty_ordered, c.client_no from client_master c, product_master p, sales_order s, sales_order_details sod where (s.client_no=c.client_no and sod.product_no=p.product_no and sod.s_order_no=s.s_order_no) and c.client_no in('C00001','C00002') --------------------5. Nested Queries :----------------- --------------------43----------------- 43) Find the product_no and description of non-moving products. select product_no , description from product_master where product_no in (select product_no from sales_order_details where s_order_no in (select s_order_no from sales_order where order_status='IP') ); --------------------44----------------- 44) Find the customer name, address1, address2, city and pin code for the client who has placed order no O19001 select name, address1,address2, city, pincode from client_master where client_no in( select client_no from sales_order where s_order_no ='O19001'); --------------------45----------------- 45) Find the client names who have placed orders before the month of May, 1996 select * from client_master where client_no in( select client_no from sales_order where to_char(s_order_date,'mm')<05); --with join select c.name, to_char(s.s_order_date,'month') "Month" from client_master c, sales_order s where c.client_no =s.client_no and to_char(s_order_date,'mm')<05 --------------------46----------------- 46) Find out if product 1.44 Drive is ordered by client and print the client_no, name to whom it is was sold. select client_no , name from client_master where client_no in( select client_no from sales_order where s_order_no in( select s_order_no from sales_order_details where product_no in( select product_no from product_master where description !='1.44 Drive' ) ) ) ---with join select c.client_no , c.name, p.description from client_master c, product_master p, sales_order s, sales_order_details sod where (s.client_no=c.client_no and sod.product_no=p.product_no and sod.s_order_no=s.s_order_no)and p.description != '1.44 Floppies' --------------------47----------------- 47) Find the names of clients who have placed orders worth Rs. 10000 or more. select name from client_master where client_no in( select client_no from sales_order where s_order_no in( select s_order_no from sales_order_details where product_rate*qty_ordered>=10000 ) ); ---with join select c.name, sod.product_rate*qty_ordered "Amount" from client_master c, product_master p, sales_order s, sales_order_details sod where (s.client_no=c.client_no and sod.product_no=p.product_no and sod.s_order_no=s.s_order_no) and product_rate*qty_ordered>=10000 --------------------6. Queries using Date:----------------- --------------------48----------------- 48) Display the order number and day on which clients placed their order. select s.s_order_no, to_char(s.s_order_date,'ddth') "Day" from sales_order s, sales_order_details sod where s.s_order_no=sod.s_order_no; --------------------49----------------- 49) Display the month (in alphabets) and date when the order must deliver. select to_char(dely_date,'month'), to_char(dely_date,'dd') from sales_order --------------------50----------------- 50) Display the s_order_date in the format . E.g. 12-February-1996 select to_char(s_order_Date,'dd-month-yyyy') from sales_order --------------------51----------------- 51) Find the date, 15 days after todays date. select sysdate+15 from dual --------------------52----------------- 52) Find the number of days elapsed between todays date and the delivery date of the orders placed by the clients. select dely_date, (sysdate-dely_date) from sales_order; --------------------7. Table Updations:----------------- --------------------53----------------- 53) Change the s_order_date of client_no C00001 to 24/07/96. ALTER TABLE SALES_ORDER DISABLE CONSTRAINT CHECKDELYDATE; update sales_order set s_order_date='24-jul-1996' where client_no='C00001'; --------------------54----------------- 54) Change the selling price of 1.44 Floppy Drive to Rs. 1150.00 update product_master set sell_price=1150 where description='1.44 Floppies'; --------------------55----------------- 55) Delete the records with order number O19001 from the order table. delete from sales_order where s_order_no='O19001'; --------------------56----------------- 56) Delete all the records having delivery date before 10th July96 delete from sales_order where dely_date='10-JUL-1996'; --------------------57----------------- 57) Change the city of client_no C00005 to Bombay. update client_master set city='Bombay' where client_no='C00005'; --------------------58----------------- 58) Change the delivery date of order number O10008 to 16/08/96 update sales_order set dely_date='16-aUG-1996' where s_order_no='O10008'; --------------------59----------------- 59) Change the bal_due of client_no C00001 to 1000 update client_master set bal_due=1000 where client_no='C00001'; --------------------60----------------- 60) Change the cost price of 1.44 Floppy Drive to Rs. 950.00. update product_master set cost_price=950.00 where description='1.44 Floppies'; -------------------------------------
true
e8180d910a1cbaf49153e8bdb1ff4ec71e9b31f8
SQL
YDyachenko/sungorus
/data/structure.sql
UTF-8
4,660
3.28125
3
[ "MIT" ]
permissive
# ************************************************************ # Sequel Pro SQL dump # Версия 4096 # # http://www.sequelpro.com/ # http://code.google.com/p/sequel-pro/ # # Адрес: localhost (MySQL 5.6.17) # Схема: passwords # Время создания: 2015-02-08 18:12:44 +0000 # ************************************************************ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; # Дамп таблицы accounts # ------------------------------------------------------------ CREATE TABLE `accounts` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned NOT NULL, `folder_id` int(10) unsigned NOT NULL, `favorite` tinyint(1) NOT NULL DEFAULT '0', `date_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `date_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, `name` varchar(45) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `fk_account_user` (`user_id`), KEY `fk_account_folder` (`folder_id`), CONSTRAINT `fk_account_folder` FOREIGN KEY (`folder_id`) REFERENCES `folders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_account_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; # Дамп таблицы accounts_data # ------------------------------------------------------------ CREATE TABLE `accounts_data` ( `account_id` int(11) unsigned NOT NULL, `data` blob NOT NULL, UNIQUE KEY `account_id` (`account_id`), CONSTRAINT `fk_account_data` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; # Дамп таблицы auth_log_failure # ------------------------------------------------------------ CREATE TABLE `auth_log_failure` ( `ip` int(11) unsigned NOT NULL, `count` tinyint(4) NOT NULL, `datetime` datetime DEFAULT NULL, PRIMARY KEY (`ip`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; # Дамп таблицы auth_log_success # ------------------------------------------------------------ CREATE TABLE `auth_log_success` ( `user_id` int(11) unsigned NOT NULL, `ip` int(11) unsigned NOT NULL, `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `user_agent` varchar(255) NOT NULL DEFAULT '', KEY `fk_log_user` (`user_id`), CONSTRAINT `fk_log_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; # Дамп таблицы encryption_keys # ------------------------------------------------------------ CREATE TABLE `encryption_keys` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(11) unsigned NOT NULL, `key` blob NOT NULL, `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`), KEY `fk_user_key` (`user_id`), CONSTRAINT `fk_user_key` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; # Дамп таблицы folders # ------------------------------------------------------------ CREATE TABLE `folders` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned DEFAULT NULL, `name` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_folder_user` (`user_id`), CONSTRAINT `fk_folder_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; # Дамп таблицы users # ------------------------------------------------------------ CREATE TABLE `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `email` varchar(100) NOT NULL, `login` varchar(50) NOT NULL, `password` varchar(60) NOT NULL DEFAULT '', `key_hash` varchar(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `email_UNIQUE` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true