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
4b646550aab52b4def14276a2e8730d5cb1f6de6
SQL
riskihendrawan61/FRAMEWORK_B_1515015061_060397
/laravel5/praktikumlaravel5.sql
UTF-8
12,033
3.015625
3
[ "MIT" ]
permissive
-- phpMyAdmin SQL Dump -- version 4.5.1 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: 06 Apr 2017 pada 08.18 -- Versi Server: 10.1.16-MariaDB -- PHP Version: 7.0.9 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `praktikumlaravel5` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `dosen` -- CREATE TABLE `dosen` ( `id` int(10) UNSIGNED NOT NULL, `nama` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `nip` varchar(18) COLLATE utf8_unicode_ci NOT NULL, `alamat` text COLLATE utf8_unicode_ci NOT NULL, `pengguna_id` int(10) UNSIGNED NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `dosen` -- INSERT INTO `dosen` (`id`, `nama`, `nip`, `alamat`, `pengguna_id`, `created_at`, `updated_at`) VALUES (9, 'Masnawati', '226677', 'Jl. Perjuangan', 4, '2017-03-18 03:12:16', '2017-03-18 03:12:16'); -- -------------------------------------------------------- -- -- Struktur dari tabel `dosen_matakuliah` -- CREATE TABLE `dosen_matakuliah` ( `id` int(10) UNSIGNED NOT NULL, `dosen_id` int(10) UNSIGNED NOT NULL, `matakuliah_id` int(10) UNSIGNED NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `dosen_matakuliah` -- INSERT INTO `dosen_matakuliah` (`id`, `dosen_id`, `matakuliah_id`, `created_at`, `updated_at`) VALUES (1, 9, 1, '2017-03-18 03:54:57', '2017-03-18 03:54:57'); -- -------------------------------------------------------- -- -- Struktur dari tabel `jadwal_matakuliah` -- CREATE TABLE `jadwal_matakuliah` ( `id` int(10) UNSIGNED NOT NULL, `mahasiswa_id` int(10) UNSIGNED NOT NULL, `ruangan_id` int(10) UNSIGNED NOT NULL, `dosen_matakuliah_id` int(10) UNSIGNED NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `jadwal_matakuliah` -- INSERT INTO `jadwal_matakuliah` (`id`, `mahasiswa_id`, `ruangan_id`, `dosen_matakuliah_id`, `created_at`, `updated_at`) VALUES (1, 1, 1, 1, '2017-03-18 04:22:06', '2017-03-18 04:22:06'); -- -------------------------------------------------------- -- -- Struktur dari tabel `mahasiswa` -- CREATE TABLE `mahasiswa` ( `id` int(10) UNSIGNED NOT NULL, `nama` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `nim` varchar(10) COLLATE utf8_unicode_ci NOT NULL, `alamat` text COLLATE utf8_unicode_ci NOT NULL, `pengguna_id` int(10) UNSIGNED NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `mahasiswa` -- INSERT INTO `mahasiswa` (`id`, `nama`, `nim`, `alamat`, `pengguna_id`, `created_at`, `updated_at`) VALUES (1, 'Muhammad Iqbal', '1515015077', 'Jl. Perjuangan 9', 4, '2017-03-18 03:30:09', '2017-04-05 22:16:37'); -- -------------------------------------------------------- -- -- Struktur dari tabel `matakuliah` -- CREATE TABLE `matakuliah` ( `id` int(10) UNSIGNED NOT NULL, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `keterangan` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `matakuliah` -- INSERT INTO `matakuliah` (`id`, `title`, `keterangan`, `created_at`, `updated_at`) VALUES (1, 'Pemrograman Visual', 'Wajib', '2017-03-18 03:41:35', '2017-03-18 03:41:35'); -- -------------------------------------------------------- -- -- Struktur dari tabel `migrations` -- CREATE TABLE `migrations` ( `migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `batch` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `migrations` -- INSERT INTO `migrations` (`migration`, `batch`) VALUES ('2014_10_12_000000_create_users_table', 1), ('2014_10_12_100000_create_password_resets_table', 1), ('2017_03_09_052546_buat_table_pengguna', 1), ('2017_03_09_054715_buat_table_pengguna1', 1), ('2017_03_11_095655_buat_table_dosen', 2), ('2017_03_11_101207_buat_table_mahasiswa', 3), ('2017_03_11_102017_buat_table_ruangan', 4), ('2017_03_11_102424_buat_table_matakuliah', 5), ('2017_03_11_102658_buat_table_dosen_matakuliah', 6), ('2017_03_11_103700_buat_table_jadwal_matakuliah', 7); -- -------------------------------------------------------- -- -- Struktur dari tabel `password_resets` -- CREATE TABLE `password_resets` ( `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `token` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- Struktur dari tabel `pengguna` -- CREATE TABLE `pengguna` ( `id` int(10) UNSIGNED NOT NULL, `username` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `pengguna` -- INSERT INTO `pengguna` (`id`, `username`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES (4, 'iqq_bal', '', NULL, '2017-03-18 02:02:00', '2017-03-24 02:13:56'), (5, 'iqq_bal', 'bontang', NULL, '2017-03-18 04:11:17', '2017-03-18 04:11:17'); -- -------------------------------------------------------- -- -- Struktur dari tabel `pengguna1` -- CREATE TABLE `pengguna1` ( `id` int(10) UNSIGNED NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -------------------------------------------------------- -- -- Struktur dari tabel `ruangan` -- CREATE TABLE `ruangan` ( `id` int(10) UNSIGNED NOT NULL, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Dumping data untuk tabel `ruangan` -- INSERT INTO `ruangan` (`id`, `title`, `created_at`, `updated_at`) VALUES (1, '405', '2017-03-18 04:08:01', '2017-03-18 04:08:01'); -- -------------------------------------------------------- -- -- Struktur dari tabel `users` -- CREATE TABLE `users` ( `id` int(10) UNSIGNED NOT NULL, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Indexes for dumped tables -- -- -- Indexes for table `dosen` -- ALTER TABLE `dosen` ADD PRIMARY KEY (`id`), ADD KEY `dosen_pengguna_id_foreign` (`pengguna_id`); -- -- Indexes for table `dosen_matakuliah` -- ALTER TABLE `dosen_matakuliah` ADD PRIMARY KEY (`id`), ADD KEY `dosen_matakuliah_dosen_id_foreign` (`dosen_id`), ADD KEY `dosen_matakuliah_matakuliah_id_foreign` (`matakuliah_id`); -- -- Indexes for table `jadwal_matakuliah` -- ALTER TABLE `jadwal_matakuliah` ADD PRIMARY KEY (`id`), ADD KEY `jadwal_matakuliah_mahasiswa_id_foreign` (`mahasiswa_id`), ADD KEY `jadwal_matakuliah_ruangan_id_foreign` (`ruangan_id`), ADD KEY `jadwal_matakuliah_dosen_matakuliah_id_foreign` (`dosen_matakuliah_id`); -- -- Indexes for table `mahasiswa` -- ALTER TABLE `mahasiswa` ADD PRIMARY KEY (`id`), ADD KEY `mahasiswa_pengguna_id_foreign` (`pengguna_id`); -- -- Indexes for table `matakuliah` -- ALTER TABLE `matakuliah` ADD PRIMARY KEY (`id`); -- -- Indexes for table `password_resets` -- ALTER TABLE `password_resets` ADD KEY `password_resets_email_index` (`email`), ADD KEY `password_resets_token_index` (`token`); -- -- Indexes for table `pengguna` -- ALTER TABLE `pengguna` ADD PRIMARY KEY (`id`); -- -- Indexes for table `pengguna1` -- ALTER TABLE `pengguna1` ADD PRIMARY KEY (`id`); -- -- Indexes for table `ruangan` -- ALTER TABLE `ruangan` ADD PRIMARY KEY (`id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `users_email_unique` (`email`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `dosen` -- ALTER TABLE `dosen` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; -- -- AUTO_INCREMENT for table `dosen_matakuliah` -- ALTER TABLE `dosen_matakuliah` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `jadwal_matakuliah` -- ALTER TABLE `jadwal_matakuliah` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `mahasiswa` -- ALTER TABLE `mahasiswa` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; -- -- AUTO_INCREMENT for table `matakuliah` -- ALTER TABLE `matakuliah` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `pengguna` -- ALTER TABLE `pengguna` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `pengguna1` -- ALTER TABLE `pengguna1` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `ruangan` -- ALTER TABLE `ruangan` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; -- -- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables) -- -- -- Ketidakleluasaan untuk tabel `dosen` -- ALTER TABLE `dosen` ADD CONSTRAINT `dosen_pengguna_id_foreign` FOREIGN KEY (`pengguna_id`) REFERENCES `pengguna` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Ketidakleluasaan untuk tabel `dosen_matakuliah` -- ALTER TABLE `dosen_matakuliah` ADD CONSTRAINT `dosen_matakuliah_dosen_id_foreign` FOREIGN KEY (`dosen_id`) REFERENCES `dosen` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `dosen_matakuliah_matakuliah_id_foreign` FOREIGN KEY (`matakuliah_id`) REFERENCES `matakuliah` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Ketidakleluasaan untuk tabel `jadwal_matakuliah` -- ALTER TABLE `jadwal_matakuliah` ADD CONSTRAINT `jadwal_matakuliah_dosen_matakuliah_id_foreign` FOREIGN KEY (`dosen_matakuliah_id`) REFERENCES `dosen_matakuliah` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `jadwal_matakuliah_mahasiswa_id_foreign` FOREIGN KEY (`mahasiswa_id`) REFERENCES `mahasiswa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `jadwal_matakuliah_ruangan_id_foreign` FOREIGN KEY (`ruangan_id`) REFERENCES `ruangan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Ketidakleluasaan untuk tabel `mahasiswa` -- ALTER TABLE `mahasiswa` ADD CONSTRAINT `mahasiswa_pengguna_id_foreign` FOREIGN KEY (`pengguna_id`) REFERENCES `pengguna` (`id`) ON DELETE CASCADE 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
15a2bc80c7ecda46a2d286e9e1428d83a39e6019
SQL
CUBRID/cubrid-testcases
/sql/_23_apricot_qa/_01_sql_extension3/_04_mutitable_update_delete/_01_multi_table_update/_03_adhoc/cases/_03_adhoc_delete_update_1.sql
UTF-8
10,078
3.71875
4
[ "BSD-3-Clause" ]
permissive
-- This testcase use modified Oracle samples. See below for the license: -- Copyright (c) 2015 Oracle -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. drop table if exists t1,t2,t3; create table t1(col1 date); insert into t1 values(date'1999-01-01'), (date'2000-01-01'); create table t2(col1 smallint, col2 date); insert into t2 values(5, date'2000-01-01'), (13, '2007-12-12'); create table t3(col1 bigint, col2 date); insert into t3 values(5, date'2000-01-01'), (13, '2007-12-12'); update t2 inner join t1 on t1.col1=t2.col2 set t2.col1=t2.col1 where rownum<1; update t2 inner join t1 on t1.col1=t2.col2 set t2.col1=2 where rownum<2; update t2 inner join t1 on t1.col1=t2.col2 inner join t3 on t3.col2=t1.col1 set t1.col1=t2.col2 where rownum<2; drop t1,t2,t3; drop table if exists md1,md2; create table md1(id1 int primary key, col1 varchar); insert into md1 values(11, 'aaa'), (22, 'bbb'); create table md2(id2 smallint, col2 varchar); insert into md2 values(22, 'ccc'), (22, 'ddd'); --trigger action table create table action_tbl(a int primary key auto_increment, b char(20)); --create trigger create trigger aft_upd after update on md1 execute insert into action_tbl(b) values('AFTER UPDATE'); update md1 m1 inner join md2 m2 on m1.id1=m2.id2 set m1.col1=m2.col2; drop table md1,md2; drop table action_tbl; drop table if exists p1,p2; create table p1(col1 time) partition by range(col1) (partition p1 values less than (time'12:12:13'), partition p2 values less than (time'12:12:15'), partition p3 values less than (time'12:12:18')); insert into p1 values('12:12:16'), ('12:12:17'), ('12:12:15'); create table p2(col2 time) partition by range(col2) (partition p1 values less than (time'12:12:12'), partition p2 values less than (time'12:12:16'), partition p3 values less than (time'14:14:15')); insert into p2 values('12:12:16'), ('12:12:16'), ('12:12:17'); update p1 right outer join p2 on p1.col1=p2.col2 set p1.col1=p2.col2-2, p2.col2=p1.col1; drop table p1,p2; drop table if exists p1,p2; create table p1(id1 int) partition by list(id1) ( partition p1 values in (1, 2), partition p2 values in (3, 4) ); insert into p1 values(2); create table p2(id2 int) partition by hash(id2) partitions 3; insert into p2 values(1), (2); update p1, p2 set p1.id1=3, p2.id2=8 where p1.id1=p2.id2; drop table p1,p2; drop table if exists t1,t2; create table t1(a int); insert into t1 values(1), (1), (1), (1); create table t2(b int); insert into t2 values(1), (1), (1), (1); update t1 m1, t2 m2 set m1.a=100, m2.b=100 where m1.a=m2.b; update t1 m1, t2 m2 set m1.a=100 where m1.a=m2.b; drop table t1; create table t1(a int); insert into t1 values(1), (2), (3), (4); update t1 m1, t1 m2 set m1.a=100, m2.a=200 where m1.a=m2.a; drop table t1,t2; drop table if exists t1,t2; create table t1(id int, phone varchar(20)) partition by hash(id) partitions 5; create table t2(id int , name varchar(20)) partition by hash(id) partitions 5; insert into t1 values(1,'111-1111'), (2,'222-2222'), (3, '333-3333'), (4, '444-4444'), (5, '555-5555'); insert into t2 values(1,'George'),(2,'Laura'),(3,'Max'); update t1, t2 set t1.id=100, t2.id=200 where t1.id=t2.id; drop table t1,t2; drop table if exists t1,t2; create table t1(id1 int, col2 clob); insert into t1 values(1, 'cubrid'), (2, 'mysql'), (3, 'abc'); create table t2(col1 clob, id2 int); insert into t2 values('aa', 1), ('mysql', 2); update t1 m1 left outer join t2 on clob_to_char(t2.col1)=clob_to_char(m1.col2) set t2.col1=char_to_clob('updated2'), t2.id2=m1.id1; drop table t1,t2; drop table if exists t1,t2; create table t1(id1 bigint, col1 time); insert into t1 values(1000000, '12:12:12'), (2000000, '12:12:13'); create table t2(id2 bigint, col2 time); insert into t2 values(1, '11:11:11'), (2, '12:12:12'); prepare st from 'update t1 m1 right outer join t2 m2 on m1.col1=m2.col2 set m1.col1=date_add(m2.col2, interval ? second);'; drop table t1,t2; drop table if exists bonuses,emp; create class bonuses (emp_id int, bonus int); create class emp (emp_id int, salary int); insert into bonuses values (153,100); insert into bonuses values (154,100); insert into bonuses values (155,100); insert into bonuses values (156,100); insert into bonuses values (157,100); insert into bonuses values (158,100); insert into bonuses values (159,100); insert into bonuses values (160,100); insert into bonuses values (161,100); insert into bonuses values (162,100); insert into bonuses values (163,100); insert into emp values (153,200); insert into emp values (154,500); insert into emp values (155,550); insert into emp values (156,350); insert into emp values (157,600); insert into emp values (158,450); insert into emp values (159,550); insert into emp values (160,650); insert into emp values (161,700); insert into emp values (162,520); insert into emp values (163,675); insert into emp values (201,400); insert into emp values (202,450); insert into emp values (203,300); merge into bonuses using emp on bonuses.emp_id = emp.emp_id when matched then update set bonuses.bonus=bonuses.bonus+emp.salary*0.1 where emp.salary<600; select count(*) from bonuses order by 1; select count(*) from emp order by 1; delete a,b from bonuses a ,emp b where a.emp_id=b.emp_id; delete bonuses from emp bonuses; drop table bonuses,emp; drop table if exists t1; create table t1 (a int primary key, b int, c int, d char(10),e char(100),f char(500),index i_t1_b(b)) ; create index i_t_ab on t1(a, abs(b)); insert into t1 select rownum,rownum, rownum, rownum||'', rownum||'', rownum||'' from db_class c1, db_class c2, db_class c3 limit 100;; select count(*) from t1 ; delete t1,t2 from t1 t1,t1 t2 where t1.a=t2.a and t1.a<10 using index t1.i_t1_b ; delete t1,t2 from t1 t1,t1 t2 where t1.a=t2.a and t1.a<100 and t2.a<100 using index t1.i_t1_b ; drop table if exists t1; create table t1 (a int primary key, b int, c int, d char(10),e char(100),f char(500),index i_t1_b(b)) PARTITION BY RANGE (a) (PARTITION a VALUES LESS THAN (100), PARTITION before_2008 VALUES LESS THAN (20000) ); create index i_t_ab on t1(a, abs(b)); insert into t1 select rownum,rownum, rownum, rownum||'', rownum||'', rownum||'' from db_class c1, db_class c2, db_class c3 limit 100;; select count(*) from t1 ; delete t1,t2 from t1 t1,t1 t2 where t1.a=t2.a and t1.a<10 using index t1.i_t1_b ; delete t1,t2 from t1 t1,t1 t2 where t1.a=t2.a and t1.a<100 and t2.a<100 using index t1.i_t1_b ; drop table if exists t1; create table t1 (a int primary key, b int, c int, d char(10),e char(100),f char(500),index i_t1_b(b)) PARTITION BY hash(a) partitions 2; create index i_t_ab on t1(a, abs(b)); insert into t1 select rownum,rownum, rownum, rownum||'', rownum||'', rownum||'' from db_class c1, db_class c2, db_class c3 limit 100;; select count(*) from t1 ; delete t1,t2 from t1 t1,t1 t2 where t1.a=t2.a and t1.a<10 using index t1.i_t1_b ; delete t1,t2 from t1 t1,t1 t2 where t1.a=t2.a and t1.a<10 and INST_NUM() <5 using index t1.i_t1_b ; delete t1,t2 from t1 t1,t1 t2 where t1.a=t2.a and t1.a<100 and t2.a<100 using index t1.i_t1_b ; drop table if exists t1; drop table if exists test; CREATE TABLE test (id int not null primary key, type int not null); CREATE INDEX idx ON test (id, type); insert into test select rownum ,rownum%9 from db_class a,db_class b ,db_class limit 100; select * FROM test WHERE type=5 OR (type=3 AND id=123456) ; select /*+ recompile */ * FROM test WHERE type=5 and (type=3 AND id=123456) ; DELETE FROM test WHERE type=5 OR (type=3 AND id=123456); drop table if exists test; drop table if exists DISTRICT,WAREHOUSE; CREATE TABLE WAREHOUSE(W_ID integer primary key); CREATE TABLE DISTRICT(D_W_ID Int, foreign key (D_W_ID)references WAREHOUSE(W_ID)); alter table DISTRICT add constraint foreign key (D_W_ID)references WAREHOUSE(W_ID) ON UPDATE RESTRICT; insert into WAREHOUSE select rownum from db_class limit 10; insert into DISTRICT select rownum from db_class limit 10; alter table DISTRICT drop CONSTRAINT fk_district_d_w_id; alter table DISTRICT change d_w_id d_w_id varchar(10); update DISTRICT set d_w_id=null; DELETE a,b FROM WAREHOUSE a, DISTRICT b where a.W_ID=b.D_W_ID; alter table DISTRICT change d_w_id d_w_id char(10); select count(*) from WAREHOUSE; select count(*) from DISTRICT; drop table if exists DISTRICT,WAREHOUSE; drop table if exists t1,t2,t3; CREATE TABLE t1 (C1 INT PRIMARY KEY, C2 CHAR(20), C3 BIT(1)); CREATE TABLE t2 (C1 INT PRIMARY KEY, C2 CHAR(20), C3 BIT(2)); CREATE TABLE t3 (C1 INT PRIMARY KEY, C2 CHAR(20), C3 BIT(3)); insert into t1 values (1,'FOO',B'0'), (2,'BAR', B'1'); insert into t2 values (1,'FOO',B'0'), (2,'BAR', B'1'); insert into t3 values (1,'FOO',B'0'), (2,'BAR', B'1'); insert into t1 values (4,'FOO',B'0'), (3,'BAR', B'0'); insert into t2 values (4,'FOO',B'0'), (3,'BAR', B'0'); insert into t3 values (4,'FOO',B'0'), (3,'BAR', B'0'); delete t2 from t1 left join t2 on t1.c1=t2.c1 where t1.c3=B'1' ; delete t1,t2 from t1,t2 where t1.c1=t2.c1; drop table if exists t1,t2,t3;
true
c4a114fedb99f10001f96f44c5b48d9ed687ab03
SQL
DrUzair/HarVis
/VisQueries/VideoLifeSpanQuery.sql
UTF-8
240
3.125
3
[]
no_license
SELECT Date_format(min(CreatedOn), '%d-%m-%Y') AS Since, DATEDIFF(max(CreatedOn),min(CreatedOn)) AS LifeTime, count(*) CommentCount, VideoID, VideoTitle, VideoAuthor FROM utubevideocomments GROUP By VideoID ORDER BY CommentCount DESC
true
847ac2fae573c21f38fe099afee7a952e1ca0f0c
SQL
jackob101/bugTracker
/src/test/resources/createData.sql
UTF-8
6,913
2.5625
3
[]
no_license
INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(1,24,'email1@gmail.com', 'Last name 1', 'Name 1', 0, 'Nickname 1', 'auth0|1111'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(2,24,'email2@gmail.com', 'Last name 2', 'Name 2', 0, 'Nickname 2', 'auth0|2222'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(3,24,'email3@gmail.com', 'Last name 3', 'Name 3', 0, 'Nickname 3', 'auth0|3333'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(4,24,'email4@gmail.com', 'Last name 4', 'Name 4', 0, 'Nickname 4', 'auth0|4444'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(5,24,'email5@gmail.com', 'Last name 5', 'Name 5', 0, 'Nickname 5', 'auth0|5555'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(6,24,'email6@gmail.com', 'Last name 6', 'Name 6', 0, 'Nickname 6', 'auth0|6666'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(7,24,'email7@gmail.com', 'Last name 7', 'Name 7', 0, 'Nickname 7', 'auth0|7777'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(8,24,'email8@gmail.com', 'Last name 8', 'Name 8', 0, 'Nickname 8', 'auth0|8888'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(9,24,'email9@gmail.com', 'Last name 9', 'Name 9', 0, 'Nickname 9', 'auth0|9999'); INSERT INTO User(id, age, email, lastname, name, emailVerified, nickname, sub) VALUES(10,24,'email10@gmail.com', 'Last name 10', 'Name 10', 0, 'Nickname 10', 'auth0|10101010'); INSERT INTO Project(id, name, description) VALUES (1,'Project number: 1', 'This is description for project number 1'); INSERT INTO Project(id, name, description) VALUES (2,'Project number: 2', 'This is description for project number 2'); INSERT INTO Project(id, name, description) VALUES (3,'Project number: 3', 'This is description for project number 3'); INSERT INTO Project(id, name, description) VALUES (4,'Project number: 4', 'This is description for project number 4'); INSERT INTO Project(id, name, description) VALUES (5,'Project number: 5', 'This is description for project number 5'); INSERT INTO Issue(id, title, description, openedTime, closedTime, priority, createdById, projectId) VALUES (1, 'Title for issue number 1', 'Description for issue number 1', '2021-08-18 17:04:04', NULL, 0, 1, 1), (2, 'Title for issue number 2', 'Description for issue number 2', '2021-08-18 17:04:04', NULL, 1, 1, 1), (3, 'Title for issue number 3', 'Description for issue number 3', '2021-08-18 17:04:04', '2021-09-15 14:25:01',1, 1, 1), (4, 'Title for issue number 4', 'Description for issue number 4', '2021-08-18 17:04:04', NULL,2, 1, 1), (5, 'Title for issue number 5', 'Description for issue number 5', '2021-08-18 17:04:04', '2021-08-18 21:20:05',2, 1, 1), (6, 'Title for issue number 6', 'Description for issue number 6', '2021-08-18 17:06:06', NULL,2, 2, 2), (7, 'Title for issue number 7', 'Description for issue number 7', '2021-08-18 17:07:07', NULL,2, 2, 2), (8, 'Title for issue number 8', 'Description for issue number 8', '2021-08-18 17:08:08', '2021-08-18 21:20:05',2, 2, 2), (9, 'Title for issue number 9', 'Description for issue number 9', '2021-08-18 17:09:09', NULL,2, 3, 2), (10, 'Title for issue number 10', 'Description for issue number 10', '2021-08-18 17:10:10', NULL,2, 3, 3), (11, 'Title for issue number 11', 'Description for issue number 11', '2021-08-18 17:11:11', NULL,1, 4, 3), (12, 'Title for issue number 12', 'Description for issue number 12', '2021-08-18 17:12:12', '2021-08-18 21:20:05',1, 4, 3), (13, 'Title for issue number 13', 'Description for issue number 13', '2021-08-18 17:13:13', NULL,1, 4, 3), (14, 'Title for issue number 14', 'Description for issue number 14', '2021-08-18 17:14:14', NULL,1, 4, 3), (15, 'Title for issue number 15', 'Description for issue number 15', '2021-08-18 17:15:15', NULL,1, 5, 3), (16, 'Title for issue number 16', 'Description for issue number 16', '2021-08-18 17:16:16', NULL,1, 5, 3), (17, 'Title for issue number 17', 'Description for issue number 17', '2021-08-18 17:17:17', '2021-08-18 21:20:05',0, 6, 3), (18, 'Title for issue number 18', 'Description for issue number 18', '2021-08-18 17:18:18', NULL,0, 7, 4), (19, 'Title for issue number 19', 'Description for issue number 19', '2021-08-18 17:19:19', NULL,0, 8, 4), (20, 'Title for issue number 20', 'Description for issue number 20', '2021-08-18 17:20:20', NULL,0, 7, 4), (21, 'Title for issue number 21', 'Description for issue number 21', '2021-08-18 17:21:21', '2021-08-18 21:20:05',1, 7, 4), (22, 'Title for issue number 22', 'Description for issue number 22', '2021-08-18 17:22:22', NULL,1, 8, 4), (23, 'Title for issue number 23', 'Description for issue number 23', '2021-08-18 17:23:23', NULL,2, 9, 4), (24, 'Title for issue number 24', 'Description for issue number 24', '2021-08-18 17:24:24', '2021-08-18 21:20:05',2, 10, 4), (25, 'Title for issue number 25', 'Description for issue number 25', '2021-08-18 17:25:25', NULL,2, 10, 4); INSERT INTO Issue_User(issue_id, user_id) VALUES (1,1),(1,2),(4,3),(4,2),(4,4),(10,5),(10,6),(10,4),(22,10),(22,4); INSERT INTO Project_User(project_id, user_id) VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(3,2),(3,4),(4,6),(4,7),(4,9); INSERT INTO Comment(id, comment, user_id, issue_id, creationDate) VALUES (1, 'This is example comment number 1', 1, 1, '2021-08-18 17:01:01'), (2, 'This is example comment number 2', 2, 1, '2022-08-28 17:02:02'), (3, 'This is example comment number 3', 2, 1, '2023-08-28 17:03:03'), (4, 'This is example comment number 4', 2, 1, '2024-08-28 17:04:04'), (5, 'This is example comment number 5', 1, 1, '2025-08-18 17:05:05'), (6, 'This is example comment number 6', 2, 2, '2026-08-18 17:06:06'), (7, 'This is example comment number 7', 2, 2, '2027-08-18 17:07:07'), (8, 'This is example comment number 8', 3, 3, '2028-08-18 17:08:08'), (9, 'This is example comment number 9', 3, 3, '2029-08-18 17:09:09'), (10, 'This is example comment number 10', 3, 3, '2029-08-18 17:09:09'), (11, 'This is example comment number 11', 5, 10, '2029-08-18 17:09:09'), (12, 'This is example comment number 12', 3, 10, '2029-08-18 17:09:09'), (13, 'This is example comment number 13', 5, 10, '2029-08-18 17:09:09'), (14, 'This is example comment number 14', 3, 10, '2029-08-18 17:09:09'), (15, 'This is example comment number 15', 3, 15, '2029-08-18 17:09:09'), (16, 'This is example comment number 16', 7, 15, '2029-08-18 17:09:09'), (17, 'This is example comment number 17', 7, 15, '2029-08-18 17:09:09'), (18, 'This is example comment number 18', 6, 15, '2029-08-18 17:09:09'), (19, 'This is example comment number 19', 3, 20, '2029-08-18 17:09:09'), (20, 'This is example comment number 20', 3, 20, '2029-08-18 17:09:09');
true
9542303a7b555d50f055354e746bc3867b013c08
SQL
bellmit/webdemo
/dbscript/mysql/01basisscript/operator/tables/oper_social_account.sql
UTF-8
758
3.15625
3
[]
no_license
/***************************************************************************** -- OPER_SOCIAL_ACCOUNT : *****************************************************************************/ drop table if exists OPER_SOCIAL_ACCOUNT; create table OPER_SOCIAL_ACCOUNT( id varchar(64) not null, operatorId varchar(64) not null, type varchar(64) not null, uniqueId varchar(64) not null, username varchar(64), headImgUrl varchar(256), attributes varchar(1000), lastUpdateDate datetime(6) not null default now(6), createDate datetime(6) not null default now(6), primary key(id) ); create unique index IDX_SOCIAL_ACCOUNT_00 on OPER_SOCIAL_ACCOUNT(uniqueId,type); create unique index IDX_SOCIAL_ACCOUNT_01 on OPER_SOCIAL_ACCOUNT(operatorId,type);
true
338531405a2fb313cb1e2d6086b7e4684685b7f7
SQL
JulieAnn2330/employee-tracker
/db/schemas.sql
UTF-8
1,498
4.25
4
[ "MIT" ]
permissive
/*View Employees by Manager*/ select * from employee where manager_id = 1; select * from employee where manager_id = 2; /*View all Employees by Manager*/ SELECT employee.first_name, employee.last_name, employee.manager_id, employee.manager_name from employee; /*View Departments, Roles, Employees Individually*/ select * from employee; select * from role; select * from department; /*View Departments, Roles, Employees Aggregate*/ SELECT employee.first_name, employee.last_name, role.title, department.department_name from role inner join employee on employee.role_id = role.role_id inner join department on department.department_id = role.department_id order by employee.first_name; /*Update employee role*/ UPDATE employee SET role_id = 8 WHERE id = 17; /*View Department Budgets*/ SELECT SUM(salary) FROM employee where ; SELECT sum(salary) from role inner join employee on employee.role_id = role.role_id inner join department on department.department_id = role.department_id where department_id = ? order by employee.first_name; SELECT CONCAT(first_name, ' ', last_name) AS 'Name' from employee; delete from employee where 'Name' = "Test Test"; select * from employee where manager_id=2 and id=2 = 'Troy Batson'; SELECT employee.first_name, employee.last_name, role.role, role.salary, department.department_name from role inner join employee on employee.role_id = role.role_id inner join department on department.department_id = role.department_id where department_name = 'sales';
true
fd922596f9f00999a5ee7c21ff68c889f3792d60
SQL
wladko0/sql-scripts-macola-wisys-epicor
/ItemNoLengthScript.sql
UTF-8
364
3.203125
3
[]
no_license
USE [001] SELECT RTRIM(imitmidx_sql.item_no), iminvloc_sql.loc, iminvloc_sql.prod_cat, qty_on_hand, qty_allocated, qty_on_ord, usage_ytd, prior_year_usage, imitmidx_sql.item_desc_1, imitmidx_sql.item_desc_2 FROM iminvloc_sql INNER JOIN imitmidx_sql on iminvloc_sql.item_no = imitmidx_sql.item_no WHERE len(rtrim(imitmidx_sql.item_no)) > 15 and activity_cd = 'A'
true
da2a2d1099b4e27d6032662c2e44c9e7efd4b4a0
SQL
yalagin/todo
/mytodo.sql
UTF-8
3,612
3.09375
3
[]
no_license
-- -------------------------------------------------------- -- Host: localhost -- Server version: 10.2.6-MariaDB-log - mariadb.org binary distribution -- 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 mytodo CREATE DATABASE IF NOT EXISTS `mytodo` /*!40100 DEFAULT CHARACTER SET latin1 */; USE `mytodo`; -- Dumping structure for table mytodo.images CREATE TABLE IF NOT EXISTS `images` ( `id` int(11) NOT NULL AUTO_INCREMENT, `task_id` int(11) unsigned NOT NULL, `file` varchar(255) NOT NULL, PRIMARY KEY (`id`), KEY `task_id` (`task_id`), CONSTRAINT `FK_images_tasks` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=latin1; -- Dumping data for table mytodo.images: ~5 rows (approximately) /*!40000 ALTER TABLE `images` DISABLE KEYS */; INSERT INTO `images` (`id`, `task_id`, `file`) VALUES (86, 156, '642d5e8b60876dea30ac854945844ce5.jpg'), (87, 156, '80caf03e537a2825881085e2818d6a2c.jpg'), (88, 156, '86bb335b32da74af2719af2b4ffc128e.jpg'), (89, 156, 'fb5677fa6af97123ed9e93d7b7daa729.jpg'), (90, 165, '9bab5929f6857f82ab87eb767e0f8fb9.jpg'); /*!40000 ALTER TABLE `images` ENABLE KEYS */; -- Dumping structure for table mytodo.tasks CREATE TABLE IF NOT EXISTS `tasks` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `description` text NOT NULL, `name` varchar(255) DEFAULT NULL, `email` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=166 DEFAULT CHARSET=latin1 COMMENT='\r\n'; -- Dumping data for table mytodo.tasks: ~12 rows (approximately) /*!40000 ALTER TABLE `tasks` DISABLE KEYS */; INSERT INTO `tasks` (`id`, `description`, `name`, `email`) VALUES (154, '333', '333', '333'), (155, '333', '333', '333'), (156, '333', '333', '333'), (157, 'rrrr', 'rrr', 'rrr'), (158, '333', '333', '333'), (159, '333', '333', '333'), (160, '333', '333', '333'), (161, '333', '333', '333'), (162, '333', '333', '333'), (163, '333', '333', '333'), (164, 'eee', 'eee', 'Eee'), (165, 'eee', 'eee', 'Eee'); /*!40000 ALTER TABLE `tasks` ENABLE KEYS */; -- Dumping structure for table mytodo.users CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `is_admin` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=latin1; -- Dumping data for table mytodo.users: ~3 rows (approximately) /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` (`id`, `name`, `email`, `password`, `is_admin`) VALUES (1, 'test1', 'yalagin@gmail.com', '$2y$10$i736BlltgU4d6sZZxbGgueK9S///jzamUZ7OSPKSR.YmxJEfHpcNi', 0), (2, 'test', 'yalagin@gmail.com', '$2y$10$lfu0z7yhrJdvrxhKeUgqK./Vu4V6.FPWnnkcL2n7/o6eJtz.JyBUO', 0), (24, 'admin', 'admin@gmail.com', '$2y$10$4/myFUps1KFASyECk41cvu/1TixTk.JndYoWUTkHDhMlHgYcBZpcm', 1); /*!40000 ALTER TABLE `users` 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
cabbdeba2a19e1600709e54bfeb286534719d8ab
SQL
kimjaneclark/codeclan_working_2019
/week_03/day_1/lightabers.sql
UTF-8
745
3.5
4
[]
no_license
DROP TABLE lightsabers; DROP TABLE characters; CREATE TABLE characters ( id SERIAL8 PRIMARY KEY, name VARCHAR(255), darkside BOOLEAN, age INT ); CREATE TABLE lightsabers ( id SERIAL8 PRIMARY KEY, hilt_metal VARCHAR(255) NOT NULL, colour VARCHAR(255) NOT NULL, character_id INT8 REFERENCES characters(id) ); INSERT INTO characters (name, darkside, age) VALUES('Obi-Wan Kenobi', false, 27); INSERT INTO lightsabers (hilt_metal, colour, character_id) VALUES('steel', 'green', 1); INSERT INTO lightsabers (hilt_metal, colour, character_id) VALUES('palladium', 'red', 1); INSERT INTO lightsabers (hilt_metal, colour, character_id) VALUES('iron', 'blue', 20 ); SELECT * FROM characters; SELECT * FROM lightsabers WHERE character_id = 1;
true
2c82122fb45eb97883b867b405ccbc5f94245a2d
SQL
cankush625/Database
/SQL/aggregate_functions.sql
UTF-8
3,217
4.65625
5
[ "MIT" ]
permissive
use books_db; /*Using the database which is already created*/ select database(); /*count*/ /*Using count to count number of records*/ select count(*) as 'Number of books' from books; select count(author_fname) as 'Number of Authors' from books; /*Using count with distinct*/ select count(distinct(author_fname)) as 'Number of Authors' from books; select count(distinct author_fname, author_lname) as 'Number of Authors' from books; /*Using count with like*/ select count(title) as "Title containing 'the'" from books where title like '%the%'; /*group by*/ /*It groups the results under the mentioned field and shows only first record*/ select title, author_lname from books group by author_lname; /*Using group by with count*/ /*Count how many books each author have written*/ select author_lname, count(*) as 'Books by each author' from books group by author_lname; select author_fname, author_lname, count(*) as 'Books by each author' from books group by author_fname, author_lname; /*Using group by with count and order by*/ select released_year, count(*) as 'Books released in year' from books group by released_year order by released_year; /*Using group by with concat, count and order by*/ select concat('In ', released_year, ', ', count(*), ' book(s) are released!') as 'Books released in year' from books group by released_year order by released_year; /*min or max*/ select min(released_year) from books; select min(pages) from books; select max(released_year) from books; select max(pages) from books; /*Selecting title of the longest book*/ /*Both gives same result by changing the position of the column*/ /*But both of these gives wrong result*/ select max(pages), title from books; /*gives wrong result*/ select title, max(pages) from books; /*gives wrong result*/ /*Solution to the problem above is 'Subquery'*/ /*Subquery*/ select * from books where pages = (select max(pages) from books); select title, pages from books where pages = (select max(pages) from books); /*Another way of doing it using only one select*/ select * from books order by pages desc limit 1; select * from books order by pages asc limit 1; /*Using min and max with group by*/ select author_fname, author_lname, min(released_year) from books group by author_fname, author_lname; select author_fname, author_lname, max(released_year) from books group by author_fname, author_lname; /*selecting longest page count for the authors*/ select author_fname, author_lname, max(pages) from books group by author_fname, author_lname; /*selecting smallest page count for the authors*/ select author_fname, author_lname, min(pages) from books group by author_fname, author_lname; /*Using max, group by and concat together*/ select concat(author_fname, ' ', author_lname) as 'Author', max(pages) as 'Longest book' from books group by author_fname, author_lname; /*sum*/ select sum(pages) from books; /*Sum all pages each author have written*/ select author_fname, author_lname, sum(pages) from books group by author_fname, author_lname; /*avg*/ select avg(pages) from books; /*Calculating average stock quantity for books released in same year*/ select released_year, avg(stock_quantity) from books group by released_year;
true
00f6672daa3108d55a0c233fa3764888a837943d
SQL
PierreLefeuvre/forum
/forum.sql
UTF-8
2,419
3.40625
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.6.4 -- https://www.phpmyadmin.net/ -- -- Client : 127.0.0.1 -- Généré le : Mer 28 Mars 2018 à 11:07 -- Version du serveur : 5.7.14 -- Version de PHP : 5.6.25 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de données : `forum` -- -- -------------------------------------------------------- -- -- Structure de la table `posts` -- CREATE TABLE `posts` ( `post_id` int(11) NOT NULL, `message` text, `nickname` varchar(256) DEFAULT NULL, `topic_id` int(11) DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, `ip` varchar(15) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Structure de la table `topics` -- CREATE TABLE `topics` ( `topic_id` int(11) NOT NULL, `title` varchar(256) DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Index pour les tables exportées -- -- -- Index pour la table `posts` -- ALTER TABLE `posts` ADD PRIMARY KEY (`post_id`), ADD KEY `FK_post_topic_id` (`topic_id`), ADD KEY `modified` (`modified`); ALTER TABLE `posts` ADD FULLTEXT KEY `message` (`message`); -- -- Index pour la table `topics` -- ALTER TABLE `topics` ADD PRIMARY KEY (`topic_id`); ALTER TABLE `topics` ADD FULLTEXT KEY `title` (`title`); -- -- AUTO_INCREMENT pour les tables exportées -- -- -- AUTO_INCREMENT pour la table `posts` -- ALTER TABLE `posts` MODIFY `post_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=57; -- -- AUTO_INCREMENT pour la table `topics` -- ALTER TABLE `topics` MODIFY `topic_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=41; -- -- Contraintes pour les tables exportées -- -- -- Contraintes pour la table `posts` -- ALTER TABLE `posts` ADD CONSTRAINT `FK_post_topic_id` FOREIGN KEY (`topic_id`) REFERENCES `topics` (`topic_id`) ON DELETE CASCADE 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
817cb2342c37f6530f903abcd2b133c9b0a86628
SQL
diunuge/TodoMore
/sql/hints.sql
UTF-8
899
3.125
3
[ "BSD-2-Clause" ]
permissive
-- Install the hints. WARNING this deletes previous ones to avoid conflicts, -- so if you've modified the hints, be sure to save your changes first! delete from hint; COPY hint(id, hint, author) FROM stdin; 1 If a task seems formidable, break it down into smaller ones. 2 Be honest with yourself; if you're really never going to do a task, delete it! Ian 3 Start every day with a look at your TodoMore list; it can help organize your day. 4 If a task can be done in a minute or two, do it now rather than entering it into TodoMore and have to do it later! Ian 5 Try to keep no more than 10 top-priority items, to avoid getting overwhelmed 6 Tell us how we can improve TodoMore. Better yet, fix it and send us the code via a GitHub "pull request". Ian 7 When you finish a Todo item, TodoMore lets you either delete it completely, or mark it Done (Done items are hidden from the normal view) \.
true
15ac2ca4ceee6314f8c477f9b41375699450f627
SQL
jobsonrp/ProjetoInfraRU
/banco/bancoru.sql
UTF-8
2,002
3.46875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.2.7.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: 21-Ago-2017 às 02:12 -- Versão do servidor: 5.5.39 -- PHP Version: 5.4.31 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; -- -- Database: `dbru` -- CREATE DATABASE IF NOT EXISTS `dbru` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; USE `dbru`; -- -------------------------------------------------------- -- -- Estrutura da tabela `Rfid` -- DROP TABLE IF EXISTS `Rfid`; CREATE TABLE IF NOT EXISTS `Rfid` ( `id` int(11) NOT NULL, `tag` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ; -- -- Extraindo dados da tabela `Rfid` -- INSERT INTO `Rfid` (`id`, `tag`) VALUES (1, '111'), (2, '222'), (3, '333'), (4, '444'), (5, '555'), (6, '666'), (7, '777'), (8, '888'), (9, '999'), (10, 'd58890b5'), (11, '9d527fb5'); -- -------------------------------------------------------- -- -- Estrutura da tabela `Usuario` -- DROP TABLE IF EXISTS `Usuario`; CREATE TABLE IF NOT EXISTS `Usuario` ( `id` int(11) NOT NULL, `rfid` varchar(45) NOT NULL, `nome` varchar(45) NOT NULL, `cpf` int(11) NOT NULL, `saldo` float NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ; -- -- Extraindo dados da tabela `Usuario` -- INSERT INTO `Usuario` (`id`, `rfid`, `nome`, `cpf`, `saldo`) VALUES (4, '999', 'José', 111, 53.32), (9, '111', 'Jobson', 123456, 0), (10, '888', 'Maria', 654987, 0); -- -- Indexes for dumped tables -- -- -- Indexes for table `Rfid` -- ALTER TABLE `Rfid` ADD PRIMARY KEY (`id`); -- -- Indexes for table `Usuario` -- ALTER TABLE `Usuario` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `rfid_UNIQUE` (`rfid`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `Rfid` -- ALTER TABLE `Rfid` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=12; -- -- AUTO_INCREMENT for table `Usuario` -- ALTER TABLE `Usuario` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=11;
true
c2aeda31007baeb6b753f7ee59233f1f72c11ef8
SQL
zongzhiliu/trial_matching
/scripts/viecure/ct_LCA/match_stage.sql
UTF-8
784
3.640625
4
[]
no_license
/*** match attribute for cancer stage Requires: cohort, crit_attribute_used, trial_attribute_used stage Results: _p_a_t_stage */ drop table if exists _p_a_t_stage cascade; create table _p_a_t_stage as; with cau as ( select attribute_id, code_type, code , attribute_value--, attribute_value_norm from crit_attribute_used where code_type in ('stage_base', 'stage_like') ), tau as ( select attribute_id, trial_id , ie_value from trial_attribute_used --where ie_value = 'yes' ) select person_id, trial_id, attribute_id , bool_or(case code_type when 'stage_base' then stage_base = code when 'stage_like' then stage like code end) as match from (stage cross join cau) join tau using (attribute_id) group by person_id, trial_id, attribute_id ;
true
a1936a9156769296982087eac3b68e325a40c6cb
SQL
Nakzz/Online-Portfolio-Ajmain-Naqib
/build/includes/database/setup.sql
UTF-8
2,796
3.546875
4
[]
no_license
-- ----------------------------------------------------- -- MySQL Database setup. -- Author: Ajmain Naqib -- Data: 6/2/18 -- ----------------------------------------------------- -- ----------------------------------------------------- -- Creates Database called Resume -- ----------------------------------------------------- CREATE DATABASE IF NOT EXISTS Resume; USE Resume; -- ----------------------------------------------------- -- table for Experiances with Required columns -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS Resume.Experiences( ID INT NOT NULL AUTO_INCREMENT, Position VARCHAR(255) NOT NULL, Employer VARCHAR(255) NOT NULL, Location VARCHAR(255) NOT NULL, Task_1 VARCHAR(255) NOT NULL, Task_2 VARCHAR(255), Task_3 VARCHAR(255), Project_1 VARCHAR(255), Project_1_Link VARCHAR(255), Project_2 VARCHAR(255), Project_2_Link VARCHAR(255), Project_3 VARCHAR(255), Project_3_Link VARCHAR(255), TimeStart VARCHAR(255) NOT NULL, TimeEnd VARCHAR(255) NOT NULL, Datestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Modified_Datastamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id)); -- ----------------------------------------------------- -- table for Experiances with Required columns -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS Resume.Education( ID INT NOT NULL AUTO_INCREMENT, Institution VARCHAR(255) NOT NULL, Location VARCHAR(255) NOT NULL, Courses VARCHAR(255) NOT NULL, Details VARCHAR(255), TimeStart VARCHAR(255) NOT NULL, TimeEnd VARCHAR(255) NOT NULL, Datestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Modified_Datastamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id)); -- ----------------------------------------------------- -- table for Skills with Required columns -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS Resume.Skills( ID INT NOT NULL AUTO_INCREMENT, Name VARCHAR(255) NOT NULL, Percentage VARCHAR(255) NOT NULL, Datestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Modified_Datastamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id)); -- ----------------------------------------------------- -- table for Softwares with Required columns -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS Resume.Softwares( ID INT NOT NULL AUTO_INCREMENT, Name VARCHAR(255) NOT NULL, Percentage VARCHAR(255) NOT NULL, Datestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Modified_Datastamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id));
true
0819e3962d8d2f1b2e302ca995077fbf037a41e9
SQL
qgadrian/elovendo
/src/sql/populate-database.sql
UTF-8
2,850
2.796875
3
[]
no_license
--------------------------------------------------- -- Sentencias de creación de tablas y secuencias -- --------------------------------------------------- -- ROLES INSERT INTO role VALUES (1, 'ROLE_USER'); INSERT INTO role VALUES (2, 'ROLE_ADMIN'); -- USER -- avatar uservalue, points, registerDate, roleid, you're welcome INSERT INTO userprofile VALUES(1, 'Admin', '$2a$10$LjDlebedYsrYKAMrZC4thu2mRmEeWCGJ76FN6Kt0v3FxgO8bc.VIa', 'Admin', 'admin', NULL, NULL, 0, 'elovendogod', 'images/default/profile/default', 100, 999, NOW(), 2, TRUE, NULL); -- CATEGORY INSERT INTO category VALUES (1, 'Tecnología'); INSERT INTO category VALUES (2, 'Deportes'); INSERT INTO category VALUES (3, 'Hogar'); INSERT INTO category VALUES (4, 'Motor'); INSERT INTO category VALUES (5, 'Mascotas'); INSERT INTO category VALUES (6, 'Libros'); INSERT INTO category VALUES (7, 'Moda'); INSERT INTO category VALUES (8, 'Joyería'); INSERT INTO category VALUES (9, 'Niños'); INSERT INTO category VALUES (10, 'Música'); -- SUBCATEGORY INSERT INTO subcategory VALUES(1, 1, 'Moviles'); INSERT INTO subcategory VALUES(2, 1, 'Videoconsolas'); INSERT INTO subcategory VALUES(3, 1, 'Informática'); INSERT INTO subcategory VALUES(4, 1, 'Imagen'); INSERT INTO subcategory VALUES(5, 1, 'Sonido'); INSERT INTO subcategory VALUES(6, 1, 'Fotografía'); INSERT INTO subcategory VALUES(7, 2, 'Relojes GPS'); INSERT INTO subcategory VALUES(8, 2, 'Ropa'); INSERT INTO subcategory VALUES(9, 2, 'Zapatillas'); INSERT INTO subcategory VALUES(10, 2, 'Bicicletas'); INSERT INTO subcategory VALUES(11, 2, 'Accesorios'); INSERT INTO subcategory VALUES(12, 3, 'Sofás'); INSERT INTO subcategory VALUES(13, 3, 'Electrodomésticos'); INSERT INTO subcategory VALUES(14, 3, 'Muebles'); INSERT INTO subcategory VALUES(15, 3, 'Jardín'); INSERT INTO subcategory VALUES(16, 3, 'Otros'); INSERT INTO subcategory VALUES(17, 4, 'Coches'); INSERT INTO subcategory VALUES(18, 4, 'Motos'); INSERT INTO subcategory VALUES(19, 4, 'Náutica'); INSERT INTO subcategory VALUES(20, 4, 'Remolques'); INSERT INTO subcategory VALUES(22, 4, 'Neumáticos'); INSERT INTO subcategory VALUES(23, 4, 'Accesorios coches'); INSERT INTO subcategory VALUES(24, 4, 'Accesorios motos'); INSERT INTO subcategory VALUES(25, 4, 'Otros'); -- ITEMS --INSERT INTO item VALUES (NULL, 1, 2, 'PS4 + 2 mandos + Juegos', 'Play station 4 original, comprada en Marruecos, está un poco rayada.', 1, 200, NOW(), null); --INSERT INTO item VALUES (NULL, 2, 2, 'XBOX ONE + 3 mandos', 'Original, se vende porque me compré una gameboy', 2, 250.5, NOW(), null); --INSERT INTO item VALUES (NULL, 1, 3, 'PC 3ghz + 8GB RAM Nvidia 964GTZ', 'Está como nuevo, vendo por no usar', 1, 500.5, NOW(), null); --INSERT INTO item VALUES (NULL, 1, 4, 'Televisión 20 pulgadas', 'Un televisor grande y con muy buena pantalla', 2, 1200, NOW(), null);
true
511e5d19f4b21a5f49f0f16dab911d77982a8a2e
SQL
Acsilvei/DFNB_as
/views/dbo.v_balance_on_dec31.sql
UTF-8
902
3.140625
3
[]
no_license
/***************************************************************************************************************** NAME: dbo.v_balance_on_dec31 PURPOSE: Create the dbo.v_balance_on_dec31 view MODIFICATION LOG: Ver Date Author Description ----- ---------- ---------------- ------------------------------------------------------------------------------- 1.0 10/28/2020 ADRIANASILVEIRA 1. Built this table for IT240 DFNB Project1 RUNTIME: 0 min NOTES: This view shows the balance on December 31 per account. ******************************************************************************************************************/ CREATE VIEW dbo.v_balance_on_dec31 AS SELECT acct_id , as_of_date --AS [Varchar(50)]) , cur_bal FROM DFNB2.dbo.t_acct_fact WHERE month(as_of_date) = 12 GROUP BY acct_id , as_of_date , cur_bal;
true
a54ed54650985a12d8d3ef3025482d2cb087f4de
SQL
NASOKILA/04.Databases-Basics-MSSQL-Server
/08.Build In Functions/WildCards.sql
UTF-8
173
2.875
3
[]
no_license
SELECT EmployeeID, FirstName, LastName FROM Employees WHERE FirstName LIKE('%to') SELECT EmployeeID, FirstName, LastName FROM Employees WHERE FirstName LIKE('Te[tn]%')
true
0a2abf65bbaa4c568240c9a1531fecb89a42ef17
SQL
manwillaaron/client-keep
/db/init.sql
UTF-8
787
3.484375
3
[]
no_license
drop table expenses; drop table account_junc; drop table expense_account; drop table users; create table users ( id serial PRIMARY key, email text, hash text ); create table expense_account( account_id serial primary key, monthly_budget int, monthly_income int ); create table account_junc ( account_junc_id serial PRIMARY key, account_id int REFERENCES expense_account(account_id), id int REFERENCES users(id) ); create table expenses ( expense_id serial PRIMARY key, store text, amount int, date text, catagory VARCHAR(100), account_id int REFERENCES expense_account(account_id) ); create table patients ( id serial primary key, firstname varchar(15), lastname varchar(20), number varchar(12), email varchar(100) )
true
b1d5458adb607f22022a631a4caac73073e1a2ed
SQL
opengauss-mirror/openGauss-server
/contrib/file_fdw/file_fdw--1.0.sql
UTF-8
509
2.578125
3
[ "LicenseRef-scancode-mulanpsl-2.0-en", "LicenseRef-scancode-unknown-license-reference", "PostgreSQL", "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-unicode", "LicenseRef-scancode-warranty-disclaimer", "curl", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LGPL-2.1-only", "CC-BY-4.0", ...
permissive
/* contrib/file_fdw/file_fdw--1.0.sql */ -- complain if script is sourced in psql, rather than via CREATE EXTENSION \echo Use "CREATE EXTENSION file_fdw" to load this file. \quit CREATE FUNCTION pg_catalog.file_fdw_handler() RETURNS fdw_handler AS 'MODULE_PATHNAME' LANGUAGE C STRICT NOT FENCED; CREATE FUNCTION file_fdw_validator(text[], oid) RETURNS void AS 'MODULE_PATHNAME' LANGUAGE C STRICT NOT FENCED; CREATE FOREIGN DATA WRAPPER file_fdw HANDLER file_fdw_handler VALIDATOR file_fdw_validator;
true
a5fcbdb7da5127d33d135e2e981308f7784de880
SQL
Wils-Kris5/database-exercises
/adlister.sql
UTF-8
746
3.5
4
[]
no_license
CREATE DATABASE if not exists adlister_db; CREATE TABLE IF NOT EXISTS users ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, email VARCHAR(60), password VARCHAR(50), PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS ads ( id INT UNSIGNED NOT NULL, title VARCHAR(60), description VARCHAR(180), user_id INT UNSIGNED NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ); CREATE TABLE IF NOT EXISTS categories( id INT UNSIGNED NOT NULL, title VARCHAR(60), PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS ads_categories ( ads_id INT UNSIGNED NOT NULL, categories_id INT UNSIGNED NOT NULL, FOREIGN KEY (ads_id) REFERENCES ads(id), FOREIGN KEY (categories_id) REFERENCES categories(id) );
true
19e1e014577ceac90100923662b6f73e8a59e370
SQL
guopanboo/database
/mysql/view/view_powerstation_month_energy.sql
UTF-8
1,079
3.546875
4
[]
no_license
CREATE or replace VIEW view_powerstation_month_energy(pid, year, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, total) AS select POWERSTATION_ID as pid, FLG_YEAR as year, sum(if(FLG_MONTH='1', MONTH_ENERGY, 0)) as M1, sum(if(FLG_MONTH='2', MONTH_ENERGY, 0)) as M2, sum(if(FLG_MONTH='3', MONTH_ENERGY, 0)) as M3, sum(if(FLG_MONTH='4', MONTH_ENERGY, 0)) as M4, sum(if(FLG_MONTH='5', MONTH_ENERGY, 0)) as M5, sum(if(FLG_MONTH='6', MONTH_ENERGY, 0)) as M6, sum(if(FLG_MONTH='7', MONTH_ENERGY, 0)) as M7, sum(if(FLG_MONTH='8', MONTH_ENERGY, 0)) as M8, sum(if(FLG_MONTH='9', MONTH_ENERGY, 0)) as M9, sum(if(FLG_MONTH='10', MONTH_ENERGY, 0)) as M10, sum(if(FLG_MONTH='11', MONTH_ENERGY, 0)) as M11, sum(if(FLG_MONTH='12', MONTH_ENERGY, 0)) as M12, sum(MONTH_ENERGY) as TOTAL_ENERGY from cj_powerstation_month group by POWERSTATION_ID, FLG_YEAR ; select * from cj_powerstation_month where POWERSTATION_ID = 'f5041cd4-94db-44ea-94e8-e12a8f00ebd9' and FLG_YEAR = 2016 order by FLG_MONTH asc; select * from view_powerstation_month_energy;
true
a4b7a66a60fe0398a31ca26db7de9ab7ffccde79
SQL
Setorator/TDDD37
/lab4/c/Question10MakeBooking.sql
UTF-8
2,150
3.21875
3
[]
no_license
/****************************************************************************************** Question 10, concurrency This is the second of two scripts that tests that the BryanAir database can handle concurrency. This script sets up a valid reservation and tries to pay for it in such a way that at most one such booking should be possible (or the plane will run out of seats). This script should be run in both terminals, in parallel. **********************************************************************************************/ SELECT "Testing script for Question 10, Adds a booking, should be run in both terminals" as "Message"; SELECT "Adding a reservations and passengers" as "Message"; CALL addReservation("MIT","HOB",2010,1,"Monday","09:00:00",21,@a); CALL addPassenger(@a,00000031,"Saruman"); CALL addPassenger(@a,00000032,"Orch1"); CALL addPassenger(@a,00000033,"Orch2"); CALL addPassenger(@a,00000034,"Orch3"); CALL addPassenger(@a,00000035,"Orch4"); CALL addPassenger(@a,00000036,"Orch5"); CALL addPassenger(@a,00000037,"Orch6"); CALL addPassenger(@a,00000038,"Orch7"); CALL addPassenger(@a,00000039,"Orch8"); CALL addPassenger(@a,00000040,"Orch9"); CALL addPassenger(@a,00000041,"Orch10"); CALL addPassenger(@a,00000042,"Orch11"); CALL addPassenger(@a,00000043,"Orch12"); CALL addPassenger(@a,00000044,"Orch13"); CALL addPassenger(@a,00000045,"Orch14"); CALL addPassenger(@a,00000046,"Orch15"); CALL addPassenger(@a,00000047,"Orch16"); CALL addPassenger(@a,00000048,"Orch17"); CALL addPassenger(@a,00000049,"Orch18"); CALL addPassenger(@a,00000050,"Orch19"); CALL addPassenger(@a,00000051,"Orch20"); CALL addContact(@a,00000031,"saruman@magic.mail",080667989); SELECT SLEEP(5); SELECT "Making payment, supposed to work for one session and be denied for the other" as "Message"; lock tables allFlights read, credit_card read; CALL addPayment (@a, "Sauron",7878787879); unlock tables; SELECT "Nr of free seats on the flight (should be 19 if no overbooking occured, otherwise -2): " as "Message", (SELECT nr_of_free_seats from allFlights where departure_week = 1) as "nr_of_free_seats";
true
5260b6cd806590d464e7e9ddf30a2cc01277a6e3
SQL
Apostle8888/test_task_3
/src/main/java/Service/TablesDocPatRec.sql
UTF-8
2,064
4.09375
4
[]
no_license
CREATE TABLE IF NOT EXISTS DOCTORS ( ID BIGINT NOT NULL, FIRSTNAME VARCHAR(255) NOT NULL, SECONDNAME VARCHAR(255) NOT NULL, LASTNAME VARCHAR(255) NOT NULL, SPECIALIZATION VARCHAR(255) NOT NULL, CONSTRAINT DOCTORS_PKEY PRIMARY KEY (ID) ) CREATE TABLE IF NOT EXISTS PATIENTS ( ID BIGINT NOT NULL, FIRSTNAME VARCHAR(255) NOT NULL, SECONDNAME VARCHAR(255) NOT NULL, LASTNAME VARCHAR(255) NOT NULL, PHONE VARCHAR(255) NOT NULL, CONSTRAINT PATIENTS_PKEY PRIMARY KEY (ID) ) CREATE TABLE IF NOT EXISTS RECIPES ( ID BIGINT NOT NULL, DESCRIPTION VARCHAR(255) NOT NULL, RECDATE DATE NOT NULL, DURATION VARCHAR(255) NOT NULL, PRIORITY VARCHAR(255) NOT NULL, DOCTOR BIGINT NOT NULL, PATIENT BIGINT NOT NULL, CONSTRAINT RECIPES_PKEY PRIMARY KEY (ID), CONSTRAINT RECIPES_DOCTOR_FKEY FOREIGN KEY (DOCTOR) REFERENCES DOCTORS (ID), CONSTRAINT RECIPES_PATIENT_FKEY FOREIGN KEY (PATIENT) REFERENCES PATIENTS (ID) ) INSERT INTO DOCTORS (ID, FIRSTNAME, SECONDNAME, LASTNAME, SPECIALIZATION) VALUES (?, ?, ?, ?, ?) INSERT INTO PATIENTS (ID, FIRSTNAME, SECONDNAME, LASTNAME, PHONE) VALUES (?, ?, ?, ?, ?) INSERT INTO RECIPES (ID, DESCRIPTION, RECDATE, DURATION, PRIORITY, DOCTOR, PATIENT) VALUES (?, ?, ?, ?, ?, ?, ?) SELECT ID, FIRSTNAME, SECONDNAME, LASTNAME, SPECIALIZATION FROM DOCTORS SELECT ID, FIRSTNAME, SECONDNAME, LASTNAME, PHONE FROM PATIENTS SELECT ID, DESCRIPTION, RECDATE, DURATION, PRIORITY, DOCTOR, PATIENT FROM RECIPES SELECT ID, FIRSTNAME, SECONDNAME, LASTNAME, SPECIALIZATION FROM DOCTORS WHERE ID=? SELECT ID, FIRSTNAME, SECONDNAME, LASTNAME, PHONE FROM PATIENTS WHERE ID=? SELECT ID, DESCRIPTION, RECDATE, DURATION, PRIORITY, DOCTOR, PATIENT RECIPES WHERE DOCTOR=? AND PATIENT=? UPDATE DOCTORS SET FIRSTNAME=?, SECONDNAME=?, LASTNAME=?, SPECIALIZATION=? WHERE ID=? UPDATE PATIENTS SET FIRSTNAME=?, SECONDNAME=?, LASTNAME=?, PHONE=? WHERE ID=? UPDATE RECIPES SET DESCRIPTION=?, RECDATE=?, DURATION=?, PRIORITY=?, DOCTOR=?, PATIENT=? WHERE ID=? DELETE FROM DOCTORS WHERE ID=? DELETE FROM PATIENTS WHERE ID=? DELETE FROM RECIPES WHERE ID=?
true
e2f60334bcf5f47b2b2c4e28afb08c7549ce10e3
SQL
pedestrianlove/php
/guestbook/sql_command/guestbook2.sql
UTF-8
9,049
3.140625
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 2.10.3 -- http://www.phpmyadmin.net -- -- 主機: localhost -- 建立日期: Jun 08, 2011, 01:31 PM -- 伺服器版本: 6.0.4 -- PHP 版本: 6.0.0-dev SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- 資料庫: `guestbook2` -- -- CREATE DATABASE `guestbook` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; -- USE `b13_25362198_guestbook`; USE `tryDB`; -- -------------------------------------------------------- -- -- 資料表格式: `message` -- CREATE TABLE `message` ( `id` int(11) NOT NULL AUTO_INCREMENT, `author` varchar(10) NOT NULL DEFAULT '', `subject` tinytext NOT NULL, `content` text NOT NULL, `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ; -- -- 列出以下資料庫的數據: `message` -- INSERT INTO `message` VALUES (1, '陳小貞', '超級大富翁', '根據網路最新票選,網友們心目中最想看到蕭薔參加台視超級大富翁的節目,希望有一天真的可以看到蕭美人上陣。', '2004-08-01 15:28:36'); INSERT INTO `message` VALUES (2, '陳俊榮', '王力宏發新片了', '好消息告訴大家,王力宏發新片了,裡面有好聽的「龍的傳人」,建議大家可以用力聽聽看喔~!', '2004-08-01 15:30:03'); INSERT INTO `message` VALUES (3, '小咪', '狄鶯和孫鵬離婚了', '好勁爆的消息喔,甫生子的狄鶯才剛和孫鵬結婚,未料又旋風似的離婚了,令人不禁感嘆現代人的婚姻真難維繫。', '2004-08-01 15:32:34'); INSERT INTO `message` VALUES (4, '孫小美', '好戲鹿鼎記上場', '華視最近上演的新戲鹿鼎記,不僅女主角們陣容堅強,有朱茵、林心如、舒淇、陳法蓉...,更維持了張衛健一貫的搞笑風格,相當有看頭。', '2004-08-01 15:35:54'); INSERT INTO `message` VALUES (5, 'Amily', '酷酷的謝霆鋒', '記得日前謝霆鋒在記者會上,原本愉快的他,卻被記者問了 「如何當好繼父」的問題,而神情不快並斥責記者無聊,身為歌迷的我們,希望記者們不要再老是問一些這類的問題,多給歌手們一點私人空間。', '2004-08-01 15:38:29'); INSERT INTO `message` VALUES (6, '皮皮', '東東與張柏芝公佈戀情', '繼天后王菲與謝霆鋒公開戀情之後,又有一對俊男美女公開戀情,那就是東東和張柏芝,如果藝人們都勇於承認戀情,那麼狗仔隊可要失業了。', '2004-08-01 15:40:55'); INSERT INTO `message` VALUES (7, '颺', 'GiGi出精選集了', '梁詠琪 GiGi 在與鄭伊健的戀情風波之後,重新出發,推出了個人第一張精選集,內有膽小鬼、洗臉、短髮、愛的代價等好歌。', '2004-08-01 15:43:24'); INSERT INTO `message` VALUES (8, '阿淵', '魔女的條件重播', '哈日族最喜歡的魔女的條件又要重播了,這次是在東森綜合台,8 月 22 日 20:00 開始,喜歡菜菜子的朋友們千萬不要錯過了。', '2004-08-01 15:48:06'); INSERT INTO `message` VALUES (9, '阿淵', '神啊!請給我多一點時間要重播', '深田恭子和金城武合作演出的日劇 "神啊!請給我多一點時間" 要在東森綜合台重播,時間是 8 月 3 日 20:00。', '2004-08-01 15:52:02'); INSERT INTO `message` VALUES (10, '哈日寶寶', '惡作劇之吻要重播', '由漫畫改編的惡作劇之吻是一齣有趣的校園喜劇,男主角柏原崇個性孤傲,女主角佐藤藍子熱情活潑,衛視中文台將於 8 月 2日 20:00 重播該劇。', '2004-08-01 15:54:50'); INSERT INTO `message` VALUES (11, '哈日寶寶', '日本最具人氣藝人', '日本最近一本問卷統計出,十大最具人氣藝人分別為早安少女組、倉木麻衣、宇多田、椎名林禽、濱崎步、小柳由紀、優香、福山雅治、藤井龍和 AIKO。', '2004-08-01 15:58:59'); INSERT INTO `message` VALUES (12, '大餅', '中視八點挑戰金頭腦', '中視八點檔將於八月份推出益智節目,取代傳統的連續劇,對於不喜歡收看連續劇的朋友,這或野i以是另一個選擇。', '2004-08-01 16:01:06'); INSERT INTO `message` VALUES (13, '聽風在唱', '雙陳飛車記', '日前演出飛車追逐的雙陳,陳俊生、陳明真召開記者會,說明兩人並無發生衝突,更無腳踹車門,拉扯第三者之激烈動作,希望就此平息此風波。', '2004-08-01 16:03:45'); INSERT INTO `message` VALUES (14, '小倩', '徐若萱代言遠傳易付卡', '繼陳曉東之後,徐若萱成為遠傳易付卡的第二位代言人,而且該廣告已密集的在大各電視台播出,讓我們可以目睹徐若萱跳街舞的漫妙舞姿。', '2004-08-01 16:05:47'); INSERT INTO `message` VALUES (15, '佩佩', '吳宗憲新歡蜘蛛女', '原本以為吳宗憲在與陳孝萱分手之後會失志一陣子,沒想到這位天王有著通天本領,紅粉知己前仆後繼,立刻又傳出有蜘蛛女成為天王的新歡,看來天王是不會寂寞的。', '2004-08-01 16:08:46'); INSERT INTO `message` VALUES (16, '小倩', '大 S 徵求男友', '與酷龍傳出誹聞的大 S 日前在我猜我猜我猜猜的節目中,公開徵求男友,祝福大 S 早日找到適合的對象,能夠和小 S 一樣幸福的走上紅地毯的另一端。', '2004-08-01 16:10:47'); INSERT INTO `message` VALUES (17, '小聰明', '猜猜小叮噹的身高', '您知道小叮噹的身高和體重是一樣的數字嗎? 這是我在電視節目上看到的,答案是129.3喔。', '2004-08-01 16:13:51'); INSERT INTO `message` VALUES (18, '陳小貞', '天搖地動', '"天搖地動" 電影描述的是 1991 年 10 月漁船安麗雅號為了增加漁獲量,於是開往弗萊明角,未料當地氣象預告超級颶風葛瑞斯正在接近中,安麗雅號與其它船隻即將面臨前所未有的危機。', '2004-08-01 16:17:50'); INSERT INTO `message` VALUES (19, '陳俊榮', '超視八點新戲秋天的童話', '超視八點新戲秋天的童話是一個美麗純樸的少女、一個期待真愛的富家子弟、一個真心相待的青梅竹馬交織而成的美麗秋天童話,播出時間為 7 月 31 日起星期一到五晚間 10:00。', '2004-08-01 16:21:02'); INSERT INTO `message` VALUES (20, '阿淵', '臥虎藏龍開啟武俠電影新紀元', '國際知名導演李安的新作 "臥虎藏龍" 是第一部好萊塢投資的中國武俠電影,在台甫一推出便創下票房佳績。', '2004-08-01 16:24:00'); INSERT INTO `message` VALUES (21, 'Amily', '王菲開口 20 字就賺進 80 萬', '超級天后王菲在受邀參加一個網站的聊天室,只有開口說了 20 個字,有 80 萬元入袋,真是令人羨慕,而且天后還是保持著其一貫的酷酷作風,高興回答就回個是,不高興回答就不回答囉。', '2004-08-01 16:28:31'); INSERT INTO `message` VALUES (22, '小瓜呆', '張曼娟進駐 News98 八點檔', '張曼娟受 News98 電台之邀,將主持其八點檔之節目,內容將以溫馨導向。', '2004-08-01 17:48:19'); INSERT INTO `message` VALUES (23, '陳小貞', '蕭亞軒夏日薔薇演唱會', '新少男殺手蕭亞軒將於 8 月 26 日下午 6:00 舉辦個人演唱會,據唱片公司表示,這場演唱會斥資千萬,同時蕭亞軒正加緊努力排演中。', '2004-08-01 18:00:47'); INSERT INTO `message` VALUES (24, '李寶釵', '張國榮演唱會', '張國榮日前剛完成一場個人演唱會,在這場演唱會中,大家除了可以看到張國榮載歌載舞、精采萬分的演出之外,還可以看到大帥哥穿上數套裙裝的造型,真是讓女生看了也忌妒。', '2004-08-01 21:21:52'); INSERT INTO `message` VALUES (25, '小瓜呆', '七夕的雨', '昨天看到台視的超級大富翁節目,裡面有一個題目是七夕的雨是誰的眼瓷 A 答案分別為 1. 織女 2. 牛郎 3. 喜鵲 4. 王母娘娘,未料答題的情侶竟然回答喜鵲,喔,我的老天爺啊,真是好神奇的答案。', '2004-08-01 21:26:56'); INSERT INTO `message` VALUES (26, '小倩', '一窩蜂的益智節目', '回想在有線電視開放經營的時候,電視台一窩蜂的推出靈異節目,而現在,則是一窩蜂的推出益智節目,從星期一到星期五,幾乎天天都有,令人不禁感嘆,為何節目的製作人總是如此無創意,往往是互相抄襲,甚至很多節目是抄襲自日本,節目製作人請多多加油了。', '2004-08-01 21:31:06'); INSERT INTO `message` VALUES (27, '童言', '驚天動地 60 秒', '這部電影是描述藍道為一名頂尖的偷車賊,其最高記錄是在 60 秒之內偷走一部車。由於不希望自己的弟弟步其後塵,藍道決定金盆洗手,未料數年後,弟弟闖下大禍,藍道必須在四天內偷走 50 部名車,才能幫助弟弟,就在藍道開始動手的時候,過去來不及逮捕藍道的警方亦盯上他,最後,藍道能否在 24 小時之內完成任務解救弟弟呢?請看電影結局。', '2004-08-03 14:32:20');
true
d3599102fc1567e0e6413a2f849e0c59b2687827
SQL
Somesh1997/PJP_JAVA_TRAINING
/Restricting and sorting data/restrict4.sql
UTF-8
117
2.6875
3
[]
no_license
select last_name,job_id,hire_date from employees where last_name ='Matos' or last_name='Taylor' order by hire_date;
true
21b8a5f755865a7074856495413271cdbe30ca64
SQL
FreddieAbad/Ingenieria_de_Sistemas_Materias
/Bases de Datos 1 - Relacionales/Proyecto Interciclo/EntregaBD/ProcedimientosAlmacenados.sql
WINDOWS-1250
9,711
3.46875
3
[]
no_license
set serveroutput on size 30000; CREATE OR REPLACE PROCEDURE conteoEncuesta(id IN number,nombre in varchar2, descripcion in varchar2, idtipoencuesta in number) is total NUMBER; l_mensaje VARCHAR2(100) := 'Incorrecto!'; begin total :=0; select count(*) into total from encuesta where IDENCUESTA = id; if total=0 then insert into ENCUESTA values (id, nombre, descripcion, idtipoencuesta); ELSE DBMS_OUTPUT.put_line(l_mensaje); end if; end conteoEncuesta; begin conteoencuesta(773,'hola','hola',1); commit; end; --join de tablas respuesta con encuesta select count(*) from encuesta e inner join respuestaopcionmultiple r on e.idencuesta=r.idencuesta and r.idusuario='0104496765' inner join respuestatexto re on re.idencuesta=e.idencuesta and re.idusuario='0104496765'; -------------------------------------------------------------------------------------------------------------------------------- ------------------------PROCEDIMIENTO VERIFICACION MAS DE 10 ENCUESTAS---------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- ---procedimiento conteo mas de 10 encuestas '0104496765' set serveroutput on size 30000; CREATE OR REPLACE PROCEDURE conteoEncuestaUsuario(ci varchar2, suscripcion out number) is total number; mensajeAdelante VARCHAR2(100) := 'Adelante!'; mensajeAlto VARCHAR2(100) := 'Contrata una suscripcion!'; begin total:=0; suscripcion:=0; select count(*) into total from encuesta e inner join respuestaopcionmultiple r on e.idencuesta=r.idencuesta and r.idusuario=ci inner join respuestatexto re on re.idencuesta=e.idencuesta and re.idusuario=ci; if total>10 then suscripcion:=0; DBMS_OUTPUT.put_line(mensajeAlto); else suscripcion:=1; DBMS_OUTPUT.put_line(mensajeAdelante); end if; end conteoEncuestaUsuario; --------------INICIO PRUEBA VERIFICACION COMPRA MEMBRESIA declare returnvalue NUMBER; salida NUMBER; begin conteoEncuestaUsuario('0104496765',returnvalue); DBMS_OUTPUT.PUT_LINE (returnvalue); commit; end; --------------INICIO PRUEBA ADELANTE declare returnvalue NUMBER; salida NUMBER; begin conteoEncuestaUsuario('010446765',returnvalue); DBMS_OUTPUT.PUT_LINE (returnvalue); commit; end; ------ LISTO -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------VALIDACION CEDULA------------------------------------------------------------ -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- CREATE OR REPLACE PROCEDURE validarCIEC(ci in varchar2, valido out number) is verificador number; finalS number; suma number; aux number; begin suma :=0; aux:=0; valido:=0; verificador:=to_number(substr(ci,-1)); if to_number(substr(ci,1,2))<24 then if to_number(substr(ci,3,1))<6 then FOR i IN 1..9 LOOP if MOD(i,2) = 0 then aux :=TO_NUMBER((SUBSTR(ci,i,1))); if aux >=10 then aux :=aux -9; end if; else aux := TO_NUMBER((SUBSTR(ci,i,1)))*2; if aux >=10 then aux :=aux -9; end if; end if; suma := suma + aux; aux:=0; END LOOP; end if; finalS:=suma+verificador; if mod(finalS,10)=0 then DBMS_OUTPUT.PUT_LINE ('Cedula Correcta'); valido:=1; else DBMS_OUTPUT.PUT_LINE ('Cedula Incorrecta'); valido:=0; end if; else DBMS_OUTPUT.PUT_LINE ('Cedula Incorrecta'); valido:=0; end if; end validarCIEC; --LISTO VALIDACION --PRUEBA CORRECTA declare returnvalue NUMBER; begin validarCIEC('0104496765',returnvalue); DBMS_OUTPUT.PUT_LINE (returnvalue); commit; end; ----INCORRECTA declare returnvalue NUMBER; begin validarCIEC('0104497765',returnvalue); DBMS_OUTPUT.PUT_LINE (returnvalue); commit; end; SELECT LENGTH(TRIM(TRANSLATE('1f2cccc3', ' +-.0123456789',' '))) FROM dual; -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- --------------------Procedimiento Separar Respuesta Numerica Texto de OM ------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- create or replace procedure preguntaAlphaNumOpcionM(ci varchar2, respuestasNum in out varchar2,respuestasString out varchar2) is numRespuesta number; respuestaOM varchar2(500):=''; validacion number; salidaT varchar2(3900) := ''; salidaN varchar2(3900) := ''; idrom varchar2(100):=''; idp varchar2(100):=''; ide varchar2(100):=''; ido varchar2(100):=''; begin numRespuesta:=0; respuestasString:=''; respuestasNum:=''; select count(o.nombreopcion) into numRespuesta from encuesta e inner join respuestaopcionmultiple r on e.idencuesta=r.idencuesta and r.idusuario=ci inner join opciones o on o.idopcion=r.idopcion and r.idusuario=ci; for i in 1..numRespuesta LOOP select o.nombreopcion,r.idrespuestaopcionmultiple,r.idpregunta,r.idencuesta,r.idopcion into respuestaOM,idrom,idp,ide,ido from encuesta e inner join respuestaopcionmultiple r on e.idencuesta=r.idencuesta and r.idusuario=ci inner join opciones o on o.idopcion=r.idopcion and r.idusuario=ci; SELECT LENGTH(TRIM(TRANSLATE(respuestaOM, ' +-.0123456789',' '))) into validacion FROM dual; if validacion>=1 then salidaT:=salidaT || ' ' || TO_CHAR(idrom) || ' ' || TO_CHAR(idp)|| ' ' || TO_CHAR(ide) || ' ' || TO_CHAR(ido)|| ' ' || respuestaOM || '~'; else salidaN:=salidaN || ' ' || TO_CHAR(idrom) || ' ' || TO_CHAR(idp)|| ' ' || TO_CHAR(ide) || ' ' || TO_CHAR(ido)|| ' ' || respuestaOM || '~'; end if; respuestaOM:=''; end loop; DBMS_OUTPUT.PUT_LINE (respuestasString); DBMS_OUTPUT.PUT_LINE (respuestasNum); --if condicion=1 then respuestasString:=salidaT; --else respuestasNum:=salidaN; --end if; end; --listo --inicio prueba declare returnTexto varchar2(3950); returnNum varchar2(3950); begin preguntaAlphaNumOpcionM('1111111111',returnNum,returnTexto); DBMS_OUTPUT.PUT_LINE (returnTexto); DBMS_OUTPUT.PUT_LINE (returnNum); commit; end; --LISTO -------------------------------------------------------------------------------------------------------------------------------- ----------------------------PROC SEPARAR RESPUESTAS NUMERICAS DE TEXTO EN RESPUESTAS TEXTO-------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- create or replace procedure preguntaAlphaNumTexto(ci varchar2, respuestasNum in out varchar2,respuestasString out varchar2) is numRespuesta number; respuestaT varchar2(500):=''; validacion number; -- si es mayor a 1 es texto, si es null es numero salidaT varchar2(3900) := ''; salidaN varchar2(3900) := ''; idrt varchar2(100):=''; idp varchar2(100):=''; ide varchar2(100):=''; begin numRespuesta:=0; respuestasString:=''; respuestasNum:=''; select count(r.respuesta) into numRespuesta from encuesta e inner join respuestatexto r on e.idencuesta=r.idencuesta and r.idusuario=ci; for i in 1..numRespuesta LOOP select r.respuesta,r.idrespuestatexto,r.idpregunta,r.idencuesta into respuestaT,idrt,idp,ide from encuesta e inner join respuestatexto r on e.idencuesta=r.idencuesta and r.idusuario=ci; SELECT LENGTH(TRIM(TRANSLATE(respuestaT, ' +-.0123456789',' '))) into validacion FROM dual; if validacion>=1 then salidaT:=salidaT || ' ' || TO_CHAR(idrt) || ' ' || TO_CHAR(idp)|| ' ' || TO_CHAR(ide) || ' ' || respuestaT || '~'; else salidaN:=salidaN || ' ' || TO_CHAR(idrt) || ' ' || TO_CHAR(idp)|| ' ' || TO_CHAR(ide) || ' ' || respuestaT || '~'; end if; respuestaT:=''; end loop; respuestasString:=salidaT; respuestasNum:=salidaN; end preguntaAlphaNumTexto; --listo --inicio prueba declare returnTexto varchar2(3950); returnNum varchar2(3950); begin preguntaAlphaNumTexto('0104301338',returnNum,returnTexto); DBMS_OUTPUT.PUT_LINE (returnTexto); DBMS_OUTPUT.PUT_LINE (returnNum); commit; end; --LISTO
true
e8ae6b59efa8b923bd327ca03bd476a716c6a988
SQL
danton2000/Projeto_Celular_PHP
/Projeto_Celular/banco/bdcelular.sql
UTF-8
5,987
3.234375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.9.1 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Tempo de geração: 16-Abr-2020 às 16:57 -- Versão do servidor: 10.4.8-MariaDB -- versão do PHP: 7.2.24 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Banco de dados: `bdcelular` -- CREATE DATABASE IF NOT EXISTS `bdcelular` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; USE `bdcelular`; -- -------------------------------------------------------- -- -- Estrutura da tabela `tbadmin` -- CREATE TABLE `tbadmin` ( `id_adm` int(11) NOT NULL, `nome_adm` varchar(150) NOT NULL, `login_adm` varchar(80) NOT NULL, `senha_adm` varchar(8) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Extraindo dados da tabela `tbadmin` -- INSERT INTO `tbadmin` (`id_adm`, `nome_adm`, `login_adm`, `senha_adm`) VALUES (1, 'danton', 'danton', '1'), (2, 'Fabio', 'fabio', '1'); -- -------------------------------------------------------- -- -- Estrutura da tabela `tbcelular` -- CREATE TABLE `tbcelular` ( `id_cel` int(11) NOT NULL, `nome_cel` varchar(80) DEFAULT NULL, `memoria_cel` varchar(80) DEFAULT NULL, `armazenamento_cel` varchar(80) DEFAULT NULL, `preco_cel` decimal(6,2) DEFAULT NULL, `tela_cel` varchar(80) DEFAULT NULL, `sistema_cel` varchar(80) DEFAULT NULL, `camera_cel` varchar(80) DEFAULT NULL, `fk_id_adm` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Extraindo dados da tabela `tbcelular` -- INSERT INTO `tbcelular` (`id_cel`, `nome_cel`, `memoria_cel`, `armazenamento_cel`, `preco_cel`, `tela_cel`, `sistema_cel`, `camera_cel`, `fk_id_adm`) VALUES (1, 'Xiaomi Redmi Go', '1 GB', '16 GB', '400.00', '5 Pol', 'Android', '8 MP', NULL), (2, 'Samsung Galaxy J6', '2 GB', '32 GB', '860.00', '5 Pol', 'Android ', '13 MP', NULL), (3, 'Moto G7 Play', '2 GB', '32 GB', '650.00', '6 Pol ', 'Android ', '13 MP', NULL), (4, 'LG K12 Plus', '3 GB', '32 GB', '700.00', '6 Pol', 'Android ', '16 MP', NULL), (5, 'Moto G7 Power', '3 GB', '32 GB', '900.00', '6 Pol', 'Android ', '8 MP', NULL), (6, 'Galaxy A30', '4 GB', '64 GB', '1100.00', '6 Pol', 'Android ', '16 MP', NULL), (7, 'Zenfone Max Shot', '3 GB', '32 GB', '1000.00', '6 Pol', 'Android ', '8 MP', NULL), (8, 'Galaxy M30', '4 GB', '64 GB', '1100.00', '6 Pol', 'Android ', '13 MP', NULL), (9, 'Moto Z3 Play', '4 GB', '64 GB', '1400.00', '6 Pol ', 'Android ', '12 MP', NULL), (10, 'Moto G7 Plus', '4 GB', '64 GB', '1300.00', '6 Pol', 'Android ', '16 MP ', NULL), (11, 'Zenfone 5', '4 GB', '64 GB', '1600.00', '6 Pol', 'Android ', '12 MP', NULL), (12, 'Xiaomi Mi 8 Lite', '4 GB ', '64 GB', '1000.00', '6 Pol', 'Android ', '12 MP', NULL), (13, 'Motorola One Vision', '4 GB ', '128 GB', '1500.00', '6 Pol', 'Android ', '25 MP ', NULL), (14, 'Redmi Note 7 ', '3 GB ', '32 GB', '1000.00', '6 Pol', 'Android ', '13 MP ', NULL), (15, 'Galaxy A70', '6 GB', '128 GB', '1800.00', '7 Pol', 'Android ', '32 MP ', NULL), (16, 'iPhone 8 Plus', '8 GB', '64 GB', '4600.00', '5 Pol', 'iOS', '12 MP', NULL), (17, 'Galaxy S9 Plus', '6 GB', '128 GB', '2600.00', '6 Pol', 'Android ', '12 MP ', NULL), (18, 'Huawei P30 Pro', '8 GB ', '256 GB', '5000.00', '6 Pol', 'Android ', '40 MP ', NULL), (19, 'iPhone XR', '3 GB', '64 GB', '3900.00', '6 Pol', 'iOS', '12 MP ', NULL), (20, 'Xiaomi Mi 9', '6 GB', '128 GB', '2400.00', '6 Pol', 'Android ', '48 MP', NULL), (21, 'Galaxy S10e', '6 GB', '128 GB', '2800.00', '6 Pol', 'Android ', '12 MP', NULL), (22, 'iPhone XS Max', '4 GB', '64 GB', '6200.00', '6 Pol', 'iOS', '12 MP ', NULL), (23, 'Galaxy S10 Plus', '8 GB', '128 GB', '3500.00', '6 Pol', 'Android ', '12 MP', NULL), (26, 'Galaxy A50', '4 GB', '64 GB', '1600.00', '6 Pol', 'Android', '25 MP', NULL), (27, 'Multilaser MS50L', '1 GB', '8 GB', '350.00', '5 Pol', 'Android', '8 MP', NULL), (28, 'Mirage 62S ', '1 GB', '8 GB', '370.00', '5 Pol', 'Android', '8 MP', NULL), (29, 'Samsung Galaxy M10', '3 GB', '32 GB', '750.00', '6 Pol', 'Android ', '13 MP', NULL), (31, 'Samsung Galaxy Note 7', '6 GB ', '128 GB', '3000.00', '6 Pol', 'Android ', '12 MP ', NULL), (32, 'Multilaser ms60X', '2 GB', '16 GB', '800.00', '5 Pol', 'Android', '13 MP', NULL); -- -------------------------------------------------------- -- -- Estrutura da tabela `tbcontatos` -- CREATE TABLE `tbcontatos` ( `id_contato` int(11) NOT NULL, `nome_contato` varchar(100) NOT NULL, `email_contato` varchar(100) NOT NULL, `senha_contato` varchar(200) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Índices para tabelas despejadas -- -- -- Índices para tabela `tbadmin` -- ALTER TABLE `tbadmin` ADD PRIMARY KEY (`id_adm`); -- -- Índices para tabela `tbcelular` -- ALTER TABLE `tbcelular` ADD PRIMARY KEY (`id_cel`); -- -- Índices para tabela `tbcontatos` -- ALTER TABLE `tbcontatos` ADD PRIMARY KEY (`id_contato`); -- -- AUTO_INCREMENT de tabelas despejadas -- -- -- AUTO_INCREMENT de tabela `tbadmin` -- ALTER TABLE `tbadmin` MODIFY `id_adm` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT de tabela `tbcelular` -- ALTER TABLE `tbcelular` MODIFY `id_cel` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34; -- -- AUTO_INCREMENT de tabela `tbcontatos` -- ALTER TABLE `tbcontatos` MODIFY `id_contato` int(11) NOT NULL AUTO_INCREMENT; -- -- Restrições para despejos de tabelas -- -- -- Limitadores para a tabela `tbcelular` -- ALTER TABLE `tbcelular` ADD CONSTRAINT `fk_id_adm` FOREIGN KEY (`fk_id_adm`) REFERENCES `tbadmin` (`id_adm`) ON DELETE CASCADE ON UPDATE CASCADE; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
d086f8f75878a8c4b4d57e1b732c86973ec39616
SQL
Geeta-hub/SQL_Repo
/QueryProject.sql
MacCentralEurope
23,467
3.375
3
[]
no_license
USE Student CREATE TABLE studies( PNAME varchar(50), INSTITUTE varchar(50), COURSE varchar(10), COURSEFEE money) INSERT INTO studies VALUES ('ANAND','SABHARI','PGDCA',4500), ('ALTAF','COIT','DCA',7200), ('JULIANA','BDPS','MCA',22000), ('KAMALA','PRAGATHI','DCA',5000), ('MARY','SABHARI','PGDCA',4500), ('NELSON','PRAGATHI','DAP',6200), ('PATRICK','PRAGATHI','DCAP',5200), ('QADIR','APPLE','HDCA',14000), ('RAMESH','SABHARI','PGDCA',4500), ('REBECCA','BRILLIANT','DCAP',11000), ('REVATHI','SABHARI','DAP',5000), ('VIJAYA','BDPS','DCA',48000) SELECT * FROM studies CREATE TABLE software( PNAME VARCHAR(50), TITLE VARCHAR(50), DEVELOPIN VARCHAR(50), SCOST MONEY, DCOST MONEY, SOLD INT) INSERT INTO software VALUES ('MARY','README','CPP',300,1200,84), ('ANAND','PARACHUTES','BASIC',399.95,6000,43), ('ANAND','VIDEO TITLING','PASCAL',7500,16000,9), ('JULIANA','INVENTORY','COBOL',3000,3500,0), ('KAMALA','PAYROLL PKG.','DBASE',9000,20000,0), ('MARY','FINANCIAL ACCT','ORACLE',18000,85000,4), ('PATTRICK','README','CPP',300,1200,84), ('QADIR','BOMBS AWAY','ASSEMBLY',750,3000,11), ('RAMESH','HOTEL MGMT','DBASE',13000,35000,4), ('RAMESH', 'DEAD LEE','PASCAL',599.95,4500,73), ('REMITHA','PC UTITIES','C',725,5000,51), ('REMITHA','TSR HELP PKG.','ASSEMBLY',2500,6000,7), ('REVATHI','HOSPITAL MGMT','PASCAL',1100,75000,2), ('VIJAYA','TSR EDITOR','C',900,700,6) CREATE TABLE programmer( PNAME VARCHAR(50), DOB DATE, DOJ DATE, GENDER CHAR(1), PROF1 VARCHAR(25), PROF2 VARCHAR(25), SALARY MONEY) INSERT INTO programmer VALUES ('ANAND','12-APR-66','21-APR-92','M','PASCAL','BASIC',3200), ('ALTAF','02-JUN-64','13-NOV-90','M','CLIPPER','COBOL',2800), ('JULIANA','31-JAN-60','21-APR-90','F','COBOL','DBASE',3000), ('KAMALA','30-OCT-68','02-JAN-92','F','C','DBASE',2900), ('MARY','24-JUN-70','01-FEB-91','F','CPP','ORACLE',4500), ('NELSON','11-SEP-85','11-OCT-89','M','COBOL','DBASE',2500), ('PATTRICK','10-NOV-65','21-APR-90','M','PASCAL','CLIPPER',2800), ('QADIR','31-AUG-65','21-APR-91','M','ASSEMBLY','C',3000), ('RAMESH','03-MAY-67','28-FEB-91','M','PASCAL','DBASE',3200), ('REBECCA','01-JAN-67','01-DEC-90','F','BASIC','COBOL',2500), ('REMITHA','19-APR-70','20-APR-93','F','C','ASSEMBLY',3600), ('REVATHI','02-DEC-69','02-JAN-92','F','PASCAL','BASIC',3700), ('VIJAYA','14-DEC-65','02-MAY-92','F','FOXPRO','C',3500) --1. Find out the selling cost AVG for packages developed in Pascal. SELECT AVG(SCOST) FROM software WHERE DEVELOPIN IN ('PASCAL','pascal') --2. Display Names, Ages of all Programmers. SELECT PNAME, YEAR(GETDATE()) - YEAR(DOB) AS AGE FROM programmer --3. Display the Names of those who have done the DAP Course. SELECT PNAME, COURSE FROM studies WHERE COURSE IN ('DAP', 'dap') --4. Display the Names and Date of Births of all Programmers Born in January. SELECT PNAME, DOB FROM programmer WHERE MONTH(DOB) = 1 --5. What is the Highest Number of copies sold by a Package. SELECT MAX(SOLD) AS HIGHEST_COPIES FROM software --6. Display lowest course Fee. SELECT MIN(COURSEFEE) FROM studies --7. How many programmers done the PGDCA Course? SELECT COUNT(PNAME) FROM studies WHERE COURSE IN ('PGDCA','pgdca') --8. How much revenue has been earned thru sales of Packages Developed in C. SELECT SUM(SCOST*SOLD) AS REVENUE FROM software WHERE DEVELOPIN IN ('C','c') --9. Display the Details of the Software Developed by Ramesh. SELECT PNAME, TITLE, DEVELOPIN FROM software WHERE PNAME IN ('RAMESH','ramesh') --10. How many Programmers Studied at Sabhari. SELECT COUNT(PNAME) FROM studies WHERE INSTITUTE IN ('SABHARI','sabhari') --11. Display details of Packages whose sales crossed the 2000 Mark. SELECT * FROM software WHERE (SCOST*SOLD) >2000 --12. Display the Details of Packages for which Development Cost have been recovered. SELECT * FROM software WHERE SCOST*SOLD > DCOST --13. What is the cost of the costliest software development in Basic SELECT MAX(DCOST) FROM software WHERE DEVELOPIN IN ('BASIC','basic') --14. How many Packages Developed in DBASE. SELECT COUNT(TITLE) FROM software WHERE DEVELOPIN IN ('DBASE','dbase') --15. How many programmers studied in Pragathi. SELECT COUNT(PNAME) FROM studies WHERE INSTITUTE IN ('PRAGATHI','pragathi') --16. How many Programmers Paid 5000 to 10000 for their course? SELECT COUNT(PNAME) FROM studies WHERE COURSEFEE BETWEEN 5000 AND 10000 --17. What is AVG Course Fee? SELECT AVG(COURSEFEE) FROM studies --18. Display the details of the Programmers Knowing C. SELECT * FROM programmer WHERE PROF1 IN ('C','c') OR PROF2 IN ('C','c') --19. How many Programmers know either COBOL or PASCAL. SELECT COUNT(*) FROM programmer WHERE PROF1 IN ('COBOL','cobol','PASCAL','pascal') OR PROF2 IN ('COBOL','cobol','PASCAL','pascal') --20. How many Programmers Dont know PASCAL and C SELECT COUNT(*) FROM programmer WHERE PROF1 NOT IN ('PASCAL','pascal','C','c') AND PROF2 NOT IN ('PASCAL','pascal','C','c') --21. How old is the Oldest Male Programmer. SELECT MAX(DATEDIFF(YY,DOB,GETDATE())) AS AGE FROM programmer WHERE GENDER IN ('M','m') --22. What is the AVG age of Female Programmers. SELECT AVG(DATEDIFF(YY,DOB,GETDATE())) FROM programmer WHERE GENDER IN ('F','f') --23. Calculate the Experience in Years for each Programmer and Display with their names in Descending order. SELECT PNAME, DATEDIFF(YY,DOJ,GETDATE()) AS EXPERIENCE FROM programmer ORDER BY EXPERIENCE DESC --24. Who are the Programmers who celebrate their Birthdays During the Current Month. SELECT PNAME, DOB FROM programmer WHERE MONTH(DOB) = MONTH(GETDATE()) --25. How many Female Programmers Are There. SELECT COUNT(PNAME) FROM programmer WHERE GENDER IN ('F','f') --26. What are the Languages studied by Male Programmers. SELECT DISTINCT PROF2 AS LANGUAGES FROM programmer WHERE GENDER IN ('M','m') UNION SELECT DISTINCT PROF2 FROM programmer WHERE GENDER IN ('M','m') --27. What is the AVG Salary. SELECT ROUND(AVG(SALARY),2) AS AVG_SAL FROM programmer --28. How many people draw salary 2000 to 4000. SELECT COUNT(*) FROM programmer WHERE SALARY BETWEEN 2000 AND 4000 --29. Display the details of those who dont know Clipper, COBOL or PASCAL. SELECT * FROM programmer WHERE PROF1 NOT IN('CLIPPER','clipper','COBOL','cobol','PASCAL','pascal') AND PROF2 NOT IN('CLIPPER','clipper','COBOL','cobol','PASCAL','pascal') --30. Display the Cost of Package Developed By each Programmer. SELECT PNAME, DCOST, SCOST FROM software --31. Display the sales values of the Packages Developed by the each Programmer. SELECT PNAME, TITLE, SCOST FROM software --32. Display the Number of Packages sold by Each Programmer. SELECT PNAME,COUNT(SOLD) AS NO_PACKAGES FROM software GROUP BY PNAME --33. Display the sales cost of the packages Developed by each Programmer Language wise. SELECT PNAME, DEVELOPIN, SUM(SCOST) AS COST_PACKAGES FROM software GROUP BY PNAME, DEVELOPIN --34. Display each language name with AVG Development Cost, AVG Selling Cost and AVG Price Per Copy SELECT DEVELOPIN AS LANGUAGE, AVG(DCOST) AS AVG_DCOST, AVG(SCOST) AS AVG_SCOST, AVG(SOLD) AS AVG_PRICE_COPY FROM software GROUP BY DEVELOPIN --35. Display each programmers name, costliest and cheapest Packages Developed by him or her. SELECT PNAME, MAX(DCOST) AS COSTLIEST_PCK, MIN(DCOST) AS CHEAPEST_PCK FROM software GROUP BY PNAME --36. Display each institute name with number of Courses, Average Cost Per Course. SELECT INSTITUTE, COUNT(COURSE) AS COURSES, AVG(COURSEFEE) AVG_PER_COURSE FROM studies GROUP BY INSTITUTE --37. Display each institute Name with Number of Students. SELECT INSTITUTE, COUNT(PNAME) AS NO_STUDENTS FROM studies GROUP BY INSTITUTE --38. Display Names of Male and Female Programmers. Gender also. SELECT PNAME, GENDER FROM programmer --39. Display the Name of Programmers and Their Packages SELECT PNAME, SALARY*12 AS SAL_PACKAGE FROM programmer --40. Display the Number of Packages in Each Language Except C and C++. SELECT DEVELOPIN, COUNT(TITLE) AS NO_PKG FROM software GROUP BY DEVELOPIN HAVING DEVELOPIN NOT IN ('C','c','C++','c++') --41. Display the Number of Packages in Each Language for which Development Cost is less than 1000. SELECT DEVELOPIN, COUNT(TITLE) AS NO_PKG FROM software WHERE DCOST < 1000 GROUP BY DEVELOPIN --42. Display AVG Difference between SCOST, DCOST for Each Package SELECT TITLE, ABS(AVG(SCOST) - AVG(DCOST)) AS DIFF_SCOST_DCOST FROM software GROUP BY TITLE --43. Display the total SCOST, DCOST and amount to be recovered for each Programmer for --Those Whose Cost has not yet been Recovered. SELECT SUM(SCOST) TOTAL_SCOST, SUM(DCOST) AS TOTAL_DCOST, ABS(SUM(SCOST)-SUM(DCOST)) AS AMT_TOBE_RECOVERED FROM software GROUP BY PNAME --44. Display Highest, Lowest and Average Salaries for those earning more than 2000. SELECT MAX(SALARY) AS HIGHEST_SAL, MIN(SALARY) AS LOWEST_SAL, AVG(SALARY) AS AVG_SAL FROM programmer WHERE SALARY >2000 --45. Who is the Highest Paid C Programmers. SELECT PNAME, SALARY FROM programmer WHERE SALARY IN( SELECT MAX(SALARY) FROM programmer WHERE (PROF1 IN ('C','c') OR PROF2 IN ('C','c'))) --46. Who is the Highest Paid Female COBOL Programmer. SELECT * FROM programmer WHERE GENDER IN ('F','f') AND SALARY IN( SELECT MAX(SALARY) FROM programmer WHERE (PROF1 IN ('COBOL','cobol') OR PROF2 IN ('COBOL','cobol')) AND GENDER IN ('F','f')) --47. Display the names of the highest paid programmers for each Language. SELECT PROF1,MAX(SALARY) FROM programmer GROUP BY PROF1 UNION SELECT PROF2, MAX(SALARY) FROM programmer GROUP BY PROF2 --48. Who is the least experienced Programmer. SELECT PNAME, DOJ FROM programmer WHERE DOJ IN (SELECT MAX(DOJ) FROM programmer) -- 49. Who is the most experienced male programmer knowing PASCAL. SELECT TOP(1) PNAME,MIN(DATEDIFF(YY,DOJ,GETDATE())) AS EXPERIENCE, DOJ FROM programmer WHERE GENDER = 'M' AND (PROF1 IN ('PASCAL','pascal') or PROF2 IN ('PASCAL','pascal') ) GROUP BY PNAME, DOJ --50. Which Language is known by only one Programmer. SELECT PROF1, COUNT(PROF1) AS NO_PEOPLE FROM programmer WHERE PROF1 NOT IN (SELECT PROF2 FROM programmer) GROUP BY PROF1 HAVING COUNT(PROF1) = 1 UNION SELECT PROF2, COUNT(PROF2) AS NO_PEOPLE FROM programmer WHERE PROF2 NOT IN (SELECT PROF1 FROM programmer) GROUP BY PROF2 HAVING COUNT(PROF2) = 1 --51. Who is the Above Programmer Referred in 50 SELECT PNAME FROM PROGRAMMER WHERE PROF1 IN((SELECT PROF1 FROM programmer GROUP BY PROF1 HAVING COUNT(PROF1) <= 1 EXCEPT SELECT PROF2 FROM programmer GROUP BY PROF2 HAVING COUNT(PROF2) <=1) EXCEPT SELECT PROF2 FROM programmer) UNION SELECT PNAME FROM PROGRAMMER WHERE PROF2 IN((SELECT PROF2 FROM programmer GROUP BY PROF2 HAVING COUNT(PROF2) <= 1 EXCEPT SELECT PROF1 FROM programmer GROUP BY PROF1 HAVING COUNT(PROF1) <=1) EXCEPT SELECT PROF1 FROM programmer) --52. Who is the Youngest Programmer knowing DBASE. SELECT PNAME , DOB FROM programmer WHERE (PROF1 IN ('DBASE','dbase') OR PROF2 IN ('DBASE','dbase')) AND DOB IN (SELECT MAX(DOB) FROM programmer) --53. Which Female Programmer earning more than 3000 does not know C, C++, ORACLE or DBASE. SELECT PNAME, PROF1, PROF2, SALARY FROM programmer WHERE GENDER IN ('F','f') AND (PROF1 IN ('C','C++','ORACLE','DBASE') OR PROF1 IN ('C','C++','ORACLE','DBASE')) AND SALARY > 3000 --54. Which Institute has most number of Students. SELECT TOP 1 INSTITUTE, COUNT(PNAME) AS NO_STU FROM studies GROUP BY INSTITUTE ORDER BY NO_STU DESC --55. What is the Costliest course. SELECT COURSE, COURSEFEE FROM studies WHERE COURSEFEE = (SELECT MAX(COURSEFEE) FROM studies) --56. Which course has been done by the most of the Students. SELECT TOP 2 COUNT(PNAME) AS NO_STUDENTS, COURSE FROM studies GROUP BY COURSE ORDER BY NO_STUDENTS DESC --57. Which Institute conducts costliest course. SELECT INSTITUTE, COURSEFEE FROM studies WHERE COURSEFEE = (SELECT MAX(COURSEFEE) FROM studies) --58. Display the name of the Institute and Course, which has below AVG course fee. SELECT INSTITUTE, COURSE, COURSEFEE FROM studies WHERE COURSEFEE < (SELECT AVG(COURSEFEE) FROM studies) --59. Display the names of the courses whose fees are within 1000 (+ or -) of the Average Fee. SELECT COURSE FROM studies GROUP BY COURSE HAVING AVG(COURSEFEE) < 1000 OR AVG(COURSEFEE) >1000 --60. Which package has the Highest Development cost. SELECT TITLE FROM software WHERE DCOST = (SELECT MAX(DCOST) FROM software) --61. Which course has below AVG number of Students. SELECT COURSE,COUNT(Course) AS STUDENTS_COUNT FROM STUDIES GROUP BY COURSE HAVING COUNT(COURSE) < = (SELECT SUM(C)/COUNT(C) FROM (SELECT COUNT(COURSE) AS C from studies GROUP BY COURSE) AS MYTABLE) --62. Which Package has the lowest selling cost. SELECT DISTINCT TITLE FROM software WHERE SCOST = (SELECT MIN(SCOST) FROM software) --63. Who Developed the Package that has sold the least number of copies. SELECT PNAME, TITLE FROM software WHERE SOLD = (SELECT MIN(SOLD) FROM software) --64. Which language has used to develop the package, which has the highest sales amount. SELECT DISTINCT DEVELOPIN, TITLE, SOLD FROM software WHERE SOLD = (SELECT MAX(SOLD) FROM software) --65.How many copies of package that has the least difference between development and selling cost where sold. SELECT TITLE, SOLD FROM software WHERE ABS(DCOST-SCOST) = (SELECT MIN(ABS(DCOST-SCOST)) FROM software) --66. Which is the costliest package developed in PASCAL. SELECT TITLE, DEVELOPIN FROM software WHERE DCOST = (SELECT MAX(DCOST) FROM software WHERE DEVELOPIN IN ('PASCAL','pascal')) --67. Which language was used to develop the most number of Packages. SELECT DISTINCT DEVELOPIN FROM software WHERE SOLD = (SELECT MAX(SOLD) FROM software) --68. Which programmer has developed the highest number of Packages. SELECT TOP 1 PNAME FROM software WHERE SOLD = (SELECT MAX(SOLD) FROM software) --69. Who is the Author of the Costliest Package. SELECT PNAME FROM software WHERE SCOST = (SELECT MAX(SCOST) FROM software) --70. Display the names of the packages, which have sold less than the AVG number of copies. SELECT TITLE, SOLD FROM software WHERE SOLD < (SELECT AVG(SOLD) FROM software) --71.Who are the authors of the Packages, which have recovered more than double the Development cost. SELECT PNAME, TITLE, DCOST FROM software WHERE ((DCOST-SCOST)*SOLD) > 2*DCOST --72. Display the programmer Name and the cheapest packages developed by them in each language. SELECT PNAME,DEVELOPIN, MIN(DCOST) FROM software GROUP BY PNAME,DEVELOPIN --73. Display the language used by each programmer to develop the Highest Selling and Lowest-selling package. SELECT PNAME, DEVELOPIN, MAX(SCOST) AS MAX_SCOST, MIN(SCOST) AS MIN_SCOST FROM software GROUP BY PNAME,DEVELOPIN --74. Who is the youngest male Programmer born in 1965. SELECT TOP 1 PNAME, DOB FROM programmer WHERE GENDER IN ('M','m') AND YEAR(DOB) = 1965 ORDER BY YEAR(DOB) --75. Who is the oldest Female Programmer who joined in 1992. SELECT TOP 1 PNAME, DOJ,YEAR(DOB) AS DOB FROM programmer WHERE GENDER IN ('F','f') AND YEAR(DOJ) = 1992 ORDER BY DOB DESC --76. In which year was the most number of Programmers born. SELECT TOP 1 YEAR(DOB), COUNT(*) AS MAX_COUNT FROM programmer GROUP BY YEAR(DOB) ORDER BY MAX_COUNT DESC --77. In which month did most number of programmers join. SELECT TOP 1 DATENAME(MONTH,DOJ), COUNT(*) AS MOST_JOIN FROM programmer GROUP BY DATENAME(MONTH,DOJ) ORDER BY MOST_JOIN DESC --78. In which language are most of the programmers proficient. SELECT DISTINCT PROF1 FROM programmer WHERE PROF1 = (SELECT MAX(PROF1) FROM programmer) UNION SELECT DISTINCT PROF2 FROM programmer WHERE PROF2 = (SELECT MAX(PROF2) FROM programmer) --79. Who are the male programmers earning below the AVG salary of Female Programmers. SELECT PNAME, SALARY FROM programmer WHERE GENDER IN ('M','m') AND SALARY < (SELECT AVG(SALARY) FROM programmer WHERE GENDER IN ('F','f')) --80. Who are the Female Programmers earning more than the Highest Paid. SELECT * FROM programmer WHERE GENDER IN ('F','f') AND SALARY > (SELECT MAX(SALARY) FROM programmer) --81. Which language has been stated as the prof by most of the Programmers. WITH RESULT AS( SELECT PROF1 AS LANGUAGE, COUNT(PNAME) AS COUNT_PROGRAMMERS FROM programmer GROUP BY PROF1 UNION SELECT PROF2 , COUNT(PNAME) FROM programmer GROUP BY PROF2) SELECT LANGUAGE, MAX(COUNT_PROGRAMMERS) AS COUNT_PROGRAMMERS FROM RESULT WHERE COUNT_PROGRAMMERS = (SELECT MAX(COUNT_PROGRAMMERS) FROM RESULT) GROUP BY LANGUAGE ORDER BY COUNT_PROGRAMMERS DESC --82. Display the details of those who are drawing the same salary. SELECT P1.* FROM programmer P1 INNER JOIN programmer P2 ON P1.SALARY = P2.SALARY --83. Display the details of the Software Developed by the Male Programmers Earning More than 3000/-. SELECT P.PNAME, S.TITLE, S.DEVELOPIN, P.SALARY FROM programmer P INNER JOIN software S ON P.PNAME = S.PNAME WHERE P.GENDER IN ('M','m') AND P.SALARY > 3000 --84. Display the details of the packages developed in Pascal by the Female Programmers SELECT S.* FROM software S INNER JOIN programmer P ON S.PNAME = P.PNAME WHERE P.GENDER IN ('F','f') AND S.DEVELOPIN IN ('PASCAL','pascal') --85. Display the details of the Programmers who joined before 1990. SELECT * FROM programmer WHERE YEAR(DOJ) < 1990 --86. Display the details of the Software Developed in C By female programmers of Pragathi. SELECT S.* FROM software S INNER JOIN studies ST ON S.PNAME = ST.PNAME INNER JOIN programmer P ON S.PNAME = P.PNAME WHERE S.DEVELOPIN = 'C' AND P.GENDER = 'F' AND ST.INSTITUTE = 'PRAGATHI' --87. Display the number of packages, No. of Copies Sold and sales value of each programmer institute wise. SELECT ST.INSTITUTE ,COUNT(TITLE) AS TOT_PACKG, SUM(SOLD) AS TOT_SOLD, SUM(SCOST) as TOT_SAL_VAL FROM software S INNER JOIN studies ST ON S.PNAME = ST.PNAME GROUP BY ST.INSTITUTE --88. Display the details of the software developed in DBASE by Male Programmers, --who belong to the institute in which most number of Programmers studied. SELECT S.*, ST.INSTITUTE FROM software S INNER JOIN studies ST ON S.PNAME = ST.PNAME INNER JOIN programmer P ON S.PNAME = P.PNAME WHERE S.DEVELOPIN IN ('DBASE','dbase') AND P.GENDER IN ('M','m') AND ST.INSTITUTE IN (SELECT TOP 1 INSTITUTE FROM studies GROUP BY INSTITUTE ORDER BY COUNT(PNAME) DESC) --89. Display the details of the software Developed by the male programmers Born before 1965 --and female programmers born after 1975. SELECT S.* FROM software S INNER JOIN programmer P ON S.PNAME = P.PNAME WHERE (P.GENDER = 'M' AND YEAR(P.DOB) < 1965) OR (P.GENDER = 'F' AND YEAR(P.DOB) > 1975) --90. Display the details of the software that has developed in the language which is neither the first --nor the second proficiency of the programmers. SELECT S.* FROM software S INNER JOIN programmer P ON S.PNAME = P.PNAME WHERE S.DEVELOPIN != P.PROF1 AND S.DEVELOPIN != P.PROF2 --91. Display the details of the software developed by the male students of sabhari. SELECT S.* FROM software S INNER JOIN programmer P ON S.PNAME = P.PNAME INNER JOIN studies ST ON S.PNAME = ST.PNAME WHERE P.GENDER = 'M' AND ST.INSTITUTE = 'SABHARI' --92. Display the names of the programmers who have not developed any packages. SELECT * FROM programmer WHERE PNAME NOT IN (SELECT PNAME FROM software) --93. What is the total cost of the Software developed by the programmers of Apple. SELECT SUM(DCOST) AS TOTAL_DEV_COST FROM software S INNER JOIN studies ST ON S.PNAME = ST.PNAME WHERE ST.INSTITUTE = 'APPLE' --94. Who are the programmers who joined on the same day. SELECT P1.PNAME, P1.DOJ FROM programmer P1 INNER JOIN programmer P2 ON P1.DOJ = P2.DOJ WHERE P1.PNAME != P2.PNAME --95. Who are the programmers who have the same Prof2. SELECT P1.PNAME, P1.PROF2 FROM programmer P1 INNER JOIN programmer P2 ON P1.PROF2 = P2.PROF2 WHERE P1.PNAME != P2.PNAME --96. Display the total sales value of the software, institute wise. SELECT ST.INSTITUTE, SUM(S.SCOST) FROM software S INNER JOIN studies ST ON S.PNAME = ST.PNAME GROUP BY ST.INSTITUTE --97. In which institute does the person who developed the costliest package studied. SELECT ST.INSTITUTE, ST.PNAME FROM studies ST INNER JOIN software S ON ST.PNAME = S.PNAME WHERE S.DCOST IN (SELECT MAX(DCOST) FROM software) ----98. Which language listed in prof1,prof2 has not been used to develop any package. SELECT PROF1 AS LANGUAGE FROM programmer WHERE PROF1 NOT IN (SELECT DEVELOPIN FROM software) UNION SELECT PROF2 FROM programmer WHERE PROF2 NOT IN (SELECT DEVELOPIN FROM software) --99.How much does the person who developed the highest selling package earn and what course did SELECT P.PNAME, P.SALARY, T.COURSE FROM programmer P INNER JOIN software S ON P.PNAME = S.PNAME INNER JOIN studies T ON P.PNAME = T.PNAME WHERE S.SCOST IN (SELECT MAX(SCOST) FROM software) --100.How many months will it take for each programmer to recover the cost of the Course underwent SELECT P.PNAME, P.SALARY, S.COURSEFEE, CEILING(S.COURSEFEE/P.SALARY) AS MONTHS_TO_RECOVER FROM programmer P INNER JOIN STUDIES S ON P.PNAME = S.PNAME --101. Which is the costliest package by a person with under 3 years experience. SELECT P.PNAME, S.TITLE, S.SCOST, S.SOLD FROM programmer P INNER JOIN software S ON P.PNAME = S.PNAME WHERE (YEAR(GETDATE()) - YEAR(P.DOJ)) <= 3 --102. What is the AVG salary for those Whose software sales is more than 50,000/-. SELECT AVG(P.SALARY) FROM programmer P INNER JOIN software S ON P.PNAME = S.PNAME WHERE S.SCOST*S.SOLD > 50000 --103 How many packages were developed by students, who studied in institute that charge the lowest course fee. SELECT S.PNAME, S.TITLE, S.DEVELOPIN, ST.INSTITUTE, ST.COURSEFEE FROM software S INNER JOIN studies ST ON S.PNAME = ST.PNAME WHERE ST.INSTITUTE IN (SELECT DISTINCT INSTITUTE FROM studies WHERE COURSEFEE IN (SELECT MIN(COURSEFEE) FROM studies)) --104 How many packages were developed by the person who developed the cheapest package, where did HE/SHE studied SELECT S.PNAME,S.SOLD, ST.INSTITUTE FROM software S INNER JOIN studies ST ON S.PNAME = ST.PNAME WHERE S.DCOST = (SELECT MIN(DCOST) FROM software) --105 How many packages were developed by the female programmers earning more then the highest paid male programmer. SELECT S.* FROM SOFTWARE S INNER JOIN programmer P ON S.PNAME = P.PNAME WHERE (P.GENDER = 'F') AND P.SALARY > (SELECT MAX(SALARY) FROM programmer WHERE GENDER = 'M') --106 How many packages are developed by the most experienced programmer form BDPS. SELECT TOP 1 S.* FROM software S INNER JOIN programmer P ON S.PNAME = P.PNAME INNER JOIN studies ST ON S.PNAME = ST.PNAME WHERE ST.INSTITUTE = 'BDPS' ORDER BY P.DOJ ---107. List the programmers (form the software table) and the institutes they studied. SELECT DISTINCT F.PNAME, S.INSTITUTE FROM software F INNER JOIN studies S ON F.PNAME = S.PNAME --108 List each PROF with the number of Programmers having that PROF and the number of the packages in that PROF SELECT P.PROF1 AS PROFICIENCY, COUNT(P.PNAME) AS NO_PROGRAMMER, COUNT(S.TITLE) AS NO_PACKAGES FROM programmer P INNER JOIN software S ON P.PNAME = S.PNAME GROUP BY P.PROF1 UNION ALL SELECT P.PROF2, COUNT(P.PNAME) AS NO_PROGRAMMER, COUNT(S.TITLE) AS NO_PACKAGES FROM programmer P INNER JOIN software S ON P.PNAME = S.PNAME GROUP BY P.PROF2 ---109. List the programmer names (from the programmer table) and No. Of Packages each has developed. SELECT P.PNAME, SUM(S.SOLD) AS SUM_PKGS FROM programmer P INNER JOIN software S ON P.PNAME = S.PNAME GROUP BY P.PNAME ORDER BY SUM_PKGS DESC
true
ebc91e6085dc4a79bca51720bd39cc7160dc9b48
SQL
1725114746/HellowWorldSystem
/drivercard/sql/ts_role.sql
UTF-8
338
2.578125
3
[]
no_license
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for zk_user -- ---------------------------- DROP TABLE IF EXISTS `ts_role`; CREATE TABLE `ts_role` ( `role_id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL , PRIMARY KEY (`role_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 auto_increment=1;
true
5b26753d15683d273463d230a7f2af63c574ca60
SQL
nakicam/70-761-Udemy
/Stored Procedure Example.sql
UTF-8
667
3.609375
4
[]
no_license
-- A simple stored procedure -- This is a query that we run often select p.LastName + ', ' + p.FirstName Name, pp.PhoneNumber from person.person p join person.PersonPhone pp on p.BusinessEntityID=pp.BusinessEntityID order by Lastname, Firstname -- Let's create a stored procedure that will -- return this information CREATE PROC GetPhone AS select p.LastName + ', ' + p.FirstName Name, pp.PhoneNumber from person.person p join person.PersonPhone pp on p.BusinessEntityID=pp.BusinessEntityID order by Lastname, Firstname --Hightlight 'GetPhone' and execute --The result of the code in the stored procedure will be returned GetPhone
true
8828d1c1f5e6e4e1a10483ec67545964bd63f9e4
SQL
FrankXuxe/SQL
/SQL - DDL - Assignment.sql
UTF-8
3,329
4.34375
4
[]
no_license
-- 1) Create each of the four tables from this Data Dictionary. Download Data Dictionary.Build it according to the exact specifications listed in the spreadsheet. (10 points for each table, 40 pts total). Insert the following record in the Patient table to make sure it was set up correctly: CREATE TABLE Patient (patientID smallint NOT NULL, fname VARCHAR (50) NOT NULL, lname VARCHAR (50) NOT NULL, dob date NOT NULL, address VARCHAR (50), city VARCHAR (50) NOT NULL, email VARCHAR (100) CONSTRAINT patientID_pk PRIMARY KEY (patientID) ) CREATE TABLE Provider (providerID smallint NOT NULL, providerSpeciality VARCHAR (100) NOT NULL, certification bit CONSTRAINT providerID_pk PRIMARY KEY (providerID) ) CREATE TABLE Visit (visitID smallint NOT NULL, visitdate DATETIME NOT NULL, patientID smallint NOT NULL CONSTRAINT visitID_pk PRIMARY KEY (visitID) CONSTRAINT patientID_fk FOREIGN KEY (patientID) REFERENCES Patient(patientID) ) CREATE TABLE VisitProvider (visitID smallint NOT NULL, providerID smallint NOT NULL, diagnosis VARCHAR (200) NOT NULL CONSTRAINT visitproviderID_pk PRIMARY KEY (visitID, providerID), CONSTRAINT visitID_fk FOREIGN KEY (visitID) REFERENCES Visit(visitID), CONSTRAINT providerID_fk FOREIGN KEY (providerID) REFERENCES Provider(providerID) ) INSERT INTO Patient VALUES (100,'John','Doe','01/01/2001','123 Main St','Waco','johndoe@test.com') select * from Patient -- 2) Create a table called patient_copy that has only the structure of the patient table. Add 2 columns to this table - "state" -- and "date_joined" based on the following specs (20 points): SELECT TOP 0 * INTO patient_copy FROM Patient ALTER TABLE patient_copy ADD state VARCHAR(2) DEFAULT 'TX' ALTER TABLE patient_copy ADD date_joined DATE select * from patient_copy -- 3) Change the length of the column address in the table patient_copy from 50 to 200 and make sure it does not allow null values. (5 points) -- ALTER TABLE patient_copy ALTER COLUMN address VARCHAR(200) NOT NULL -- 4) drop the email column from the table patient_copy (5 points) -- ALTER TABLE patient_copy DROP Column email /* 5) Create a copy of the Visit table (structure only, no data) and name it CHRISTMAS_VISIT. In this table, You can ONLY process visits that will occur during Christmas break (12/15 - 12/30). Create a check constraint that will allow visits ONLY during those days. Make sure you don't make Year as part of your constraint since it will be a policy every year. After creating the constraint, validate that it is working correctly by running the following 2 commands. The first one should fail and you should get an error saying "The INSERT statement conflicted with the CHECK constraint.....". The second one should be successful since it has a valid date. insert into christmas_visit values (1011,'1/26/2018',100) insert into spring_break_orders values (1011,'12/18/2019',100) (30 points) */ SELECT TOP 0 * INTO CHRISTMAS_VISIT FROM Visit ALTER TABLE CHRISTMAS_VISIT ADD CONSTRAINT only_chrismas_visit_cc CHECK (day(visitdate) < 31 AND day(visitdate) >14 AND month(visitdate) = 12) insert into christmas_visit values (1011,'1/26/2018',100) insert into CHRISTMAS_VISIT values (1011,'12/18/2019',100) select * from CHRISTMAS_VISIT
true
5c3f0e13af27a5231d97aedd6df2eb340dd8bb97
SQL
Adrian-Guadalupe/node-db3-guided
/queries.sql
UTF-8
228
3.515625
4
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
select c.CategoryName as Category, p.ProductName, p.Price, s.SupplierName as SuppliedBy from Products as p inner join Categories as c on p.CategoryID = c.CategoryID inner join Suppliers as s on p.SupplierID = s.SupplierID
true
ad4930ff5d818c1830ec3ba4c701412981b7b14c
SQL
ReneNyffenegger/about-sqlite
/tables/constraints/primary-key/autoincrement/vs-rowid.sql
UTF-8
529
3.21875
3
[]
no_license
create table T (p integer primary key , d); create table U (p integer primary key autoincrement, d); insert into T (d) values ('first'); insert into U (d) values ('first'); insert into T (d) values ('second'); insert into U (d) values ('second'); delete from T where d = 'second'; delete from U where d = 'second'; insert into T (d) values ('third'); insert into U (d) values ('third'); .mode column .width 2 10 select * from T; -- -- 1 first -- 2 third select * from U; -- -- 1 first -- 3 third
true
bd954b0d0893d87aa2efaf976b383bd37fea5d7d
SQL
hhwang4/RentIt
/sql/example-schema.sql
UTF-8
544
2.671875
3
[]
no_license
CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) ); INSERT INTO Persons(`PersonID`, `LastName`, `FirstName`, `Address`, `City`) values (1, "Wayne", "Bruce", "Wayne Manor", "Gotham"); INSERT INTO Persons(`PersonID`, `LastName`, `FirstName`, `Address`, `City`) values (2, "Parker", "Peter", "123 Main Street", "New York"); INSERT INTO Persons(`PersonID`, `LastName`, `FirstName`, `Address`, `City`) values (3, "Kent", "Clark", "Farmland", "Metropolis");
true
0fd82b96011e5c6317369212963a67f298c7de0f
SQL
nayaaltahan/DB_SEP4_PMI
/Incremental Load of the fact CO2.sql
UTF-8
2,971
4.03125
4
[]
no_license
drop table if exists Temp_Fact_CO2; --if not already created, create a Temporary fact table for co2 create table Temp_Fact_CO2 ( Su_Plant_ID int, Su_Profile_ID int, Su_User_ID int, Su_Date_ID int, Su_Time_ID int, Plant_ID int, Profile_ID int, User_ID int, Time Time, Date DATE, Sensor_Value decimal(6,3), CO2_Status int ); DELETE FROM Temp_Fact_CO2; insert into Temp_Fact_CO2 (Plant_ID, Profile_ID, [Date] , User_ID , [Time], [Sensor_Value] , CO2_Status) select Plant.Plant_ID, PlantProfile.Profile_ID, CAST([TimeStamp] AS DATE), Users.[User_ID] ,FORMAT([TimeStamp],'HH:mm') ,PlantData.Sensor_Value, case when Sensor_Value < CO2_Min then 1 when Sensor_Value > CO2_Min and Sensor_Value < CO2_Max then 2 when Sensor_Value > CO2_Max then 3 end as CO2_Status from SEP4_PMI.dbo.Plant join SEP4_PMI.dbo.PlantProfile on SEP4_PMI.dbo.Plant.Profile_ID = SEP4_PMI.dbo.PlantProfile.Profile_ID join SEP4_PMI.dbo.PlantData on PlantData.Plant_ID = Plant.Plant_ID join SEP4_PMI.dbo.Users on PlantProfile.[User_ID] = Users.[User_ID] where PlantData.Sensor_Type = 'CO2' AND CAST(PlantData.TimeStamp AS DATETIME) > (select last_updated from Dim_SEP4_PMI.dbo.Last_Updated); select * from Temp_Fact_CO2; ------------------------------------------------------------------------------------------------------------------------------ USE Stage_SEP4_PMI --------------------------------UPDATING THE TEMP FACT CO2 WITH SURROGATE KEY FROM THE DW------------------------------------- UPDATE Temp_Fact_CO2 SET Su_User_ID = ( SELECT TOP 1 Su_User_ID FROM Dim_SEP4_PMI.dbo.Dim_Users u WHERE u.[User_ID] = Temp_Fact_CO2.[User_ID] AND u.[ValidTo] > GETDATE()); UPDATE Temp_Fact_CO2 SET Su_Plant_ID = ( SELECT TOP 1 Su_Plant_ID FROM Dim_SEP4_PMI.dbo.Dim_Plant p WHERE p.[Plant_ID] = Temp_Fact_CO2.[Plant_ID] AND p.[ValidTo] > GETDATE()); UPDATE Temp_Fact_CO2 SET Su_Profile_ID = ( SELECT TOP 1 Su_Profile_ID FROM Dim_SEP4_PMI.dbo.Dim_PlantProfile pp WHERE pp.[Profile_ID] = Temp_Fact_CO2.[Profile_ID] AND pp.[ValidTo] > GETDATE()); UPDATE Temp_Fact_CO2 SET Su_Date_ID = ( SELECT TOP 1 Su_Date_ID FROM Dim_SEP4_PMI.dbo.Dim_Calendar d WHERE d.[CalendarDate] = Temp_Fact_CO2.[Date] ); UPDATE Temp_Fact_CO2 SET Su_Time_ID = ( SELECT TOP 1 Su_Time_ID FROM Dim_SEP4_PMI.dbo.Dim_Time t WHERE t.[Time] = Temp_Fact_CO2.[Time] ); SELECT * FROM Temp_Fact_CO2; -----------------------------POPULATING THE CO2 FACT IN THE DW WITH THE NEW ROWS--------------------------- INSERT INTO Dim_SEP4_PMI.dbo.Dim_Fact_CO2 (Su_Plant_ID, Su_Profile_ID, Su_Date_ID, Su_Time_ID, Su_User_ID, Sensor_Value, CO2_Status) SELECT Su_Plant_ID ,Su_Profile_ID, Su_Date_ID, Su_Time_ID, Su_User_ID, Sensor_Value, CO2_Status FROM Temp_Fact_CO2; -----------------------------------------------------------------------------------------------------------
true
6d2a15874e7b244ffc85e5f4c180ef8f2d33da7f
SQL
emilg1101/buu-lansedeniao
/dump/lansedeniao_new_schema.sql
UTF-8
2,454
3.5
4
[]
no_license
CREATE TABLE new_schema."like" ( id integer DEFAULT nextval('new_schema.like_id_seq'::regclass) PRIMARY KEY NOT NULL, post_id integer NOT NULL, user_id integer NOT NULL, CONSTRAINT like_post_id_fk FOREIGN KEY (post_id) REFERENCES new_schema.post (id), CONSTRAINT like_user_id_fk FOREIGN KEY (user_id) REFERENCES new_schema."user" (id) ); CREATE UNIQUE INDEX like_id_uindex ON new_schema."like" (id); INSERT INTO new_schema."like" (id, post_id, user_id) VALUES (2, 1, 3); INSERT INTO new_schema."like" (id, post_id, user_id) VALUES (3, 2, 3); INSERT INTO new_schema."like" (id, post_id, user_id) VALUES (4, 1, 1); INSERT INTO new_schema."like" (id, post_id, user_id) VALUES (5, 2, 1); CREATE TABLE new_schema.post ( id integer DEFAULT nextval('new_schema.post_id_seq'::regclass) PRIMARY KEY NOT NULL, user_id integer NOT NULL, text varchar(1024) NOT NULL, cdate timestamp DEFAULT now(), CONSTRAINT post_user_id_fk FOREIGN KEY (user_id) REFERENCES new_schema."user" (id) ); CREATE UNIQUE INDEX post_id_uindex ON new_schema.post (id); INSERT INTO new_schema.post (id, user_id, text, cdate) VALUES (1, 1, 'My first post!!!', '2019-03-21 13:10:49.636925'); INSERT INTO new_schema.post (id, user_id, text, cdate) VALUES (2, 1, 'My 2nd post.', '2019-03-21 15:49:17.680557'); INSERT INTO new_schema.post (id, user_id, text, cdate) VALUES (4, 3, 'test', '2019-03-22 00:08:35.490726'); CREATE TABLE new_schema."user" ( id integer DEFAULT nextval('new_schema.user_id_seq'::regclass) PRIMARY KEY NOT NULL, username varchar(20) NOT NULL, password varchar(255) NOT NULL, email varchar(100) NOT NULL, bdate timestamp, country varchar(20) DEFAULT NULL::character varying, gender integer DEFAULT 2 NOT NULL, rdate timestamp DEFAULT now() NOT NULL, name varchar(30) DEFAULT NULL::character varying ); CREATE UNIQUE INDEX user_id_uindex ON new_schema."user" (id); CREATE UNIQUE INDEX user_username_uindex ON new_schema."user" (username); CREATE UNIQUE INDEX user_email_uindex ON new_schema."user" (email); INSERT INTO new_schema."user" (id, username, password, email, bdate, country, gender, rdate, name) VALUES (1, 'emilg1101', '123', 'emilyandro99@gmail.com', null, null, 2, '2019-03-20 05:26:58.123423', null); INSERT INTO new_schema."user" (id, username, password, email, bdate, country, gender, rdate, name) VALUES (3, 'admin', 'admin', 'admin@admin', null, null, 2, '2019-03-21 15:53:05.725781', null);
true
2e9a65e710ce65272786657000a2c8d1a95da1cb
SQL
djones01/CHub
/CFG_SALARY_BASIS_COMPONENT_CONSTRAINT.sql
UTF-8
700
2.53125
3
[]
no_license
-------------------------------------------------------- -- Constraints for Table CFG_SALARY_BASIS_COMPONENT -------------------------------------------------------- ALTER TABLE "HCM_ADMIN"."CFG_SALARY_BASIS_COMPONENT" ADD CONSTRAINT "CFG_SALARY_BASIS_COMPONENT_PK" PRIMARY KEY ("LOOKUP_USAGE_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS TABLESPACE "USERS" ENABLE; ALTER TABLE "HCM_ADMIN"."CFG_SALARY_BASIS_COMPONENT" MODIFY ("SALARY_BASIS_NAME" NOT NULL ENABLE); ALTER TABLE "HCM_ADMIN"."CFG_SALARY_BASIS_COMPONENT" MODIFY ("ATTRIBUTE_VALUE" NOT NULL ENABLE); ALTER TABLE "HCM_ADMIN"."CFG_SALARY_BASIS_COMPONENT" MODIFY ("LOOKUP_USAGE_ID" NOT NULL ENABLE);
true
71fbdceafb2f371a3c67393d7cbdf76bd28313ee
SQL
Alnino98/pakkem
/DB/pakkem_daftar (2).sql
UTF-8
9,576
3.0625
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.8.4 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Waktu pembuatan: 27 Sep 2020 pada 21.17 -- Versi server: 10.1.37-MariaDB -- Versi PHP: 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: `pakkem_daftar` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `agenda_diikuti` -- CREATE TABLE `agenda_diikuti` ( `id` int(11) NOT NULL, `id_agenda` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `kegiatan` varchar(100) NOT NULL, `waktu_agenda` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Struktur dari tabel `anggota` -- CREATE TABLE `anggota` ( `id_pendaftar` int(11) NOT NULL, `nama` varchar(100) NOT NULL, `instansi` varchar(100) NOT NULL, `tempat_lahir` varchar(100) NOT NULL, `tanggal_lahir` date NOT NULL, `gender` varchar(50) NOT NULL, `nik` char(16) NOT NULL, `email` varchar(50) NOT NULL, `no_hp` char(16) NOT NULL, `bisa_wa` varchar(50) NOT NULL, `pendidikan` varchar(255) NOT NULL, `sertifikat` varchar(255) NOT NULL, `info_tambahan` varchar(255) NOT NULL, `status` int(11) NOT NULL, `tgl_daftar` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data untuk tabel `anggota` -- INSERT INTO `anggota` (`id_pendaftar`, `nama`, `instansi`, `tempat_lahir`, `tanggal_lahir`, `gender`, `nik`, `email`, `no_hp`, `bisa_wa`, `pendidikan`, `sertifikat`, `info_tambahan`, `status`, `tgl_daftar`) VALUES (10, 'yogga', 'yogga', 'Bandung', '2020-12-31', 'Laki-laki', '3964273687', 'yoggaajipratama99@gmail.com', '2323523', 'Ya', 'S2', 'Ya, ada', 'no', 0, '2020-09-27 16:19:50'), (11, 'Tampan sekali', 'UIN', 'Banten', '2020-09-16', 'Laki-laki', '3212212201980001', 'moh.ramdani22@gmail.com', '08961900055', 'Ya', 'S3', 'Ya, ada', 'Sudah kubillang aku tampan', 0, '2020-09-27 16:24:09'), (12, 'Tampan sekali', 'Kantor Hokage', 'Banten', '2020-09-17', 'Laki-laki', '3212212201980001', 'infokeun@gmail.com', '08961900055', 'Ya', 'S3', 'Ya, ada', 'Sudah kubillang aku tampan', 0, '2020-09-27 16:25:47'); -- -------------------------------------------------------- -- -- Struktur dari tabel `foto` -- CREATE TABLE `foto` ( `id` int(11) NOT NULL, `foto_upload` varchar(200) DEFAULT NULL, `nama_pemilik` varchar(100) NOT NULL, `email_pemilik` varchar(200) NOT NULL, `status` int(11) NOT NULL, `waktu` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data untuk tabel `foto` -- INSERT INTO `foto` (`id`, `foto_upload`, `nama_pemilik`, `email_pemilik`, `status`, `waktu`) VALUES (6, '2022737743_yoggaajipratama99@gmail.com.jpg', 'yogga', 'yoggaajipratama99@gmail.com', 1, '2020-09-27 16:19:51'), (7, '1150555032_moh.ramdani22@gmail.com.jpg', 'Tampan sekali', 'moh.ramdani22@gmail.com', 1, '2020-09-27 16:24:20'), (8, '1105236982_infokeun@gmail.com.jpg', 'Tampan sekali', 'infokeun@gmail.com', 1, '2020-09-27 16:25:55'), (9, '2067782905_batara@gmail.com.jpg', 'coba3', 'batara@gmail.com', 0, '2020-09-27 17:18:44'), (10, '1531236906_elokapanter@gmail.com.jpg', 'kkkka', 'elokapanter@gmail.com', 0, '2020-09-27 17:29:58'); -- -------------------------------------------------------- -- -- Struktur dari tabel `log` -- CREATE TABLE `log` ( `id` int(11) NOT NULL, `email` varchar(100) NOT NULL, `kegiatan` int(11) NOT NULL, `timestamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data untuk tabel `log` -- INSERT INTO `log` (`id`, `email`, `kegiatan`, `timestamp`) VALUES (9, 'yoggaajipratama99@gmail.com', 1, '2020-09-27 23:31:46'), (10, 'moh.ramdani22@gmail.com', 0, '2020-09-27 23:24:09'), (11, 'infokeun@gmail.com', 0, '2020-09-27 23:25:47'); -- -------------------------------------------------------- -- -- Struktur dari tabel `pendaftar` -- CREATE TABLE `pendaftar` ( `id_pendaftar` int(11) NOT NULL, `nama` varchar(100) NOT NULL, `instansi` varchar(100) NOT NULL, `tempat_lahir` varchar(100) NOT NULL, `tanggal_lahir` date NOT NULL, `gender` varchar(50) NOT NULL, `nik` char(16) NOT NULL, `email` varchar(50) NOT NULL, `no_hp` char(16) NOT NULL, `bisa_wa` varchar(50) NOT NULL, `pendidikan` varchar(255) NOT NULL, `sertifikat` varchar(255) NOT NULL, `info_tambahan` varchar(255) NOT NULL, `tgl_daftar` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `status` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data untuk tabel `pendaftar` -- INSERT INTO `pendaftar` (`id_pendaftar`, `nama`, `instansi`, `tempat_lahir`, `tanggal_lahir`, `gender`, `nik`, `email`, `no_hp`, `bisa_wa`, `pendidikan`, `sertifikat`, `info_tambahan`, `tgl_daftar`, `status`) VALUES (6, 'yogga', 'yogga', 'Bandung', '2020-12-31', 'Laki-laki', '3964273687', 'yoggaajipratama99@gmail.com', '2323523', 'Ya', 'S2', 'Ya, ada', 'no', '2020-09-27 16:19:51', 1), (7, 'Tampan sekali', 'UIN', 'Banten', '2020-09-16', 'Laki-laki', '3212212201980001', 'moh.ramdani22@gmail.com', '08961900055', 'Ya', 'S3', 'Ya, ada', 'Sudah kubillang aku tampan', '2020-09-27 16:24:09', 1), (8, 'Tampan sekali', 'Kantor Hokage', 'Banten', '2020-09-17', 'Laki-laki', '3212212201980001', 'infokeun@gmail.com', '08961900055', 'Ya', 'S3', 'Ya, ada', 'Sudah kubillang aku tampan', '2020-09-27 16:25:47', 1), (9, 'coba3', 'Kantor Hokage', 'Banten', '2020-09-08', 'Laki-laki', '3212212201980001', 'batara@gmail.com', '08961900055', 'Ya', 'S1', '', 'Sudah kubillang aku tampan', '2020-09-27 17:18:44', 0), (10, 'kkkka', 'Kantor Hokage', 'Banten', '2020-10-01', 'Laki-laki', '3212212201980001', 'elokapanter@gmail.com', '08961900055', 'Ya', 'D III', 'Ya, ada', 'Sudah kubillang aku tampan', '2020-09-27 17:29:58', 0); -- -------------------------------------------------------- -- -- Struktur dari tabel `sertifikat` -- CREATE TABLE `sertifikat` ( `id` int(11) NOT NULL, `sertifikat_upload` varchar(200) DEFAULT NULL, `nama_pemilik` varchar(100) NOT NULL, `email_pemilik` varchar(200) NOT NULL, `keterangan` varchar(100) NOT NULL, `status` int(11) NOT NULL, `waktu` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data untuk tabel `sertifikat` -- INSERT INTO `sertifikat` (`id`, `sertifikat_upload`, `nama_pemilik`, `email_pemilik`, `keterangan`, `status`, `waktu`) VALUES (6, '2022737743_yoggaajipratama99@gmail.com.png', 'yogga', 'yoggaajipratama99@gmail.com', 'ok', 1, '2020-09-27 16:19:51'), (7, '1150555032_moh.ramdani22@gmail.com.jpg', 'Aku Tampan', 'moh.ramdani22@gmail.com', 'Memang Tampan', 1, '2020-09-27 16:24:26'), (8, '1105236982_infokeun@gmail.com.jpg', 'Aku Tampan', 'infokeun@gmail.com', 'Memang Tampan', 1, '2020-09-27 16:26:04'), (9, '2067782905_batara@gmail.com.jpg', 'Coba', 'batara@gmail.com', 'Coba1', 0, '2020-09-27 17:18:44'), (10, '1531236906_elokapanter@gmail.com.jpg', 'aseeew', 'elokapanter@gmail.com', 'adfasdf', 0, '2020-09-27 17:29:58'); -- -------------------------------------------------------- -- -- Struktur dari tabel `users` -- CREATE TABLE `users` ( `id_user` int(11) NOT NULL, `username` varchar(100) NOT NULL, `password` varchar(100) NOT NULL, `email` varchar(50) NOT NULL, `nama` varchar(100) NOT NULL, `level` varchar(50) NOT NULL, `status` int(11) NOT NULL, `log` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data untuk tabel `users` -- INSERT INTO `users` (`id_user`, `username`, `password`, `email`, `nama`, `level`, `status`, `log`) VALUES (5, 'yogga', '8f4f4aa2c27b7c39a33895142e164354', 'yoggaajipratama99@gmail.com', 'yogga', '2', 1, '2020-09-27 16:19:51'); -- -- Indexes for dumped tables -- -- -- Indeks untuk tabel `agenda_diikuti` -- ALTER TABLE `agenda_diikuti` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `anggota` -- ALTER TABLE `anggota` ADD PRIMARY KEY (`id_pendaftar`); -- -- Indeks untuk tabel `foto` -- ALTER TABLE `foto` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `log` -- ALTER TABLE `log` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `pendaftar` -- ALTER TABLE `pendaftar` ADD PRIMARY KEY (`id_pendaftar`); -- -- Indeks untuk tabel `sertifikat` -- ALTER TABLE `sertifikat` ADD PRIMARY KEY (`id`); -- -- Indeks untuk tabel `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id_user`); -- -- AUTO_INCREMENT untuk tabel yang dibuang -- -- -- AUTO_INCREMENT untuk tabel `agenda_diikuti` -- ALTER TABLE `agenda_diikuti` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT untuk tabel `anggota` -- ALTER TABLE `anggota` MODIFY `id_pendaftar` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; -- -- AUTO_INCREMENT untuk tabel `foto` -- ALTER TABLE `foto` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT untuk tabel `log` -- ALTER TABLE `log` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12; -- -- AUTO_INCREMENT untuk tabel `pendaftar` -- ALTER TABLE `pendaftar` MODIFY `id_pendaftar` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT untuk tabel `sertifikat` -- ALTER TABLE `sertifikat` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT untuk tabel `users` -- ALTER TABLE `users` MODIFY `id_user` int(11) 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
5ba2a770dc8644b762168fbce6ab9d62c6ca5145
SQL
XiangZhaoyang/SAMS
/studentAMS.sql
UTF-8
3,152
3.65625
4
[ "Apache-2.0" ]
permissive
create database studentAMS; use studentAMS; create table user( user_id bigint(12) UNSIGNED not null primary key, user_pass varchar(256) not null default '$2y$10$vZ0Wm.W7NbcZr9Bf7dDqzeYi/TG4FwIPEgrzqtJ8GsSXu9vclyuve', user_createTime timestamp default CURRENT_TIMESTAMP, user_auth tinyint(1) not null default 1 )engine=innodb default charset=utf8; create table department( department_id int(8) UNSIGNED not null primary key, department_name varchar(15) not null, department_information text null )engine=innodb default charset=utf8; create table classes( classes_id int(8) UNSIGNED not null primary key, classes_name varchar(15) not null, classes_department_id int(8) UNSIGNED not null, classes_majorName varchar(20) not null, classes_information text null, foreign key(classes_department_id) references department(department_id) )engine=innodb default charset=utf8; create table student( student_id bigint(12) UNSIGNED not null primary key, student_classes_id int(8) UNSIGNED not null, student_sex tinyint(1) not null, student_name varchar(10) not null, student_brith char(8) null, student_address varchar(30) null, student_imghref varchar(20) null, student_information text null, student_phoneNum bigint(11) null, student_email varchar(30) null, student_idcard bigint(18) null, foreign key(student_id) references user(user_id), foreign key(student_classes_id) references classes(classes_id) )engine=innodb default charset=utf8; create table teacher( teacher_id bigint(12) UNSIGNED not null primary key, teacher_department_id int(8) UNSIGNED not null, teacher_name varchar(10) not null, teacher_sex tinyint(1) not null, teacher_brith char(8) null, teacher_address varchar(30) null, teacher_imghref varchar(20) null, teacher_information text null, teacher_phoneNum bigint(11) null, teacher_email varchar(30) null, teacher_idvard bigint(18) null, foreign key(teacher_id) references user(user_id), foreign key(teacher_department_id) references department(department_id) )engine=innodb default charset=utf8; create table course( course_id int(8) UNSIGNED not null primary key, course_teacher_id bigint(12) UNSIGNED not null, course_classes_id int(8) UNSIGNED not null, course_department_id int(8) UNSIGNED not null, course_belong varchar(10) null, course_style varchar(10) not null, course_credit tinyint(1) not null, course_name varchar(15) not null, course_year char(9) not null, course_term tinyint(1) not null, course_information text null, foreign key(course_teacher_id) references teacher(teacher_id), foreign key(course_classes_id) references classes(classes_id), foreign key(course_department_id) references department(department_id) )engine=innodb default charset=utf8; create table score( score_course_id int(8) UNSIGNED not null, score_student_id bigint(12) UNSIGNED not null, score_score float(5,2) null, score_gpa float(2,1) null, score_pass tinyint(1) null, score_second float(3,2) null, score_information text null, foreign key(score_course_id) references course(course_id), foreign key(score_student_id) references student(student_id), primary key(score_course_id, score_student_id) )engine=innodb default charset=utf8;
true
99fd412f51cdf05420c0a1550a02ee9c02b6570f
SQL
orzocogorzo/mobility-analytics
/postgis/perpendicular_difference.sql
UTF-8
710
3.671875
4
[]
no_license
ALTER TABLE width.rotate90 DROP COLUMN difference; ALTER TABLE width.rotate90 ADD COLUMN difference geometry(MultiLineString, 25831); UPDATE width.rotate90 SET difference = ST_Multi(ST_Difference(lines.geom, intersections.geom)) FROM width.rotate90 as lines LEFT JOIN ( SELECT a.line_id, ST_UNION(a.poly) AS geom FROM ( SELECT tmp_lines.id as line_id, cd.geom as poly FROM width.rotate90 as tmp_lines, cadastre as cd WHERE ST_Intersects( tmp_lines.geom::geometry, cd.geom::geometry ) = true ) as a GROUP BY a.line_id ) as intersections ON lines.id = intersections.line_id;
true
1cf6d9e0bc8dedbff5371739a3f624186a2a35da
SQL
luomo135/26-
/博客系统(struts+hibernate+spring)/博客/文档源码和数据库文件/doc/dlog4j_mysql_323.sql
WINDOWS-1252
13,005
2.796875
3
[]
no_license
/*==============================================================*/ /* Database name: WebDlogݿṹ */ /* DBMS name: MySQL 3.23 */ /* Created on: 2004-10-8 15:38:53 */ /*==============================================================*/ drop table if exists dlog_attachment; drop table if exists dlog_bookmark; drop table if exists dlog_category; drop table if exists dlog_draft; drop table if exists dlog_edit_track; drop table if exists dlog_favorite; drop table if exists dlog_iptrack; drop table if exists dlog_journal; drop table if exists dlog_message; drop table if exists dlog_param; drop table if exists dlog_reference; drop table if exists dlog_reply; drop table if exists dlog_site; drop table if exists dlog_user; drop table if exists dlog_visit; /*==============================================================*/ /* Table: dlog_attachment */ /*==============================================================*/ create table if not exists dlog_attachment ( att_id int not null, logid int, att_type int not null, att_urltype int not null, att_url varchar(50) not null, primary key (att_id) ); /*==============================================================*/ /* Table: dlog_bookmark */ /*==============================================================*/ create table if not exists dlog_bookmark ( markid int not null, logid int, siteid int, userid int, marktype int not null, createTime timestamp not null, markorder int not null, primary key (markid) ); /*==============================================================*/ /* Table: dlog_category */ /*==============================================================*/ create table if not exists dlog_category ( catid int not null, siteid int, catname varchar(40) not null, iconurl varchar(20), cattype int not null, sortOrder int not null, primary key (catid) ); /*==============================================================*/ /* Table: dlog_draft */ /*==============================================================*/ create table if not exists dlog_draft ( draftid int not null, siteid int, userid int, author varchar(50), author_url varchar(100), title varchar(100), content text, saveTime timestamp not null, refUrl varchar(100), weather varchar(20) not null, moodLevel int, useFace int not null, useUbb int not null, showFormerly int not null, primary key (draftid) ); /*==============================================================*/ /* Table: dlog_edit_track */ /*==============================================================*/ create table if not exists dlog_edit_track ( track_id int not null, logid int, userid int, modifytime timestamp not null, primary key (track_id) ); /*==============================================================*/ /* Table: dlog_favorite */ /*==============================================================*/ create table if not exists dlog_favorite ( favid int not null, siteid int, title varchar(100) not null, detail text, url varchar(250) not null, in_new_wnd int not null, createTime timestamp not null, sortOrder int not null, primary key (favid) ); /*==============================================================*/ /* Table: dlog_iptrack */ /*==============================================================*/ create table if not exists dlog_iptrack ( trackid int not null, userid int not null, ipaddr char(15) not null, loginTime timestamp not null, primary key (trackid) ); /*==============================================================*/ /* Table: dlog_journal */ /*==============================================================*/ create table if not exists dlog_journal ( logid int not null, catid int, siteid int, userid int, author varchar(50), author_url varchar(100), title varchar(100), content text, logkeys varchar(40), logTime timestamp not null, refUrl varchar(100), weather varchar(20) not null, moodLevel int, useFace int not null, useUbb int not null, showFormerly int not null, replyNotify int, viewcount int not null, replyCount int not null, delete_time timestamp, "status" int not null, primary key (logid) ); /*==============================================================*/ /* Table: dlog_message */ /*==============================================================*/ create table if not exists dlog_message ( msgid int not null, fromUserId int not null, toUserId int not null, content text not null, ishtml int not null, sendTime timestamp not null, readTime timestamp, "status" int not null, primary key (msgid) ); /*==============================================================*/ /* Table: dlog_param */ /*==============================================================*/ create table if not exists dlog_param ( p_id int not null, siteid int, p_name varchar(20) not null, p_desc varchar(100), p_type int not null, p_value varchar(100), primary key (p_id) ); /*==============================================================*/ /* Table: dlog_reference */ /*==============================================================*/ create table if not exists dlog_reference ( refid int not null, logid int, refurl varchar(100) not null, title varchar(100), excerpt varchar(200), blog_name varchar(50) not null, remoteAddr char(15) not null, reftime timestamp not null, primary key (refid) ); /*==============================================================*/ /* Table: dlog_reply */ /*==============================================================*/ create table if not exists dlog_reply ( cmtid int not null, siteid int, userid int, logid int, faceurl varchar(20), content text, useFace int not null, useUbb int not null, showFormerly int not null, writetime timestamp not null, primary key (cmtid) ); /*==============================================================*/ /* Table: dlog_site */ /*==============================================================*/ create table if not exists dlog_site ( siteid int not null, sitename varchar(20) not null, displayName varchar(100) not null, sitedetail text, siteicon varchar(50), sitelogo varchar(50), cssfile varchar(50), createTime timestamp not null, lastTime timestamp, siteurl varchar(100), "status" int not null, primary key (siteid) ); /*==============================================================*/ /* Table: dlog_user */ /*==============================================================*/ create table if not exists dlog_user ( userid int not null, siteid int, username varchar(20) not null, "password" varchar(50) not null, displayName varchar(50), email varchar(50), homepage varchar(100), resume varchar(250), portrait varchar(40), logincount int, regTime timestamp not null, lastTime timestamp, userRole int not null, ownerCats varchar(20), primary key (userid) ); /*==============================================================*/ /* Table: dlog_visit */ /*==============================================================*/ create table if not exists dlog_visit ( visitID int not null, remoteAddr varchar(15), refererURL varchar(200), requestURL varchar(100) not null, userAgent varchar(100), visitDate char(8) not null, visitTime char(6) not null );
true
e6ae58e898443d2118c0c2e1a10e151fccc8d443
SQL
jesp209i/database
/week 36/PetHospitalData.sql
UTF-8
1,283
3.0625
3
[]
no_license
use PetHospital; INSERT INTO dbo.Treatment VALUES ('Rabies Vaccination'),('Examine and Treat Wound'),('Heart worm test'),('Tetanus Vaccination'),('Annual Check up'),('Eye wash'); INSERT INTO dbo.PetType VALUES ('Dog'),('Cat'),('Bird'); INSERT INTO dbo.Owner VALUES ('Will','Jensen','Vestergade 90','5000', 'Odense C'), ('Terry','Kim','Datenbank Strasse 1','5000','Odense C'); INSERT INTO dbo.Pet VALUES ('Rover', DATEADD(yy,-12,GETDATE()), 1, 1), ('Spot', DATEADD(yy,-2,GETDATE()), 1, 2), ('Morris', DATEADD(yy,-4,GETDATE()), 2, 1), ('Tweedy', DATEADD(yy,-2,GETDATE()), 3, 2); INSERT INTO dbo.Visit VALUES ('2015-01-13 18:44:43.557',1,NULL), ('2015-03-27 18:44:43.557',1,NULL), ('2015-04-02 18:44:43.557',1,NULL), ('2015-01-21 18:44:43.557',2,NULL), ('2015-03-10 18:44:43.557',2,NULL), ('2014-01-23 18:44:43.557',3,NULL), ('2015-01-13 18:44:43.557',3,NULL), ('2015-04-30 18:44:43.557',4,NULL), ('2015-04-30 18:44:43.557',4,NULL) INSERT INTO dbo.Visit_Treatment VALUES (1,1), (2,2), (3,3), (4,4), (5,3), (6,1), (7,1), (8,5), (9,6) INSERT INTO dbo.PetType_Treatment_Price VALUES (1,1,300), (2,1,240) INSERT INTO dbo.Invoice VALUES ('2015-01-31 08:00:00.000', 0); -- Link above invoice to visits. UPDATE dbo.Visit SET InvoiceId = 1 WHERE VisitDate = '2015-01-13 18:44:43.557'
true
523e16c8a0bbc0460c77b2b6b1087312f67e7e17
SQL
lihuibin/vanillatest
/sql/department.sql
UTF-8
448
2.875
3
[]
no_license
/* */ use tel; SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for department -- ---------------------------- DROP TABLE IF EXISTS `department`; CREATE TABLE `department` ( `id` int(10) NOT NULL AUTO_INCREMENT, `pid` int(10) NOT NULL, `depname` varchar(70) NOT NULL, PRIMARY KEY (`id`), KEY `pid` (`pid`) USING BTREE, FULLTEXT KEY `name` (`depname`) ) ENGINE=MyISAM AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;
true
d3086f5ee2aafd4e3385bdaa1037c727a6e86047
SQL
Gomader/Database_Final
/my temporal trigger.sql
UTF-8
1,864
3.640625
4
[]
no_license
delimiter | drop procedure if exists biggo | create procedure biggo() begin set @date=(select curdate()); update DataBaseClass.items set status=1 where endtime <= @data and state = 0; end | set global event_scheduler = 1; create event if not exists events on schedule every 1 second on completion preserve do call biggo(); alter event events on completion preserve enable; delimiter | drop trigger if exists deal | create trigger deal after update on DataBaseClass.items for each row begin update DataBaseClass.user set balance = (select (balance + income*0.98) from (select user.id,balance,sum(bidprice)as income from user join items on items.sellerid=user.id and items.state = 1 group by user.id)as a where a.id=user.id); update DataBaseClass.admin set balance = (select income*0.02 from (select user.id,balance,sum(bidprice)as income from user join items on items.sellerid=user.id and items.state = 1 group by user.id)as a where a.id=user.id) + admin.balance; update DataBaseClass.user set numberOfItemsSold = (select count from items where sellerid = user.id); update DataBaseClass.user set balance = (select (balance - cost) from (select id,balance,sum(bidprice)as cost from user join (select bider,bidprice from items join bidinformation on price = bidprice where items.state=1) as buyer on buyer.bider = user.id group by bider)as b); update DataBaseClass.user set numberOfItemsPurchased = (select count from items join bidinformation on buyprice = price where user.id = bidinformation.bider); update DataBaseClass.user set state = 2 where state = 1; end | | delimiter | drop trigger if exists increase | create trigger deal after insert on DataBaseClass.bidinformation for each row begin update DataBaseClass.items bidprice = (select price from bidinformation order by price desc limit 1 where itemid = items.id); end | |
true
9444725b12a1ea1ca16f70b9a1c7873b59af864b
SQL
lijie27/SecurityGuardSystem
/SQL File/clientmsdb.sql
UTF-8
12,822
3.109375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 5.1.0 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Apr 18, 2021 at 06:45 PM -- Server version: 10.4.18-MariaDB -- PHP Version: 8.0.3 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: `clientmsdb` -- -- -------------------------------------------------------- -- -- Table structure for table `feedback` -- CREATE TABLE `feedback` ( `Feedback_no` int(10) UNSIGNED NOT NULL, `CompanyName` varchar(200) NOT NULL, `Issue` varchar(50) NOT NULL, `Submitted_date` date DEFAULT NULL, `Feedback_details` varchar(50) NOT NULL, `Status` varchar(10) NOT NULL, `From` varchar(20) NOT NULL, `Role` varchar(30) NOT NULL, `Response` varchar(100) NOT NULL, `Response_date` date DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `invoice_details` -- CREATE TABLE `invoice_details` ( `invoiceID` int(10) UNSIGNED NOT NULL, `ID` int(10) NOT NULL, `due_date` date NOT NULL, `product_details` varchar(200) NOT NULL, `unit_hours` int(20) DEFAULT NULL, `product_quantity` date NOT NULL, `product_cost` decimal(20,2) NOT NULL, `product_amount` decimal(20,2) NOT NULL, `product_sub` decimal(20,2) NOT NULL, `product_tax` decimal(20,2) NOT NULL, `product_discount` decimal(20,2) NOT NULL, `product_total` decimal(20,2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `invoice_view` -- CREATE TABLE `invoice_view` ( `invoiceID` int(6) UNSIGNED NOT NULL, `date_received` date NOT NULL, `due_date` date NOT NULL, `invoice_amount` decimal(20,2) NOT NULL, `invoice_status` varchar(20) NOT NULL, `payment_date` date DEFAULT NULL, `payment_method` varchar(15) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `tblaccount` -- CREATE TABLE `tblaccount` ( `AccountID` varchar(7) NOT NULL, `Picture` varchar(150) NOT NULL, `Name` varchar(50) NOT NULL, `Password` varchar(20) NOT NULL, `Phone` int(20) NOT NULL, `Status` varchar(8) NOT NULL DEFAULT 'Active', `Race` varchar(15) NOT NULL, `Nationality` varchar(20) NOT NULL, `Age` int(2) NOT NULL, `PassportNo` varchar(20) NOT NULL, `Visa_Status` varchar(5) NOT NULL, `Medical_checkUp` varchar(150) NOT NULL, `Passport_Copy` varchar(150) NOT NULL, `WorkingPermitDueDate` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `tblaccount` -- INSERT INTO `tblaccount` (`AccountID`, `Picture`, `Name`, `Password`, `Phone`, `Status`, `Race`, `Country`, `Age`, `Gender`, `PassportNo.`, `Visa Status`, `Medical check-up`, `Passport Copy`, `WorkingPermitDueDate`) VALUES ('GU002', 'guard.jpg', 'Mohammad Muthu', '123', 122523654, 'Active', 'Bangali', 'Bangladesh', 25, 'Male', 'A12345678', 'D3', 'medical.jpg', 'passport.jpg', '2024-04-01'); -- -------------------------------------------------------- -- -- Table structure for table `tbladmin` -- CREATE TABLE `tbladmin` ( `ID` int(10) NOT NULL, `AdminName` varchar(120) DEFAULT NULL, `UserName` varchar(120) DEFAULT NULL, `MobileNumber` bigint(10) DEFAULT NULL, `Email` varchar(120) DEFAULT NULL, `Password` varchar(120) DEFAULT NULL, `AdminRegdate` timestamp NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbladmin` -- INSERT INTO `tbladmin` (`ID`, `AdminName`, `UserName`, `MobileNumber`, `Email`, `Password`, `AdminRegdate`) VALUES (1, 'Admin', 'admin', 8979555562, 'admin@gmail.com', 'f925916e2754e5e03f75dd58a5733251', '2019-10-21 07:01:36'); -- -------------------------------------------------------- -- -- Table structure for table `tblclient` -- CREATE TABLE `tblclient` ( `client_id` int(10) NOT NULL, `AccountID` int(10) DEFAULT NULL, `ContactName` varchar(120) DEFAULT NULL, `CompanyName` varchar(120) DEFAULT NULL, `Address` varchar(200) DEFAULT NULL, `City` varchar(120) DEFAULT NULL, `State` varchar(120) DEFAULT NULL, `ZipCode` int(10) DEFAULT NULL, `Workphnumber` bigint(10) DEFAULT NULL, `Cellphnumber` bigint(10) DEFAULT NULL, `Email` varchar(200) DEFAULT NULL, `Password` varchar(200) NOT NULL, `CreationDate` timestamp NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tblclient` -- INSERT INTO `tblclient` (`client_id`, `AccountID`, `ContactName`, `CompanyName`, `Address`, `City`, `State`, `ZipCode`, `Workphnumber`, `Cellphnumber`, `Email`, `Password`, `CreationDate`) VALUES (1, 900370752, 'Sanjay Malhotra', 'ABC Private Limited', 'ABC Private Limited\r\nB-150,Okhla New Delhi', 'New Delhi', 'Delhi/NCR', 1100096, 8888888888, 4354354354, 'abc@gmail.com', '202cb962ac59075b964b07152d234b70', '2019-10-22 04:40:11'), (2, 884010538, 'Sidharth Sukla', 'Infosys Pvt Ltd', 'Infosys Pvt Ltd\r\nC-123, Sector 15 Noida ', 'Noida', 'NCR', 1321121, 4454545454, 7787878787, 'infosys@gmail.com', '202cb962ac59075b964b07152d234b70', '2019-10-22 05:24:39'), (3, 809338201, 'Naveen Singh', 'ghj pvt ltd', 'ghj pvt ltd\r\ng-127 Delhi', 'New Delhi', 'Delhi/NCR', 1100096, 4464654665, 4654654646, 'ghj@gmail.com', '202cb962ac59075b964b07152d234b70', '2019-10-22 05:26:50'), (4, 639974991, 'Abir Rajwansh', 'KML PVT LTD', 'KML PVT LTD\r\nh-224 sector 62, Noida(NCR)', 'Noida', 'Delhi/NCR', 5465456, 5523235656, 8985652332, 'kml@gmail.com', '202cb962ac59075b964b07152d234b70', '2019-10-22 05:29:59'), (5, 602410634, 'Kundan Shah', 'JK Enterprises', 'JK Enterprises\r\nH-120,Shivala Varanasi', 'Varanasi', 'UP', 221001, 1213465464, 1645489799, 'jk@gmail.com', '202cb962ac59075b964b07152d234b70', '2019-10-23 10:42:52'), (6, 426546224, 'Anuj Kumar', 'PHPGurukul Programming Blog', 'New Delhi', 'New Delhi', 'Delhi', 110001, 9354778033, 9354778033, 'phpgurukulofficial@gmail.com', 'f925916e2754e5e03f75dd58a5733251', '2019-11-27 16:00:24'), (7, 967927403, 'eqw', '12', '12', '12', 'eqw', 2222, 23123, 12331, 'sanjay1@hotmail.com', 'aa78c3db4fc4a1a343183d6113ec46ba', '2021-04-13 07:18:58'); -- -------------------------------------------------------- -- -- Table structure for table `tblpage` -- CREATE TABLE `tblpage` ( `ID` int(10) NOT NULL, `PageType` varchar(120) DEFAULT NULL, `PageTitle` varchar(200) DEFAULT NULL, `PageDescription` mediumtext DEFAULT NULL, `Email` varchar(120) DEFAULT NULL, `MobileNumber` bigint(10) DEFAULT NULL, `UpdationDate` timestamp NULL DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tblpage` -- INSERT INTO `tblpage` (`ID`, `PageType`, `PageTitle`, `PageDescription`, `Email`, `MobileNumber`, `UpdationDate`) VALUES (1, 'aboutus', 'About Us', 'bghjgjhg', NULL, NULL, '2019-10-24 07:54:52'), (2, 'contactus', 'Contact Us', 'D-204, Hole Town South West,Delhi-110096,India', 'info@gmail.com', 8529631237, '2019-10-24 07:56:56'); -- -------------------------------------------------------- -- -- Table structure for table `tblservicedetail` -- CREATE TABLE `tblservicedetail` ( `ServiceID` varchar(10) NOT NULL, `ServiceDetail_ID` varchar(10) NOT NULL, `Guard_Day` int(2) NOT NULL, `Guard_Hour` int(2) NOT NULL, `Guard_Month` int(2) NOT NULL, `Hour` int(11) NOT NULL, `Day` int(3) NOT NULL, `Month` int(3) NOT NULL, `Discount_Code` varchar(20) NOT NULL, `Price` decimal(10,0) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `tblservicedetail` -- INSERT INTO `tblservicedetail` (`ServiceID`, `ServiceDetail_ID`, `Guard_Day`, `Guard_Hour`, `Guard_Month`, `Hour`, `Day`, `Month`, `Discount_Code`, `Price`) VALUES ('S001', 'SD001', 1, 0, 1, 6, 0, 1, '', '6800'); -- -------------------------------------------------------- -- -- Table structure for table `tblservices` -- CREATE TABLE `tblservices` ( `ServiceID` varchar(10) NOT NULL, `CompanyName` varchar(200) DEFAULT NULL, `ClientName` varchar(30) DEFAULT NULL, `Email` varchar(30) NOT NULL, `Phone` int(15) NOT NULL, `ServiceDetail_ID` varchar(10) NOT NULL, `Remark` varchar(50) NOT NULL, `Address` varchar(50) NOT NULL, `Postcode` int(6) NOT NULL, `State` varchar(20) NOT NULL, `CreateDate` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `Status` varchar(16) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tblservices` -- INSERT INTO `tblservices` (`ServiceID`, `CompanyName`, `ClientName`, `Email`, `Phone`, `ServiceDetail_ID`, `Remark`, `Address`, `Postcode`, `State`, `CreateDate`, `Status`) VALUES ('S001', 'Consolsys sdn bhd', 'Mr.Ahmad', 'ahmad@consolsys.com', 1124522369, 'SD001', '', '52,Jalan Wangsa', 53300, 'Kuala Lumpur', '2021-04-16 08:44:37', 'Assigned'); -- -------------------------------------------------------- -- -- Table structure for table `tblstaff` -- CREATE TABLE `tblstaff` ( `StaffID` varchar(9) NOT NULL, `Name` varchar(20) NOT NULL, `Phone` int(15) NOT NULL, `Email` varchar(25) NOT NULL, `Password` varchar(20) NOT NULL, `Address` varchar(20) NOT NULL, `State` varchar(20) NOT NULL, `Postcode` int(5) NOT NULL, `Nationality` varchar(20) NOT NULL, `Status` varchar(10) NOT NULL, `Department` varchar(20) NOT NULL, `Position` varchar(20) NOT NULL, `Level` varchar(4) NOT NULL, `Salary` int(10) NOT NULL, `Joined date` date NOT NULL, `Visa status` varchar(3) NOT NULL, `Picture` varchar(100) NOT NULL, `Gender` varchar(6) NOT NULL, `Age` int(2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- -- -- Table structure for table `tblvisitor` -- CREATE TABLE `tblvisitor` ( `VisitorID` varchar(10) NOT NULL, `Name` varchar(20) NOT NULL, `Phone` int(20) NOT NULL, `IC` int(15) NOT NULL, `DateVisited` date NOT NULL DEFAULT current_timestamp(), `WalkInTime` time NOT NULL DEFAULT current_timestamp(), `WalkOutTime` time NOT NULL, `TotalVisitTime` varchar(15) NOT NULL, `VisitUnit` varchar(10) NOT NULL, `VisitMethod` varchar(20) NOT NULL, `Remark` varchar(100) NOT NULL, `Status` varchar(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Indexes for dumped tables -- -- -- Indexes for table `feedback` -- ALTER TABLE `feedback` ADD PRIMARY KEY (`Feedback_no`); -- -- Indexes for table `invoice_details` -- ALTER TABLE `invoice_details` ADD PRIMARY KEY (`invoiceID`); -- -- Indexes for table `invoice_view` -- ALTER TABLE `invoice_view` ADD PRIMARY KEY (`invoiceID`); -- -- Indexes for table `tblaccount` -- ALTER TABLE `tblaccount` ADD PRIMARY KEY (`AccountID`); -- -- Indexes for table `tbladmin` -- ALTER TABLE `tbladmin` ADD PRIMARY KEY (`ID`); -- -- Indexes for table `tblclient` -- ALTER TABLE `tblclient` ADD PRIMARY KEY (`client_id`); -- -- Indexes for table `tblpage` -- ALTER TABLE `tblpage` ADD PRIMARY KEY (`ID`); -- -- Indexes for table `tblservicedetail` -- ALTER TABLE `tblservicedetail` ADD PRIMARY KEY (`ServiceID`); -- -- Indexes for table `tblservices` -- ALTER TABLE `tblservices` ADD PRIMARY KEY (`ServiceID`); -- -- Indexes for table `tblstaff` -- ALTER TABLE `tblstaff` ADD PRIMARY KEY (`StaffID`); -- -- Indexes for table `tblvisitor` -- ALTER TABLE `tblvisitor` ADD PRIMARY KEY (`VisitorID`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `feedback` -- ALTER TABLE `feedback` MODIFY `Feedback_no` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `invoice_details` -- ALTER TABLE `invoice_details` MODIFY `invoiceID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `invoice_view` -- ALTER TABLE `invoice_view` MODIFY `invoiceID` int(6) UNSIGNED NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `tbladmin` -- ALTER TABLE `tbladmin` MODIFY `ID` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `tblclient` -- ALTER TABLE `tblclient` MODIFY `client_id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `tblpage` -- ALTER TABLE `tblpage` MODIFY `ID` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- Constraints for dumped tables -- -- -- Constraints for table `invoice_details` -- ALTER TABLE `invoice_details` ADD CONSTRAINT `invoice_details_ibfk_1` FOREIGN KEY (`invoiceID`) REFERENCES `invoice_view` (`invoiceID`) ON DELETE CASCADE ON UPDATE CASCADE; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
86a04b70b599726f494e041327f2553bf67fe668
SQL
adiSuper94/growfin-desk-demo
/src/main/resources/db/migration/V1__initdb.sql
UTF-8
3,080
3.890625
4
[]
no_license
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE SCHEMA IF NOT EXISTS core; CREATE TYPE ticket_status AS ENUM ( 'open', 'waiting_on_customer', 'customer_responded', 'resolved', 'closed' ); CREATE TYPE ticket_history_type AS ENUM ( 'status', 'priority', 'assignee' ); CREATE TYPE ticket_priority AS ENUM ( 'p0', 'p1', 'p2' ); CREATE TYPE ticket_type AS ENUM ( 'type1', 'type2', 'type3' ); CREATE TABLE org ( id UUID DEFAULT uuid_generate_v4 () PRIMARY KEY, name VARCHAR(50) NOT NULL ); CREATE TABLE customer ( id UUID DEFAULT uuid_generate_v4 () PRIMARY KEY, name VARCHAR(100) NOT NULL, email_id VARCHAR(100) NOT NULL UNIQUE, active BOOLEAN DEFAULT TRUE, org_id UUID NOT NULL, FOREIGN KEY (org_id) REFERENCES org(id) ON DELETE CASCADE ); CREATE TABLE agent ( id UUID DEFAULT uuid_generate_v4 () PRIMARY KEY, name VARCHAR(100) NOT NULL, email_id VARCHAR(100) NOT NULL UNIQUE, active BOOLEAN DEFAULT TRUE, org_id UUID NOT NULL, FOREIGN KEY (org_id) REFERENCES org(id) ON DELETE CASCADE ); CREATE TABLE ticket ( id UUID DEFAULT uuid_generate_v4 () PRIMARY KEY, title VARCHAR(200), description VARCHAR(1500), status ticket_status NOT NULL, priority ticket_priority, type ticket_type NOT NULL, creator_id UUID, assignee_id UUID, customer_id UUID, created_at TIMESTAMP NOT NULL, modified_at TIMESTAMP NOT NULL, org_id UUID NOT NULL, FOREIGN KEY (org_id) REFERENCES org(id) ON DELETE CASCADE, FOREIGN KEY (creator_id) REFERENCES agent(id) ON DELETE CASCADE, FOREIGN KEY (assignee_id) REFERENCES agent(id) ON DELETE CASCADE, FOREIGN KEY (customer_id) REFERENCES customer(id) ON DELETE CASCADE ); CREATE TABLE ticket_history ( id UUID DEFAULT uuid_generate_v4 () PRIMARY KEY, ticket_id UUID, author UUID NOT NULL, type ticket_history_type NOT NULL, old_value VARCHAR(1500), new_value VARCHAR(150) NOT NULL, created_at TIMESTAMP NOT NULL, org_id UUID NOT NULL, FOREIGN KEY (org_id) REFERENCES org(id) ON DELETE CASCADE, FOREIGN KEY (ticket_id) REFERENCES ticket(id) ON DELETE CASCADE, FOREIGN KEY (author) REFERENCES agent(id) ON DELETE CASCADE ); CREATE TABLE response ( id UUID DEFAULT uuid_generate_v4 () PRIMARY KEY, ticket_id UUID, author UUID, text VARCHAR(1500) NOT NULL, created_at TIMESTAMP NOT NULL, org_id UUID NOT NULL, FOREIGN KEY (org_id) REFERENCES org(id) ON DELETE CASCADE, FOREIGN KEY (ticket_id) REFERENCES ticket(id) ON DELETE CASCADE, FOREIGN KEY (author) REFERENCES agent(id) ON DELETE CASCADE ); CREATE TABLE cx_notification ( id UUID DEFAULT uuid_generate_v4 () PRIMARY KEY, template_location VARCHAR(100) NOT NULL, context jsonb NOT NULL, to_address UUID, is_sent boolean, org_id UUID NOT NULL, FOREIGN KEY (org_id) REFERENCES org(id) ON DELETE CASCADE, FOREIGN KEY (to_address) REFERENCES customer(id) ON DELETE CASCADE ); -- ticket CREATE INDEX IF NOT EXISTS ticket_assignee ON ticket (assignee_id); --ticket_history CREATE INDEX IF NOT EXISTS ticket_history_ticket_id ON ticket_history (ticket_id);
true
c2709c36d31709f0c65ffe11da01d1e859ea17a4
SQL
Mitchell-Stone/Team_Project
/eits.sql
UTF-8
12,725
3.328125
3
[]
no_license
-- -- Database: `eits` -- -- -------------------------------------------------------- -- -- Table structure for table `admin` -- CREATE TABLE `admin` ( `adminID` int(11) NOT NULL, `firstName` varchar(255) NOT NULL, `lastName` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `phoneNumber` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `admin` -- INSERT INTO `admin` (`adminID`, `firstName`, `lastName`, `email`, `password`, `phoneNumber`) VALUES (1, 'Mitch', 'Stone', 'mitchStone@email.com', 'seasame', '0404040404'), (2, 'aa', 'aa', 'aa@aa.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', '0606066060'), (4, 'Gaben', 'Newell', 'lordgaben@steam.money', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL), (5, 'Bill', 'Gates', 'billgates@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', '01010101'); -- -------------------------------------------------------- -- -- Table structure for table `assessment` -- CREATE TABLE `assessment` ( `assessmentID` int(11) NOT NULL, `courseID` int(11) NOT NULL, `title` varchar(255) NOT NULL, `description` text NOT NULL, `date` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `assessment` -- INSERT INTO `assessment` (`assessmentID`, `courseID`, `title`, `description`, `date`) VALUES (1, 1, 'History Of Pepe', 'Research the history of the pepe meme.', '2018-05-31'), (2, 1, 'Classic Memes', 'Research the History of the most classic and iconic memes.', '2018-06-23'), (3, 1, 'Foreign Memes 1 - Italian memes', 'Research the most popular memes used in the ex-Roman Empire.', '2018-06-30'), (4, 2, 'HTML5', 'Do Hello world in HTMl5.', '2018-06-30'), (5, 2, 'CSS3', 'Style Hello World In CSS3.', '2018-06-22'), (6, 3, 'Java', 'Learn Java.', '2018-06-20'), (7, 3, 'C#', 'Learn C#.', '2018-06-15'), (8, 4, 'EITS Learning Management App.', 'With the help of your jolly goodfellows build the EITS learning management app according to the project manager''s specs.', '2018-06-18'), (9, 4, 'Document EITS', 'Draft a viable project to develop a complete product.', '2018-06-14'), (10, 5, 'Attempt to learn Sourcetree', 'In case of failure refer to Mr. Stone.', '2018-06-29'), (11, 4, 'MS Projects', 'Use MS Projects to create a viable project.', '2018-06-22'), (12, 6, 'CPR Practice1', 'Do the CPR.', '2018-06-21'), (13, 6, 'CPR Practice 2', 'Do more CPR.', '2018-06-16'), (14, 7, 'Anatomy 1 ', 'Learn about your insides.', '2018-06-16'), (15, 7, 'Anatomy 2', 'Learn about your mate''s insides.', '2018-06-22'), (16, 7, 'Anatomy 3 ', 'Learn about your mate''s cat''s insides. He will not be pleased.', '2018-06-21'), (17, 8, 'Emergency Vehicle equipment', 'Learn about the emergency vehicle equipment.', '2018-06-29'), (18, 8, 'Speed driving course', 'Try to save people while driving like a nutcase.', '2018-06-30'), (19, 9, 'hand washing', 'That''s about it.', '2018-06-22'), (20, 9, 'Surgeon Hand Washing', 'A bit more.', '2018-06-21'), (21, 10, 'Word and PP', 'MS Word and Power point.', '2018-06-15'), (22, 10, 'Excell ', 'Like MySQL but green.', '2018-06-15'), (23, 11, 'MS Projects', 'Learn how to use Projects.', '2018-06-16'), (24, 12, 'MS Others', 'Learn about lesser known MS Office programs, also become pro at Excell and PP animations. ', '2018-06-15'), (25, 13, 'Emergency Management Operations', 'Learn how to save all the people at the same time while sitting at your desk.', '2018-06-15'), (26, 14, 'Photoshop', 'Learn photoshop', '2018-06-22'), (27, 15, 'Illustrator', 'Learn Illustrator.', '2018-06-22'), (28, 16, 'Learn lightroom', 'Learn that and all the other Adobe software.', '2018-06-22'), (29, 17, 'Model making 1', 'Build a tiny house.', '2018-06-21'), (30, 18, 'Model making 2', 'Build more tiny houses and call it a tiny city. Filled with tiny people and a tiny park.', '2018-06-22'), (31, 19, 'Visual Arts 1', 'Learn about visual arts.', '2018-06-21'), (32, 19, 'Performing Arts', 'Learn about performing arts.', '2018-06-22'); -- -------------------------------------------------------- -- -- Table structure for table `attendance` -- CREATE TABLE `attendance` ( `date` date NOT NULL, `studentID` int(11) NOT NULL, `courseID` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `caseworker` -- CREATE TABLE `caseworker` ( `employeeID` int(11) NOT NULL, `firstName` varchar(255) NOT NULL, `lastName` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `specialty` varchar(255) DEFAULT NULL, `phoneNumber` varchar(30) DEFAULT NULL, `bio` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `caseworker` -- INSERT INTO `caseworker` (`employeeID`, `firstName`, `lastName`, `email`, `password`, `specialty`, `phoneNumber`, `bio`) VALUES (1, 'Dave', 'Hunt', 'david.hunt@hotmail.com', 'seasame', 'Stuff', '404040404', '2'), (2, 'j', 'j', 'j', 'GJ9AA0vnoZnx+piRZo7jq2BJ+C04xovnD1luqy4YV7c=', NULL, NULL, NULL), (3, 'Lamp', 'Blanket', 'lampblanket@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL), (4, 'Jar', 'O''Mayo', 'jaromayo@email.mayo', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL), (5, 'Neill', 'Blomkamp', 'district9@prawn.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', 'IT', '909090', 'Cool guy'), (6, 'My', 'Smith', 'mysql@oracle.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', 'IT', '23232323', 'Cool'); -- -------------------------------------------------------- -- -- Table structure for table `courses` -- CREATE TABLE `courses` ( `courseID` int(11) NOT NULL, `name` varchar(255) NOT NULL, `industry` varchar(255) NOT NULL, `location` varchar(255) NOT NULL, `numberOfHours` int(11) NOT NULL, `finishingDegree` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `courses` -- INSERT INTO `courses` (`courseID`, `name`, `industry`, `location`, `numberOfHours`, `finishingDegree`) VALUES (1, 'Meme History', 'Memes', 'Meme Campus', 69, 420), (2, 'Internet Programming 1', 'IT', 'Coomera', 50, 1), (3, 'Object Oriented Programming 1', 'IT', 'Coomera', 100, 1), (4, 'Project Management 1', 'Management', 'Coomera', 100, 1), (5, 'Basics of Sourcetree', 'Pain', 'Hell', 250, 1), (6, 'CPR 1', 'Health', 'Coomera', 30, 1), (7, 'Basic Anatomy 1', 'Health', 'Coomera', 100, 1), (8, 'Ambulance Operations', 'Health', 'Southport', 200, 1), (9, 'Sanitation', 'Health', 'Coomera', 20, 1), (10, 'Basic MS Office', 'IT', 'Coomera', 100, 1), (11, 'Intermediate MS Office', 'IT', 'Coomera', 200, 1), (12, 'Advanced MS Office', 'IT', 'Coomera', 250, 1), (13, 'Ambulance Dispatch', 'Health', 'Southport', 200, 1), (14, 'Adobe Suite Basics', 'IT', 'Coomera', 100, 1), (15, 'Adobe Suite Intermediate', 'IT', 'Coomera', 250, 1), (16, 'Adobe Suite Advanced', 'IT', 'Coomera', 420, 1), (17, 'Modelling 1 ', 'Design', 'Coomera', 300, 1), (18, 'Modelling 2', 'Design', 'Coomera', 400, 1), (19, 'Art History', 'History', 'Coomera', 100, 1); -- -------------------------------------------------------- -- -- Table structure for table `student` -- CREATE TABLE `student` ( `studentID` int(11) NOT NULL, `diplomaID` int(11) DEFAULT NULL, `employeeID` int(11) DEFAULT NULL, `firstName` varchar(255) NOT NULL, `lastName` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `industryPreference` int(11) DEFAULT NULL, `visitCount` int(11) DEFAULT NULL, `averageGrade` int(11) DEFAULT NULL, `assessmentsPassed` tinyint(1) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `student` -- INSERT INTO `student` (`studentID`, `diplomaID`, `employeeID`, `firstName`, `lastName`, `email`, `password`, `industryPreference`, `visitCount`, `averageGrade`, `assessmentsPassed`) VALUES (2, 1, 1, 'Matteo', 'Baldini', 'Matteo@live.com', 'seasame', NULL, NULL, NULL, NULL), (3, 1, 1, 'Dion', 'Bird', 'DionBird@live.com', 'seasame', NULL, NULL, NULL, NULL), (7, 1, 3, 'o', 'o', 'o', 'ZcdMFaaGGHu2u/mVj0lPxrgAaANKZZqa1EmRsIxY8tI=', NULL, NULL, NULL, NULL), (8, 1, 4, 'ggg', 'ggg', 'ggg', 'Vpx/C0HOlklgKgIYzQLtCwo9kxMDKUUcx4K339p5znE=', NULL, NULL, NULL, NULL), (9, NULL, NULL, 'Matteo', 'Baldini', 'matteo.baldini@outlook.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (10, NULL, NULL, 'Mitchell', 'Stone', 'mitch.stone@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (11, NULL, NULL, 'Jake', 'Smith', 'jake.smith@email.ru', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (12, NULL, NULL, 'Dion', 'Bird', 'dion.bird@email.jp', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (13, NULL, NULL, 'David', 'Hunt', 'david.hunt@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (14, NULL, NULL, 'Scott', 'Green', 'scott.green@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (15, NULL, NULL, 'Post', 'Malone', 'post.malone@email.420', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (16, NULL, NULL, 'Bob', 'Marley', 'bob.marley@email.ja', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (17, NULL, NULL, 'Ziggy', 'Marley', 'z.marley@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (18, NULL, NULL, 'Harry', 'Potter', 'h.p@email.hogwarts', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (19, NULL, NULL, 'Ronald', 'Weasley', 'r.w@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (20, NULL, NULL, 'Hermione', 'Granger', 'h.g@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (21, NULL, NULL, 'Ronald', 'McDonald', 'r.mcd@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (22, NULL, NULL, 'Mudge', 'TheCat', 'mdgthc@email.com', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (23, NULL, NULL, 'Bottle', 'O''Water', 'bottleowater@email.h2o', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (24, 2, 3, 'aaa', 'aaa', 'aaa', 'mDSHbc+wXLFnpcJJU+uljErImxrfV/KPL50JrxB+6PA=', NULL, NULL, NULL, NULL), (25, 3, 4, 'lll', 'lll', 'lll', 'yqIu9aEp2n8d08ROcy3cnL4UHC9FQoWQ74ot3xJWLVU=', NULL, NULL, NULL, NULL); -- -- Indexes for dumped tables -- -- -- Indexes for table `admin` -- ALTER TABLE `admin` ADD PRIMARY KEY (`adminID`); -- -- Indexes for table `assessment` -- ALTER TABLE `assessment` ADD PRIMARY KEY (`assessmentID`), ADD KEY `courseID` (`courseID`); -- -- Indexes for table `attendance` -- ALTER TABLE `attendance` ADD KEY `studentID` (`studentID`), ADD KEY `courseID` (`courseID`); -- -- Indexes for table `caseworker` -- ALTER TABLE `caseworker` ADD PRIMARY KEY (`employeeID`); -- -- Indexes for table `courses` -- ALTER TABLE `courses` ADD PRIMARY KEY (`courseID`); -- -- Indexes for table `student` -- ALTER TABLE `student` ADD PRIMARY KEY (`studentID`), ADD KEY `employee` (`employeeID`), ADD KEY `diplomaID` (`diplomaID`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `admin` -- ALTER TABLE `admin` MODIFY `adminID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `assessment` -- ALTER TABLE `assessment` MODIFY `assessmentID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33; -- -- AUTO_INCREMENT for table `caseworker` -- ALTER TABLE `caseworker` MODIFY `employeeID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; -- -- AUTO_INCREMENT for table `courses` -- ALTER TABLE `courses` MODIFY `courseID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20; -- -- AUTO_INCREMENT for table `student` -- ALTER TABLE `student` MODIFY `studentID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26; -- -- Constraints for dumped tables -- -- -- Constraints for table `assessment` -- ALTER TABLE `assessment` ADD CONSTRAINT `assessment_ibfk_2` FOREIGN KEY (`courseID`) REFERENCES `courses` (`courseID`); -- -- Constraints for table `attendance` -- ALTER TABLE `attendance` ADD CONSTRAINT `attendance_ibfk_1` FOREIGN KEY (`studentID`) REFERENCES `student` (`studentID`), ADD CONSTRAINT `attendance_ibfk_2` FOREIGN KEY (`courseID`) REFERENCES `courses` (`courseID`); -- -- Constraints for table `student` -- ALTER TABLE `student` ADD CONSTRAINT `student_ibfk_1` FOREIGN KEY (`employeeID`) REFERENCES `caseworker` (`employeeID`), ADD CONSTRAINT `student_ibfk_2` FOREIGN KEY (`diplomaID`) REFERENCES `diploma` (`diplomaID`) ON DELETE SET NULL ON UPDATE SET NULL; /*!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
c79fde51dff72cb5af4917db6066d4ff2540b43b
SQL
tkionshao/Cov_Push_Tool
/sp_history/SP_Generate_Global_Statistic_cell_agg_gsm.sql
UTF-8
13,888
2.6875
3
[]
no_license
DELIMITER $$ USE `gt_global_statistic`$$ DROP PROCEDURE IF EXISTS `SP_CreateDB_LTE`$$ CREATE DEFINER=`covmo`@`%` PROCEDURE `SP_Generate_Global_Statistic_cell_agg_gsm`(IN DATA_DATE DATE,IN DATA_HOUR TINYINT(2),IN PU_ID MEDIUMINT(9),IN TECH_MASK TINYINT(2), IN GT_DB VARCHAR(100)) BEGIN DECLARE SP_Process VARCHAR(100) DEFAULT NULL; DECLARE WORKER_ID VARCHAR(10) DEFAULT CONNECTION_ID(); DECLARE Spider_SP_ERROR CONDITION FOR SQLSTATE '99998'; DECLARE KPI_ERROR CONDITION FOR SQLSTATE '99999' ; DECLARE ZOOM_LEVEL INT; INSERT INTO gt_gw_main.sp_log VALUES('gt_gw_main','SP_Generate_Global_Statistic_cell_agg_gsm',CONCAT(GT_DB,' CREATE TEMPORARY TABLE tmp_materialization_',WORKER_ID), NOW()); SET @SqlCmd=CONCAT('SELECT `att_value` INTO @ZOOM_LEVEL FROM gt_covmo.`sys_config` WHERE `group_name`=''system'' AND att_name = ''MapResolution'';'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET SESSION group_concat_max_len=102400; SET @SqlCmd=CONCAT('DROP TEMPORARY TABLE IF EXISTS ',GT_DB,'.tmp_materialization_',WORKER_ID,';'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('CREATE TEMPORARY TABLE ',GT_DB,'.tmp_materialization_',WORKER_ID,' ( `DATA_DATE` datetime NOT NULL, `DATA_HOUR` tinyint(4) NOT NULL, `CELL_ID` mediumint(9) NOT NULL, `SITE_ID` varchar(20) DEFAULT NULL, `BSC_ID` mediumint(9) NOT NULL, `BCCH_ARFCN` smallint(5) unsigned DEFAULT NULL, `BANDINDEX` varchar(10) DEFAULT NULL, `INIT_CALL_CNT` int(11) DEFAULT NULL, `END_CALL_CNT` int(11) DEFAULT NULL, `VOICE_CNT` int(11) DEFAULT NULL, `SIGNAL_CNT` int(11) DEFAULT NULL, `SMS_CNT` int(11) DEFAULT NULL, `GPRS_CNT` int(11) DEFAULT NULL, `OTHER_CNT` int(11) DEFAULT NULL, `END_VOICE_CNT` int(11) DEFAULT NULL, `END_SIGNAL_CNT` int(11) DEFAULT NULL, `END_SMS_CNT` int(11) DEFAULT NULL, `END_GPRS_CNT` int(11) DEFAULT NULL, `END_OTHER_CNT` int(11) DEFAULT NULL, `BLOCK_VOICE_CNT` int(11) DEFAULT NULL, `BLOCK_GPRS_CNT` int(11) DEFAULT NULL, `BLOCK_SMS_CNT` int(11) DEFAULT NULL, `BLOCK_SIGNAL_CNT` int(11) DEFAULT NULL, `BLOCK_OTHER_CNT` int(11) DEFAULT NULL, `DROP_VOICE_CNT` int(11) DEFAULT NULL, `DROP_SIGNAL_CNT` int(11) DEFAULT NULL, `DROP_SMS_CNT` int(11) DEFAULT NULL, `DROP_GPRS_CNT` int(11) DEFAULT NULL, `DROP_OTHER_CNT` int(11) DEFAULT NULL, `NON_BLOCK_VOICE_CNT` int(11) DEFAULT NULL, `NON_BLOCK_SIGNAL_CNT` int(11) DEFAULT NULL, `NON_BLOCK_SMS_CNT` int(11) DEFAULT NULL, `NON_BLOCK_GPRS_CNT` int(11) DEFAULT NULL, `NON_BLOCK_OTHER_CNT` int(11) DEFAULT NULL, `RXLEV_SUM` double DEFAULT NULL, `RXLEV_CNT` int(11) DEFAULT NULL, `RXQUAL_SUM` double DEFAULT NULL, `RXQUAL_CNT` int(11) DEFAULT NULL, `CALL_SETUP_TIME_SUM` int(11) DEFAULT NULL, `CALL_SETUP_TIME_CNT` int(11) DEFAULT NULL, `CALL_SETUP_TIME_VOICE_SUM` int(11) DEFAULT NULL, `CALL_SETUP_TIME_VOICE_CNT` int(11) DEFAULT NULL, `CALL_SETUP_TIME_SIG_SUM` int(11) DEFAULT NULL, `CALL_SETUP_TIME_SIG_CNT` int(11) DEFAULT NULL, `CALL_SETUP_TIME_SMS_SUM` int(11) DEFAULT NULL, `CALL_SETUP_TIME_SMS_CNT` int(11) DEFAULT NULL, `CALL_SETUP_TIME_GPRS_SUM` int(11) DEFAULT NULL, `CALL_SETUP_TIME_GPRS_CNT` int(11) DEFAULT NULL, `CALL_SETUP_TIME_OTH_SUM` int(11) DEFAULT NULL, `CALL_SETUP_TIME_OTH_CNT` int(11) DEFAULT NULL, `SF_VOICE_CNT` int(11) DEFAULT NULL, `SF_DATA_CNT` int(11) DEFAULT NULL, `SF_SMS_CNT` int(11) DEFAULT NULL, `SF_SIGNAL_CNT` int(11) DEFAULT NULL, `SF_OTHER_CNT` int(11) DEFAULT NULL, `CALL_DUR_SUM` double DEFAULT NULL, `VOICE_DUR_SUM` double DEFAULT NULL, `DATA_DUR_SUM` double DEFAULT NULL ,PRIMARY KEY (`CELL_ID`,`BSC_ID`,`BCCH_ARFCN`,`BANDINDEX`,`DATA_DATE`,`DATA_HOUR`) ) ENGINE=MYISAM DEFAULT CHARSET=latin1;'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; INSERT INTO gt_gw_main.sp_log VALUES('gt_gw_main','SP_Generate_Global_Statistic_cell_agg_gsm',CONCAT(GT_DB,' INSERT INTO tbl_',GT_DB,'_',WORKER_ID), NOW()); SET @SqlCmd=CONCAT('DROP TEMPORARY TABLE IF EXISTS ',GT_DB,'.tmp_cell_gsm_start_',WORKER_ID,';'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('DROP TEMPORARY TABLE IF EXISTS ',GT_DB,'.tmp_cell_gsm_end_',WORKER_ID,';'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('CREATE TEMPORARY TABLE ',GT_DB,'.tmp_cell_gsm_start_',WORKER_ID,' ENGINE=MYISAM AS SELECT POS_FIRST_CELL AS `CELL_ID` ,POS_FIRST_BSC AS `BSC_ID` ,POS_FIRST_SITE AS `SITE_ID` ,POS_FIRST_BCCH_ARFCN AS `BCCH_ARFCN` ,POS_FIRST_BANDINDEX AS `BANDINDEX` ,DATA_DATE ,DATA_HOUR ,COUNT(*) AS `INIT_CALL_CNT` ,SUM(IF(CALL_TYPE=10,1,0)) AS VOICE_CNT ,SUM(IF(CALL_TYPE=15,1,0)) AS SIGNAL_CNT ,SUM(IF(CALL_TYPE=16,1,0)) AS SMS_CNT ,SUM(IF(CALL_TYPE=20,1,0)) AS GPRS_CNT ,SUM(IF(CALL_TYPE NOT IN (10,15,16,20),1,0)) AS OTHER_CNT ,SUM(IF(CALL_STATUS=3 AND CALL_TYPE=10,1,0)) AS BLOCK_VOICE_CNT ,SUM(IF(CALL_STATUS=3 AND CALL_TYPE=20,1,0)) AS BLOCK_GPRS_CNT ,SUM(IF(CALL_STATUS=3 AND CALL_TYPE=16,1,0)) AS BLOCK_SMS_CNT ,SUM(IF(CALL_STATUS=3 AND CALL_TYPE=15,1,0)) AS BLOCK_SIGNAL_CNT ,SUM(IF(CALL_STATUS=3 AND CALL_TYPE NOT IN (10,15,16,20),1,0)) AS BLOCK_OTHER_CNT ,SUM(POS_FIRST_RXLEV_FULL_DOWNLINK) AS RXLEV_SUM ,COUNT(POS_FIRST_RXLEV_FULL_DOWNLINK) AS RXLEV_CNT ,SUM(POS_FIRST_RXQUAL_FULL_DOWNLINK) AS RXQUAL_SUM ,COUNT(POS_FIRST_RXQUAL_FULL_DOWNLINK) AS RXQUAL_CNT ,SUM(CALL_SETUP_TIME) AS CALL_SETUP_TIME_SUM ,SUM(IF(CALL_SETUP_TIME>=0,1,0)) AS CALL_SETUP_TIME_CNT ,IFNULL(SUM(IF(CALL_TYPE =10,CALL_SETUP_TIME,0)),0) AS CALL_SETUP_TIME_VOICE_SUM ,IFNULL(SUM(IF(CALL_SETUP_TIME>=0 AND CALL_TYPE =10,1,0)),0) AS CALL_SETUP_TIME_VOICE_CNT ,IFNULL(SUM(IF(CALL_TYPE =15,CALL_SETUP_TIME,0)),0) AS CALL_SETUP_TIME_SIG_SUM ,IFNULL(SUM(IF(CALL_SETUP_TIME>=0 AND CALL_TYPE =15,1,0)),0) AS CALL_SETUP_TIME_SIG_CNT ,IFNULL(SUM(IF(CALL_TYPE =16,CALL_SETUP_TIME,0)),0) AS CALL_SETUP_TIME_SMS_SUM ,IFNULL(SUM(IF(CALL_SETUP_TIME>=0 AND CALL_TYPE =16,1,0)),0) AS CALL_SETUP_TIME_SMS_CNT ,IFNULL(SUM(IF(CALL_TYPE =20,CALL_SETUP_TIME,0)),0) AS CALL_SETUP_TIME_GPRS_SUM ,IFNULL(SUM(IF(CALL_SETUP_TIME>=0 AND CALL_TYPE =20,1,0)),0) AS CALL_SETUP_TIME_GPRS_CNT ,IFNULL(SUM(IF(CALL_TYPE NOT IN (10,15,16,20),CALL_SETUP_TIME,0)),0) AS CALL_SETUP_TIME_OTH_SUM ,IFNULL(SUM(IF(CALL_SETUP_TIME>=0 AND CALL_TYPE NOT IN (10,15,16,20),1,0)),0) AS CALL_SETUP_TIME_OTH_CNT ,SUM(IF(CALL_STATUS=6 AND CALL_TYPE=10,1,0)) AS SF_VOICE_CNT ,SUM(IF(CALL_STATUS=6 AND CALL_TYPE=20,1,0)) AS SF_DATA_CNT ,SUM(IF(CALL_STATUS=6 AND CALL_TYPE=16,1,0)) AS SF_SMS_CNT ,SUM(IF(CALL_STATUS=6 AND CALL_TYPE=15,1,0)) AS SF_SIGNAL_CNT ,SUM(IF(CALL_STATUS=6 AND CALL_TYPE NOT IN (10,15,16,20),1,0)) AS SF_OTHER_CNT FROM ',GT_DB,'.table_call_gsm WHERE DATA_HOUR =',DATA_HOUR,' AND POS_FIRST_CELL IS NOT NULL AND POS_FIRST_BSC=',PU_ID,' GROUP BY POS_FIRST_BSC,POS_FIRST_CELL,`POS_FIRST_BCCH_ARFCN`,`POS_FIRST_BANDINDEX` ORDER BY NULL; '); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('CREATE TEMPORARY TABLE ',GT_DB,'.tmp_cell_gsm_end_',WORKER_ID,' ENGINE=MYISAM AS SELECT POS_LAST_CELL AS `CELL_ID` ,POS_LAST_BSC AS `BSC_ID` ,POS_LAST_SITE AS `SITE_ID` ,POS_LAST_BCCH_ARFCN AS `BCCH_ARFCN` ,POS_LAST_BANDINDEX AS `BANDINDEX` ,DATA_DATE ,DATA_HOUR ,COUNT(*) AS `END_CALL_CNT` ,SUM(IF(CALL_TYPE=10,1,0)) AS END_VOICE_CNT ,SUM(IF(CALL_TYPE=15,1,0)) AS END_SIGNAL_CNT ,SUM(IF(CALL_TYPE=16,1,0)) AS END_SMS_CNT ,SUM(IF(CALL_TYPE=20,1,0)) AS END_GPRS_CNT ,SUM(IF(CALL_TYPE NOT IN (10,15,16,20),1,0)) AS END_OTHER_CNT ,SUM(IF(CALL_STATUS=2 AND CALL_TYPE=10,1,0)) AS DROP_VOICE_CNT ,SUM(IF(CALL_STATUS=2 AND CALL_TYPE=15,1,0)) AS DROP_SIGNAL_CNT ,SUM(IF(CALL_STATUS=2 AND CALL_TYPE=16,1,0)) AS DROP_SMS_CNT ,SUM(IF(CALL_STATUS=2 AND CALL_TYPE=20,1,0)) AS DROP_GPRS_CNT ,SUM(IF(CALL_STATUS=2 AND CALL_TYPE NOT IN (10,15,16,20),1,0)) AS DROP_OTHER_CNT ,SUM(IF(CALL_STATUS IN (1,2,4,5) AND CALL_TYPE=10,1,0)) AS `NON_BLOCK_VOICE_CNT` ,SUM(IF(CALL_STATUS IN (1,2,4,5) AND CALL_TYPE=15,1,0)) AS `NON_BLOCK_SIGNAL_CNT` ,SUM(IF(CALL_STATUS IN (1,2,4,5) AND CALL_TYPE=16,1,0)) AS `NON_BLOCK_SMS_CNT` ,SUM(IF(CALL_STATUS IN (1,2,4,5) AND CALL_TYPE=20,1,0)) AS `NON_BLOCK_GPRS_CNT` ,SUM(IF(CALL_STATUS IN (1,2,4,5) AND CALL_TYPE NOT IN (10,15,16,20),1,0)) AS `NON_BLOCK_OTHER_CNT` FROM ',GT_DB,'.table_call_gsm WHERE DATA_HOUR =',DATA_HOUR,' AND POS_LAST_CELL IS NOT NULL AND POS_LAST_BSC=',PU_ID,' GROUP BY POS_LAST_CELL,POS_LAST_BSC,POS_LAST_BCCH_ARFCN,POS_LAST_BANDINDEX ORDER BY NULL; '); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('CREATE INDEX `ix_tile_gsm_fq` ON ',GT_DB,'.tmp_cell_gsm_start_',WORKER_ID,' (`CELL_ID`,`BSC_ID`,BCCH_ARFCN,BANDINDEX);'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('CREATE INDEX `ix_tile_gsm_fq` ON ',GT_DB,'.tmp_cell_gsm_end_',WORKER_ID,' (`CELL_ID`,`BSC_ID`,BCCH_ARFCN,BANDINDEX);'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('INSERT INTO ',GT_DB,'.`tmp_materialization_',WORKER_ID,'` ( `CELL_ID`,`SITE_ID`,`BSC_ID`,BCCH_ARFCN,BANDINDEX,DATA_DATE,DATA_HOUR) SELECT `CELL_ID`,`SITE_ID`,`BSC_ID`,BCCH_ARFCN,BANDINDEX,DATA_DATE,DATA_HOUR FROM ( SELECT `CELL_ID`,`SITE_ID`,',PU_ID,' AS `BSC_ID`,BCCH_ARFCN,BANDINDEX,DATA_DATE,DATA_HOUR FROM ',GT_DB,'.tmp_cell_gsm_start_',WORKER_ID,' UNION SELECT `CELL_ID`,`SITE_ID`,',PU_ID,' AS `BSC_ID`,BCCH_ARFCN,BANDINDEX,DATA_DATE,DATA_HOUR FROM ',GT_DB,'.tmp_cell_gsm_end_',WORKER_ID,' ) AA;'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('UPDATE ',GT_DB,'.`tmp_materialization_',WORKER_ID,'` a,',GT_DB,'.`tmp_cell_gsm_start_',WORKER_ID,'` B SET A.INIT_CALL_CNT=B.INIT_CALL_CNT ,A.VOICE_CNT=B.VOICE_CNT ,A.SIGNAL_CNT=B.SIGNAL_CNT ,A.SMS_CNT=B.SMS_CNT ,A.GPRS_CNT=B.GPRS_CNT ,A.OTHER_CNT=B.OTHER_CNT ,A.BLOCK_VOICE_CNT=B.BLOCK_VOICE_CNT ,A.BLOCK_GPRS_CNT=B.BLOCK_GPRS_CNT ,A.BLOCK_SMS_CNT=B.BLOCK_SMS_CNT ,A.BLOCK_SIGNAL_CNT=B.BLOCK_SIGNAL_CNT ,A.BLOCK_OTHER_CNT=B.BLOCK_OTHER_CNT ,A.RXLEV_SUM=B.RXLEV_SUM ,A.RXLEV_CNT=B.RXLEV_CNT ,A.RXQUAL_SUM=B.RXQUAL_SUM ,A.RXQUAL_CNT=B.RXQUAL_CNT ,A.CALL_SETUP_TIME_SUM=B.CALL_SETUP_TIME_SUM ,A.CALL_SETUP_TIME_CNT=B.CALL_SETUP_TIME_CNT ,A.CALL_SETUP_TIME_VOICE_SUM=B.CALL_SETUP_TIME_VOICE_SUM ,A.CALL_SETUP_TIME_VOICE_CNT=B.CALL_SETUP_TIME_VOICE_CNT ,A.CALL_SETUP_TIME_SIG_SUM=B.CALL_SETUP_TIME_SIG_SUM ,A.CALL_SETUP_TIME_SIG_CNT=B.CALL_SETUP_TIME_SIG_CNT ,A.CALL_SETUP_TIME_SMS_SUM=B.CALL_SETUP_TIME_SMS_SUM ,A.CALL_SETUP_TIME_SMS_CNT=B.CALL_SETUP_TIME_GPRS_CNT ,A.CALL_SETUP_TIME_GPRS_SUM=B.CALL_SETUP_TIME_GPRS_SUM ,A.CALL_SETUP_TIME_GPRS_CNT=B.CALL_SETUP_TIME_GPRS_CNT ,A.CALL_SETUP_TIME_OTH_SUM=B.CALL_SETUP_TIME_OTH_SUM ,A.CALL_SETUP_TIME_OTH_CNT=B.CALL_SETUP_TIME_OTH_CNT ,A.SF_VOICE_CNT=B.SF_VOICE_CNT ,A.SF_DATA_CNT=B.SF_DATA_CNT ,A.SF_SMS_CNT=B.SF_SMS_CNT ,A.SF_SIGNAL_CNT=B.SF_SIGNAL_CNT ,A.SF_OTHER_CNT=B.SF_OTHER_CNT WHERE A.CELL_ID=B.CELL_ID AND A.BSC_ID=B.BSC_ID AND A.BCCH_ARFCN=B.BCCH_ARFCN AND A.BANDINDEX=B.BANDINDEX;'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('UPDATE ',GT_DB,'.`tmp_materialization_',WORKER_ID,'` a,',GT_DB,'.`tmp_cell_gsm_end_',WORKER_ID,'` B SET A.END_CALL_CNT=B.END_CALL_CNT ,A.END_VOICE_CNT=B.END_VOICE_CNT ,A.END_SIGNAL_CNT=B.END_SIGNAL_CNT ,A.END_SMS_CNT=B.END_SMS_CNT ,A.END_GPRS_CNT=B.END_GPRS_CNT ,A.END_OTHER_CNT=B.END_OTHER_CNT ,A.DROP_VOICE_CNT=B.DROP_VOICE_CNT ,A.DROP_SIGNAL_CNT=B.DROP_SIGNAL_CNT ,A.DROP_SMS_CNT=B.DROP_SMS_CNT ,A.DROP_GPRS_CNT=B.DROP_GPRS_CNT ,A.DROP_OTHER_CNT=B.DROP_OTHER_CNT ,A.NON_BLOCK_VOICE_CNT=B.NON_BLOCK_VOICE_CNT ,A.NON_BLOCK_SIGNAL_CNT=B.NON_BLOCK_SIGNAL_CNT ,A.NON_BLOCK_SMS_CNT=B.NON_BLOCK_SMS_CNT ,A.NON_BLOCK_GPRS_CNT=B.NON_BLOCK_GPRS_CNT ,A.NON_BLOCK_OTHER_CNT=B.NON_BLOCK_OTHER_CNT WHERE A.CELL_ID=B.CELL_ID AND A.BSC_ID=B.BSC_ID AND A.BCCH_ARFCN=B.BCCH_ARFCN AND A.BANDINDEX=B.BANDINDEX;'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('SELECT * FROM ',GT_DB,'.tmp_materialization_',WORKER_ID,' WHERE CELL_ID >0;'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('DROP TEMPORARY TABLE IF EXISTS ',GT_DB,'.tmp_materialization_',WORKER_ID,';'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('DROP TEMPORARY TABLE IF EXISTS ',GT_DB,'.tmp_cell_gsm_start_',WORKER_ID,';'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; SET @SqlCmd=CONCAT('DROP TEMPORARY TABLE IF EXISTS ',GT_DB,'.tmp_cell_gsm_end_',WORKER_ID,';'); PREPARE Stmt FROM @SqlCmd; EXECUTE Stmt; DEALLOCATE PREPARE Stmt; INSERT INTO gt_gw_main.sp_log VALUES('gt_gw_main','SP_Generate_Global_Statistic_cell_agg_gsm',CONCAT(GT_DB,' END'), NOW()); END$$ DELIMITER ;
true
c0138c36eb62ce1827daefde4886a0629720a453
SQL
VictorFarfan98/MoneyManagerServiceapp
/src/sql/migration/1.0.3/002-update-main-user-sp.sql
UTF-8
4,482
4.1875
4
[ "MIT" ]
permissive
use ${DB_MAIN}; DROP PROCEDURE IF EXISTS User_Save; DELIMITER $$ CREATE PROCEDURE `User_Save`( pFirstName nvarchar(32), pLastName nvarchar(32), pPicture nvarchar(256), pNickname nvarchar(32), pEmail nvarchar(32), pExtId nvarchar(32), pProvider nvarchar(16), pRoleId INT) BEGIN DECLARE varUserId INT UNSIGNED; DECLARE varProfileId INT UNSIGNED; DECLARE varRoleId INT UNSIGNED; SET varUserId = (select UserId from User where ExtId=pExtId and Provider=pProvider); IF varUserId is null then INSERT INTO `User` (Email, Password, Provider, ExtId, CreatedAt, Status) VALUES (pEmail, null,pProvider, pExtId, NOW(), 10); SET varUserId =(SELECT LAST_INSERT_ID()); INSERT INTO UserProfile (UserId, Currency, FirstName, LastName, Picture, ExtNickName) VALUES (varUserId, 'GTQ', pFirstName, pLastName, pPicture, pNickname ); INSERT INTO UserRole(UserId, RoleId, CreatedAt, `Status`) VALUES (varUserId, pRoleId, NOW(), 1); ELSE SET varProfileId = (select Id from UserProfile where UserId=varUserId); IF varProfileId IS NULL THEN INSERT INTO UserProfile (UserId, Currency, FirstName, LastName, Picture, ExtNickName ) VALUES (UserId, 'GTQ', pFirstName, pLastName, pPicture, pNickname); ELSE UPDATE UserProfile set FirstName = pFirstName, LastName = pLastName, Picture = pPicture, ExtNickName = pNickname WHERE Id=varProfileId; END IF; SET varRoleId = (select Id from UserRole where UserId=varUserId); IF varRoleId IS NULL THEN INSERT INTO UserRole(UserId, RoleId, CreatedAt, `Status`) VALUES (varUserId, pRoleId, NOW(), 1); ELSE UPDATE UserRole SET RoleId = pRoleId WHERE UserId=varUserId; END IF; END IF; select varUserId UserId; END $$ DELIMITER ; USE `${DB_MAIN}`; DROP procedure IF EXISTS `User_Get`; DELIMITER $$ USE `${DB_MAIN}`$$ CREATE PROCEDURE `User_Get`( pUserId INT, pEmail nvarchar(32), pExtId nvarchar(32), pProvider nvarchar(16) ) BEGIN SELECT u.UserId id, u.Email email, u.ExtId extId, u.Provider `provider`, u.Status `status`, up.FirstName firstName, up.LastName lastName, up.ExtNickName extNickName, up.Picture picture FROM User u JOIN UserProfile up ON (u.UserId = up.Id) WHERE ( (pEmail IS NULL OR LOWER(u.Email) = LOWER(pEmail)) AND (pUserId IS NULL OR u.UserId = pUserId) AND (pExtId IS NULL OR u.ExtId = pExtId) AND (pProvider IS NULL OR u.Provider = pProvider) ); END$$ DELIMITER ; USE `${DB_MAIN}`; DROP procedure IF EXISTS `Team_Save`; DELIMITER $$ USE `${DB_MAIN}`$$ CREATE PROCEDURE `Team_Save`( pTitle nvarchar(256), pParentTeamId INT, pCreatedBy INT, pLeaderId INT ) BEGIN DECLARE varDataRoleId INT UNSIGNED; DECLARE varTeamId INT UNSIGNED; INSERT INTO Team(Title, ParentTeamId, CreatedBy, CreatedAt, `Status`) VALUES (pTitle, pParentTeamId, pCreatedBy, NOW(), 1); SET varTeamId =(SELECT LAST_INSERT_ID()); IF pLeaderId IS NOT NULL THEN INSERT INTO UserDataRole(UserId, DataRoleId, TeamId, CreatedAt, `Status`) VALUES (pLeaderId, 1, varTeamId, NOW(), 1); END IF; select varTeamId TeamId; END$$ DELIMITER ; USE `${DB_MAIN}`; DROP procedure IF EXISTS `Team_AddUser`; DELIMITER $$ USE `${DB_MAIN}`$$ CREATE PROCEDURE `Team_AddUser`( pTeamId INT, pUserId INT, pDataRoleId INT ) BEGIN DECLARE varDataRoleId INT UNSIGNED; DECLARE varTeamId INT UNSIGNED; SET varDataRoleId = (select Id from UserDataRole where TeamId=pTeamId and DataRoleId=pDataRoleId and UserId=pUserId); IF varDataRoleId is null then SET varDataRoleId = (select Id from UserDataRole where TeamId=pTeamId and UserId=pUserId); #User is not a member of the team IF varDataRoleId is null then INSERT INTO UserDataRole(UserId, DataRoleId, TeamId, CreatedAt, `Status`) VALUES (pUserId, pDataRoleId, pTeamId, NOW(), 1); SET varDataRoleId =(SELECT LAST_INSERT_ID()); ELSE #Change the role in the team to the selected one UPDATE UserDataRole SET DataRoleId = pDataRoleId WHERE (TeamId = pTeamId AND UserId = pUserId); END IF; END IF; select 'Role Assigned' message; END$$ DELIMITER ;
true
89c057484dae1676d86bbfd153938c4c200149ed
SQL
tysker/bacholar_database_assignments
/dbd_exam-main/dbd_system/application/server/docker/scripts/01_dbd_tables.sql
UTF-8
2,042
3.4375
3
[]
no_license
--DROP DATABASE IF EXISTS postgres; DROP TABLE IF EXISTS users_keyword_stocks; DROP TABLE IF EXISTS users_keyword; DROP TABLE IF EXISTS users_stocks; DROP TABLE IF EXISTS keywords CASCADE; DROP TABLE IF EXISTS stocks CASCADE; DROP TABLE IF EXISTS users CASCADE; DROP TABLE IF EXISTS log_keywords; DROP TABLE IF EXISTS log_stocks; DROP TABLE IF EXISTS log_users; --CREATE DATABASE postgres; CREATE TABLE IF NOT EXISTS users ( id SERIAL PRIMARY KEY, username varchar(100) NOT NULL, email varchar(100) NOT null UNIQUE, pwd varchar(100) NOT NULL ); CREATE TABLE IF NOT EXISTS stocks ( id SERIAL PRIMARY key, stockname varchar(100) NOT NULL ); CREATE TABLE IF NOT EXISTS keywords ( id SERIAL PRIMARY KEY, keyword varchar(100) NOT NULL ); CREATE TABLE IF NOT EXISTS users_stocks( user_id SERIAL REFERENCES users (id) ON DELETE CASCADE, stock_id SERIAL REFERENCES stocks (id) ON DELETE CASCADE, PRIMARY KEY (user_id, stock_id) ); CREATE TABLE IF NOT EXISTS users_keywords( user_id SERIAL REFERENCES users (id) ON DELETE CASCADE, keyword_id SERIAL REFERENCES keywords (id) ON DELETE CASCADE, PRIMARY KEY (user_id, keyword_id) ); CREATE TABLE IF NOT EXISTS users_keywords_stocks( user_id SERIAL REFERENCES users (id) ON DELETE CASCADE, keyword_id SERIAL REFERENCES keywords (id) ON DELETE CASCADE, stock_id SERIAL REFERENCES stocks (id) ON DELETE CASCADE, PRIMARY KEY (user_id, keyword_id, stock_id) ); CREATE TABLE IF NOT EXISTS log_keywords ( id SERIAL PRIMARY KEY, keyword varchar(100) NOT NULL, db_username varchar(100) NOT NULL, adding_time varchar(100) NOT NULL ); CREATE TABLE IF NOT EXISTS log_stocks ( id SERIAL PRIMARY KEY, stockname varchar(100) NOT NULL, db_username varchar(100) NOT NULL, adding_time varchar(100) NOT NULL ); CREATE TABLE IF NOT EXISTS log_users ( id SERIAL PRIMARY KEY, username varchar(100) NOT NULL, email varchar(100) NOT NULL, db_username varchar(100) NOT NULL, adding_time varchar(100) NOT NULL );
true
44230595cfe389dec63e1f7901a68de034e34703
SQL
open-fred/db
/preprocessing/hydrolib/bfg_grdc_runoff/fred_pp_bfg_grdc_setup.sql
ISO-8859-1
2,759
3.515625
4
[]
no_license
/* BFG GRDC runoff measurement data __copyright__ = "Reiner Lemoine Institut" __license__ = "GNU Affero General Public License Version 3 (AGPL-3.0)" __url__ = "" __author__ = "Ludee" */ -- BFG GRDC timeseries DROP TABLE IF EXISTS hydrolib.bfg_grdc_runoff; CREATE TABLE hydrolib.bfg_grdc_runoff ( id serial, station text, "type" varchar(1), year smallint, time_series real[], CONSTRAINT bfg_grdc_runoff_pkey PRIMARY KEY (id)); -- grant (oeuser) ALTER TABLE hydrolib.bfg_grdc_runoff OWNER TO oeuser; -- metadata COMMENT ON TABLE hydrolib.bfg_grdc_runoff IS '{ "title": "Bundesanstalt fr Gewsserkunde (BfG) - Global Runoff Data Center (GRDC) - runoff measurement data", "description": "Extract from Global Runoff Data Center (GRDC)", "language": [ "eng", "ger" ], "spatial": {"location": "none", "extent": "Germany", "resolution": "none"}, "temporal": {"reference_date": "yearly", "start": "01-01", "end": "12-31", "resolution": "1 d"}, "sources": [ {"name": "Global Runoff Data Center (GRDC), 56068 Koblenz, Germany", "description": "Daten wurden von dem Global Runoff Data Center (grdc@bafg.de) bereitgestellt.", "url": "http://www.bafg.de/GRDC/EN/02_srvcs/21_tmsrs/riverdischarge_node.html", "license": "none", "copyright": ""} ], "license": {"id": "none", "name": "none", "version": "none", "url": "none", "instruction": "Datenquelle: The Global Runoff Data Center, 56068 Koblenz, Germany. Not to be transferred, used for commercial purposes, accessed to unauthorized persons, or kept on the general data processing facilities after completion of the studies (see declaration of the data user)", "copyright": "none"}, "contributors": [ {"name": "chloelucas", "email": "none", "date": "2017-08-30", "comment": "Add metadata"}, {"name": "Ludee", "email": "none", "date": "2017-09-07", "comment": "Add data"} ], "resources": [ {"name": "hydrolib.bfg_grdc_runoff", "format": "PostgreSQL", "fields": [ {"name": "id", "description": "Unique identifier", "unit": "none"}, {"name": "station", "description": "Unique identifier", "unit": "none"}, {"name": "type", "description": "[W] gauge height in cm; [Q] runoff in m/s", "unit": "cm or m/s"}, {"name": "year", "description": "Reference year", "unit": "none"}, {"name": "time_series", "description": "Example value", "unit": "cm or m/s"} ] } ], "metadata_version": "1.3"}'; -- select description SELECT obj_description('hydrolib.bfg_grdc_runoff' ::regclass) ::json;
true
7c46d5d68855699854cd2385be29ac86c63f507e
SQL
nProdanov/TelerikAcademy
/Databases/SQL-Intro/homework.sql
UTF-8
2,204
4.375
4
[]
no_license
USE TelerikAcademy -- Task 04. SELECT * FROM Departments -- Task 05. SELECT Name FROM Departments -- Task 06. SELECT FirstName, Salary FROM Employees -- Task 07. SELECT FirstName + ' ' + LastName as [Full Name] FROM Employees -- Task 08. SELECT FirstName + '.' + LastName + '@telerik.com' as [Email] FROM Employees -- Task 09. SELECT DISTINCT Salary FROM Employees -- Task 10. SELECT * FROM Employees WHERE JobTitle = 'Sales Representative' -- Task 11. SELECT FirstName, LastName FROM Employees WHERE (lower(FirstName)) LIKE 'sa%' -- Task 12. SELECT FirstName, LastName FROM Employees WHERE (lower(LastName)) LIKE '%ei%' -- Task 13. SELECT FirstName, Salary FROM Employees WHERE Salary BETWEEN 20000 AND 30000 ORDER BY Salary -- Task 14. SELECT FirstName, Salary FROM Employees WHERE Salary IN (25000, 14000, 12500, 23600) -- Task 15. SELECT FirstName, LastName FROM Employees WHERE ManagerID IS NULL -- Task 16. SELECT FirstName, Salary FROM Employees WHERE Salary > 50000 ORDER BY Salary DESC -- Task 17. SELECT TOP 5 FirstName, Salary FROM Employees ORDER BY Salary DESC -- Task 18. SELECT e.FirstName, a.AddressText FROM Employees as e JOIN Addresses as a ON e.AddressID = a.AddressID -- Task 19. SELECT e.FirstName, a.AddressText FROM Employees as e, Addresses as a WHERE e.AddressID = a.AddressID -- Task 20. SELECT e.FirstName, e.ManagerID, m.FirstName, m.EmployeeID FROM Employees as e JOIN Employees as m ON e.ManagerID = m.EmployeeID -- Task 21. SELECT e.FirstName as [Employe], a.AddressText, m.FirstName as [Manager] FROM Employees as e JOIN Addresses as a ON e.AddressID = a.AddressID JOIN Employees as m ON e.ManagerID = m.EmployeeID -- Task 22. SELECT Name FROM Departments UNION SELECT Name FROM Towns -- Task 23. SELECT e.FirstName as [Employe], m.FirstName[Manager] FROM Employees as e LEFT OUTER JOIN Employees as m ON e.ManagerID = m.EmployeeID -- Task 23. SELECT e.FirstName as [Employe], m.FirstName[Manager] FROM Employees as e RIGHT OUTER JOIN Employees as m ON e.ManagerID = m.EmployeeID -- Task 24. SELECT FirstName, d.Name, HireDate FROM Employees as e, Departments as d WHERE e.DepartmentID = d.DepartmentID AND d.Name IN ('Sales', 'Finance')
true
5843711f7ecd22de9ba344493c54db28316d3a7d
SQL
Nhok95/MavenProjects
/carInsurance/bin/src/main/resources/data/h2/schema.sql
UTF-8
639
3.3125
3
[]
no_license
/*Para eliminar una tabla ees DROP TABLE IF EXISTS*/ DROP TABLE IF EXISTS VEHICULOS; DROP TABLE IF EXISTS COLORES; DROP TABLE IF EXISTS TIPOS; /*UN BIGINT ES UN LONG*/ CREATE TABLE VEHICULOS ( CODIGO BIGINT NOT NULL, MARCA VARCHAR(100) NOT NULL, MODELO VARCHAR(100) NOT NULL, COEFF DOUBLE(10) NOT NULL, PRIMARY KEY (CODIGO) ); CREATE TABLE COLORES ( CODIGO BIGINT NOT NULL, NOMBRE VARCHAR(60) NOT NULL, COEFF DOUBLE(10) NOT NULL, PRIMARY KEY (CODIGO) ); CREATE TABLE TIPOS ( CODIGO BIGINT NOT NULL, NOMBRE VARCHAR(60) NOT NULL, COEFF DOUBLE(10) NOT NULL, PRIMARY KEY (CODIGO) );
true
c2aea65a359911cc0b23296dcb8ecc3a7e0916b2
SQL
DiegoCartagena/Syslogistic
/exportPhoenixLogistic.sql
ISO-8859-10
10,611
2.640625
3
[]
no_license
-------------------------------------------------------- -- Archivo creado - martes-junio-23-2020 -------------------------------------------------------- -------------------------------------------------------- -- DDL for Table BL -------------------------------------------------------- CREATE TABLE "HR"."BL" ( "ID_BL" NUMBER, "NOMBRE_NAVE" VARCHAR2(20 BYTE), "NUM_SELLO" NUMBER, "CONSIGNATARIO" VARCHAR2(30 BYTE), "CONSIGNANTE" VARCHAR2(30 BYTE), "PESO" NUMBER, "VOL_CUBICO" NUMBER, "MERCADERIA" VARCHAR2(20 BYTE), "TIPO_CARGA" VARCHAR2(20 BYTE), "FECHA_SALIDA" VARCHAR2(20 BYTE), "FECHA_ARRIBO" VARCHAR2(20 BYTE), "UNIDADES" NUMBER, "CARGA" VARCHAR2(20 BYTE), "INCOTERMS" VARCHAR2(20 BYTE), "PAIS" VARCHAR2(20 BYTE), "DOCUMENTACION" VARCHAR2(20 BYTE) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING 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" ; -------------------------------------------------------- -- DDL for Table CLIENTE -------------------------------------------------------- CREATE TABLE "HR"."CLIENTE" ( "ID_CLIENTE" NUMBER, "NOMBRE_CL" VARCHAR2(50 BYTE), "DIRECCION" VARCHAR2(50 BYTE), "TELEFONO" NUMBER, "EMAIL" VARCHAR2(30 BYTE), "ID_COMUNA" VARCHAR2(20 BYTE), "ID_GIRO" VARCHAR2(20 BYTE) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING 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" ; -------------------------------------------------------- -- DDL for Table PROVEEDOR -------------------------------------------------------- CREATE TABLE "HR"."PROVEEDOR" ( "ID_PROVEEDOR" NUMBER, "NOMBRE_PROVEEDOR" VARCHAR2(50 BYTE), "ID_GIRO" VARCHAR2(30 BYTE), "CONTACTO" NUMBER, "EMAIL" VARCHAR2(50 BYTE), "DIRECCION" VARCHAR2(50 BYTE), "ID_COMUNA" NUMBER, "ID_REG" NUMBER, "ID_PAIS" VARCHAR2(20 BYTE), "ID_TPROVEEDOR" VARCHAR2(20 BYTE) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING 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" ; -------------------------------------------------------- -- DDL for Table ROL -------------------------------------------------------- CREATE TABLE "HR"."ROL" ( "ROL_ID" NUMBER, "ROL" VARCHAR2(20 BYTE) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING 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" ; -------------------------------------------------------- -- DDL for Table USERS -------------------------------------------------------- CREATE TABLE "HR"."USERS" ( "USER_ID" NUMBER, "USERNAME" VARCHAR2(20 BYTE), "PASSWORD" VARCHAR2(100 BYTE), "ENABLED" NUMBER(1,0), "ROL" VARCHAR2(20 BYTE) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING 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" ; -------------------------------------------------------- -- DDL for Table USERS_ROL -------------------------------------------------------- CREATE TABLE "HR"."USERS_ROL" ( "USER_ID" NUMBER, "ROL_ID" NUMBER ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING 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" ; -------------------------------------------------------- -- DDL for Table AA_AGENTE_DE_ADUANA -------------------------------------------------------- CREATE TABLE "HR."AA_AGENTE_DE_ADUANA" ( "ID_AGENTE" NUMBER, "NOMBRE_AGENTE" VARCHAR2(60 BYTE), "PAIS" VARCHAR2(20 BYTE), "TIPO_TLC" VARCHAR2(20 BYTE) ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING 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 "HR" ; REM INSERTING into HR.BL SET DEFINE OFF; Insert into HR.BL (ID_BL,NOMBRE_NAVE,NUM_SELLO,CONSIGNATARIO,CONSIGNANTE,PESO,VOL_CUBICO,MERCADERIA,TIPO_CARGA,FECHA_SALIDA,FECHA_ARRIBO,UNIDADES,CARGA,INCOTERMS,PAIS,DOCUMENTACION) values ('1','Titanic','1','Test','Test','1','1','Hielo','Test','04/05/20','10/04/20','10','Test','Test','Chile','Test'); Insert into HR.BL (ID_BL,NOMBRE_NAVE,NUM_SELLO,CONSIGNATARIO,CONSIGNANTE,PESO,VOL_CUBICO,MERCADERIA,TIPO_CARGA,FECHA_SALIDA,FECHA_ARRIBO,UNIDADES,CARGA,INCOTERMS,PAIS,DOCUMENTACION) values ('2','Maria','1','Test','Test','1','1','Hielo','Test','04/08/20','10/04/20','10','Test','Test','Chile','Test'); Insert into HR.BL (ID_BL,NOMBRE_NAVE,NUM_SELLO,CONSIGNATARIO,CONSIGNANTE,PESO,VOL_CUBICO,MERCADERIA,TIPO_CARGA,FECHA_SALIDA,FECHA_ARRIBO,UNIDADES,CARGA,INCOTERMS,PAIS,DOCUMENTACION) values ('3','Pinta','1','Test','Test','1','1','Hielo','Test','04/05/20','10/04/20','10','Test','Test','Chile','Test'); Insert into HR.BL (ID_BL,NOMBRE_NAVE,NUM_SELLO,CONSIGNATARIO,CONSIGNANTE,PESO,VOL_CUBICO,MERCADERIA,TIPO_CARGA,FECHA_SALIDA,FECHA_ARRIBO,UNIDADES,CARGA,INCOTERMS,PAIS,DOCUMENTACION) values ('4','Nia','1','Test','Test','1','1','Hielo','Test','04/05/20','10/04/20','10','Test','Test','Chile','Test'); REM INSERTING into HR.CLIENTE SET DEFINE OFF; Insert into HR.CLIENTE (ID_CLIENTE,NOMBRE_CL,DIRECCION,TELEFONO,EMAIL,ID_COMUNA,ID_GIRO) values ('1','Juan','Test','123456','Test','Test','Test'); Insert into HR.CLIENTE (ID_CLIENTE,NOMBRE_CL,DIRECCION,TELEFONO,EMAIL,ID_COMUNA,ID_GIRO) values ('2','Alejandro','Test','123456','Test','Test','Test'); Insert into HR.CLIENTE (ID_CLIENTE,NOMBRE_CL,DIRECCION,TELEFONO,EMAIL,ID_COMUNA,ID_GIRO) values ('3','Diego','Test','123456','Test','Test','Test'); Insert into HR.CLIENTE (ID_CLIENTE,NOMBRE_CL,DIRECCION,TELEFONO,EMAIL,ID_COMUNA,ID_GIRO) values ('4','Sergio','Test','123456','Test','Test','Test'); REM INSERTING into HR.PROVEEDOR SET DEFINE OFF; Insert into HR.PROVEEDOR (ID_PROVEEDOR,NOMBRE_PROVEEDOR,ID_GIRO,CONTACTO,EMAIL,DIRECCION,ID_COMUNA,ID_REG,ID_PAIS,ID_TPROVEEDOR) values ('1','Nestle','Test','123','Test','Test','1','1','Test','Test'); Insert into HR.PROVEEDOR (ID_PROVEEDOR,NOMBRE_PROVEEDOR,ID_GIRO,CONTACTO,EMAIL,DIRECCION,ID_COMUNA,ID_REG,ID_PAIS,ID_TPROVEEDOR) values ('2','Disney','Test','123','Test','Test','1','1','Test','Test'); Insert into HR.PROVEEDOR (ID_PROVEEDOR,NOMBRE_PROVEEDOR,ID_GIRO,CONTACTO,EMAIL,DIRECCION,ID_COMUNA,ID_REG,ID_PAIS,ID_TPROVEEDOR) values ('3','Fox','Test','123','Test','Test','1','1','Test','Test'); Insert into HR.PROVEEDOR (ID_PROVEEDOR,NOMBRE_PROVEEDOR,ID_GIRO,CONTACTO,EMAIL,DIRECCION,ID_COMUNA,ID_REG,ID_PAIS,ID_TPROVEEDOR) values ('4','CNN','Test','123','Test','Test','1','1','Test','Test'); REM INSERTING into HR.ROL SET DEFINE OFF; Insert into HR.ROL (ROL_ID,ROL) values ('1','ROLE_ADMIN'); REM INSERTING into HR.USERS SET DEFINE OFF; Insert into HR.USERS (USER_ID,USERNAME,PASSWORD,ENABLED,ROL) values ('1','admin','$2y$12$qak4EFXxB0kbnz7JNbDkce9jGRwp.hIStBd1V4CA.O7pRIMA/xunS','1','ROLE_ADMIN'); REM INSERTING into HR.USERS_ROL SET DEFINE OFF; Insert into HR.USERS_ROL (USER_ID,ROL_ID) values ('1','1'); -------------------------------------------------------- -- DDL for Index ROL_PK -------------------------------------------------------- CREATE UNIQUE INDEX "HR"."ROL_PK" ON "HR"."ROL" ("ROL_ID") 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" ; -------------------------------------------------------- -- DDL for Index USERS_PK -------------------------------------------------------- CREATE UNIQUE INDEX "HR"."USERS_PK" ON "HR"."USERS" ("USER_ID") 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" ; -------------------------------------------------------- -- Constraints for Table ROL -------------------------------------------------------- ALTER TABLE "HR"."ROL" ADD CONSTRAINT "ROL_PK" PRIMARY KEY ("ROL_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 "HR"."ROL" MODIFY ("ROL_ID" NOT NULL ENABLE); -------------------------------------------------------- -- Constraints for Table USERS -------------------------------------------------------- ALTER TABLE "HR"."USERS" MODIFY ("USER_ID" NOT NULL ENABLE); ALTER TABLE "HR"."USERS" ADD CONSTRAINT "USERS_PK" PRIMARY KEY ("USER_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; -------------------------------------------------------- -- Ref Constraints for Table USERS_ROL -------------------------------------------------------- ALTER TABLE "HR"."USERS_ROL" ADD CONSTRAINT "USERS_ROL_FK1" FOREIGN KEY ("USER_ID") REFERENCES "HR"."USERS" ("USER_ID") ENABLE; ALTER TABLE "HR"."USERS_ROL" ADD CONSTRAINT "USERS_ROL_FK2" FOREIGN KEY ("ROL_ID") REFERENCES "HR"."ROL" ("ROL_ID") ENABLE;
true
2534052d76267b131d6d6915796b164250f41db6
SQL
Temelakiev/SoftUni-Projects
/Databases/SQL Introduction/Problem13_Write a SQL query to find the salary of all employees whose salary is in the range [20000…30000]/EmployeesWithSalaries20000-30000.sql
UTF-8
104
2.5625
3
[]
no_license
SELECT FirstName + ' ' + LastName AS [Name], Salary FROM Employees WHERE Salary BETWEEN 20000 and 30000
true
b45a22b97fe1b2035cd9fc47f61e0bf7ff05502f
SQL
Usman233/Medical-Consultation
/mdc.sql
UTF-8
31,011
3.140625
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.1.14 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: May 30, 2020 at 05:42 PM -- Server version: 5.6.17 -- PHP Version: 5.5.12 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `mdc` -- -- -------------------------------------------------------- -- -- Table structure for table `chat_message` -- CREATE TABLE IF NOT EXISTS `chat_message` ( `chat_message_id` int(11) NOT NULL AUTO_INCREMENT, `to_user_id` int(11) NOT NULL, `from_user_id` int(11) NOT NULL, `chat_message` text NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `status` int(1) NOT NULL, PRIMARY KEY (`chat_message_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `contact` -- CREATE TABLE IF NOT EXISTS `contact` ( `id` bigint(100) NOT NULL AUTO_INCREMENT, `name` varchar(100) DEFAULT NULL, `email` varchar(100) DEFAULT NULL, `msg` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `login` -- CREATE TABLE IF NOT EXISTS `login` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; -- -- Dumping data for table `login` -- INSERT INTO `login` (`user_id`, `username`, `password`) VALUES (1, 'johnsmith', '$2y$10$4REfvTZpxLgkAR/lKG9QiOkSdahOYIR3MeoGJAyiWmRkEFfjH3396'), (2, 'peterParker', '$2y$10$4REfvTZpxLgkAR/lKG9QiOkSdahOYIR3MeoGJAyiWmRkEFfjH3396'), (3, 'davidMoore', '$2y$10$4REfvTZpxLgkAR/lKG9QiOkSdahOYIR3MeoGJAyiWmRkEFfjH3396'), (5, 'usman', 'usman'); -- -------------------------------------------------------- -- -- Table structure for table `login_details` -- CREATE TABLE IF NOT EXISTS `login_details` ( `login_details_id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `last_activity` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `is_type` enum('no','yes') NOT NULL, PRIMARY KEY (`login_details_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_admins` -- CREATE TABLE IF NOT EXISTS `p_admins` ( `adminID` int(10) unsigned NOT NULL AUTO_INCREMENT, `created` int(10) unsigned NOT NULL, `lastactive` int(10) unsigned NOT NULL, `status` tinyint(4) NOT NULL, `ses` varchar(32) NOT NULL, `login` varchar(15) NOT NULL, `password` varchar(32) NOT NULL, `email` varchar(160) NOT NULL, `access` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`adminID`), UNIQUE KEY `login` (`login`), KEY `ses` (`ses`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `p_admins` -- INSERT INTO `p_admins` (`adminID`, `created`, `lastactive`, `status`, `ses`, `login`, `password`, `email`, `access`) VALUES (1, 1590851272, 1590852231, 0, '65834e685403d4772c84e1cb7c1529c8', 'usman', '81dc9bdb52d04dc20036dbd8313ed055', 'rodvd33@gmail.com', ''); -- -------------------------------------------------------- -- -- Table structure for table `p_canned` -- CREATE TABLE IF NOT EXISTS `p_canned` ( `canID` int(10) unsigned NOT NULL AUTO_INCREMENT, `opID` int(10) unsigned NOT NULL, `deptID` int(10) unsigned NOT NULL, `catID` smallint(6) NOT NULL DEFAULT '-1', `cats_extra` text NOT NULL, `title` varchar(80) CHARACTER SET utf8 NOT NULL, `message` mediumtext CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`canID`), KEY `opID` (`opID`), KEY `deptID` (`deptID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_canned_auto` -- CREATE TABLE IF NOT EXISTS `p_canned_auto` ( `opID` int(10) unsigned NOT NULL, `canID` int(10) unsigned NOT NULL, PRIMARY KEY (`opID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_departments` -- CREATE TABLE IF NOT EXISTS `p_departments` ( `deptID` int(10) unsigned NOT NULL AUTO_INCREMENT, `visible` tinyint(4) NOT NULL, `display` tinyint(3) unsigned NOT NULL, `queue` tinyint(4) NOT NULL, `tshare` tinyint(4) NOT NULL, `texpire` int(10) unsigned NOT NULL, `rname` tinyint(1) unsigned NOT NULL DEFAULT '1', `rquestion` tinyint(4) NOT NULL, `remail` tinyint(4) NOT NULL, `temail` tinyint(4) NOT NULL, `aemail` tinyint(4) NOT NULL, `temaild` tinyint(4) NOT NULL, `rtype` tinyint(4) NOT NULL, `rtime` int(10) unsigned NOT NULL, `savem` tinyint(3) unsigned NOT NULL, `vupload` varchar(45) NOT NULL, `ctimer` tinyint(1) NOT NULL DEFAULT '1', `custom` text CHARACTER SET utf8 NOT NULL, `smtp` text NOT NULL, `lang` varchar(15) NOT NULL, `name` varchar(80) CHARACTER SET utf8 NOT NULL, `email` varchar(160) NOT NULL, `emailm_cc` varchar(160) NOT NULL, `emailt` varchar(160) NOT NULL, `emailt_bcc` tinyint(1) NOT NULL, `msg_greet` text CHARACTER SET utf8 NOT NULL, `msg_offline` text CHARACTER SET utf8 NOT NULL, `msg_busy` text CHARACTER SET utf8 NOT NULL, `msg_email` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`deptID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `p_departments` -- INSERT INTO `p_departments` (`deptID`, `visible`, `display`, `queue`, `tshare`, `texpire`, `rname`, `rquestion`, `remail`, `temail`, `aemail`, `temaild`, `rtype`, `rtime`, `savem`, `vupload`, `ctimer`, `custom`, `smtp`, `lang`, `name`, `email`, `emailm_cc`, `emailt`, `emailt_bcc`, `msg_greet`, `msg_offline`, `msg_busy`, `msg_email`) VALUES (1, 1, 255, 0, 0, 0, 1, 1, 1, 1, 0, 0, 2, 45, 6, '0', 1, '', '', 'english', 'university', 'abc@gmail.com', '', '', 0, 'An agent will be with you shortly. Thank you for your patience.', 'Agents are not available at this time. Please leave a message.', 'Agents are not available at this time. Please leave a message.', 'Hi %%visitor%%,\r\n\r\nHere is the complete chat transcript for your reference:\r\n\r\n%%transcript%%\r\n\r\n==========\r\n\r\n%%operator%%\r\n%%op_email%%\r\n'); -- -------------------------------------------------------- -- -- Table structure for table `p_dept_groups` -- CREATE TABLE IF NOT EXISTS `p_dept_groups` ( `groupID` int(10) unsigned NOT NULL, `name` varchar(45) CHARACTER SET utf8 NOT NULL, `lang` varchar(15) NOT NULL DEFAULT 'english', `deptids` varchar(45) NOT NULL, PRIMARY KEY (`groupID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_dept_ops` -- CREATE TABLE IF NOT EXISTS `p_dept_ops` ( `deptID` int(10) unsigned NOT NULL, `opID` int(10) unsigned NOT NULL, `display` tinyint(4) NOT NULL, `visible` tinyint(4) NOT NULL, `status` tinyint(4) NOT NULL, `dept_offline` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`deptID`,`opID`), KEY `display` (`display`,`visible`), KEY `dept_offline` (`dept_offline`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_dept_vars` -- CREATE TABLE IF NOT EXISTS `p_dept_vars` ( `deptID` int(11) NOT NULL, `idle_o` tinyint(3) unsigned NOT NULL, `idle_v` tinyint(3) unsigned NOT NULL, `trans_f_dept` tinyint(3) unsigned NOT NULL, `prechat_form` tinyint(1) NOT NULL DEFAULT '1', `offline_form` tinyint(1) unsigned NOT NULL DEFAULT '1', `qest` tinyint(1) unsigned NOT NULL, `qpos` tinyint(1) unsigned NOT NULL, `qlimit` tinyint(2) unsigned NOT NULL DEFAULT '5', `timestamp` tinyint(1) unsigned NOT NULL DEFAULT '1', `emarketID` int(10) unsigned NOT NULL, `qtexts` varchar(255) CHARACTER SET utf8 NOT NULL, `greeting_title` varchar(255) CHARACTER SET utf8 NOT NULL, `greeting_body` varchar(255) CHARACTER SET utf8 NOT NULL, `end_chat_msg` text CHARACTER SET utf8 NOT NULL, `gdpr_msg` text CHARACTER SET utf8 NOT NULL, `offline_msg_template` text CHARACTER SET utf8 NOT NULL, `offline_auto_reply` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`deptID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_emarketing` -- CREATE TABLE IF NOT EXISTS `p_emarketing` ( `statID` int(10) unsigned NOT NULL AUTO_INCREMENT, `emarketID` int(10) unsigned NOT NULL, `created` int(10) unsigned NOT NULL, `thevalue` tinyint(1) NOT NULL, `email` varchar(160) CHARACTER SET utf8 NOT NULL, `md5_vis` varchar(32) NOT NULL, `sdate` int(10) unsigned NOT NULL, `ces` varchar(32) NOT NULL, PRIMARY KEY (`statID`), UNIQUE KEY `emarketID` (`emarketID`,`md5_vis`), KEY `created` (`created`), KEY `thevalue` (`thevalue`), KEY `email` (`email`), KEY `md5_vis` (`md5_vis`), KEY `sdate` (`sdate`), KEY `ces` (`ces`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_external` -- CREATE TABLE IF NOT EXISTS `p_external` ( `extID` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(40) CHARACTER SET utf8 NOT NULL, `url` varchar(255) NOT NULL, PRIMARY KEY (`extID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_ext_ops` -- CREATE TABLE IF NOT EXISTS `p_ext_ops` ( `extID` int(10) NOT NULL, `opID` int(10) NOT NULL, UNIQUE KEY `extID` (`extID`,`opID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_footprints` -- CREATE TABLE IF NOT EXISTS `p_footprints` ( `created` int(10) unsigned NOT NULL, `archive` tinyint(1) NOT NULL, `ip` varchar(45) NOT NULL, `os` tinyint(1) NOT NULL, `browser` tinyint(1) NOT NULL, `md5_vis` varchar(32) NOT NULL, `md5_page` varchar(32) DEFAULT NULL, `onpage` varchar(255) NOT NULL, `title` varchar(150) CHARACTER SET utf8 NOT NULL, KEY `ip` (`ip`), KEY `created` (`created`), KEY `md5_vis` (`md5_vis`), KEY `md5_page` (`md5_page`), KEY `archive` (`archive`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_footprints_u` -- CREATE TABLE IF NOT EXISTS `p_footprints_u` ( `footID` int(10) unsigned NOT NULL AUTO_INCREMENT, `md5_vis` varchar(32) NOT NULL, `created` int(10) unsigned NOT NULL, `updated` int(10) unsigned NOT NULL, `deptID` int(10) unsigned NOT NULL, `marketID` int(10) unsigned NOT NULL, `chatting` tinyint(1) NOT NULL, `os` tinyint(1) NOT NULL, `browser` tinyint(1) NOT NULL, `footprints` int(10) unsigned NOT NULL, `requests` int(10) unsigned NOT NULL, `initiates` int(10) unsigned NOT NULL, `resolution` varchar(15) NOT NULL, `ip` varchar(45) NOT NULL, `onpage` varchar(255) NOT NULL, `title` varchar(255) CHARACTER SET utf8 NOT NULL, `refer` text CHARACTER SET utf8 NOT NULL, `country` varchar(2) CHARACTER SET utf8 NOT NULL, `region` varchar(42) CHARACTER SET utf8 NOT NULL, `city` varchar(50) CHARACTER SET utf8 NOT NULL, `latitude` float NOT NULL, `longitude` float NOT NULL, PRIMARY KEY (`footID`), UNIQUE KEY `md5_vis` (`md5_vis`), KEY `updated` (`updated`), KEY `created` (`created`), KEY `ip` (`ip`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_footstats` -- CREATE TABLE IF NOT EXISTS `p_footstats` ( `sdate` int(10) unsigned NOT NULL, `md5_page` varchar(32) NOT NULL, `total` int(10) unsigned NOT NULL, `onpage` varchar(255) NOT NULL, PRIMARY KEY (`sdate`,`md5_page`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_ips` -- CREATE TABLE IF NOT EXISTS `p_ips` ( `md5_vis` varchar(32) NOT NULL, `ip` varchar(45) NOT NULL, `created` int(10) unsigned NOT NULL, `t_footprints` int(10) unsigned NOT NULL, `t_requests` int(10) unsigned NOT NULL, `t_initiate` int(10) unsigned NOT NULL, `i_footprints` int(10) unsigned NOT NULL, PRIMARY KEY (`md5_vis`), KEY `created` (`created`), KEY `ip` (`ip`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_lang_packs` -- CREATE TABLE IF NOT EXISTS `p_lang_packs` ( `deptID` int(10) unsigned NOT NULL, `lang_vars` text CHARACTER SET utf8 NOT NULL, UNIQUE KEY `deptID` (`deptID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_marketing` -- CREATE TABLE IF NOT EXISTS `p_marketing` ( `marketID` int(10) unsigned NOT NULL AUTO_INCREMENT, `skey` varchar(4) NOT NULL, `name` varchar(80) CHARACTER SET utf8 NOT NULL, `color` varchar(6) NOT NULL, PRIMARY KEY (`marketID`), KEY `skey` (`skey`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_market_c` -- CREATE TABLE IF NOT EXISTS `p_market_c` ( `sdate` int(10) unsigned NOT NULL, `marketID` int(10) unsigned NOT NULL, `clicks` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`sdate`,`marketID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_mboard` -- CREATE TABLE IF NOT EXISTS `p_mboard` ( `messageID` int(10) unsigned NOT NULL AUTO_INCREMENT, `created` int(10) unsigned NOT NULL, `status` tinyint(3) unsigned NOT NULL, `opID` int(10) unsigned NOT NULL, `message` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`messageID`), KEY `created` (`created`), KEY `status` (`status`), KEY `opID` (`opID`), KEY `messageID` (`messageID`,`opID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_messages` -- CREATE TABLE IF NOT EXISTS `p_messages` ( `messageID` int(10) unsigned NOT NULL AUTO_INCREMENT, `created` int(10) unsigned NOT NULL, `chat` tinyint(3) unsigned NOT NULL, `deptID` int(10) unsigned NOT NULL, `footprints` int(10) unsigned NOT NULL, `ip` varchar(45) NOT NULL, `vname` varchar(80) NOT NULL, `vemail` varchar(160) NOT NULL, `ces` varchar(32) NOT NULL, `md5_vis` varchar(32) NOT NULL, `subject` varchar(155) NOT NULL, `onpage` varchar(255) NOT NULL, `refer` text CHARACTER SET utf8 NOT NULL, `custom` text CHARACTER SET utf8 NOT NULL, `message` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`messageID`), KEY `md5_vis` (`md5_vis`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `p_messages` -- INSERT INTO `p_messages` (`messageID`, `created`, `chat`, `deptID`, `footprints`, `ip`, `vname`, `vemail`, `ces`, `md5_vis`, `subject`, `onpage`, `refer`, `custom`, `message`) VALUES (1, 1590852270, 0, 1, 1, '::1', 'faiqa', 'abc@gmail.com', '', '3d4a6ee706ddc4876aee5f12b106771a', 'question', '', '', '', 'hi'); -- -------------------------------------------------------- -- -- Table structure for table `p_notes` -- CREATE TABLE IF NOT EXISTS `p_notes` ( `noteID` int(10) unsigned NOT NULL AUTO_INCREMENT, `created` int(10) unsigned NOT NULL, `opID` int(10) unsigned NOT NULL, `deptID` int(10) unsigned NOT NULL, `isnote` tinyint(3) unsigned NOT NULL, `ces` varchar(32) NOT NULL, `message` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`noteID`), KEY `created` (`created`), KEY `opID` (`opID`), KEY `deptID` (`deptID`), KEY `ces` (`ces`), KEY `isnote` (`isnote`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_operators` -- CREATE TABLE IF NOT EXISTS `p_operators` ( `opID` int(10) unsigned NOT NULL AUTO_INCREMENT, `lastactive` int(10) unsigned NOT NULL, `lastrequest` int(11) unsigned NOT NULL, `status` tinyint(4) NOT NULL, `mapper` tinyint(1) unsigned NOT NULL, `mapp` tinyint(1) unsigned NOT NULL, `signall` tinyint(4) NOT NULL, `rate` tinyint(1) unsigned NOT NULL, `op2op` tinyint(1) unsigned NOT NULL, `traffic` tinyint(1) unsigned NOT NULL, `viewip` tinyint(1) unsigned NOT NULL, `nchats` tinyint(1) NOT NULL DEFAULT '1', `maxc` tinyint(1) NOT NULL, `maxco` tinyint(1) NOT NULL, `canID` tinyint(4) NOT NULL, `tag` tinyint(1) NOT NULL DEFAULT '1', `peer` tinyint(1) unsigned NOT NULL, `upload` varchar(45) NOT NULL, `ses` varchar(32) NOT NULL, `ces` varchar(32) NOT NULL, `rating` tinyint(4) NOT NULL, `sms` int(10) unsigned NOT NULL, `smsnum` varchar(155) NOT NULL, `login` varchar(15) NOT NULL, `password` varchar(32) NOT NULL, `name` varchar(80) CHARACTER SET utf8 NOT NULL, `email` varchar(160) NOT NULL, `pic` tinyint(1) unsigned NOT NULL, `pic_form_display` tinyint(1) unsigned NOT NULL, `view_chats` tinyint(1) unsigned NOT NULL, `dept_offline` tinyint(1) NOT NULL, `theme` varchar(15) NOT NULL, PRIMARY KEY (`opID`), KEY `ses` (`ses`), KEY `status` (`status`), KEY `name` (`name`), KEY `maxc` (`maxc`), KEY `mapp` (`mapp`), KEY `rate` (`rate`), KEY `sms` (`sms`), KEY `smsnum` (`smsnum`), KEY `email` (`email`), KEY `lastactive` (`lastactive`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_opstatus_log` -- CREATE TABLE IF NOT EXISTS `p_opstatus_log` ( `created` int(11) NOT NULL, `opID` int(11) NOT NULL, `status` tinyint(4) NOT NULL, `mapp` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`created`,`opID`), KEY `created` (`created`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_op_vars` -- CREATE TABLE IF NOT EXISTS `p_op_vars` ( `opID` int(10) unsigned NOT NULL, `canID` int(10) unsigned NOT NULL, `sound` tinyint(1) NOT NULL, `blink` tinyint(1) NOT NULL, `blink_r` tinyint(1) NOT NULL, `dn_response` tinyint(1) NOT NULL, `dn_request` tinyint(1) NOT NULL, `dn_always` tinyint(1) NOT NULL, `nsleep` tinyint(1) unsigned NOT NULL DEFAULT '1', `shorts` tinyint(1) unsigned NOT NULL, `mapp_c` tinyint(1) unsigned NOT NULL, `pic_edit` tinyint(1) unsigned NOT NULL, `upload_ses` int(10) unsigned NOT NULL, `vis_idle_canned` varchar(90) NOT NULL, `can_cats` text CHARACTER SET utf8 NOT NULL, `lang_vars` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`opID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_proaction_c` -- CREATE TABLE IF NOT EXISTS `p_proaction_c` ( `proactionID` int(11) NOT NULL, `sdate` int(10) unsigned NOT NULL, `views` mediumint(8) unsigned NOT NULL, `taken` mediumint(8) unsigned NOT NULL, `declined` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`proactionID`,`sdate`), KEY `views` (`views`,`taken`,`declined`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_queue` -- CREATE TABLE IF NOT EXISTS `p_queue` ( `queueID` int(10) unsigned NOT NULL AUTO_INCREMENT, `created` int(11) NOT NULL, `updated` int(10) unsigned NOT NULL, `deptID` int(10) unsigned NOT NULL, `embed` tinyint(1) unsigned NOT NULL, `ces` varchar(32) NOT NULL, `md5_vis` varchar(32) NOT NULL, `ops_d` varchar(200) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`queueID`), KEY `ces` (`ces`), KEY `md5_vis` (`md5_vis`), KEY `deptID` (`deptID`), KEY `ops_d` (`ops_d`), KEY `embed` (`embed`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_queue_log` -- CREATE TABLE IF NOT EXISTS `p_queue_log` ( `logID` int(10) unsigned NOT NULL AUTO_INCREMENT, `created` int(10) unsigned NOT NULL, `ended` int(10) unsigned NOT NULL, `sdate` int(10) unsigned NOT NULL, `status` tinyint(1) NOT NULL, `deptID` int(10) unsigned NOT NULL, `ces` varchar(32) NOT NULL, PRIMARY KEY (`logID`), KEY `created` (`created`), KEY `ended` (`ended`), KEY `status` (`status`), KEY `ces` (`ces`), KEY `deptID` (`deptID`), KEY `sdate` (`sdate`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_refer` -- CREATE TABLE IF NOT EXISTS `p_refer` ( `md5_vis` varchar(32) NOT NULL, `created` int(10) unsigned NOT NULL, `archive` tinyint(1) NOT NULL, `marketID` int(10) unsigned NOT NULL, `md5_page` varchar(32) NOT NULL, `refer` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`md5_vis`), KEY `created` (`created`), KEY `md5_page` (`md5_page`), KEY `archive` (`archive`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_referstats` -- CREATE TABLE IF NOT EXISTS `p_referstats` ( `sdate` int(10) unsigned NOT NULL, `md5_page` varchar(32) NOT NULL, `total` int(10) unsigned NOT NULL, `refer` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`sdate`,`md5_page`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_requests` -- CREATE TABLE IF NOT EXISTS `p_requests` ( `requestID` int(10) unsigned NOT NULL AUTO_INCREMENT, `created` int(10) unsigned NOT NULL, `ended` int(10) unsigned NOT NULL, `tupdated` int(11) NOT NULL, `updated` int(10) unsigned NOT NULL, `vupdated` int(10) unsigned NOT NULL, `status` tinyint(1) NOT NULL, `auto_pop` tinyint(4) NOT NULL, `initiated` tinyint(1) NOT NULL, `deptID` int(11) unsigned NOT NULL, `opID` int(11) unsigned NOT NULL, `op2op` int(10) unsigned NOT NULL, `marketID` int(10) NOT NULL, `bses_id` varchar(32) CHARACTER SET utf8 NOT NULL, `os` tinyint(1) NOT NULL, `browser` tinyint(1) NOT NULL, `requests` int(10) unsigned NOT NULL, `rloop` tinyint(3) unsigned NOT NULL, `tloop` tinyint(4) NOT NULL, `peer` int(10) unsigned NOT NULL, `ces` varchar(32) NOT NULL, `resolution` varchar(15) NOT NULL, `vname` varchar(80) CHARACTER SET utf8 NOT NULL, `vemail` varchar(160) NOT NULL, `ip` varchar(45) NOT NULL, `country` varchar(3) NOT NULL, `md5_vis` varchar(32) NOT NULL, `md5_vis_` varchar(32) NOT NULL, `sim_ops` varchar(155) NOT NULL, `sim_ops_` varchar(155) NOT NULL, `onpage` varchar(255) NOT NULL, `title` varchar(150) CHARACTER SET utf8 NOT NULL, `rstring` varchar(255) NOT NULL, `refer` text CHARACTER SET utf8 NOT NULL, `custom` text CHARACTER SET utf8 NOT NULL, `question` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`requestID`), UNIQUE KEY `ces` (`ces`), KEY `opID` (`opID`), KEY `op2op` (`op2op`), KEY `status` (`status`), KEY `md5_vis` (`md5_vis`), KEY `updated` (`updated`), KEY `vupdated` (`vupdated`), KEY `ended` (`ended`), KEY `md5_vis_` (`md5_vis_`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `p_req_log` -- CREATE TABLE IF NOT EXISTS `p_req_log` ( `ces` varchar(32) NOT NULL, `created` int(10) unsigned NOT NULL, `accepted` int(10) unsigned NOT NULL, `accepted_op` int(10) unsigned NOT NULL, `duration` mediumint(8) unsigned NOT NULL, `ended` int(10) unsigned NOT NULL, `status` tinyint(1) NOT NULL, `archive` tinyint(1) NOT NULL, `status_msg` tinyint(1) NOT NULL, `initiated` tinyint(1) NOT NULL, `deptID` int(11) unsigned NOT NULL, `opID` int(11) unsigned NOT NULL, `op2op` int(11) NOT NULL, `marketID` int(10) NOT NULL, `os` tinyint(1) NOT NULL, `browser` tinyint(1) NOT NULL, `idle_disconnect` tinyint(4) NOT NULL, `tag` tinyint(3) unsigned NOT NULL, `disc` tinyint(3) unsigned NOT NULL, `resolution` varchar(15) NOT NULL, `vname` varchar(40) CHARACTER SET utf8 NOT NULL, `vemail` varchar(160) NOT NULL, `ip` varchar(45) NOT NULL, `md5_vis` varchar(32) NOT NULL, `sim_ops` varchar(155) NOT NULL, `onpage` varchar(255) NOT NULL, `title` varchar(150) CHARACTER SET utf8 NOT NULL, `custom` text CHARACTER SET utf8 NOT NULL, `question` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`ces`), KEY `opID` (`opID`), KEY `md5_vis` (`md5_vis`), KEY `created` (`created`), KEY `archive` (`archive`), KEY `tag` (`tag`), KEY `ended` (`ended`), KEY `deptID` (`deptID`), KEY `initiated` (`initiated`), KEY `op2op` (`op2op`), KEY `accepted` (`accepted`), KEY `accepted_op` (`accepted_op`), KEY `duration` (`duration`), KEY `status_msg` (`status`,`status_msg`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_rstats_depts` -- CREATE TABLE IF NOT EXISTS `p_rstats_depts` ( `sdate` int(10) unsigned NOT NULL, `deptID` int(10) unsigned NOT NULL, `requests` int(10) NOT NULL, `taken` smallint(5) unsigned NOT NULL, `declined` smallint(5) unsigned NOT NULL, `message` smallint(5) unsigned NOT NULL, `initiated` smallint(5) unsigned NOT NULL, `rateit` smallint(5) unsigned NOT NULL, `ratings` smallint(5) unsigned NOT NULL, PRIMARY KEY (`sdate`,`deptID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_rstats_log` -- CREATE TABLE IF NOT EXISTS `p_rstats_log` ( `ces` varchar(32) NOT NULL, `created` int(10) unsigned NOT NULL, `status` tinyint(1) NOT NULL, `opID` int(10) unsigned NOT NULL, `deptID` int(10) unsigned NOT NULL, PRIMARY KEY (`ces`,`opID`), KEY `created` (`created`), KEY `opID` (`opID`), KEY `deptID` (`deptID`), KEY `status` (`status`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_rstats_ops` -- CREATE TABLE IF NOT EXISTS `p_rstats_ops` ( `sdate` int(10) unsigned NOT NULL, `opID` int(10) unsigned NOT NULL, `requests` int(10) NOT NULL, `taken` smallint(5) unsigned NOT NULL, `declined` smallint(5) unsigned NOT NULL, `message` smallint(5) unsigned NOT NULL, `initiated` smallint(5) unsigned NOT NULL, `rateit` smallint(5) unsigned NOT NULL, `ratings` smallint(5) unsigned NOT NULL, PRIMARY KEY (`sdate`,`opID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_transcripts` -- CREATE TABLE IF NOT EXISTS `p_transcripts` ( `ces` varchar(32) NOT NULL, `created` int(11) unsigned NOT NULL, `ended` int(10) unsigned NOT NULL, `deptID` int(11) unsigned NOT NULL, `opID` int(11) unsigned NOT NULL, `accepted_op` int(10) unsigned NOT NULL, `initiated` tinyint(1) NOT NULL, `op2op` int(10) unsigned NOT NULL, `rating` tinyint(1) NOT NULL, `encr` tinyint(1) NOT NULL, `fsize` mediumint(9) NOT NULL, `noteID` int(10) unsigned NOT NULL, `marketID` tinyint(3) unsigned NOT NULL, `tag` tinyint(3) unsigned NOT NULL, `vname` varchar(80) CHARACTER SET utf8 NOT NULL, `vemail` varchar(160) NOT NULL, `ip` varchar(45) NOT NULL, `md5_vis` varchar(32) NOT NULL, `custom` text CHARACTER SET utf8 NOT NULL, `question` mediumtext CHARACTER SET utf8 NOT NULL, `formatted` mediumtext CHARACTER SET utf8 NOT NULL, `plain` mediumtext CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`ces`), KEY `created` (`created`), KEY `rating` (`rating`), KEY `opID` (`opID`), KEY `md5_vis` (`md5_vis`), KEY `deptID` (`deptID`), KEY `op2op` (`op2op`), KEY `encr` (`encr`), KEY `noteID` (`noteID`), KEY `tag` (`tag`), KEY `accepted_op` (`accepted_op`), KEY `marketID` (`marketID`), FULLTEXT KEY `plain` (`plain`), FULLTEXT KEY `custom` (`custom`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `p_vars` -- CREATE TABLE IF NOT EXISTS `p_vars` ( `varID` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(10) NOT NULL, `position` tinyint(1) NOT NULL, `ts_clean` int(10) unsigned NOT NULL, `ts_clear` int(10) unsigned NOT NULL, `ts_queue` int(10) unsigned NOT NULL, `char_set` varchar(155) NOT NULL, `profile_pic` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`varID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `p_vars` -- INSERT INTO `p_vars` (`varID`, `code`, `position`, `ts_clean`, `ts_clear`, `ts_queue`, `char_set`, `profile_pic`) VALUES (1, '0', 1, 0, 1590853020, 0, '', 0); -- -------------------------------------------------------- -- -- Table structure for table `reg_doctor` -- CREATE TABLE IF NOT EXISTS `reg_doctor` ( `id` bigint(100) NOT NULL AUTO_INCREMENT, `name` varchar(100) DEFAULT NULL, `email` varchar(100) DEFAULT NULL, `password_doc` varchar(100) DEFAULT NULL, `city` varchar(100) DEFAULT NULL, `specialization` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; -- -- Dumping data for table `reg_doctor` -- INSERT INTO `reg_doctor` (`id`, `name`, `email`, `password_doc`, `city`, `specialization`) VALUES (5, 'faiqa', 'faiqa@gmail.com', '1234', 'lahore', 'dentist'), (6, 'faiqa', 'abc@gmail.com', '1234', 'karachi', 'gynacologist'), (7, 'faiqa', 'abc@gmail.com', '1234', 'karachi', 'gynacologist'); -- -------------------------------------------------------- -- -- Table structure for table `reg_patient` -- CREATE TABLE IF NOT EXISTS `reg_patient` ( `id` bigint(100) NOT NULL AUTO_INCREMENT, `name` varchar(100) DEFAULT NULL, `email` varchar(100) DEFAULT NULL, `password_pnt` varchar(100) DEFAULT NULL, `city` varchar(100) DEFAULT NULL, `disease` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; -- -- Dumping data for table `reg_patient` -- INSERT INTO `reg_patient` (`id`, `name`, `email`, `password_pnt`, `city`, `disease`) VALUES (1, 'Usman', 'usman@gmail.com', 'usman', 'lahore', ''), (2, 'Usman', 'abc@gmail.com', 'hgjhg', 'lahore', ''), (3, 'Usman', 'abc@gmail.com', 'bnmbmn', 'lahore', ''); /*!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
771b9750c8dbe59405d8336df0e35fb6002b9324
SQL
anastasia-kucherova/geekbrains_DB
/homework/lesson9/sample.dump.sql
UTF-8
2,930
3.546875
4
[]
no_license
-- -------------------------------------------------------- -- Хост: 127.0.0.1 -- Версия сервера: 5.7.25 - MySQL Community Server (GPL) -- ОС Сервера: Win64 -- HeidiSQL Версия: 9.3.0.4984 -- -------------------------------------------------------- /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 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' */; -- Дамп структуры для таблица sample.users DROP TABLE IF EXISTS `users`; CREATE TABLE IF NOT EXISTS `users` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Имя покупателя', `birthday_at` date DEFAULT NULL COMMENT 'Дата рождения', `created_at` datetime DEFAULT CURRENT_TIMESTAMP, `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Покупатели'; -- Дамп данных таблицы sample.users: ~1 rows (приблизительно) /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` (`id`, `name`, `birthday_at`, `created_at`, `updated_at`) VALUES (1, 'Геннадий', '1990-10-05', '2020-05-12 22:01:13', '2020-05-12 22:01:13'); /*!40000 ALTER TABLE `users` ENABLE KEYS */; -- Дамп структуры для функция sample.fibonacci DROP FUNCTION IF EXISTS `fibonacci`; DELIMITER // CREATE DEFINER=`root`@`localhost` FUNCTION `fibonacci`(n INT) RETURNS int(11) BEGIN DECLARE i INT DEFAULT 0;DECLARE prev INT DEFAULT 0;DECLARE next INT DEFAULT 1;DECLARE temp INT;WHILE i < n DO SET temp = next;SET next = prev + next;SET prev = temp;SET i = i + 1;END WHILE;RETURN prev;END// DELIMITER ; -- Дамп структуры для функция sample.hello DROP FUNCTION IF EXISTS `hello`; DELIMITER // CREATE DEFINER=`root`@`localhost` FUNCTION `hello`() RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci BEGIN DECLARE hours TINYINT DEFAULT TIME_FORMAT(NOW(), '%H');DECLARE result VARCHAR(255);CASE WHEN hours >= 0 AND hours < 6 THEN SET result = "Доброй ночи";WHEN hours >= 6 AND hours < 12 THEN SET result = "Доброе утро";WHEN hours >= 12 AND hours < 18 THEN SET result = "Добрый день";WHEN hours >= 18 AND hours < 24 THEN SET result = "Добрый вечер";END CASE;RETURN result;END// DELIMITER ; /*!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
159aab9ada3e456e7a90a60ea9fbf9b88b5d36f0
SQL
crachel8521/Interaction-Design
/hhp.sql
UTF-8
6,201
3.765625
4
[]
no_license
-- create the database DROP DATABASE IF EXISTS hhp; CREATE DATABASE hhp; -- select the database USE hhp; DROP TABLE IF EXISTS Accounts; CREATE TABLE Accounts ( user_id int auto_increment, user_name varchar(155)not null, password varchar(35) not null, last_name varchar(35) not null, first_name varchar(35) not null, user_sname varchar(50), email varchar(35) not null, address varchar(155), age int not null, user_type varchar(35), build_request boolean not null default 0, CONSTRAINT PK_Person PRIMARY KEY (user_id,user_name) ); INSERT INTO Accounts VALUES (1, 'SCindy','hhp','Smith','Cindy', 'Cindy07','cindy@uncc.edu', '1234, address comes here',21,'user', 0), (2, 'JElmer','hhp','Jones','Elmer', 'Elmar17','jones@uncc.edu', '1234, address comes here',7,'user', 1), (3, 'SRalph','hhp','Simonian','Ralph', ' ','ralph@uncc.edu', '1234, address comes here',14,'user', 0), (4, 'RAmanda','hhp','Riley','Amanda', 'Amanda15','amanda@hhp.com', '1234, address comes here',23,'builder', 0), (5, 'RAmanda','hhp','Riley','Amanda', 'Amanda15','amanda@hhp.com', '1234, address comes here',23,'builder', 0), (6, 'RAmanda','hhp','Riley','Amanda', 'Amanda15','amanda@hhp.com', '1234, address comes here',23,'builder', 0) ; DROP TABLE IF EXISTS Events; CREATE TABLE Events ( event_id int auto_increment, event_name varchar(155) not null, event_desc varchar(255), event_type varchar(35) not null, event_location varchar(155), event_photo blob, event_link varchar(245) not null, CONSTRAINT PK_Event PRIMARY KEY (event_id) ); INSERT INTO Events VALUES (1,'Demo, User Studies', 'Students will submit their user study progress report and demonstrate their project development','Class','Charlotte', '', 'https://uncc.instructure.com/courses/46603/assignments/167853'), (2,'Grad Scholarly Article', 'Graduate students will submit their research based on their projects','Graduate Students','Charlotte', '', 'https://uncc.instructure.com/courses/46603/assignments/167853'), (3,'Final Demo', 'Students will demonstrate their final functional project','Class','Charlotte', '', 'https://uncc.instructure.com/courses/46603/assignments/167853') ; select * from Events; DROP TABLE IF EXISTS Stories; CREATE TABLE Stories ( story_id int auto_increment, story_title varchar(155) not null, user_id int not null, story_text varchar(1000), story_photo blob, date_posted Datetime, likes int not null, CONSTRAINT PK_Story PRIMARY KEY (story_id), CONSTRAINT FK_Story FOREIGN KEY (user_id) REFERENCES Accounts(user_id) ); INSERT INTO Stories VALUES (1,"Hamed's Genium story", 3, "Living in a big city, Hamed spends a lot of time walking and being outdoors. He depends on the Genium prosthetic leg to help him stay active with exercise and keep up with his friends and his career. As a prosthetist, Hamed knows the importance of a high functioning prosthesis like the Genium prosthetic leg.", '',now(),2), (2,"Josh's DynamicArm story", 2, "Josh's drive and passion are reflected in every area of his life. Whether he is knotting his tie in preparation for handling a legal case or loosening up for a 3-point shot from the arc, he uses his DynamicArm to the fullest.", '',now(),5), (3,"Andrew and the X3 waterproof prosthetic leg", 1, "Lt. Col. (Ret.) Andrew Lourake was the first Air Force pilot with an above-knee amputation to return to active duty. He did it on a C-Leg, and has since moved on to the X3, Ottobock's remarkable waterproof microprocessor knee. In addition to jetting around lakes, he takes to the sky and works at the Veterans Air Command (VAC), an amazing organization that provides free air transportation to post 9/11 combat wounded and their families for medical and other compassionate purposes through a network of volunteer aircraft owners and pilots.", '',now(), 4) ; select * from stories; DROP TABLE IF EXISTS Mentor; CREATE TABLE Mentor ( user_id int not null, mentor_id int not null, mentee_id int not null, mentorship_type varchar(35) not null, CONSTRAINT FK_Mentor FOREIGN KEY (user_id) REFERENCES Accounts(user_id) ); INSERT INTO Mentor VALUES (1, 1, 2, 'mentor'), (2, 1, 2, 'mentee') ; DROP TABLE IF EXISTS Builder_Status; CREATE TABLE Builder_Status ( status_id int auto_increment, builder_user_id int not null, recipient_user_id int not null, builder_name varchar(100) not null, status_update blob, status_desc varchar(500), date_posted datetime not null, CONSTRAINT PK_Status PRIMARY KEY (status_id), CONSTRAINT FK_Builder FOREIGN KEY (builder_user_id) REFERENCES Accounts(user_id), CONSTRAINT FK_Recipient FOREIGN KEY (recipient_user_id) REFERENCES Accounts(user_id) ); INSERT INTO Builder_Status(builder_user_id, recipient_user_id, builder_name, status_update, status_desc, date_posted) VALUES (4, 2,'Steven Smith','','Hand is in the designing process', now()), (4, 2,'Steven Smith','','Motor and other accessories ordered', now()), (4, 2,'Steven Smith','','Device building is started', now()) ; select * from builder_status; DROP TABLE IF EXISTS Recipient_Info; CREATE TABLE Recipient_Info ( recipient_id int, recipient_firstname varchar(100) not null, recipient_lastname varchar(100) not null, hand_measurement varchar(500) not null, filler_name varchar(100) not null, contact_info varchar(100) not null, date_posted datetime not null, CONSTRAINT FK_RecipientInfo FOREIGN KEY (recipient_id) REFERENCES Accounts(user_id) ); INSERT INTO Recipient_Info(recipient_id,recipient_firstname, recipient_lastname, hand_measurement, filler_name , contact_info, date_posted) VALUES (2,'Elmer','Jones','Hand measurements are provided', 'Robert Jones', 9802586459, now()) ; select * from Recipient_Info; delete from Recipient_Info where recipient_id=2; DROP TABLE IF EXISTS Mentor; CREATE TABLE Builders ( user_id int not null, description varchar(500) not null, CONSTRAINT FK_Mentor FOREIGN KEY (user_id) REFERENCES Accounts(user_id) ); INSERT INTO Builders VALUES (4, 'Im a father of three with a home workshop with two 3D printers.'), (5, 'I work with the local library to do 3D printing for different projects.'), (6, 'I am a builder for the Helping Hand Project at UNCC and use the campus printers to build devices.') ;
true
7507cb8053a17b7c3db58fd8494cd7a2a9a574b4
SQL
YYMo/csc343automarker
/all/group_0567/a2.sql
UTF-8
7,041
4.21875
4
[]
no_license
-- Query 1 statements CREATE VIEW first_countries AS SELECT cid AS c1id, cname AS c1name, neighbor FROM country NATURAL JOIN neighbour WHERE cid=country; CREATE VIEW first_and_neighbours AS SELECT c1id, c1name, cid AS c2id, cname as c2name, height FROM first_countries NATURAL JOIN country WHERE neighbor=country.cid; CREATE VIEW maxes AS SELECT c1id, max(height), c1name FROM first_and_neighbours GROUP BY c1id, c1name ORDER BY c1id; CREATE VIEW answer AS select c1id, c1name, c2id, c2name FROM first_and_neighbours NATURAL JOIN maxes WHERE max=height ORDER BY c1id; INSERT INTO Query1(SELECT * FROM answer); DROP VIEW first_countries CASCADE; -- Query 2 statements CREATE VIEW landlocked_countries AS SELECT cid, cname FROM country WHERE cid NOT IN (SELECT cid FROM oceanaccess) ORDER BY cname; INSERT INTO Query2(SELECT * FROM landlocked_countries); DROP VIEW landlocked_countries; -- Query 3 statements CREATE VIEW landlocked_countries AS SELECT cid, cname FROM country WHERE cid NOT IN (SELECT cid FROM oceanaccess) ORDER BY cname; CREATE VIEW surrounded_by_1 AS SELECT country FROM neighbour GROUP BY country HAVING count(country)=1; CREATE VIEW locked_and_surrounded AS SELECT cid FROM ((SELECT cid FROM landlocked_countries) INTERSECT (SELECT country FROM surrounded_by_1))intersected; CREATE VIEW first_countries AS SELECT cid AS c1id, cname AS c1name from locked_and_surrounded NATURAL JOIN country ORDER BY cid; CREATE VIEW second_countries AS SELECT neighbor FROM first_countries, neighbour WHERE c1id=country ORDER BY neighbor; CREATE VIEW second_countries_complete AS SELECT neighbor AS c2id, cname AS c2name FROM second_countries, country WHERE neighbor=cid ORDER BY neighbor; CREATE VIEW answer AS SELECT DISTINCT * FROM first_countries, second_countries_complete ORDER BY c1name; INSERT INTO Query3 (SELECT * FROM answer); DROP VIEW landlocked_countries CASCADE; DROP VIEW surrounded_by_1 CASCADE; -- Query 4 statements -- CREATE VIEW indirect_access AS SELECT country, neighbor, oid FROM oceanaccess NATURAL JOIN neighbour WHERE neighbor=cid; CREATE VIEW all_access AS SELECT country AS cid, oid FROM ((SELECT country, oid FROM indirect_access) UNION (SELECT * FROM oceanaccess)) all_access; CREATE VIEW answer AS SELECT cname, oname FROM (SELECT cid, oname FROM all_access NATURAL JOIN ocean)ocean_names NATURAL JOIN country ORDER BY cname ASC, oname DESC; INSERT INTO Query4 (SELECT * FROM answer); DROP VIEW indirect_access CASCADE; -- Query 5 statements CREATE VIEW in_years AS SELECT * FROM hdi WHERE year >=2009 AND year <=2013; CREATE VIEW averages AS SELECT cid, avg(hdi_score) AS avghdi FROM in_years GROUP BY cid; CREATE VIEW answer AS SELECT averages.cid AS cid, cname, avghdi FROM averages, country WHERE averages.cid=country.cid ORDER BY avghdi DESC LIMIT 10; INSERT INTO Query5 (SELECT * FROM answer); DROP VIEW in_years CASCADE; -- Query 6 statements CREATE VIEW nine AS SELECT cid, hdi_score FROM hdi WHERE year='2009'; CREATE VIEW ten AS SELECT cid, hdi_score FROM hdi WHERE year='2010'; CREATE VIEW eleven AS SELECT cid, hdi_score FROM hdi WHERE year='2011'; CREATE VIEW twelve AS SELECT cid, hdi_score FROM hdi WHERE year='2012'; CREATE VIEW thirteen AS SELECT cid, hdi_score FROM hdi WHERE year='2013'; CREATE VIEW first_increase AS SELECT ten.cid, ten.hdi_score FROM nine,ten WHERE ten.hdi_score>nine.hdi_score AND nine.cid=ten.cid; CREATE VIEW second_increase AS SELECT eleven.cid, eleven.hdi_score FROM first_increase, eleven WHERE eleven.hdi_score>first_increase.hdi_score AND first_increase.cid=eleven.cid; CREATE VIEW third_increase AS SELECT twelve.cid, twelve.hdi_score FROM second_increase, twelve WHERE twelve.hdi_score>second_increase.hdi_score AND second_increase.cid=twelve.cid; CREATE VIEW fourth_increase AS SELECT thirteen.cid FROM third_increase, thirteen WHERE thirteen.hdi_score>third_increase.hdi_score AND third_increase.cid=thirteen.cid; CREATE VIEW answer AS SELECT cid, cname FROM fourth_increase NATURAL JOIN country; INSERT INTO Query6(SELECT * FROM answer); DROP VIEW nine CASCADE; DROP VIEW ten CASCADE; DROP VIEW eleven CASCADE; DROP VIEW twelve CASCADE; DROP VIEW thirteen CASCADE; -- Query 7 statements CREATE VIEW religion_and_num AS SELECT (population * rpercentage) AS num, * FROM country NATURAL JOIN religion; CREATE VIEW answer AS SELECT rid, rname, sum (num) AS followers FROM religion_and_num GROUP BY religion_and_num.rid, religion_and_num.rname ORDER BY followers DESC; DROP VIEW religion_and_num CASCADE; -- Query 8 statements -- CREATE VIEW max AS SELECT cid, max(lpercentage) AS lpercentage FROM language GROUP BY cid; CREATE VIEW most_pop AS SELECT cid, lname FROM max NATURAL JOIN language WHERE max.cid = language.cid AND max.lpercentage = language.lpercentage; CREATE VIEW first_pops AS SELECT country, lname AS c1lname, neighbor FROM most_pop NATURAL JOIN neighbour WHERE country=cid; CREATE VIEW combined_pops AS SELECT country AS c1id, c1lname, neighbor AS c2id, lname AS c2lname FROM first_pops NATURAL JOIN most_pop WHERE neighbor=cid; CREATE VIEW pairs AS SELECT c1id, c2id, c1lname AS lname FROM combined_pops WHERE c1lname = c2lname; CREATE VIEW first_rename AS SELECT cname AS c1name, c2id, lname FROM pairs NATURAL JOIN country WHERE c1id = cid; CREATE VIEW answer AS SELECT c1name, cname AS c2name, lname FROM first_rename NATURAL JOIN country WHERE c2id = cid; INSERT INTO Query8 (SELECT * FROM answer); DROP VIEW max CASCADE; -- Query 9 statements CREATE VIEW oceans_and_depths AS SELECT cname, height, depth FROM country NATURAL JOIN oceanaccess NATURAL JOIN ocean; CREATE VIEW ocean_span AS SELECT cname, max(depth-height) AS total_span FROM oceans_and_depths GROUP BY cname; CREATE VIEW max_diff_ocean AS SELECT cname, total_span FROM ocean_span WHERE total_span = (SELECT max(total_span) from ocean_span); CREATE VIEW landlocked_countries AS SELECT cname, height FROM country WHERE cid NOT IN (SELECT cid FROM oceanaccess) ORDER BY cname; CREATE VIEW landlocked_span AS SELECT cname, height AS total_span FROM landlocked_countries WHERE height = (SELECT max(height) from landlocked_countries); CREATE VIEW all_country_spans AS SELECT * FROM ((SELECT * from max_diff_ocean) UNION (select * from landlocked_span))all_countries; CREATE VIEW answer AS SELECT cname, total_span AS totalspan FROM all_country_spans WHERE total_span = (SELECT max(total_span) FROM all_country_spans); INSERT INTO Query9 (SELECT * FROM answer); DROP VIEW oceans_and_depths CASCADE; DROP VIEW landlocked_countries CASCADE; -- Query 10 statements CREATE VIEW border_lengths AS SELECT country, sum(length) AS borderslength FROM neighbour GROUP BY country; CREATE VIEW cid_border AS SELECT country, borderslength FROM border_lengths WHERE borderslength = (SELECT max(borderslength) FROM border_lengths); CREATE VIEW answer AS SELECT cname, borderslength FROM cid_border, country WHERE country = cid; INSERT INTO Query10 (SELECT * FROM answer); DROP VIEW border_lengths CASCADE;
true
aeb04545c0db1e6d6dd051ed3258b3bd8ff9a307
SQL
PetePhx/relational-databases
/sql_book/basic_exercises.sql
UTF-8
1,154
3.515625
4
[]
no_license
1. Write a query that returns all of the customer names from the orders table. SELECT customer_name FROM orders; customer_name ----------------- Todd Perez Florence Jordan Robin Barnes Joyce Silva Joyce Silva (5 rows) 2. Write a query that returns all of the orders that include a Chocolate Shake. SELECT * FROM orders WHERE drink = 'Chocolate Shake'; id | customer_name | burger | side | drink ----+-----------------+-------------------------+-------+----------------- 2 | Florence Jordan | LS Cheeseburger | Fries | Chocolate Shake 4 | Joyce Silva | LS Double Deluxe Burger | Fries | Chocolate Shake 3. Write a query that returns the burger, side, and drink for the order with an id of 2. SELECT burger, side, drink FROM orders WHERE id = 2; burger | side | drink -----------------+-------+----------------- LS Cheeseburger | Fries | Chocolate Shake (1 row) 4. Write a query that returns the name of anyone who ordered Onion Rings. SELECT customer_name FROM orders WHERE side = 'Onion Rings'; customer_name --------------- Robin Barnes Joyce Silva (2 rows)
true
ea43c7c317cbfcd8d431af3d941680864a279b67
SQL
silence-do-good/stress-test-Postgres-and-MySQL
/dump/high/day15/select0345.sql
UTF-8
177
2.640625
3
[]
no_license
SELECT timeStamp, temperature FROM ThermometerOBSERVATION o WHERE timestamp>'2017-11-14T03:45:00Z' AND timestamp<'2017-11-15T03:45:00Z' AND temperature>=0 AND temperature<=78
true
22996a3ea058aab162803d87077f17218807c726
SQL
kimill1394/php_hw_shoppingmall
/model/viewinit.sql
UTF-8
998
3.09375
3
[]
no_license
create view v_sheep as select sheep.sheepno, sheep.sheepname, sheep.sheepsalerate, sheep.sheepprice, sheep.sheepimg, sheep.sheepstar, sheep.buycount, its.itemstatusimg, kos.kindname, kos.kindno, kos.kindcomment from sheep, itemstatus its, kindofsheep kos where sheep.kindno=kos.kindno and its.itemstatusno = sheep.sheepstatusno; -- list.php, detail.php에서 사용할 양정보 뷰 ㅎ.ㅎ -- user 타입과 정보를 묶은 겁니당 주문과 계산 시 유용~.~ create view v_user as select u.userid, u.username, u.usernick, u.userage, u.userpoint, t.usertype, t.userpointrate from user u, usertype t where u.usertypeno = t.usertypeno;selec -- 구매목록에 사용할 구입양과 구입정보 -- objsheep, sheep, v_user create view v_shoppinglist as select l.shoppingno, l.shopperid, l.shoppedsheepno, l.shoppeddate, s.sheepname, s.sheepprice, s.sheepimg, s.sheepstar from sheep s, shoppinglist l where s.sheepno = l.shoppedsheepno;
true
5a82d4e6c19d0d03939d0d00db7a33dfcd5333cc
SQL
GreenBeee/demo-commerce-app
/src/main/resources/sql/schema.sql
UTF-8
1,298
3.59375
4
[]
no_license
CREATE DATABASE 'demoappdb'; CREATE TABLE 'categories' ( 'id' bigint NOT NULL, 'name' varchar(255) DEFAULT NULL, 'parent_id' bigint DEFAULT NULL, PRIMARY KEY ('id'), FOREIGN KEY ('parent_id') REFERENCES 'categories' ('id') ); CREATE TABLE 'product_categories' ( 'product_id' bigint NOT NULL, 'category_id' bigint NOT NULL, PRIMARY KEY ('product_id','category_id'), FOREIGN KEY ('category_id') REFERENCES 'categories' ('id'), FOREIGN KEY ('product_id') REFERENCES 'products' ('id') ); CREATE TABLE 'products' ( 'id' bigint NOT NULL, 'name' varchar(255) DEFAULT NULL, 'currency' varchar(255) DEFAULT NULL, 'price' double DEFAULT NULL, 'quantity' int DEFAULT NULL, PRIMARY KEY ('id') ); CREATE TABLE 'roles' ( 'id' int NOT NULL AUTO_INCREMENT, 'name' varchar(20) DEFAULT NULL, PRIMARY KEY ('id') ); CREATE TABLE 'user_roles' ( 'user_id' bigint NOT NULL, 'role_id' int NOT NULL, PRIMARY KEY ('user_id','role_id'), FOREIGN KEY ('role_id') REFERENCES 'roles' ('id'), FOREIGN KEY ('user_id') REFERENCES 'users' ('id') ); CREATE TABLE 'users' ( 'id' bigint NOT NULL AUTO_INCREMENT, 'password' varchar(255) DEFAULT NULL, 'username' varchar(255) DEFAULT NULL, PRIMARY KEY ('id') ); create sequence if not exists hibernate_sequence start with 100;
true
6f6db82e4037d4500b6e640cb50333e55f996f18
SQL
ZFGCCP/ZFGC3
/src/main/database/tables/PM_BACKUP_CODE.sql
UTF-8
406
2.78125
3
[ "MIT" ]
permissive
CREATE TABLE IF NOT EXISTS `PM_BACKUP_CODE` ( `PM_BACKUP_CODE_ID` int(11) NOT NULL AUTO_INCREMENT, `USERS_ID` int(11) NOT NULL, `ENCRYPTED_KEY_AES` varchar(32) NOT NULL, PRIMARY KEY (`PM_BACKUP_CODE_ID`), KEY `FK_PM_BACKUP_CODE_ID_USERS_ID` (`USERS_ID`), CONSTRAINT `FK_PM_BACKUP_CODE_ID_USERS_ID` FOREIGN KEY (`USERS_ID`) REFERENCES `users` (`USERS_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
true
0cf12c1922277e6738d7616bc661d4ec471a2a35
SQL
yiyixiaozhi/SimpleSessionBasedConversation
/doc/yiyixiaozhi.sql
UTF-8
5,048
3.34375
3
[ "Apache-2.0" ]
permissive
/* SQLyog Community Edition- MySQL GUI v8.03 MySQL - 5.7.9 : Database - yiyixiaozhi ********************************************************************* */ /*!40101 SET NAMES utf8 */; /*!40101 SET SQL_MODE=''*/; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; CREATE DATABASE /*!32312 IF NOT EXISTS*/`yiyixiaozhi` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `yiyixiaozhi`; /*Table structure for table `t_operation` */ DROP TABLE IF EXISTS `t_operation`; CREATE TABLE `t_operation` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', `operation` varchar(20) NOT NULL COMMENT '操作状态', `operation_help` varchar(150) DEFAULT NULL COMMENT '操作状态帮助', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8; /*Data for the table `t_operation` */ insert into `t_operation`(`id`,`operation`,`operation_help`) values (1,'新增商品','请输入要创建的商品,例如:\\n方便面'),(2,'删除商品','请输入要删除的商品编号,前面加d,例如:\\nd\\n1'),(3,'修改商品','请输入待修改的商品{商品编号+商品名称},例如:\\n1\\n方便面'),(4,'新增进货记录','请输入要新增的进货记录{商品编号+进货总价+进货数量+客户名称},例如:\\n1\\n10\\n10\\n张三'),(5,'删除进货记录','请输入要删除的进货记录编号,前面加d,例如:\\nd\\n1'),(6,'修改进货记录','请输入待修改的进货记录{进货记录编号+进货总价+进货数量+客户名称},例如:\\n1\\n10.5\\n10\\n张三'),(7,'新增销售记录','请输入待添加销售记录{商品编号+销售总价+销售数量+客户名称},例如:\\n1\\n10.5\\n10\\n张三'),(8,'删除销售记录','请输入要删除的销售记录编号,前面加d,例如:\\nd\\n1'),(9,'修改销售记录','请输入待修改的销售记录{销售记录编号+销售总价+销售数量+客户名称},例如:\\n1\\n10.5\\n10\\n张三'); /*Table structure for table `t_purchase` */ DROP TABLE IF EXISTS `t_purchase`; CREATE TABLE `t_purchase` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `purchase_time` datetime DEFAULT NULL COMMENT '进货时间', `purchase_price` decimal(10,2) NOT NULL COMMENT '进货价格', `purchase_num` int(11) NOT NULL COMMENT '进货数量', `client_name` varchar(20) NOT NULL COMMENT '客户名称', `shop_id` bigint(20) NOT NULL COMMENT '商品索引', `user_id` bigint(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `t_purchase` */ /*Table structure for table `t_sale` */ DROP TABLE IF EXISTS `t_sale`; CREATE TABLE `t_sale` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `sale_time` datetime DEFAULT NULL COMMENT '销售时间', `sale_price` decimal(10,2) NOT NULL COMMENT '销售价格', `sale_num` int(11) NOT NULL COMMENT '销售数量', `client_name` varchar(20) NOT NULL COMMENT '客户名称', `shop_id` bigint(20) NOT NULL COMMENT '商品索引', `user_id` bigint(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*Data for the table `t_sale` */ /*Table structure for table `t_shop` */ DROP TABLE IF EXISTS `t_shop`; CREATE TABLE `t_shop` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `name` varchar(50) NOT NULL COMMENT '商品名称', `user_id` bigint(20) NOT NULL COMMENT '商品创建者', `update_time` datetime DEFAULT NULL COMMENT '创建/修改时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `t_shop` */ /*Table structure for table `t_stock` */ DROP TABLE IF EXISTS `t_stock`; CREATE TABLE `t_stock` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `stock_time` datetime DEFAULT NULL COMMENT '更新时间', `stock_price` decimal(10,2) NOT NULL COMMENT '存货价格', `stock_num` int(11) NOT NULL COMMENT '存货数量', `shop_id` bigint(20) NOT NULL COMMENT '商品索引', `user_id` bigint(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `t_stock` */ /*Table structure for table `t_user` */ DROP TABLE IF EXISTS `t_user`; CREATE TABLE `t_user` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `username` varchar(20) DEFAULT NULL COMMENT '用户名', `mobile` varchar(20) DEFAULT NULL COMMENT '手机号', `openid` varchar(50) NOT NULL COMMENT '微信openId', `nickname` varchar(20) DEFAULT NULL COMMENT '用户昵称', `password` varchar(50) DEFAULT NULL COMMENT '密码', `operation_id` int(11) NOT NULL DEFAULT '1' COMMENT '操作状态索引', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `t_user` */ /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
true
ed2dc210b9d2d2dd765ff769c3b6ba821acac24f
SQL
UKHomeOffice/hocs-info-service
/src/main/resources/db/postgresql/V1_24__CREATE_TABLE_CASE_DETAIL_FIELD.sql
UTF-8
517
3.53125
4
[ "MIT", "OGL-UK-3.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
DROP TABLE IF EXISTS case_details_field; CREATE TABLE IF NOT EXISTS case_details_field ( id BIGSERIAL PRIMARY KEY, case_type VARCHAR(25) NOT NULL, name TEXT NOT NULL, component TEXT NOT NULL, props JSONB DEFAULT '{}', CONSTRAINT case_details_field_name_case_type_idempotent UNIQUE (name, case_type), CONSTRAINT fk_case_details_field_case_type FOREIGN KEY (case_type) REFERENCES case_type (type) ); CREATE INDEX idx_case_details_field_name_case_type ON case_details_field(name, case_type);
true
8069536fc09ee1cc1531d942bdff459c5ba3cf3c
SQL
x1987624/SNS
/Web/Applications/CMS/Setup/Install/MySql/01_Install_CMS_Schema.sql
UTF-8
5,660
2.859375
3
[]
no_license
DROP TABLE IF EXISTS `spb_cms_Addon_Links`; CREATE TABLE `spb_cms_Addon_Links` ( ContentItemId Int(11) NOT NULL, Color Varchar(16) NOT NULL, IsBold TinyInt NOT NULL, LinkUrl Varchar(512) NOT NULL, PRIMARY KEY (`ContentItemId`) )ENGINE=innodb DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `spb_cms_Addon_News`; CREATE TABLE `spb_cms_Addon_News` ( ContentItemId BigInt NOT NULL, TrimBodyAsSummary TinyInt NOT NULL, Body mediumtext NOT NULL, CopyFrom Varchar(255) NOT NULL, CopyFromUrl Varchar(512) NOT NULL, EnableComment TinyInt NOT NULL, OriginalAuthor Varchar(64) NOT NULL, Editor Varchar(64) NOT NULL, Color Varchar(16) NOT NULL, IsBold TinyInt NOT NULL, FirstAsTitleImage TinyInt NOT NULL, AutoPage TinyInt NOT NULL, PageLength Int(11) NOT NULL, PRIMARY KEY (`ContentItemId`) )ENGINE=innodb DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `spb_cms_ContentAttachments`; CREATE TABLE `spb_cms_ContentAttachments` ( AttachmentId BigInt NOT NULL AUTO_INCREMENT, UserId BigInt NOT NULL, UserDisplayName Varchar(64) NOT NULL, `FileName` Varchar(255) NOT NULL DEFAULT '', FriendlyFileName Varchar(255) NOT NULL DEFAULT '', MediaType Int(11) NOT NULL DEFAULT 99, ContentType Varchar(128) NOT NULL DEFAULT '', FileLength BigInt NOT NULL DEFAULT 0, Height Int(11) NOT NULL DEFAULT 0, Width Int(11) NOT NULL, Price Int(11) NOT NULL DEFAULT 0, `Password` Varchar(32) NOT NULL DEFAULT '', IP Varchar(64) NOT NULL, DateCreated DateTime NOT NULL, PropertyNames mediumtext DEFAULT NULL, PropertyValues mediumtext DEFAULT NULL, KEY `IX_MediaType` (`MediaType`), KEY `IX_UserId` (`UserId`), PRIMARY KEY (`AttachmentId`) )ENGINE=innodb DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `spb_cms_ContentFolderModerators`; CREATE TABLE `spb_cms_ContentFolderModerators` ( Id Int(11) NOT NULL AUTO_INCREMENT, ContentFolderId Int(11) NOT NULL, UserId BigInt NOT NULL, PRIMARY KEY (`Id`) )ENGINE=innodb DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `spb_cms_ContentFolders`; CREATE TABLE `spb_cms_ContentFolders` ( ContentFolderId Int(11) NOT NULL AUTO_INCREMENT, FolderName Varchar(255) NOT NULL, `Description` Varchar(2000) NOT NULL, ParentId Int(11) NOT NULL, ParentIdList Varchar(255) NOT NULL, ChildCount Int(11) NOT NULL, Depth Int(11) NOT NULL, IsEnabled TinyInt NOT NULL, ContentItemCount Int(11) NOT NULL, DateCreated DateTime NOT NULL, ContentTypeKeys Varchar(255) NOT NULL, DisplayOrder Int(11) NOT NULL, EnableContribute TinyInt NOT NULL, IsAsNavigation TinyInt NOT NULL, NeedAuditing TinyInt NOT NULL, IsLink TinyInt NOT NULL, LinkUrl Varchar(255) NOT NULL, IsLinkToNewWindow TinyInt NOT NULL, Page_List Varchar(128) NOT NULL, Page_Detail Varchar(128) NOT NULL, ExtensionField mediumtext DEFAULT NULL, PropertyNames mediumtext DEFAULT NULL, PropertyValues mediumtext DEFAULT NULL, PRIMARY KEY (`ContentFolderId`) )ENGINE=innodb DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `spb_cms_ContentItems`; CREATE TABLE `spb_cms_ContentItems` ( ContentItemId BigInt NOT NULL AUTO_INCREMENT, ContentFolderId Int(11) NOT NULL, ContentTypeId Int(11) NOT NULL, Title Varchar(255) NOT NULL, FeaturedImageAttachmentId BigInt DEFAULT NULL, FeaturedImage Varchar(255) DEFAULT NULL, UserId BigInt NOT NULL, Author Varchar(64) NOT NULL, Summary Varchar(512) NOT NULL, IsContributed TinyInt NOT NULL, IsEssential TinyInt NOT NULL, IsGlobalSticky TinyInt NOT NULL, GlobalStickyDate DateTime NOT NULL, IsFolderSticky TinyInt NOT NULL, FolderStickyDate DateTime NOT NULL, IsLocked TinyInt NOT NULL, AuditStatus SmallInt NOT NULL, IP Varchar(64) NOT NULL, ReleaseDate DateTime NOT NULL, DateCreated DateTime NOT NULL, LastModified DateTime NOT NULL, DisplayOrder BigInt NOT NULL, PropertyNames mediumtext DEFAULT NULL, PropertyValues mediumtext DEFAULT NULL, PRIMARY KEY (`ContentItemId`) )ENGINE=innodb DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `spb_cms_ContentTypeColumnDefinitions`; CREATE TABLE `spb_cms_ContentTypeColumnDefinitions` ( ColumnId Int(11) NOT NULL AUTO_INCREMENT, ContentTypeId Int(11) NOT NULL, ColumnName Varchar(64) NOT NULL, ColumnLabel Varchar(128) NOT NULL, IsBuiltIn TinyInt NOT NULL, DataType Varchar(64) NOT NULL, `Length` Int(11) NOT NULL, `Precision` Varchar(64) NOT NULL, IsNotNull TinyInt NOT NULL, DefaultValue Varchar(64) NOT NULL, IsIndex TinyInt NOT NULL, IsUnique TinyInt NOT NULL, KeyOrIndexName Varchar(64) NOT NULL, KeyOrIndexColumns Varchar(255) NOT NULL, ControlCode Varchar(64) NOT NULL, InitialValue Varchar(20) NOT NULL, EnableInput TinyInt NOT NULL, EnableEdit TinyInt NOT NULL, ValidateRole Varchar(64) DEFAULT NULL, PRIMARY KEY (`ColumnId`) )ENGINE=innodb DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `spb_cms_ContentTypeDefinitions`; CREATE TABLE `spb_cms_ContentTypeDefinitions` ( ContentTypeId Int(11) NOT NULL AUTO_INCREMENT, ContentTypeName Varchar(64) NOT NULL, ContentTypeKey Varchar(64) NOT NULL, IsBuiltIn TinyInt NOT NULL, DisplayOrder Int(11) NOT NULL, TableName Varchar(64) NOT NULL, ForeignKey Varchar(64) NOT NULL, Page_New Varchar(128) NOT NULL, Page_Edit Varchar(128) NOT NULL, Page_Manage Varchar(128) NOT NULL, Page_Default_List Varchar(128) NOT NULL, Page_Default_Detail Varchar(128) NOT NULL, IsEnabled TinyInt NOT NULL, EnableContribute TinyInt NOT NULL, EnableComment TinyInt NOT NULL, EnableAttachment TinyInt NOT NULL, AllowContributeRoleNames Varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (`ContentTypeId`) )ENGINE=innodb DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `spb_cms_FormControlDefinitions`; CREATE TABLE `spb_cms_FormControlDefinitions` ( ControlCode Varchar(64) NOT NULL, ControlName Varchar(64) NOT NULL, `Description` Varchar(255) DEFAULT NULL, PRIMARY KEY (`ControlCode`) )ENGINE=innodb DEFAULT CHARSET=utf8;
true
94bd0425a63521adaf60e8be83bb0453685168de
SQL
Crimsonfoxy/Statistician-v2
/src/main/resources/SQLPatches/stats_v3.sql
UTF-8
1,424
2.796875
3
[]
no_license
/* * Forgot to add default values for all new bigints */ -- ------------------------ -- Fixes for `blocks` table -- ------------------------ ALTER TABLE `blocks` CHANGE `num_destroyed` `num_destroyed` BIGINT UNSIGNED DEFAULT '0' NOT NULL; ALTER TABLE `blocks` CHANGE `num_placed` `num_placed` BIGINT UNSIGNED DEFAULT '0' NOT NULL; -- ------------------------ -- Fixes for `pickup_drop` table -- ------------------------ ALTER TABLE `pickup_drop` CHANGE `num_pickedup` `num_pickedup` BIGINT UNSIGNED DEFAULT '0' NOT NULL; ALTER TABLE `pickup_drop` CHANGE `num_dropped` `num_dropped` BIGINT UNSIGNED DEFAULT '0' NOT NULL; -- ------------------------ -- Fixes for `players` table -- ------------------------ ALTER TABLE `players` CHANGE `num_secs_loggedon` `num_secs_loggedon` BIGINT UNSIGNED DEFAULT '0' NOT NULL; ALTER TABLE `players` CHANGE `distance_traveled` `distance_traveled` BIGINT UNSIGNED DEFAULT '0' NOT NULL; ALTER TABLE `players` CHANGE `distance_traveled_in_minecart` `distance_traveled_in_minecart` BIGINT UNSIGNED DEFAULT '0' NOT NULL; ALTER TABLE `players` CHANGE `distance_traveled_in_boat` `distance_traveled_in_boat` BIGINT UNSIGNED DEFAULT '0' NOT NULL; ALTER TABLE `players` CHANGE `distance_traveled_on_pig` `distance_traveled_on_pig` BIGINT UNSIGNED DEFAULT '0' NOT NULL; -- --------------------------- -- Update DBVersion To 3 -- -------------------------- UPDATE `config` SET `dbVersion` = 3;
true
bfc6829082f71156e2f5dfc9fbd761136f92cfe5
SQL
Nina-Hgh/HackerRank
/SQL/Basic/01-Revising the Select Query I.sql
UTF-8
145
2.59375
3
[]
no_license
/* "*" means all of the columns WHERE is used for adding condition*/ SELECT * FROM CITY WHERE COUNTRYCODE ="USA" AND POPULATION > 100000;
true
0c1b0fc3ac57368b60ef042811d233c2ab8e34bd
SQL
lucaburatti7/A00-Training-plan
/Mainframe Training/HISOFT/Hisoft Training/cobol_serve/SQL文/D342CHS_TBL.Sql
SHIFT_JIS
3,005
3.03125
3
[]
no_license
DROP TABLE D342CHS_TBL ; CREATE TABLE D342CHS_TBL ( _ԍ CHAR(10) NOT NULL, ă[X NUMBER(2,0) NOT NULL, Ǘ CHAR(1) NOT NULL, \A NUMBER(2,0) NOT NULL, ގ CHAR(3) NOT NULL, R[h CHAR(9) NOT NULL, xR[h CHAR(5) NOT NULL, ޘA NUMBER(3,0) NOT NULL, x˗`FbN CHAR(1) NOT NULL, 擾N CHAR(8) NOT NULL, ގ擾σtO CHAR(1) NOT NULL, A NUMBER(2,0) NOT NULL, Rg VARCHAR2(80) NOT NULL, ލ쐬敪 CHAR(1) NOT NULL, σtO CHAR(1) NOT NULL, XVN CHAR(8) NOT NULL, XV CHAR(8) NOT NULL, XV CHAR(8) NOT NULL, ͒S҃R[h CHAR(8) NOT NULL, ԍ CHAR(15) NOT NULL, t CHAR(8) NOT NULL, CHAR(8) NOT NULL, x\ CHAR(8) NOT NULL, ޓo^ CHAR(8) NOT NULL, _o^`FbN CHAR(1) NOT NULL, o^`FbN CHAR(1) NOT NULL, X_ CHAR(8) NOT NULL, X_ CHAR(8) NOT NULL, ~hItBX_ CHAR(8) NOT NULL, ~hItBX_ CHAR(8) NOT NULL, Ǘ̓ CHAR(8) NOT NULL, Ǘ̎ CHAR(8) NOT NULL, tO CHAR(1) NOT NULL, o^N CHAR(8) NOT NULL, o^ CHAR(8) NOT NULL, o^S CHAR(8) NOT NULL, CONSTRAINT PK_D342CHS_TBL PRIMARY KEY ( _ԍ, ă[X, Ǘ, \A, ގ, R[h, xR[h));
true
b8ef08625dc999a43f19e370bce9c074b466b6ef
SQL
wdpimenta/oracle
/Distribui_Regioes/Procedure/ATU_CAR_P_AREA_TOTAL.prc
ISO-8859-1
12,153
3.515625
4
[]
no_license
CREATE OR REPLACE PROCEDURE TOTALPRD.ATU_CAR_P_AREA_TOTAL (P_CODUSU NUMBER, -- Cdigo do usurio logado P_IDSESSAO VARCHAR2, -- Identificador da execuo. Serve para buscar informaes dos parmetros/campos da execuo. P_QTDLINHAS NUMBER, -- Informa a quantidade de registros selecionados no momento da execuo. P_MENSAGEM OUT VARCHAR2 -- Caso seja passada uma mensagem aqui, ela ser exibida como uma informao ao usurio. )AS VPROSPECT INT := 0; VPARCEIRO INT := 0; BEGIN /* DESCRIO:1. AUTOR: Mauricio Rodrigues ATUALIZAO: Mauricio Rodrigues Data da criao: 28/11/2017 */ --1. Loop para executar cada regra pelo seu indice (CODREGPERFIL). EXECUTE IMMEDIATE 'ALTER TRIGGER TRG_UPD_TGFPAR_TOTAL DISABLE'; FOR CUR_CUS IN (SELECT REG.CODREG , REG.NOMEREG , REG.CODREGPAI , NVL(REG.AD_ATIVAPARCEIRO, 'N') AS AD_ATIVAPARCEIRO , NVL(REG.AD_ATIVAPROSPECT, 'N') AS AD_ATIVAPROSPECT , (SELECT USU.CODGRUPO FROM TSIUSU USU WHERE REG.AD_GERENTE = USU.CODUSU) AS GRUPO FROM TSIREG REG WHERE REG.CODREGPAI LIKE '2%' AND REG.ANALITICA = 'S' AND REG.ATIVA = 'S' AND (SELECT USU.CODGRUPO FROM TSIUSU USU WHERE REG.AD_GERENTE = USU.CODUSU) IN (11,12,34) --11 = Distribuio --12 = Automao --13 = Suporte ORDER BY 1) LOOP IF CUR_CUS.AD_ATIVAPARCEIRO = 'S' THEN VPARCEIRO := 1; ELSE VPARCEIRO := 0; END IF; IF CUR_CUS.AD_ATIVAPROSPECT = 'S' THEN VPROSPECT := 1; ELSE VPROSPECT := 0; END IF; IF CUR_CUS.GRUPO = 11 THEN FOR CUR2 IN (SELECT AREA.CODREG, AREA.CODBAI, AREA.CODCID, (SELECT CID.UF FROM TSICID CID WHERE AREA.CODCID=CID.CODCID) AS UF FROM AD_AREAS AREA WHERE (SELECT REG.ATIVA FROM TSIREG REG WHERE AREA.CODREG = REG.CODREG) = 'S' AND AREA.CODREG = CUR_CUS.CODREG ORDER BY 1,2) LOOP -----------------------SEM BAIRRO IF CUR2.CODBAI IS NULL THEN -------------------SE FOR PROSPECT IF VPROSPECT = 1 THEN UPDATE TCSPAP PAP SET PAP.AD_REGIAODISTRIBUICAO = CUR2.CODREG WHERE (SELECT MAX(CID.CODCID) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.UF; COMMIT; END IF; -------------------SE FOR PARCEIRO IF VPARCEIRO = 1 THEN UPDATE TGFPAR PARC SET PARC.AD_REGIAODISTRIBUICAO = CUR2.CODREG WHERE PARC.CODCID = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.CODCID=PARC.CODCID) = CUR2.UF; COMMIT; END IF; ELSE-------------------COM BAIRRO -------------------SE FOR PROSPECT IF VPROSPECT = 1 THEN UPDATE TCSPAP PAP SET PAP.AD_REGIAODISTRIBUICAO = CUR2.CODREG WHERE (SELECT MAX(CID.CODCID) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.UF AND PAP.AD_CODBAI = CUR2.CODBAI; COMMIT; END IF; -------------------SE FOR PARCEIRO IF VPARCEIRO = 1 THEN UPDATE TGFPAR PARC SET PARC.AD_REGIAODISTRIBUICAO = CUR2.CODREG WHERE PARC.CODCID = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.CODCID=PARC.CODCID) = CUR2.UF AND PARC.CODBAI = CUR2.CODBAI; COMMIT; END IF; END IF; --P_MENSAGEM := ('<font size="12">Prospect ativo!</font>'); END LOOP; END IF; IF CUR_CUS.GRUPO = 12 THEN FOR CUR2 IN (SELECT AREA.CODREG, AREA.CODBAI, AREA.CODCID, (SELECT CID.UF FROM TSICID CID WHERE AREA.CODCID=CID.CODCID) AS UF FROM AD_AREAS AREA WHERE (SELECT REG.ATIVA FROM TSIREG REG WHERE AREA.CODREG = REG.CODREG) = 'S' AND AREA.CODREG = CUR_CUS.CODREG ORDER BY 1,2) LOOP -----------------------SEM BAIRRO IF CUR2.CODBAI IS NULL THEN -------------------SE FOR PROSPECT IF VPROSPECT = 1 THEN UPDATE TCSPAP PAP SET PAP.AD_REGIAOAUTOMACAO = CUR2.CODREG WHERE (SELECT MAX(CID.CODCID) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.UF; COMMIT; END IF; -------------------SE FOR PARCEIRO IF VPARCEIRO = 1 THEN UPDATE TGFPAR PARC SET PARC.AD_REGIAOAUTOMACAO = CUR2.CODREG WHERE PARC.CODCID = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.CODCID=PARC.CODCID) = CUR2.UF; COMMIT; END IF; ELSE-------------------COM BAIRRO -------------------SE FOR PROSPECT IF VPROSPECT = 1 THEN UPDATE TCSPAP PAP SET PAP.AD_REGIAOAUTOMACAO = CUR2.CODREG WHERE (SELECT MAX(CID.CODCID) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.UF AND PAP.AD_CODBAI = CUR2.CODBAI; COMMIT; END IF; -------------------SE FOR PARCEIRO IF VPARCEIRO = 1 THEN UPDATE TGFPAR PARC SET PARC.AD_REGIAOAUTOMACAO = CUR2.CODREG WHERE PARC.CODCID = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.CODCID=PARC.CODCID) = CUR2.UF AND PARC.CODBAI = CUR2.CODBAI; COMMIT; END IF; END IF; END LOOP; END IF; IF CUR_CUS.GRUPO = 34 THEN FOR CUR2 IN (SELECT AREA.CODREG, AREA.CODBAI, AREA.CODCID, (SELECT CID.UF FROM TSICID CID WHERE AREA.CODCID=CID.CODCID) AS UF FROM AD_AREAS AREA WHERE (SELECT REG.ATIVA FROM TSIREG REG WHERE AREA.CODREG = REG.CODREG) = 'S' AND AREA.CODREG = CUR_CUS.CODREG ORDER BY 1,2) LOOP -----------------------SEM BAIRRO IF CUR2.CODBAI IS NULL THEN -------------------SE FOR PROSPECT IF VPROSPECT = 1 THEN UPDATE TCSPAP PAP SET PAP.AD_REGIAOSUPORTE = CUR2.CODREG WHERE (SELECT MAX(CID.CODCID) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.UF; COMMIT; END IF; -------------------SE FOR PARCEIRO IF VPARCEIRO = 1 THEN UPDATE TGFPAR PARC SET PARC.AD_REGIAOSUPORTE = CUR2.CODREG WHERE PARC.CODCID = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.CODCID=PARC.CODCID) = CUR2.UF; COMMIT; END IF; ELSE-------------------COM BAIRRO -------------------SE FOR PROSPECT IF VPROSPECT = 1 THEN UPDATE TCSPAP PAP SET PAP.AD_REGIAOSUPORTE = CUR2.CODREG WHERE (SELECT MAX(CID.CODCID) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.NOMECID = PAP.NOMECID) = CUR2.UF AND PAP.AD_CODBAI = CUR2.CODBAI; COMMIT; END IF; -------------------SE FOR PARCEIRO IF VPARCEIRO = 1 THEN UPDATE TGFPAR PARC SET PARC.AD_REGIAOSUPORTE = CUR2.CODREG WHERE PARC.CODCID = CUR2.CODCID AND (SELECT MAX(CID.UF) FROM TSICID CID WHERE CID.CODCID=PARC.CODCID) = CUR2.UF AND PARC.CODBAI = CUR2.CODBAI; COMMIT; END IF; END IF; --P_MENSAGEM := ('<font size="12">Prospect ativo!</font>'); END LOOP; END IF; END LOOP; EXECUTE IMMEDIATE 'ALTER TRIGGER TRG_UPD_TGFPAR_TOTAL ENABLE'; P_MENSAGEM := ('<span class="spans"><b>Atualizao das Regies finalizada!</b></span>'); END; /
true
a2b7ffd632a5a1528b6fa8a48e82b3fd5227c347
SQL
Git-Good-Milo/Week-2-SQL-Homework
/SQLQuery2.sql
UTF-8
136
2.6875
3
[]
no_license
USE Northwind -- Q1 How many orders in NWDD? SELECT COUNT(OrderID) AS 'Number Of Orders' FROM Orders; -- A1 Number of Orders is = 830
true
d5685e23b510e33b01e4c7c9bb5fe68c3d1e060b
SQL
Sma110ran9e/MicroServiceExamSystem
/exam_system.sql
UTF-8
22,335
3.3125
3
[]
no_license
/* Navicat Premium Data Transfer Source Server : user Source Server Type : MySQL Source Server Version : 50644 Source Host : localhost:3306 Source Schema : exam_system Target Server Type : MySQL Target Server Version : 50644 File Encoding : 65001 Date: 30/06/2020 14:03:36 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for exam -- ---------------------------- DROP TABLE IF EXISTS `exam`; CREATE TABLE `exam` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userId` int(11) DEFAULT NULL, `userName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '出卷人姓名', `examName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `examType` int(255) DEFAULT NULL COMMENT '试卷类型', `time` datetime(0) DEFAULT NULL COMMENT '考试截止时间', `oneId` int(11) DEFAULT NULL, `twoId` int(11) DEFAULT NULL, `threeId` int(11) DEFAULT NULL, `fourId` int(11) DEFAULT NULL, `fiveId` int(11) DEFAULT NULL, `sixId` int(11) DEFAULT NULL, `sevenId` int(11) DEFAULT NULL, `eightId` int(11) DEFAULT NULL, `nineId` int(11) DEFAULT NULL, `tenId` int(11) DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of exam -- ---------------------------- INSERT INTO `exam` VALUES (1, 5, 'wjf', '数据结构在线测试(四)', 1, '2020-06-22 20:00:00', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); INSERT INTO `exam` VALUES (2, 5, 'mwf', '软工导论在线测试(一)', 3, '2020-06-15 19:00:00', 2, 4, 6, 7, 8, 9, 10, 16, 17, 20); INSERT INTO `exam` VALUES (3, 5, 'wjf', '操作系统在线测试(二)', 2, '2020-06-25 18:00:00', 12, 13, 14, 15, 21, 22, 23, 24, 25, 26); INSERT INTO `exam` VALUES (4, 5, 'xc', '分布式期末考试', 4, '2020-06-15 14:00:00', 2, 3, 4, 5, 7, 8, 9, 10, 17, 20); INSERT INTO `exam` VALUES (5, 5, 'wjf', '操作系统期末考试', 2, '2020-07-17 20:49:09', 11, 12, 13, 15, 21, 22, 23, 24, 25, 26); INSERT INTO `exam` VALUES (6, 5, 'mwf', 'q', 1, '2020-07-05 02:06:10', 1, 2, 3, 4, 7, 8, 9, 10, 16, 17); INSERT INTO `exam` VALUES (7, 6, 'mwf', 'q', 2, '2020-07-05 02:08:14', 11, 12, 13, 14, 15, 21, 22, 23, 24, 25); INSERT INTO `exam` VALUES (8, 6, 'mwf', '1', 2, '2020-07-05 02:08:54', 11, 12, 13, 14, 15, 21, 22, 23, 24, 25); -- ---------------------------- -- Table structure for examreport -- ---------------------------- DROP TABLE IF EXISTS `examreport`; CREATE TABLE `examreport` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userId` int(11) DEFAULT NULL COMMENT '考生ID', `examName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '考试名称', `one` int(11) DEFAULT NULL COMMENT '1-10表示每题的对错', `two` int(11) DEFAULT NULL, `three` int(11) DEFAULT NULL, `four` int(11) DEFAULT NULL, `five` int(11) DEFAULT NULL, `six` int(11) DEFAULT NULL, `seven` int(11) DEFAULT NULL, `eight` int(11) DEFAULT NULL, `nine` int(11) DEFAULT NULL, `ten` int(11) DEFAULT NULL, `grade` int(11) DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 65 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of examreport -- ---------------------------- INSERT INTO `examreport` VALUES (1, 4, '操作系统期末考试', 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 50); INSERT INTO `examreport` VALUES (2, 2, '操作系统期末考试', 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 30); INSERT INTO `examreport` VALUES (3, 3, '操作系统期末考试', 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 50); INSERT INTO `examreport` VALUES (4, 3, '操作系统期末考试', 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 40); INSERT INTO `examreport` VALUES (5, 2, '操作系统期末考试', 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 40); INSERT INTO `examreport` VALUES (6, 3, '操作系统期末考试', 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 50); INSERT INTO `examreport` VALUES (7, 4, '操作系统期末考试', 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 60); INSERT INTO `examreport` VALUES (8, 5, '操作系统期末考试', 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 90); INSERT INTO `examreport` VALUES (9, 13, '操作系统期末考试', 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 60); INSERT INTO `examreport` VALUES (10, 7, '操作系统期末考试', 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 60); INSERT INTO `examreport` VALUES (11, 8, '操作系统期末考试', 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 10); INSERT INTO `examreport` VALUES (12, 9, '操作系统期末考试', 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 80); INSERT INTO `examreport` VALUES (13, 10, '操作系统期末考试', 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 60); INSERT INTO `examreport` VALUES (14, 11, '操作系统期末考试', 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 40); INSERT INTO `examreport` VALUES (15, 12, '操作系统期末考试', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100); INSERT INTO `examreport` VALUES (16, 2, '数据结构在线测试(四)', 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 50); INSERT INTO `examreport` VALUES (17, 3, '数据结构在线测试(四)', 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 50); INSERT INTO `examreport` VALUES (18, 4, '数据结构在线测试(四)', 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 40); INSERT INTO `examreport` VALUES (19, 5, '数据结构在线测试(四)', 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 80); INSERT INTO `examreport` VALUES (20, 7, '数据结构在线测试(四)', 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 70); INSERT INTO `examreport` VALUES (21, 2, '操作系统在线测试(二)', 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 50); INSERT INTO `examreport` VALUES (22, 2, '操作系统在线测试(二)', 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 40); INSERT INTO `examreport` VALUES (23, 2, '操作系统在线测试(二)', 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 30); INSERT INTO `examreport` VALUES (24, 2, '操作系统在线测试(二)', 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 10); INSERT INTO `examreport` VALUES (25, 2, '操作系统在线测试(二)', 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 20); INSERT INTO `examreport` VALUES (26, 2, '操作系统在线测试(二)', 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 50); INSERT INTO `examreport` VALUES (27, 2, '操作系统期末考试', 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 30); INSERT INTO `examreport` VALUES (28, 2, '数据结构在线测试(四)', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); INSERT INTO `examreport` VALUES (29, 2, '操作系统期末考试', 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 40); INSERT INTO `examreport` VALUES (30, 2, '数据结构在线测试(四)', 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 40); INSERT INTO `examreport` VALUES (31, 2, '操作系统期末考试', 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 50); INSERT INTO `examreport` VALUES (32, 2, '操作系统期末考试', 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 20); INSERT INTO `examreport` VALUES (33, 3, '操作系统期末考试', 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 30); INSERT INTO `examreport` VALUES (34, 2, '操作系统期末考试', 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 30); INSERT INTO `examreport` VALUES (35, 2, '操作系统期末考试', 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 20); INSERT INTO `examreport` VALUES (36, 2, '操作系统期末考试', 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 40); INSERT INTO `examreport` VALUES (37, 3, '操作系统期末考试', 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 10); INSERT INTO `examreport` VALUES (38, 2, '数据结构在线测试(四)', 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 40); INSERT INTO `examreport` VALUES (39, 2, '操作系统期末考试', 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 10); INSERT INTO `examreport` VALUES (40, 3, '数据结构在线测试(四)', 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 30); INSERT INTO `examreport` VALUES (41, 2, '操作系统期末考试', 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 50); INSERT INTO `examreport` VALUES (42, 2, '操作系统期末考试', 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 30); INSERT INTO `examreport` VALUES (43, 2, '数据结构在线测试(四)', 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 40); INSERT INTO `examreport` VALUES (47, 2, '分布式期末考试', 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 20); INSERT INTO `examreport` VALUES (48, 2, '数据结构在线测试(四)', 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 60); INSERT INTO `examreport` VALUES (50, 2, '软工导论在线测试(一)', 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 30); INSERT INTO `examreport` VALUES (51, 2, '软工导论在线测试(一)', 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 30); INSERT INTO `examreport` VALUES (52, 2, '操作系统在线测试(二)', 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 30); INSERT INTO `examreport` VALUES (53, 2, '软工导论在线测试(一)', 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 10); INSERT INTO `examreport` VALUES (57, 2, '数据结构在线测试(四)', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); INSERT INTO `examreport` VALUES (58, 2, '数据结构在线测试(四)', 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 30); INSERT INTO `examreport` VALUES (59, 2, '数据结构在线测试(四)', 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 40); INSERT INTO `examreport` VALUES (60, 2, '数据结构在线测试(四)', 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 40); INSERT INTO `examreport` VALUES (61, 2, 'OS', 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 20); INSERT INTO `examreport` VALUES (62, 2, 'OS', 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 30); INSERT INTO `examreport` VALUES (63, 2, '操作系统期末考试', 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 20); INSERT INTO `examreport` VALUES (64, 2, '操作系统期末考试', 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 20); -- ---------------------------- -- Table structure for practicereport -- ---------------------------- DROP TABLE IF EXISTS `practicereport`; CREATE TABLE `practicereport` ( `id` int(10) NOT NULL AUTO_INCREMENT, `userid` int(10) DEFAULT NULL COMMENT '对应用户id', `one` int(2) DEFAULT NULL COMMENT '1-10题每题对错', `two` int(2) DEFAULT NULL, `three` int(2) DEFAULT NULL, `four` int(2) DEFAULT NULL, `five` int(2) DEFAULT NULL, `six` int(2) DEFAULT NULL, `seven` int(2) DEFAULT NULL, `eight` int(2) DEFAULT NULL, `nine` int(2) DEFAULT NULL, `ten` int(2) DEFAULT NULL, `grade` int(3) DEFAULT NULL COMMENT '最后得分', PRIMARY KEY (`id`) USING BTREE, INDEX `userid`(`userid`) USING BTREE, CONSTRAINT `practicereport_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT ) ENGINE = InnoDB AUTO_INCREMENT = 37 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of practicereport -- ---------------------------- INSERT INTO `practicereport` VALUES (1, 2, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 50); INSERT INTO `practicereport` VALUES (2, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 20); INSERT INTO `practicereport` VALUES (3, 2, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 40); INSERT INTO `practicereport` VALUES (4, 2, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 30); INSERT INTO `practicereport` VALUES (5, 2, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 50); INSERT INTO `practicereport` VALUES (7, 2, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 60); INSERT INTO `practicereport` VALUES (8, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 90); INSERT INTO `practicereport` VALUES (9, 3, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 70); INSERT INTO `practicereport` VALUES (10, 2, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 30); INSERT INTO `practicereport` VALUES (11, 2, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 40); INSERT INTO `practicereport` VALUES (12, 2, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 70); INSERT INTO `practicereport` VALUES (13, 2, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 40); INSERT INTO `practicereport` VALUES (14, 2, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 30); INSERT INTO `practicereport` VALUES (15, 2, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 30); INSERT INTO `practicereport` VALUES (16, 2, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 50); INSERT INTO `practicereport` VALUES (17, 3, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 30); INSERT INTO `practicereport` VALUES (18, 3, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 20); INSERT INTO `practicereport` VALUES (19, 3, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 40); INSERT INTO `practicereport` VALUES (21, 3, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 40); INSERT INTO `practicereport` VALUES (22, 2, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 30); INSERT INTO `practicereport` VALUES (23, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 20); INSERT INTO `practicereport` VALUES (24, 2, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 30); INSERT INTO `practicereport` VALUES (25, 2, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 40); INSERT INTO `practicereport` VALUES (30, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 20); INSERT INTO `practicereport` VALUES (31, 2, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 40); INSERT INTO `practicereport` VALUES (32, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); INSERT INTO `practicereport` VALUES (33, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 10); INSERT INTO `practicereport` VALUES (34, 2, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 30); INSERT INTO `practicereport` VALUES (35, 2, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 40); INSERT INTO `practicereport` VALUES (36, 2, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 30); -- ---------------------------- -- Table structure for testquestion -- ---------------------------- DROP TABLE IF EXISTS `testquestion`; CREATE TABLE `testquestion` ( `id` int(11) NOT NULL AUTO_INCREMENT, `qDescrip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '题目描述', `optionA` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'A选项答案', `optionB` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'B选项答案', `optionC` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'C选项答案', `optionD` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'D选项答案', `answer` int(255) DEFAULT NULL COMMENT '正确答案', `type` int(255) DEFAULT NULL COMMENT '题目类型', PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of testquestion -- ---------------------------- INSERT INTO `testquestion` VALUES (1, '对一组包含10个元素的非递减有序序列,采用直接插入排序排成非递增序列,其可能的比较次数和移动次数分别是:', '100, 100', '100, 54', '54, 63', '45, 44', 4, 1); INSERT INTO `testquestion` VALUES (2, '对于序列{ 49,38,65,97,76,13,27,50 },按由小到大进行排序,下面哪一个是初始步长为4的希尔排序法第一趟的结果?', '13,27,38,49,50,65,76,97', '49,13,27,50,76,38,65,97', '49,76,65,13,27,50,97,38', '97,76,65,50,49,38,27,13', 2, 1); INSERT INTO `testquestion` VALUES (3, '设主串的长度为n,模式串的长度为m,则串匹配的KMP算法时间复杂度是( )。', 'O(m)', 'O(n)', 'O(n + m)', 'O(n×m)', 3, 1); INSERT INTO `testquestion` VALUES (4, '串 ‘ababaaababaa’ 的next数组为:', '012345678999', '012121111212', '011234223456', '0123012322345', 3, 1); INSERT INTO `testquestion` VALUES (5, '若一棵二叉树的后序遍历序列是{ 1, 3, 2, 6, 5, 7, 4 },中序遍历序列是{ 1, 2, 3, 4, 5, 6, 7 },则下列哪句是错的?', '这是一棵完全二叉树', '2是1和3的父结点', '这是一棵二叉搜索树', '7是5的父结点', 1, 1); INSERT INTO `testquestion` VALUES (6, '对二叉搜索树进行什么遍历可以得到从小到大的排序序列?', '前序遍历', '后序遍历', '中序遍历', '层次遍历', 3, 1); INSERT INTO `testquestion` VALUES (7, '若二叉搜索树是有N个结点的完全二叉树,则不正确的说法是:', '平均查找效率是O(logN)', '最大值一定在最后一层', '最小值一定在叶结点上', '中位值结点在根结点或根的左子树上', 2, 1); INSERT INTO `testquestion` VALUES (8, '下列叙述正确的是()', '在任意一棵非空二叉搜索树,删除某结点后又将其插入,则所得二叉搜索树与删除前原二叉搜索树相同。', '二叉树中除叶结点外, 任一结点X,其左子树根结点的值小于该结点(X)的值;其右子树根结点的值≥该结点(X)的值,则此二叉树一定是二叉搜索树。', '虽然给出关键字序列的顺序不一样,但依次生成的二叉搜索树却是一样的。', '在二叉搜索树中插入一个新结点,总是插入到最下层,作为新的叶子结点。', 4, 1); INSERT INTO `testquestion` VALUES (9, '在AOE网中,什么是关键路径?', '最短回路', '最长回路', '从第一个事件到最后一个事件的最短路径', '从第一个事件到最后一个事件的最长路径', 4, 1); INSERT INTO `testquestion` VALUES (10, '下面关于图的存储的叙述中,哪一个是正确的?', '用相邻矩阵法存储图,占用的存储空间数只与图中结点个数有关,而与边数无关', '用相邻矩阵法存储图,占用的存储空间数只与图中边数有关,而与结点个数无关', '用邻接表法存储图,占用的存储空间数只与图中结点个数有关,而与边数无关', '用邻接表法存储图,占用的存储空间数只与图中边数有关,而与结点个数无关', 1, 1); INSERT INTO `testquestion` VALUES (11, '下面的()不是文件的存储结构。', '索引文件', '记录式文件', '串联文件', '连续文件', 2, 2); INSERT INTO `testquestion` VALUES (12, '有一磁盘,共有10个柱面,每个柱面20个磁道,每个盘面分成16个扇区。采用位示图对其存储空间进行管理。如果字长是16个二进制位,那么位示图共需 () 字。', '200', '128', '256', '100', 1, 2); INSERT INTO `testquestion` VALUES (13, '操作系统为每一个文件开辟一个存储区,在它的里面记录着该文件的有关信息。这就是所谓的()', '进程控制块', '文件控制块', '设备控制块', '作业控制块', 2, 2); INSERT INTO `testquestion` VALUES (14, '文件控制块的英文缩写符号是()', 'PCB', 'DCB', 'FCB', 'JCB', 3, 2); INSERT INTO `testquestion` VALUES (15, '一个文件的绝对路径名是从()开始,逐步沿着每一级子目录向下,最后到达指定文件的整个通路上所有子目录名组成的一个字符串。', '当前目录', '根目录', '多级目录', '二级目录', 2, 2); INSERT INTO `testquestion` VALUES (16, '一个算法应该是()。', '程序', '问题求解步骤的描述', '要满足五个基本属性', 'A和C', 2, 1); INSERT INTO `testquestion` VALUES (17, '与数据元素本身的形式、内容、相对位置、个数无关的是数据的( )。', '存储结构', '逻辑结构', '算法', '操作', 2, 1); INSERT INTO `testquestion` VALUES (20, ' 下列叙述中正确的是( )。', '一个逻辑数据结构只能有一种存储结构', '数据的逻辑结构属于线性结构,存储结构属于非线性结构', '一个逻辑数据结构可以有多种存储结构,且各种存储结构不影响数据处理的效率', '一个逻辑数据结构可以有多种存储结构,且各种存储结构影响数据处理的效率', 4, 1); INSERT INTO `testquestion` VALUES (21, '在文件系统中,采用位示图主要是实现( )。', '磁盘的驱动调度', '页面置换', '文件目录的查找', '磁盘空间的分配和回收', 4, 2); INSERT INTO `testquestion` VALUES (22, '操作系统实现按名存取的关键在于解决( )。', '文件逻辑地址到文件具体的存储地址的转换', '文件的符号名与文件具体的存储地址的转换和映射', '文件逻辑结构到文件名称转换', '文件名称到文件逻辑地址的转换', 2, 2); INSERT INTO `testquestion` VALUES (23, '下列算法中用于磁盘移臂调度的是( )。', '时间片轮转法', 'LRU算法', '最短寻找时间优先算法', '优先级高者优先算法', 3, 2); INSERT INTO `testquestion` VALUES (24, '在下面的I/O控制方式中,需要CPU干预最少的方式是( )。', '程序I/O方式', '中断驱动I/O控制方式 ', '直接存储器访问(DMA)控制方式 ', ' I/O通道控制方式', 4, 2); INSERT INTO `testquestion` VALUES (25, '与设备控制器关系最密切的软件是( )。', '设备驱动程序 ', '编译程序', '存储管理程序', '处理机管理', 1, 2); INSERT INTO `testquestion` VALUES (26, '引入缓冲可以( )。', '改善用户编程环境', '提高CPU的处理速度', '提高CPU与设备之间的并行程度', '降低计算机的硬件成本', 3, 2); -- ---------------------------- -- Table structure for user -- ---------------------------- DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `schoolId` int(11) DEFAULT NULL, `major` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `type` int(255) DEFAULT NULL, `classes` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1111 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of user -- ---------------------------- INSERT INTO `user` VALUES (1, 'admin', 1, '软件工程', 0, '172', 'admin'); INSERT INTO `user` VALUES (2, 'wzj', 1170220026, '软件工程', 2, '172', '123'); INSERT INTO `user` VALUES (3, '徐鑫', 1170220021, '软工', 2, '172789', 'xx'); INSERT INTO `user` VALUES (4, 'zcy', 1170220014, '软工', 2, '172', 'zcy'); INSERT INTO `user` VALUES (6, 'mwf', 100, '软件工程', 1, '172', '100'); INSERT INTO `user` VALUES (7, 'name2', 100002, '计算机', 2, '181', '1'); INSERT INTO `user` VALUES (8, 'name3', 100003, '数媒', 2, '172', '1'); INSERT INTO `user` VALUES (9, 'name4', 100004, '物联网', 2, '171', '1'); INSERT INTO `user` VALUES (10, 'name5', 100005, '物联网', 2, '171', '1'); INSERT INTO `user` VALUES (11, 'wjf', 101, '软件工程', 1, '172', '101'); INSERT INTO `user` VALUES (1110, 'name1', 100001, '计算机', 2, '171', '1'); SET FOREIGN_KEY_CHECKS = 1;
true
336aacca4fdc14ea1486a3d0f7defe1271117940
SQL
FilipOlofsson/CoinEagle
/cryptoanalyzer.sql
UTF-8
1,586
3.234375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.7.0 -- https://www.phpmyadmin.net/ -- -- Värd: 127.0.0.1 -- Tid vid skapande: 05 jan 2018 kl 06:23 -- Serverversion: 10.1.26-MariaDB -- PHP-version: 7.1.8 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Databas: `cryptoanalyzer` -- -- -------------------------------------------------------- -- -- Tabellstruktur `prices` -- CREATE TABLE `prices` ( `id` int(50) NOT NULL, `coin` text NOT NULL, `price` double NOT NULL, `date` bigint(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumpning av Data i tabell `prices` -- INSERT INTO `prices` (`id`, `coin`, `price`, `date`) VALUES (2, 'btc', 1337, 1515129534969), (3, 'btc', 155, 1515129547997); -- -- Index för dumpade tabeller -- -- -- Index för tabell `prices` -- ALTER TABLE `prices` ADD PRIMARY KEY (`id`), ADD KEY `date` (`date`), ADD KEY `id` (`id`), ADD KEY `date_2` (`date`); -- -- AUTO_INCREMENT för dumpade tabeller -- -- -- AUTO_INCREMENT för tabell `prices` -- ALTER TABLE `prices` MODIFY `id` int(50) 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
d580fc8e920217d9e015fc6ef1c2fc14a63a637c
SQL
Minkyoung-Kim121/SQL_basic
/kmk00_201113.sql
UHC
1,193
3.75
4
[]
no_license
show user; -- kmk00 Դϴ. -- kmk00 SESSION Ѹ ο -- ̺ Ϸ Ѵ. -- ->  SYSTEM ο , -- ̺ ٽ ̺ ϸ CREATE TABLE EMPTEST( EMPNO NUMBER(4) ,ENAME VARCHAR2(20) ,JOB VARCHAR2(20) ,DEPTNO NUMBER(2) ); -- ȴ. SELECT * FROM EMPTEST; SELECT * FROM TAB; SELECT * FROM SCOTT.EMP; SELECT * FROM SCOTT.DEPT; SELECT * FROM SCOTT.SALGRADE; CREATE TABLE EMP_KMK AS SELECT * FROM SCOTT.EMP WHERE 1=1; CREATE TABLE DEPT_KMK AS SELECT * FROM SCOTT.EMP WHERE 1=1; CREATE TABLE SALGRADE_KMK AS SELECT * FROM SCOTT.EMP WHERE 1=1; CREATE TABLE DEPT_KMK AS SELECT * FROM SCOTT.DEPT WHERE 1=1; SELECT * FROM TAB; -- create table ~ as ̺ ؿ ÷ ʹ , -- Ű(Ʈ) Ѿͼ Ѱܾ Ѵ. -- Ű(Ʈ) : PK, NOT NULL, FK -- ɼ ؾ Ѵ. ALTER TABLE DEPT_KMK ADD CONSTRAINT PK_DEPTNO PRIMARY KEY (DEPTNO);
true
44c1a5547be749c6fa92f2576c86f820acf126cc
SQL
hunglb/Telco-churn
/scripts/CUSTOMER_HISTORY_VIEW.sql
UTF-8
22,524
3.046875
3
[]
no_license
/* Sample Materials, provided under license. Licensed Materials - Property of IBM © Copyright IBM Corp. 2019. All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. drop view CHURN.CUSTOMER_HISTORY_VIEW ; */ create view CHURN.CUSTOMER_HISTORY_VIEW as select cs.AGGREGATE_RETAIL_SPEND as CUSTOMER_SUMMARY_AGGREGATE_RETAIL_SPEND , cs.AMOUNT_OF_MANAGEMENT_FEES as CUSTOMER_SUMMARY_AMOUNT_OF_MANAGEMENT_FEES , cs.ANNUAL_INCOME_OTHER as CUSTOMER_SUMMARY_ANNUAL_INCOME_OTHER , cs.ARREARS as CUSTOMER_SUMMARY_ARREARS , cs.ASSETS as CUSTOMER_SUMMARY_ASSETS , cs.AVERAGE_SENTIMENT_SCORE as CUSTOMER_SUMMARY_AVERAGE_SENTIMENT_SCORE , cs.CUSTOMER_ID as CUSTOMER_SUMMARY_CUSTOMER_ID , cs.CUSTOMER_LIFETIME_VALUE as CUSTOMER_SUMMARY_CUSTOMER_LIFETIME_VALUE , cs.END_DATE as CUSTOMER_SUMMARY_END_DATE , cs.EXPERIENCE_NUMBER_OF_PERIODS as CUSTOMER_SUMMARY_EXPERIENCE_NUMBER_OF_PERIODS , cs.EXPERIENCE_RATING as CUSTOMER_SUMMARY_EXPERIENCE_RATING , cs.FINANCIAL_ASSETS as CUSTOMER_SUMMARY_FINANCIAL_ASSETS , cs.FUNDS_UNDER_MANAGEMENT as CUSTOMER_SUMMARY_FUNDS_UNDER_MANAGEMENT , cs.LATEST_SENTIMENT_SCORE as CUSTOMER_SUMMARY_LATEST_SENTIMENT_SCORE , cs.LIABILITIES as CUSTOMER_SUMMARY_LIABILITIES , cs.LIQUID_NET_WORTH as CUSTOMER_SUMMARY_LIQUID_NET_WORTH , cs.LOG_INS_MARKET_DOWNTURN as CUSTOMER_SUMMARY_LOG_INS_MARKET_DOWNTURN , cs.LOG_INS_MARKET_UPTURN as CUSTOMER_SUMMARY_LOG_INS_MARKET_UPTURN , cs.NON_FINANCIAL_ASSETS as CUSTOMER_SUMMARY_NON_FINANCIAL_ASSETS , cs.NUMBER_OF_30_DAY_DELINQUENCIES as CUSTOMER_SUMMARY_NUMBER_OF_30_DAY_DELINQUENCIES , cs.NUMBER_OF_ACCOUNTS as CUSTOMER_SUMMARY_NUMBER_OF_ACCOUNTS , cs.NUMBER_OF_ACTIVE_ACCOUNTS as CUSTOMER_SUMMARY_NUMBER_OF_ACTIVE_ACCOUNTS , cs.NUMBER_OF_CALLS as CUSTOMER_SUMMARY_NUMBER_OF_CALLS , cs.NUMBER_OF_COMMUNICATIONS as CUSTOMER_SUMMARY_NUMBER_OF_COMMUNICATIONS , cs.NUMBER_OF_COMPLAINTS as CUSTOMER_SUMMARY_NUMBER_OF_COMPLAINTS , cs.NUMBER_OF_CREDIT_BUREAU_INQUIRIES as CUSTOMER_SUMMARY_NUMBER_OF_CREDIT_BUREAU_INQUIRIES , cs.NUMBER_OF_DORMANT_CREDIT_CARD_ARRANGEMENTS as CUSTOMER_SUMMARY_NUMBER_OF_DORMANT_CREDIT_CARD_ARRANGEMENTS , cs.NUMBER_OF_EMAILS as CUSTOMER_SUMMARY_NUMBER_OF_EMAILS , cs.NUMBER_OF_HARD_INQUIRIES as CUSTOMER_SUMMARY_NUMBER_OF_HARD_INQUIRIES , cs.NUMBER_OF_LOGINS as CUSTOMER_SUMMARY_NUMBER_OF_LOGINS , cs.NUMBER_OF_MOBILE_LOGINS as CUSTOMER_SUMMARY_NUMBER_OF_MOBILE_LOGINS , cs.NUMBER_OF_NEW_ACCOUNTS_OPENED as CUSTOMER_SUMMARY_NUMBER_OF_NEW_ACCOUNTS_OPENED , cs.NUMBER_OF_OPEN_COMPLAINTS as CUSTOMER_SUMMARY_NUMBER_OF_OPEN_COMPLAINTS , cs.NUMBER_OF_POSTS as CUSTOMER_SUMMARY_NUMBER_OF_POSTS , cs.NUMBER_OF_RECOMMENDATIONS as CUSTOMER_SUMMARY_NUMBER_OF_RECOMMENDATIONS , cs.NUMBER_OF_REPORTED_CREDIT_CHECKS as CUSTOMER_SUMMARY_NUMBER_OF_REPORTED_CREDIT_CHECKS , cs.NUMBER_OF_REPORTED_MAIL_STOLEN_INCIDENTS as CUSTOMER_SUMMARY_NUMBER_OF_REPORTED_MAIL_STOLEN_INCIDENTS , cs.NUMBER_OF_SOFT_INQUIRIES as CUSTOMER_SUMMARY_NUMBER_OF_SOFT_INQUIRIES , cs.NUMBER_OF_TRADING_PERIODS as CUSTOMER_SUMMARY_NUMBER_OF_TRADING_PERIODS , cs.NUMBER_OF_TRANSACTIONS as CUSTOMER_SUMMARY_NUMBER_OF_TRANSACTIONS , cs.PRIORITY as CUSTOMER_SUMMARY_PRIORITY , cs.REAL_PROPERTY_ASSETS as CUSTOMER_SUMMARY_REAL_PROPERTY_ASSETS , cs.RETURN_10Y as CUSTOMER_SUMMARY_RETURN_10Y , cs.RETURN_1Y as CUSTOMER_SUMMARY_RETURN_1Y , cs.RETURN_2Y as CUSTOMER_SUMMARY_RETURN_2Y , cs.RETURN_3Y as CUSTOMER_SUMMARY_RETURN_3Y , cs.RETURN_5Y as CUSTOMER_SUMMARY_RETURN_5Y , cs.RETURN_LAST_QUARTER as CUSTOMER_SUMMARY_RETURN_LAST_QUARTER , cs.RETURN_SINCE_INCEPTION as CUSTOMER_SUMMARY_RETURN_SINCE_INCEPTION , cs.RETURN_YTD as CUSTOMER_SUMMARY_RETURN_YTD , cs.SOURCE_SYSTEM_ID as CUSTOMER_SUMMARY_SOURCE_SYSTEM_ID , cs.START_DATE as CUSTOMER_SUMMARY_START_DATE , 1553542044109 as CUSTOMER_SUMMARY_SYSTEM_LOAD_TIMESTAMP , cs.TOP_SPENDING_CATEGORY as CUSTOMER_SUMMARY_TOP_SPENDING_CATEGORY , cs.TOTAL_AMOUNT_OF_ALL_FEES as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_ALL_FEES , cs.TOTAL_AMOUNT_OF_BUY_TRADES as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_BUY_TRADES , cs.TOTAL_AMOUNT_OF_COMMISSION as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_COMMISSION , cs.TOTAL_AMOUNT_OF_DEPOSITS as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_DEPOSITS , cs.TOTAL_AMOUNT_OF_INTEREST_EARNED as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_INTEREST_EARNED , cs.TOTAL_AMOUNT_OF_INTEREST_FEES as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_INTEREST_FEES , cs.TOTAL_AMOUNT_OF_MARKET_CHANGE as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_MARKET_CHANGE , cs.TOTAL_AMOUNT_OF_SELL_TRADES as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_SELL_TRADES , cs.TOTAL_AMOUNT_OF_TRANSACTION_FEES as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_TRANSACTION_FEES , cs.TOTAL_AMOUNT_OF_WAIVED_FEES as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_WAIVED_FEES , cs.TOTAL_AMOUNT_OF_WITHDRAWALS as CUSTOMER_SUMMARY_TOTAL_AMOUNT_OF_WITHDRAWALS , cs.TOTAL_CALL_TIME as CUSTOMER_SUMMARY_TOTAL_CALL_TIME , cs.TOTAL_CLOSING_BALANCE as CUSTOMER_SUMMARY_TOTAL_CLOSING_BALANCE , cs.TOTAL_CLOSING_BALANCE_CREDIT_CARDS as CUSTOMER_SUMMARY_TOTAL_CLOSING_BALANCE_CREDIT_CARDS , cs.TOTAL_CLOSING_BALANCE_LOANS as CUSTOMER_SUMMARY_TOTAL_CLOSING_BALANCE_LOANS , cs.TOTAL_CLOSING_CASH_BALANCE as CUSTOMER_SUMMARY_TOTAL_CLOSING_CASH_BALANCE , cs.TOTAL_COMMUNICATIONS_AND_IT_EXPENSE as CUSTOMER_SUMMARY_TOTAL_COMMUNICATIONS_AND_IT_EXPENSE , cs.TOTAL_INWARD_CALLS as CUSTOMER_SUMMARY_TOTAL_INWARD_CALLS , cs.TOTAL_INWARD_COMMUNICATIONS as CUSTOMER_SUMMARY_TOTAL_INWARD_COMMUNICATIONS , cs.TOTAL_INWARD_EMAILS as CUSTOMER_SUMMARY_TOTAL_INWARD_EMAILS , cs.TOTAL_LOGIN_OR_QUERIES as CUSTOMER_SUMMARY_TOTAL_LOGIN_OR_QUERIES , cs.TOTAL_NET_WORTH as CUSTOMER_SUMMARY_TOTAL_NET_WORTH , cs.TOTAL_NUMBER_OF_ACCOUNTS_AS_NON_PRIMARY as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_ACCOUNTS_AS_NON_PRIMARY , cs.TOTAL_NUMBER_OF_ACCOUNTS_AS_PRIMARY as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_ACCOUNTS_AS_PRIMARY , cs.TOTAL_NUMBER_OF_ACTIVE_COMMUNICATION_THREADS as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_ACTIVE_COMMUNICATION_THREADS , cs.TOTAL_NUMBER_OF_ALL_FEES as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_ALL_FEES , cs.TOTAL_NUMBER_OF_BUY_TRADES as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_BUY_TRADES , cs.TOTAL_NUMBER_OF_DEPOSITS as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_DEPOSITS , cs.TOTAL_NUMBER_OF_SELL_TRADES as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_SELL_TRADES , cs.TOTAL_NUMBER_OF_UNITS_BOUGHT as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_UNITS_BOUGHT , cs.TOTAL_NUMBER_OF_UNITS_SOLD as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_UNITS_SOLD , cs.TOTAL_NUMBER_OF_WITHDRAWALS as CUSTOMER_SUMMARY_TOTAL_NUMBER_OF_WITHDRAWALS , cs.TOTAL_OUTWARD_CALLS as CUSTOMER_SUMMARY_TOTAL_OUTWARD_CALLS , cs.TOTAL_OUTWARD_COMMUNICATIONS as CUSTOMER_SUMMARY_TOTAL_OUTWARD_COMMUNICATIONS , cs.TOTAL_OUTWARD_EMAILS as CUSTOMER_SUMMARY_TOTAL_OUTWARD_EMAILS , cs.TRADING_VOLUME as CUSTOMER_SUMMARY_TRADING_VOLUME , cs.TYPE as CUSTOMER_SUMMARY_TYPE , ROW_NUMBER() OVER () as CUSTOMER_SUMMARY_UNIQUE_ROW_ID , cs.USER_DEFINED_BOOLEAN_1 as CUSTOMER_SUMMARY_USER_DEFINED_BOOLEAN_1 , cs.USER_DEFINED_BOOLEAN_2 as CUSTOMER_SUMMARY_USER_DEFINED_BOOLEAN_2 , cs.USER_DEFINED_BOOLEAN_3 as CUSTOMER_SUMMARY_USER_DEFINED_BOOLEAN_3 , cs.USER_DEFINED_BOOLEAN_4 as CUSTOMER_SUMMARY_USER_DEFINED_BOOLEAN_4 , cs.USER_DEFINED_BOOLEAN_5 as CUSTOMER_SUMMARY_USER_DEFINED_BOOLEAN_5 , cs.USER_DEFINED_DATE_1 as CUSTOMER_SUMMARY_USER_DEFINED_DATE_1 , cs.USER_DEFINED_DATE_2 as CUSTOMER_SUMMARY_USER_DEFINED_DATE_2 , cs.USER_DEFINED_DATE_3 as CUSTOMER_SUMMARY_USER_DEFINED_DATE_3 , cs.USER_DEFINED_DATE_4 as CUSTOMER_SUMMARY_USER_DEFINED_DATE_4 , cs.USER_DEFINED_DATE_5 as CUSTOMER_SUMMARY_USER_DEFINED_DATE_5 , cs.USER_DEFINED_INTEGER_1 as CUSTOMER_SUMMARY_USER_DEFINED_INTEGER_1 , cs.USER_DEFINED_INTEGER_2 as CUSTOMER_SUMMARY_USER_DEFINED_INTEGER_2 , cs.USER_DEFINED_INTEGER_3 as CUSTOMER_SUMMARY_USER_DEFINED_INTEGER_3 , cs.USER_DEFINED_INTEGER_4 as CUSTOMER_SUMMARY_USER_DEFINED_INTEGER_4 , cs.USER_DEFINED_INTEGER_5 as CUSTOMER_SUMMARY_USER_DEFINED_INTEGER_5 , cs.USER_DEFINED_NUMERIC_1 as CUSTOMER_SUMMARY_USER_DEFINED_NUMERIC_1 , cs.USER_DEFINED_NUMERIC_2 as CUSTOMER_SUMMARY_USER_DEFINED_NUMERIC_2 , cs.USER_DEFINED_NUMERIC_3 as CUSTOMER_SUMMARY_USER_DEFINED_NUMERIC_3 , cs.USER_DEFINED_NUMERIC_4 as CUSTOMER_SUMMARY_USER_DEFINED_NUMERIC_4 , cs.USER_DEFINED_NUMERIC_5 as CUSTOMER_SUMMARY_USER_DEFINED_NUMERIC_5 , cs.USER_DEFINED_STRING_1 as CUSTOMER_SUMMARY_USER_DEFINED_STRING_1 , cs.USER_DEFINED_STRING_2 as CUSTOMER_SUMMARY_USER_DEFINED_STRING_2 , cs.USER_DEFINED_STRING_3 as CUSTOMER_SUMMARY_USER_DEFINED_STRING_3 , cs.USER_DEFINED_STRING_4 as CUSTOMER_SUMMARY_USER_DEFINED_STRING_4 , cs.USER_DEFINED_STRING_5 as CUSTOMER_SUMMARY_USER_DEFINED_STRING_5 , 1553542044109 as CUSTOMER_SUMMARY_ALIAS_RECENT_SYSTEM_LOAD_TIMESTAMP , c.ACQUISITION_COST as CUSTOMER_ACQUISITION_COST , c.ADDRESS_HOME_CITY as CUSTOMER_ADDRESS_HOME_CITY , c.ADDRESS_HOME_COUNTRY as CUSTOMER_ADDRESS_HOME_COUNTRY , c.ADDRESS_HOME_POSTAL_CODE as CUSTOMER_ADDRESS_HOME_POSTAL_CODE , c.ADDRESS_HOME_STATE as CUSTOMER_ADDRESS_HOME_STATE , c.ADDRESS_LAST_CHANGED_DATE as CUSTOMER_ADDRESS_LAST_CHANGED_DATE , c.ADDRESS_MAILING_CITY as CUSTOMER_ADDRESS_MAILING_CITY , c.ADDRESS_MAILING_COUNTRY as CUSTOMER_ADDRESS_MAILING_COUNTRY , c.ADDRESS_MAILING_POSTAL_CODE as CUSTOMER_ADDRESS_MAILING_POSTAL_CODE , c.ADDRESS_MAILING_STATE as CUSTOMER_ADDRESS_MAILING_STATE , c.ADDRESS_WORK_CITY as CUSTOMER_ADDRESS_WORK_CITY , c.ADDRESS_WORK_COUNTRY as CUSTOMER_ADDRESS_WORK_COUNTRY , c.ADDRESS_WORK_POSTAL_CODE as CUSTOMER_ADDRESS_WORK_POSTAL_CODE , c.ADDRESS_WORK_STATE as CUSTOMER_ADDRESS_WORK_STATE , c.ADVERTISING_INDICATOR as CUSTOMER_ADVERTISING_INDICATOR , c.AGE_RANGE as CUSTOMER_AGE_RANGE , c.AGGREGATION_OPT_IN_INDICATOR as CUSTOMER_AGGREGATION_OPT_IN_INDICATOR , c.ANNUAL_INCOME as CUSTOMER_ANNUAL_INCOME , c.ATTACHMENT_ALLOWED_INDICATOR as CUSTOMER_ATTACHMENT_ALLOWED_INDICATOR , c.BIRTH_YEAR as CUSTOMER_BIRTH_YEAR , c.CONTACT_PREFERENCE as CUSTOMER_CONTACT_PREFERENCE , c.CREDIT_AUTHORITY_LEVEL as CUSTOMER_CREDIT_AUTHORITY_LEVEL , c.CREDIT_SCORE as CUSTOMER_CREDIT_SCORE , c.CREDIT_UTILIZATION as CUSTOMER_CREDIT_UTILIZATION , c.CURRENT_EMPLOYMENT_START_DATE as CUSTOMER_CURRENT_EMPLOYMENT_START_DATE , c.CUSTOMER_BEHAVIOR as CUSTOMER_CUSTOMER_BEHAVIOR , c.CUSTOMER_ID as CUSTOMER_CUSTOMER_ID , c.DATE_FIRST_ACCOUNT_OPENED as CUSTOMER_DATE_FIRST_ACCOUNT_OPENED , c.DATE_LAST_ACCOUNT_OPENED as CUSTOMER_DATE_LAST_ACCOUNT_OPENED , c.DEATH_YEAR as CUSTOMER_DEATH_YEAR , c.DEBT_SERVICE_COVERAGE_RATIO as CUSTOMER_DEBT_SERVICE_COVERAGE_RATIO , c.EDUCATION_LEVEL as CUSTOMER_EDUCATION_LEVEL , c.EFFECTIVE_DATE as CUSTOMER_EFFECTIVE_DATE , c.EMPLOYMENT_STATUS as CUSTOMER_EMPLOYMENT_STATUS , c.FAMILY_SIZE as CUSTOMER_FAMILY_SIZE , c.GENDER as CUSTOMER_GENDER , c.GEOGRAPHIC_AREA_HOME as CUSTOMER_GEOGRAPHIC_AREA_HOME , c.GEOGRAPHIC_AREA_MAILING as CUSTOMER_GEOGRAPHIC_AREA_MAILING , c.GEOGRAPHIC_AREA_WORK as CUSTOMER_GEOGRAPHIC_AREA_WORK , c.HEAD_OF_HOUSEHOLD_INDICATOR as CUSTOMER_HEAD_OF_HOUSEHOLD_INDICATOR , c.HOME_OWNER_INDICATOR as CUSTOMER_HOME_OWNER_INDICATOR , c.HOUSEHOLD_ID as CUSTOMER_HOUSEHOLD_ID , c.IMPORTANCE_LEVEL_CODE as CUSTOMER_IMPORTANCE_LEVEL_CODE , c.INFLUENCE_SCORE as CUSTOMER_INFLUENCE_SCORE , c.INTERNET_BANKING_INDICATOR as CUSTOMER_INTERNET_BANKING_INDICATOR , c.LIFE_CYCLE_STATUS_CHANGE_REASON as CUSTOMER_LIFE_CYCLE_STATUS_CHANGE_REASON , c.LIFE_CYCLE_STATUS_CHANGE_REASON as CUSTOMER_LIFE_CYCLE_STATUS_CODE , c.LOYALTY_RATING_CODE as CUSTOMER_LOYALTY_RATING_CODE , c.MARITAL_STATUS as CUSTOMER_MARITAL_STATUS , c.MARKET_GROUP as CUSTOMER_MARKET_GROUP , c.METRIC_BEHAVIOR_PROFILE as CUSTOMER_METRIC_BEHAVIOR_PROFILE , c.METRIC_BEHAVIOR_PROFILE_2 as CUSTOMER_METRIC_BEHAVIOR_PROFILE_2 , c.METRIC_BEHAVIOR_PROFILE_3 as CUSTOMER_METRIC_BEHAVIOR_PROFILE_3 , c.METRIC_BEHAVIOR_PROFILE_4 as CUSTOMER_METRIC_BEHAVIOR_PROFILE_4 , c.METRIC_BEHAVIOR_PROFILE_5 as CUSTOMER_METRIC_BEHAVIOR_PROFILE_5 , c.METRIC_COMMUNICATION_STYLE as CUSTOMER_METRIC_COMMUNICATION_STYLE , c.METRIC_FINANCIAL_KNOWLEDGE_RATING as CUSTOMER_METRIC_FINANCIAL_KNOWLEDGE_RATING , c.METRIC_LATEST_TONE as CUSTOMER_METRIC_LATEST_TONE , c.METRIC_NET_PROMOTER_SCORE as CUSTOMER_METRIC_NET_PROMOTER_SCORE , c.METRIC_PERSONALITY_TYPE as CUSTOMER_METRIC_PERSONALITY_TYPE , c.METRIC_SATISFACTION_LEVEL as CUSTOMER_METRIC_SATISFACTION_LEVEL , c.METRIC_STRENGTH_OF_RELATIONSHIP as CUSTOMER_METRIC_STRENGTH_OF_RELATIONSHIP , c.METRIC_TECH_SAVY as CUSTOMER_METRIC_TECH_SAVY , c.MONTHLY_HOUSING_COST as CUSTOMER_MONTHLY_HOUSING_COST , c.MONTHLY_NET_INCOME as CUSTOMER_MONTHLY_NET_INCOME , c.NUMBER_OF_DEPENDENT_ADULTS as CUSTOMER_NUMBER_OF_DEPENDENT_ADULTS , c.NUMBER_OF_DEPENDENT_CHILDREN as CUSTOMER_NUMBER_OF_DEPENDENT_CHILDREN , c.OLDEST_DEPENDENT_ADULT_BIRTH_YEAR as CUSTOMER_OLDEST_DEPENDENT_ADULT_BIRTH_YEAR , c.OLDEST_DEPENDENT_CHILD_BIRTH_YEAR as CUSTOMER_OLDEST_DEPENDENT_CHILD_BIRTH_YEAR , c.PERSONAL_INTEREST_TOPIC_1 as CUSTOMER_PERSONAL_INTEREST_TOPIC_1 , c.PERSONAL_INTEREST_TOPIC_2 as CUSTOMER_PERSONAL_INTEREST_TOPIC_2 , c.PREFERRED_COMMUNICATION_FORM as CUSTOMER_PREFERRED_COMMUNICATION_FORM , c.PRIMARY_ADVISOR_ID as CUSTOMER_PRIMARY_ADVISOR_ID , c.PRIMARY_ADVISOR_ORGANIZATION_ID as CUSTOMER_PRIMARY_ADVISOR_ORGANIZATION_ID , c.PRIMARY_BRANCH_PROXIMITY as CUSTOMER_PRIMARY_BRANCH_PROXIMITY , c.PRIMARY_SPOKEN_LANGUAGE as CUSTOMER_PRIMARY_SPOKEN_LANGUAGE , c.PRIMARY_WRITTEN_LANGUAGE as CUSTOMER_PRIMARY_WRITTEN_LANGUAGE , c.PROFESSION as CUSTOMER_PROFESSION , c.PURSUIT as CUSTOMER_PURSUIT , c.RECORDED_VOICE_SAMPLE_ID as CUSTOMER_RECORDED_VOICE_SAMPLE_ID , c.REFERRALS_VALUE_CODE as CUSTOMER_REFERRALS_VALUE_CODE , c.RELATIONSHIP_START_DATE as CUSTOMER_RELATIONSHIP_START_DATE , c.RETIREMENT_AGE as CUSTOMER_RETIREMENT_AGE , c.SATISFACTION_RATING_FROM_SURVEY as CUSTOMER_SATISFACTION_RATING_FROM_SURVEY , c.SECONDARY_ADVISOR_ID as CUSTOMER_SECONDARY_ADVISOR_ID , c.SECONDARY_ADVISOR_ORGANIZATION_ID as CUSTOMER_SECONDARY_ADVISOR_ORGANIZATION_ID , c.SPECIAL_TERMS_INDICATOR as CUSTOMER_SPECIAL_TERMS_INDICATOR , c.STATUS as CUSTOMER_STATUS , c.STATUS_DATE as CUSTOMER_STATUS_DATE , c.STATUS_REASON as CUSTOMER_STATUS_REASON , 1553542044109 as CUSTOMER_SYSTEM_LOAD_TIMESTAMP , RANK() OVER (ORDER BY c.CUSTOMER_ID) as CUSTOMER_UNIQUE_ROW_ID , c.URBAN_CODE as CUSTOMER_URBAN_CODE , c.USER_DEFINED_BOOLEAN_1 as CUSTOMER_USER_DEFINED_BOOLEAN_1 , c.USER_DEFINED_BOOLEAN_2 as CUSTOMER_USER_DEFINED_BOOLEAN_2 , c.USER_DEFINED_BOOLEAN_3 as CUSTOMER_USER_DEFINED_BOOLEAN_3 , c.USER_DEFINED_BOOLEAN_4 as CUSTOMER_USER_DEFINED_BOOLEAN_4 , c.USER_DEFINED_BOOLEAN_5 as CUSTOMER_USER_DEFINED_BOOLEAN_5 , c.USER_DEFINED_DATE_1 as CUSTOMER_USER_DEFINED_DATE_1 , c.USER_DEFINED_DATE_2 as CUSTOMER_USER_DEFINED_DATE_2 , c.USER_DEFINED_DATE_3 as CUSTOMER_USER_DEFINED_DATE_3 , c.USER_DEFINED_DATE_4 as CUSTOMER_USER_DEFINED_DATE_4 , c.USER_DEFINED_DATE_5 as CUSTOMER_USER_DEFINED_DATE_5 , c.USER_DEFINED_INTEGER_1 as CUSTOMER_USER_DEFINED_INTEGER_1 , c.USER_DEFINED_INTEGER_2 as CUSTOMER_USER_DEFINED_INTEGER_2 , c.USER_DEFINED_INTEGER_3 as CUSTOMER_USER_DEFINED_INTEGER_3 , c.USER_DEFINED_INTEGER_4 as CUSTOMER_USER_DEFINED_INTEGER_4 , c.USER_DEFINED_INTEGER_5 as CUSTOMER_USER_DEFINED_INTEGER_5 , c.USER_DEFINED_NUMERIC_1 as CUSTOMER_USER_DEFINED_NUMERIC_1 , c.USER_DEFINED_NUMERIC_2 as CUSTOMER_USER_DEFINED_NUMERIC_2 , c.USER_DEFINED_NUMERIC_3 as CUSTOMER_USER_DEFINED_NUMERIC_3 , c.USER_DEFINED_NUMERIC_4 as CUSTOMER_USER_DEFINED_NUMERIC_4 , c.USER_DEFINED_NUMERIC_5 as CUSTOMER_USER_DEFINED_NUMERIC_5 , c.USER_DEFINED_STRING_1 as CUSTOMER_USER_DEFINED_STRING_1 , c.USER_DEFINED_STRING_2 as CUSTOMER_USER_DEFINED_STRING_2 , c.USER_DEFINED_STRING_3 as CUSTOMER_USER_DEFINED_STRING_3 , c.USER_DEFINED_STRING_4 as CUSTOMER_USER_DEFINED_STRING_4 , c.USER_DEFINED_STRING_5 as CUSTOMER_USER_DEFINED_STRING_5 , c.WALLET_SHARE_PERCENTAGE as CUSTOMER_WALLET_SHARE_PERCENTAGE , c.YOUNGEST_DEPENDENT_ADULT_BIRTH_YEAR as CUSTOMER_YOUNGEST_DEPENDENT_ADULT_BIRTH_YEAR , c.YOUNGEST_DEPENDENT_CHILD_BIRTH_YEAR as CUSTOMER_YOUNGEST_DEPENDENT_CHILD_BIRTH_YEAR , 1553542044109 as CUSTOMER_ALIAS_RECENT_SYSTEM_LOAD_TIMESTAMP , isnull(high.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_RISK_TOLERANCE_HIGH , isnull(low.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_RISK_TOLERANCE_LOW , isnull(moderate.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_RISK_TOLERANCE_MODERATE , isnull(very_low.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_RISK_TOLERANCE_VERY_LOW , isnull(growth.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_INVESTMENT_OBJECTIVE_GROWTH , isnull(income.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_INVESTMENT_OBJECTIVE_INCOME , isnull(planning.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_INVESTMENT_OBJECTIVE_PLANNING , isnull(secure_growth.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_INVESTMENT_OBJECTIVE_SECURE_GROWTH , isnull(security.ACC_CNT, 0) as NUM_ACCOUNTS_WITH_INVESTMENT_OBJECTIVE_SECURITY from CHURN.CUSTOMER_SUMMARY cs inner join (select c_base.CUSTOMER_ID, c_base.EFFECTIVE_DATE as EFFECTIVE_FROM, min(date(isnull(c_next.EFFECTIVE_DATE, '2100-01-01')) - 1 DAYS) as EFFECTIVE_TO from CHURN.CUSTOMER c_base left outer join CHURN.CUSTOMER c_next on c_base.CUSTOMER_ID = c_next.CUSTOMER_ID and c_base.EFFECTIVE_DATE < c_next.EFFECTIVE_DATE group by c_base.CUSTOMER_ID, c_base.EFFECTIVE_DATE ) c_status_hist on c_status_hist.CUSTOMER_ID = cs.CUSTOMER_ID and c_status_hist.EFFECTIVE_FROM <= cs.END_DATE and c_status_hist.EFFECTIVE_TO >= cs.END_DATE inner join CHURN.CUSTOMER c on c_status_hist.CUSTOMER_ID = c.CUSTOMER_ID and c_status_hist.EFFECTIVE_FROM = c.EFFECTIVE_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.RISK_TOLERANCE = 'High' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) high on cs.CUSTOMER_ID = high.CUSTOMER_ID and cs.START_DATE = high.START_DATE and cs.END_DATE = high.END_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.RISK_TOLERANCE = 'Low' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) low on cs.CUSTOMER_ID = low.CUSTOMER_ID and cs.START_DATE = low.START_DATE and cs.END_DATE = low.END_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.RISK_TOLERANCE = 'Moderate' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) moderate on cs.CUSTOMER_ID = moderate.CUSTOMER_ID and cs.START_DATE = moderate.START_DATE and cs.END_DATE = moderate.END_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.RISK_TOLERANCE = 'Very Low' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) very_low on cs.CUSTOMER_ID = very_low.CUSTOMER_ID and cs.START_DATE = very_low.START_DATE and cs.END_DATE = very_low.END_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.INVESTMENT_OBJECTIVE = 'Growth' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) growth on cs.CUSTOMER_ID = growth.CUSTOMER_ID and cs.START_DATE = growth.START_DATE and cs.END_DATE = growth.END_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.INVESTMENT_OBJECTIVE = 'Income' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) income on cs.CUSTOMER_ID = income.CUSTOMER_ID and cs.START_DATE = income.START_DATE and cs.END_DATE = income.END_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.INVESTMENT_OBJECTIVE = 'Planning' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) planning on cs.CUSTOMER_ID = planning.CUSTOMER_ID and cs.START_DATE = planning.START_DATE and cs.END_DATE = planning.END_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.INVESTMENT_OBJECTIVE = 'Secure Growth' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) secure_growth on cs.CUSTOMER_ID = secure_growth.CUSTOMER_ID and cs.START_DATE = secure_growth.START_DATE and cs.END_DATE = secure_growth.END_DATE left outer join (select cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE, count(*) as ACC_CNT from CHURN.CUSTOMER_SUMMARY cs inner join CHURN.ACCOUNT a on cs.CUSTOMER_ID = a.PRIMARY_CUSTOMER_ID and a.OPEN_DATE <= cs.END_DATE and ISNULL(a.CLOSE_DATE, '2099-12-31') >= cs.END_DATE and a.INVESTMENT_OBJECTIVE = 'Security' group by cs.CUSTOMER_ID, cs.START_DATE, cs.END_DATE ) security on cs.CUSTOMER_ID = security.CUSTOMER_ID and cs.START_DATE = security.START_DATE and cs.END_DATE = security.END_DATE ; DROP TABLE CHURN.CUSTOMER_HISTORY; CREATE TABLE CHURN.CUSTOMER_HISTORY AS ( select * from CHURN.CUSTOMER_HISTORY_VIEW ) WITH NO DATA; insert into CHURN.CUSTOMER_HISTORY select * from CHURN.CUSTOMER_HISTORY_VIEW; select count(*) from CHURN.CUSTOMER_HISTORY; --returns 19251 records
true
d68ec6d89d704fa70a0e5cf0eaccc78e257cdb29
SQL
Gaya3-SQL/SQL_Exercise
/Joins/SQL_INNER_LEFT_RIGHT.sql
UTF-8
1,815
4
4
[]
no_license
--By this query we can join the the tables by using inner join syntax-- Select TOP 10 PP.Title,PP.FirstName,PP.MiddleName,PP.LastName,PA.AddressLine1,PA.AddressLine2,PA.City,SP.Name,SP.StateProvinceCode,PA.PostalCode from Person.Person AS PP INNER JOIN Person.BusinessEntityAddress AS BEA ON PP.BusinessEntityID = BEA.BusinessEntityID INNER JOIN Person.Address AS PA ON BEA.AddressID = PA.AddressID INNER JOIN Person.StateProvince AS SP ON PA.StateProvinceID = SP.StateProvinceID --Testing-- INNER JOIN Person.StateProvince AS SP ON PA.AddressLine1 = SP.StateProvinceCode --By using the left join syntax we can get the data which is mutual in both the tables and left side columns of the table-- Select TOP 10 PP.Title,PP.FirstName,PP.MiddleName,PP.LastName,PA.AddressLine1,PA.AddressLine2,PA.City,SP.Name,SP.StateProvinceCode,PA.PostalCode from Person.Person AS PP INNER JOIN Person.BusinessEntityAddress AS BEA ON PP.BusinessEntityID = BEA.BusinessEntityID INNER JOIN Person.Address AS PA ON BEA.AddressID = PA.AddressID INNER JOIN Person.StateProvince AS SP ON PA.StateProvinceID = SP.StateProvinceID LEFT JOIN Person.StateProvince AS SP ON PA.AddressLine1 = SP.StateProvinceCode --By using the Right join syntax we can get the data which is mutual in both the tables and Right side columns of the table-- Select TOP 10 PP.Title,PP.FirstName,PP.MiddleName,PP.LastName,PA.AddressLine1,PA.AddressLine2,PA.City,SP.Name,SP.StateProvinceCode,PA.PostalCode from Person.Person AS PP INNER JOIN Person.BusinessEntityAddress AS BEA ON PP.BusinessEntityID = BEA.BusinessEntityID INNER JOIN Person.Address AS PA ON BEA.AddressID = PA.AddressID INNER JOIN Person.StateProvince AS SP ON PA.StateProvinceID = SP.StateProvinceID RIGHT JOIN Person.StateProvince AS SP ON PA.AddressLine1 = SP.StateProvinceCode
true
13ff91f522019e0a1c48044b90f907f2ac1e5898
SQL
hdinsight/HivePerformanceAutomation
/workload/tpch/queries/tpch_query18.sql
UTF-8
764
3.890625
4
[]
no_license
drop view q18_tmp_cached; drop table q18_large_volume_customer_cached; create view q18_tmp_cached as select l_orderkey, sum(l_quantity) as t_sum_quantity from lineitem where l_orderkey is not null group by l_orderkey; create table q18_large_volume_customer_cached as select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, q18_tmp_cached t, lineitem l where c_custkey = o_custkey and o_orderkey = t.l_orderkey and o_orderkey is not null and t.t_sum_quantity > 300 and o_orderkey = l.l_orderkey and l.l_orderkey is not null group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate limit 100;
true
af18e21be66f40dfa232e66468822a342375d9f6
SQL
saqib010/Store_Project_Development
/SQL Queries/tables.sql
UTF-8
1,975
3.703125
4
[]
no_license
create database db_Store /************************************ LOGIN create table tb_login(username varchar(30) not null, password varchar(30) not null) insert into tb_login (username, password) values ('test','test'); select * from tb_login **************************************/ create table Supplier(Supplier_ID int IDENTITY(1,1) PRIMARY KEY, Name varchar(200) not null, Address text not null, PhoneNo varchar(30) null) insert into Supplier(Name,Address,PhoneNo) values('Salman Iftikhar','Model Town','9234749181') drop table Supplier create table Product(Product_ID int IDENTITY(1,1) PRIMARY KEY, Product_Code int not null, Name text, size varchar(50) not null, quantity int not null, Unit_price decimal(8,2)) create table Stock(Stock_ID int IDENTITY(1,1) primary key,Supplier_ID int FOREIGN KEY REFERENCES Supplier(Supplier_ID),Product_ID int FOREIGN KEY REFERENCES Product(Product_ID),Quantity int not null, Unit_price decimal(8,2)) create table OrderTable(Order_ID int IDENTITY(1,1) primary key,Order_Date Datetime not null); create table OrderDelivered(OrderDelivered_ID int IDENTITY(1,1),Order_ID int FOREIGN KEY REFERENCES OrderTable(Order_ID),Product_ID int FOREIGN KEY REFERENCES Product(Product_ID), SoldPrice decimal(8,2),SoldQuantity int not null) insert into Product(Product_Code,Name,size,quantity,Unit_price) values(0001,'China Pents','medium',9,350.4) insert into Stock(Supplier_ID,Product_ID,Quantity,Unit_price) values(1,1,9,350.4) select * from Supplier select * from Product select * from Stock select * from tb_login insert into OrderTable values (getDate()),(getDate()),(getDate()) insert into OrderDelivered values (1,1,(select Unit_price*2 from Product where Product_ID=1),2), (1,1,(select Unit_price*2 from Product where Product_ID=1),2), (2,1,(select Unit_price*1 from Product where Product_ID=1),1), (3,1,(select Unit_price*2 from Product where Product_ID=1),2) UPDATE tb_login SET username = 'aaa' WHERE username = 'a1';
true
6ada6638dfbf615cb0628161774a9c345ae71253
SQL
coleenhuang/Where-was-I
/migrations/010.do.create_verses_table.sql
UTF-8
148
2.796875
3
[]
no_license
CREATE TABLE verses ( id SERIAL PRIMARY KEY, verse_name INTEGER NOT NULL, chapter_id INTEGER REFERENCES chapters(id) ON DELETE CASCADE )
true
3e545a99feceff87ea5ebe06df9af3f3e4422e86
SQL
sidousidou/Gestion-CHU-v2
/hopitale.sql
UTF-8
8,713
3.4375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.7.4 -- https://www.phpmyadmin.net/ -- -- Hôte : 127.0.0.1 -- Généré le : Dim 16 fév. 2020 à 11:23 -- Version du serveur : 10.1.28-MariaDB -- Version de PHP : 7.1.11 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 données : `hopitale` -- create database hopitale; use hopitale; DELIMITER $$ -- -- Procédures -- CREATE DEFINER=`root`@`localhost` PROCEDURE `AddEditmedcin` (`_ID` INT, `_Name` VARCHAR(45), `_lastName` VARCHAR(45), `_user` VARCHAR(50), `_Passe` VARCHAR(45)) BEGIN IF _BookID = 0 THEN INSERT INTO `medcin` (`Nom`, `prenom`, `email`, `password`) VALUES ( _Name, _lastName, _user, _Passe); ELSE UPDATE `medcin` SET `Nom` = _Name, `prenom` = _lastName, `email` = _user, `password`=_Passe WHERE `id` = _ID; END IF; END$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `MedcinTble` () BEGIN SELECT * FROM medcin; END$$ DELIMITER ; -- -------------------------------------------------------- -- -- Structure de la table `admin` -- CREATE TABLE `admin` ( `id` int(11) NOT NULL, `nom` varchar(45) DEFAULT NULL, `prenom` varchar(45) DEFAULT NULL, `mail` varchar(45) DEFAULT NULL, `password` varchar(45) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `admin` -- INSERT INTO `admin` (`id`, `nom`, `prenom`, `mail`, `password`) VALUES (1, 'Moussaoui', 'Tarek', 'tarikmoussaoui@mt.mt', 'mt00722'); -- -------------------------------------------------------- -- -- Structure de la table `creneau_libre` -- CREATE TABLE `creneau_libre` ( `id` int(11) NOT NULL, `heure_debut` varchar(45) DEFAULT NULL, `heure_fin` varchar(45) DEFAULT NULL, `idMedcin` int(11) NOT NULL, `Etat` tinyint(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `creneau_libre` -- INSERT INTO `creneau_libre` (`id`, `heure_debut`, `heure_fin`, `idMedcin`, `Etat`) VALUES (2, '12:00', '12:30', 0, 1), (3, '1', '1', 0, 0), (4, '1', '1', 0, 0), (5, '1', '1', 0, 0), (6, '1', '1', 0, 1), (8, '1', '1', 11, 1), (9, '13', '13:30', 11, 1); -- -------------------------------------------------------- -- -- Structure de la table `creneau_libre_has_medcin` -- CREATE TABLE `creneau_libre_has_medcin` ( `creneau_libre_id` int(11) NOT NULL, `Medcin_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Structure de la table `etat_patient` -- CREATE TABLE `etat_patient` ( `id` int(11) NOT NULL, `id_patient` int(11) DEFAULT NULL, `discription` varchar(450) DEFAULT NULL, `tension` int(11) DEFAULT NULL, `Date` date DEFAULT NULL, `tempirature` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `etat_patient` -- INSERT INTO `etat_patient` (`id`, `id_patient`, `discription`, `tension`, `Date`, `tempirature`) VALUES (1, 1, 'tarik', 15, '2020-02-14', 40), (2, 2, 'ug', 1, '2001-01-01', 1); -- -------------------------------------------------------- -- -- Structure de la table `infermier` -- CREATE TABLE `infermier` ( `id` int(11) NOT NULL, `nom` varchar(45) DEFAULT NULL, `prenom` varchar(45) DEFAULT NULL, `mail` varchar(45) DEFAULT NULL, `password` varchar(45) DEFAULT NULL, `id_admin` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `infermier` -- INSERT INTO `infermier` (`id`, `nom`, `prenom`, `mail`, `password`, `id_admin`) VALUES (1, 'AA', 'AA', 'AAAA', 'AAAAA', NULL), (2, 'a', 'a', 'a', 'a', NULL), (3, 'T', 'T', 'T', 'T', NULL); -- -------------------------------------------------------- -- -- Structure de la table `medcin` -- CREATE TABLE `medcin` ( `id` int(11) NOT NULL, `Nom` varchar(45) DEFAULT NULL, `prenom` varchar(45) DEFAULT NULL, `email` varchar(45) DEFAULT NULL, `password` varchar(45) DEFAULT NULL, `id_admin` int(11) DEFAULT NULL, `Medcincol` varchar(45) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `medcin` -- INSERT INTO `medcin` (`id`, `Nom`, `prenom`, `email`, `password`, `id_admin`, `Medcincol`) VALUES (1, 'tarek', 'moussaoui', 'tarikms1aa', 'MT AG 1', NULL, NULL), (3, '_Name', '_lastName', ' _user', ' _Passe', NULL, NULL), (4, 'tarik', 'moussaoui', 'mt@', 'mt', NULL, NULL), (7, '1', 'AAA', 'AA', 'AA', NULL, NULL), (10, '1', '1', '1', '1', NULL, NULL), (11, 't', 't', 't', 't', NULL, NULL), (13, '1', '1', '1', '1', NULL, NULL), (14, 'tar', 'mou', 'mt@mt.mt', 'mt', NULL, NULL); -- -------------------------------------------------------- -- -- Structure de la table `patient` -- CREATE TABLE `patient` ( `id` int(11) NOT NULL, `nom` varchar(45) DEFAULT NULL, `prenom` varchar(45) DEFAULT NULL, `age` varchar(45) DEFAULT NULL, `sex` varchar(45) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `patient` -- INSERT INTO `patient` (`id`, `nom`, `prenom`, `age`, `sex`) VALUES (2, 't', 'moussaoui', '13', 'male'), (4, 'u', 'u', '15', 'tG'); -- -------------------------------------------------------- -- -- Structure de la table `patient_has_rdv` -- CREATE TABLE `patient_has_rdv` ( `patient_id` int(11) NOT NULL, `RDV_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Structure de la table `rdv` -- CREATE TABLE `rdv` ( `id` int(11) NOT NULL, `id_patient` int(11) DEFAULT NULL, `id_medc` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `rdv` -- INSERT INTO `rdv` (`id`, `id_patient`, `id_medc`) VALUES (1, 1, 11), (2, 2, 11), (3, 2, 11), (4, 4, 11); -- -- Index pour les tables déchargées -- -- -- Index pour la table `admin` -- ALTER TABLE `admin` ADD PRIMARY KEY (`id`); -- -- Index pour la table `creneau_libre` -- ALTER TABLE `creneau_libre` ADD PRIMARY KEY (`id`); -- -- Index pour la table `creneau_libre_has_medcin` -- ALTER TABLE `creneau_libre_has_medcin` ADD PRIMARY KEY (`creneau_libre_id`,`Medcin_id`), ADD KEY `fk_creneau_libre_has_Medcin_Medcin1_idx` (`Medcin_id`), ADD KEY `fk_creneau_libre_has_Medcin_creneau_libre1_idx` (`creneau_libre_id`); -- -- Index pour la table `etat_patient` -- ALTER TABLE `etat_patient` ADD PRIMARY KEY (`id`), ADD KEY `fk_etat_patient_patient_idx` (`id_patient`); -- -- Index pour la table `infermier` -- ALTER TABLE `infermier` ADD PRIMARY KEY (`id`), ADD KEY `fk_infermier_Admin1_idx` (`id_admin`); -- -- Index pour la table `medcin` -- ALTER TABLE `medcin` ADD PRIMARY KEY (`id`), ADD KEY `fk_Medcin_Admin1_idx` (`id_admin`); -- -- Index pour la table `patient` -- ALTER TABLE `patient` ADD PRIMARY KEY (`id`); -- -- Index pour la table `patient_has_rdv` -- ALTER TABLE `patient_has_rdv` ADD PRIMARY KEY (`patient_id`,`RDV_id`), ADD KEY `fk_patient_has_RDV_RDV1_idx` (`RDV_id`), ADD KEY `fk_patient_has_RDV_patient1_idx` (`patient_id`); -- -- Index pour la table `rdv` -- ALTER TABLE `rdv` ADD PRIMARY KEY (`id`), ADD KEY `fk_RDV_Medcin1_idx` (`id_medc`), ADD KEY `fk_RDV_patient1_idx` (`id_patient`); -- -- AUTO_INCREMENT pour les tables déchargées -- -- -- AUTO_INCREMENT pour la table `admin` -- ALTER TABLE `admin` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT pour la table `creneau_libre` -- ALTER TABLE `creneau_libre` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; -- -- AUTO_INCREMENT pour la table `etat_patient` -- ALTER TABLE `etat_patient` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT pour la table `infermier` -- ALTER TABLE `infermier` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT pour la table `medcin` -- ALTER TABLE `medcin` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; -- -- AUTO_INCREMENT pour la table `patient` -- ALTER TABLE `patient` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT pour la table `rdv` -- ALTER TABLE `rdv` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
a3401ef8cf4e7e48abd1a9f5489682b39745ae34
SQL
atakage/SQL-
/GRADE(2019-10-15)정규화.sql
UTF-8
4,524
3.75
4
[]
no_license
-- GRADE 화면 -- DB이론상 정규화 과정 /* 1. 실무에ㅓㅅ 사용하던 엑셀 데이터 =========================== 학생이름 학년 학과 취미 =================================================== 홍길동 3 컴공과 낚시, 등산, 독서 2. 엑셀 데이터를 단순히 DBMS의 테이블로 구현 -- 만약 취미가 4개인 학생은 4개 중 3개만 선택해야 하고, 취미가 3개 미만인 학생은 사용하지 않는 컬럼이 있어 낭비 ===================================================================== 학생이름 학년 학과 취미1 취미2 취미3 ===================================================================== 홍길동 3 컴공과 낚시 등산 독서 3. 제1정규화가 수행된 TABLE 스키마 ===================================================================== 학생이름 학년 학과 취미 ===================================================================== 홍길동 3 컴공과 낚시 홍길동 3 컴공과 등산 홍길동 3 컴공과 독서 테이블의 고정값을 다른 테이블로 분리하고 테이블간 JOIN을 통해 VIEW 생성하도록 구조적 변경을 하는 작업(제2정규화) tbl_student ===================================================================== 학생이름 학년 학과 취미 ===================================================================== 홍길동 3 001 001 홍길동 3 001 002 홍길동 3 001 003 성춘향 2 002 003 tbl_hobby ================================================== CODE 취미 ================================================== 001 낚시 002 등산 003 독서 tbl_dept ================================================= CODE 학과명 담임교수 ================================================= 001 컴공과 002 경제학과 */ DESC tbl_score; /* 성적일람표 테이블 구조 --------- -------- ------------- S_ID NOT NULL NUMBER S_STD NOT NULL NVARCHAR2(50) S_SUBJECT NOT NULL NVARCHAR2(50) S_SCORE NOT NULL NUMBER(3) S_REMARK NVARCHAR2(50) */ SELECT s_subject FROM tbl_score GROUP BY s_subject; CREATE TABLE tbl_subject( sb_code VARCHAR2(4) PRIMARY KEY, sb_name nVARCHAR2(20) NOT NULL, sb_pro nVARCHAR2(20) ); -- 아래 두 SQL문 결과 값이 같으면 정상 수행 SELECT COUNT(*) FROM tbl_score; SELECT COUNT(*) FROM tbl_score SC, tbl_subject SB WHERE SC.s_subject = sb.sb_name; ALTER TABLE tbl_score ADD s_sbcode VARCHAR2(4); -- 임시 컬럼 추가(tbl_subject의 sb_code 컬럼과 구조가 같은 컬럼) SELECT * FROM tbl_score; UPDATE tbl_score SC SET s_sbcode = (SELECT sb_code FROM tbl_subject SB WHERE SC.s_subject = SB.sb_name); -- tbl_subject 테이블에서 과목명을 조회하여 해당하는 과목코드를 tbl_score 테이블의 -- s_sbcode 컬럼에 UPDATE 수행 SELECT SC.s_sbcode, SB.sb_code, SC.s_subject, SB.sb_name FROM tbl_score SC, tbl_subject SB WHERE SC.s_sbcode = SB.sb_code; ALTER TABLE tbl_score DROP COLUMN s_subject; ALTER TABLE tbl_score RENAME COLUMN s_sbcode TO s_subject; SELECT * FROM tbl_score; -- 제2정규화 완료 SELECT s_std, s_subject, SB.sb_name, SB.sb_pro, s_score FROM tbl_score SC, tbl_subject SB WHERE SC.s_subject = SB.sb_code; -- Table을 JOIN할 때 이름이 같은 컬럼이 존재하면 반드시 컬럼이 어떤 TABLE에 있는 커럶인지 명시해 주어야 함 /* TABLE1 : num, name, dept TABLE2 : num, subject, pro SELECT * FROM TABLE1, TABLE2 WHERE dept = num -- 라는 형식은 num의 누구의 table인지 알 수 없어 문법 오류 발생 */ SELECT s_id, s_std, s_subject, s_score, s_remark FROM tbl_score; SELECT * FROM tbl_score WHERE s_id > 600; DELETE FROM tbl_score WHERE s_id > 600; COMMIT;
true
bc160fbae87de40edf13da9dc42f635fc1b8230d
SQL
zoecahill1/dataRepresentation-project
/database.sql
UTF-8
1,789
3.578125
4
[]
no_license
create database project; use project; create table movies( id int NOT NULL AUTO_INCREMENT, name varchar(250), genre varchar(250), description varchar(1000), totalVotes int, PRIMARY KEY(id) ); INSERT INTO `movies` (`id`, `name`, `genre`, `description`, `totalVotes`) VALUES ('1', 'Avengers: Endgame', 'Action & Adventure', 'The grave course of events set in motion by Thanos that wiped out half the universe and fractured the Avengers ranks compels the remaining Avengers to take one final stand in Marvel Studios\' grand conclusion to twenty-two films, Avengers: Endgame.', '20'); INSERT INTO `movies` (`id`, `name`, `genre`, `description`, `totalVotes`) VALUES (NULL, 'The Wizard of Oz', 'Classics', 'L. Frank Baums classic tale comes to magisterial Technicolor life! The Wizard of Oz stars legendary Judy Garland as Dorothy, an innocent farm girl whisked out of her mundane earthbound existence into a land of pure imagination. Dorothys journey in Oz will take her through emerald forests, yellow brick roads, and creepy castles, all with the help of some unusual but earnest song-happy friends', '9'); INSERT INTO `movies` (`id`, `name`, `genre`, `description`, `totalVotes`) VALUES (NULL, 'The Lord of the Rings: The Return of the King', 'Fantasy', 'Gandalf and Aragorn lead the World of Men against Sauron\'s army to draw his gaze from Frodo and Sam as they approach Mount Doom with the One Ring.', '13'); INSERT INTO `movies` (`id`, `name`, `genre`, `description`, `totalVotes`) VALUES (NULL, 'Toy Story 4', 'Comedy', 'When a new toy called \"Forky\" joins Woody and the gang, a road trip alongside old and new friends reveals how big the world can be for a toy.', '10'); create table topmovies( id int NOT NULL AUTO_INCREMENT, Title varchar(250), Year int, PRIMARY KEY(id) );
true
c4005f11a1cf555606cc0b72bc2cd75d2fe55b73
SQL
Paul-loh/MSc_Dissertation
/DWH_Database/2 - Data Vault Layer - Tables/dv.Pacer_SatFXRates.sql
UTF-8
577
2.6875
3
[]
no_license
CREATE TABLE [dv].[SatFXRates] ( [HKeyFXRate] BINARY(20) NOT NULL, [Meta_LoadDateTime] DATETIME2 NOT NULL, [Meta_LoadEndDateTime] DATETIME2 NOT NULL DEFAULT N'9999-12-31', [Meta_RecordSource] NVARCHAR (1000) NOT NULL, [Meta_ETLProcessID] INT NOT NULL, -- FK to ID of import batch [HDiffFXRatePL] BINARY(20) NOT NULL, -- Include BKs; CurrencyCode and RateDate [SSCCcyCode] NVARCHAR (100) NOT NULL, [RateToGBP] NUMERIC (38,20) NULL, CONSTRAINT [PK_SatFXRates] PRIMARY KEY NONCLUSTERED ([HKeyFXRate], [Meta_LoadDateTime]) )
true
c55aed8d0a4611ea728e17c899c7e92747aa522c
SQL
assi98/nettside
/server/database/procedures/event_edit_procedures.sql
UTF-8
2,845
3.53125
4
[]
no_license
/** Drop all procedures for recreation */ DROP PROCEDURE IF EXISTS update_event_title; DROP PROCEDURE IF EXISTS update_event_location; DROP PROCEDURE IF EXISTS update_event_description; DROP PROCEDURE IF EXISTS update_event_start_time; DROP PROCEDURE IF EXISTS update_event_end_time; DROP PROCEDURE IF EXISTS update_event_category; DROP PROCEDURE IF EXISTS update_event_capacity; DROP PROCEDURE IF EXISTS update_event; /** Update event title IN event_title_in: the new event title IN event_id_in: the id of the event Issued by: UpdateEventTitle(json: Object, event_id: number) */ CREATE PROCEDURE update_event_title(IN event_title_in varchar(50), event_id_in int) BEGIN UPDATE event SET title = event_title_in WHERE event_id = event_id_in; END; /* Update event location */ Create PROCEDURE update_event_location(IN event_location_in varchar(100), event_id_in int) BEGIN UPDATE event SET location = event_location_in WHERE event_id = event_id_in; end; /* Update event description */ CREATE PROCEDURE update_event_description(IN event_description_in longtext, event_id_in int) BEGIN UPDATE event SET description = event_description_in WHERE event_id = event_id_in; end; /* Update event start time */ CREATE PROCEDURE update_event_start_time(IN event_start_time_in DATETIME, event_id_in int) BEGIN UPDATE event SET start_time = event_start_time_in WHERE event_id = event_id_in; end; /* Update event end time */ CREATE PROCEDURE update_event_end_time(IN event_end_time_in DATETIME, event_id_in int) BEGIN UPDATE event SET end_time = event_end_time_in WHERE event_id = event_id_in; end; /* Update event category */ CREATE PROCEDURE update_event_category(IN event_category_in VARCHAR(50), event_id_in int) BEGIN UPDATE event SET category = event_category_in WHERE event_id = event_id_in; end; /* Update Event capacity */ CREATE PROCEDURE update_event_capacity(IN event_capacity_in int, event_id_in int) BEGIN UPDATE event SET capacity = event_capacity_in WHERE event_id = event_id_in; end; /* Update entire event */ CREATE PROCEDURE update_event(IN event_title_in VARCHAR(50), event_description_in VARCHAR(500), event_location_in VARCHAR(100), event_start_time_in DATETIME, event_end_time_in DATETIME, event_category_in VARCHAR(50), event_capacity_in int, event_organizer_in int, event_id_in int) BEGIN UPDATE event SET title = event_title_in, description = event_description_in, location = event_location_in, start_time = event_start_time_in, end_time = event_end_time_in, category = event_category_in, capacity = event_capacity_in, organizer = event_organizer_in WHERE event_id = event_id_in; end;
true
2ec9d8ebbbba15d6600f32ca08da6e7488f5df2b
SQL
FreddieAbad/Ingenieria_de_Sistemas_Materias
/Mineria de Datos/Tarea 4 - Operaciones Multidimensionales/operacionesMultidimensionales.sql
UTF-8
4,800
3.609375
4
[]
no_license
use practica_dw_operaciones; select * from `estacion`; select * from `medicion`; select * from `responsable`; select * from `tiempo`; select * from `tipoestacion`; -- DRILL ACROSS -- general CREATE OR REPLACE VIEW tabla_vista_medicion_gb AS SELECT est.pais, test.tipoEstacion, sum(md.temperaturaCelsius) t_celsius, sum(md.humedadRelativa) hR, sum(md.viento) viento FROM medicion as md INNER JOIN estacion as est on md.idestacion=est.idestacion INNER JOIN responsable as resp on resp.idresponsable=md.idresponsable INNER JOIN tipoestacion as test on test.idtipoEstacion=md.idtipoestacion INNER JOIN tiempo as tp on tp.idtiempo = md.idtiempo GROUP BY test.tipoEstacion; -- especifico CREATE OR REPLACE VIEW tabla_vista_medicion_da AS SELECT est.nombreEstacion, est.pais, resp.nombreResponsable, test.tipoEstacion, tp.mes, tp.anio, md.temperaturaCelsius t_celsius, md.humedadRelativa hR, md.viento viento FROM medicion as md INNER JOIN estacion as est on md.idestacion=est.idestacion INNER JOIN responsable as resp on resp.idresponsable=md.idresponsable INNER JOIN tipoestacion as test on test.idtipoEstacion=md.idtipoestacion INNER JOIN tiempo as tp on tp.idtiempo = md.idtiempo; select * from tabla_vista_medicion_gb; select * from tabla_vista_medicion_da; -- Funcion Pivote CREATE OR REPLACE VIEW tabla_vista_medicion_piv AS SELECT est.nombreEstacion, est.pais, resp.nombreResponsable, test.tipoEstacion, tp.idtiempo ,tp.mes, tp.anio, md.temperaturaCelsius t_celsius, md.humedadRelativa hR, md.viento viento FROM medicion as md INNER JOIN estacion as est on md.idestacion=est.idestacion INNER JOIN responsable as resp on resp.idresponsable=md.idresponsable INNER JOIN tipoestacion as test on test.idtipoEstacion=md.idtipoestacion INNER JOIN tiempo as tp on tp.idtiempo = md.idtiempo; CREATE OR REPLACE VIEW tp_nomest AS select nombreEstacion, pais, nombreResponsable, tipoestacion, mes, anio, t_celsius, hR, viento from tabla_vista_medicion_piv order by nombreEstacion; CREATE OR REPLACE VIEW tp_nomresp AS select nombreResponsable, nombreEstacion, pais, tipoestacion, mes, anio, t_celsius, hR, viento from tabla_vista_medicion_piv order by nombreResponsable ASC; CREATE OR REPLACE VIEW tp_tipest AS select tipoestacion, nombreEstacion, pais, nombreResponsable, mes, anio, t_celsius, hR, viento from tabla_vista_medicion_piv order by tipoestacion ASC; select * from tabla_vista_medicion_piv; select * from tp_nomest; select * from tp_nomresp; select * from tp_tipest; -- PAGE CREATE OR REPLACE VIEW vista_medicion_page_digital AS SELECT est.nombreEstacion, est.pais, resp.nombreResponsable, test.tipoEstacion, tp.mes, tp.anio, md.temperaturaCelsius t_celsius, md.humedadRelativa hR, md.viento viento FROM medicion as md INNER JOIN estacion as est on md.idestacion=est.idestacion INNER JOIN responsable as resp on resp.idresponsable=md.idresponsable INNER JOIN tipoestacion as test on test.idtipoEstacion=md.idtipoestacion INNER JOIN tiempo as tp on tp.idtiempo = md.idtiempo where test.idtipoEstacion=1; CREATE OR REPLACE VIEW vista_medicion_page_analogico AS SELECT est.nombreEstacion, est.pais, resp.nombreResponsable, test.tipoEstacion, tp.mes, tp.anio, md.temperaturaCelsius t_celsius, md.humedadRelativa hR, md.viento viento FROM medicion as md INNER JOIN estacion as est on md.idestacion=est.idestacion INNER JOIN responsable as resp on resp.idresponsable=md.idresponsable INNER JOIN tipoestacion as test on test.idtipoEstacion=md.idtipoestacion INNER JOIN tiempo as tp on tp.idtiempo = md.idtiempo where test.idtipoEstacion=2; CREATE OR REPLACE VIEW vista_medicion_page_profesional AS SELECT est.nombreEstacion, est.pais, resp.nombreResponsable, test.tipoEstacion, tp.mes, tp.anio, md.temperaturaCelsius t_celsius, md.humedadRelativa hR, md.viento viento FROM medicion as md INNER JOIN estacion as est on md.idestacion=est.idestacion INNER JOIN responsable as resp on resp.idresponsable=md.idresponsable INNER JOIN tipoestacion as test on test.idtipoEstacion=md.idtipoestacion INNER JOIN tiempo as tp on tp.idtiempo = md.idtiempo where test.idtipoEstacion=3; CREATE OR REPLACE VIEW vista_medicion_page_portatil AS SELECT est.nombreEstacion, est.pais, resp.nombreResponsable, test.tipoEstacion, tp.mes, tp.anio, md.temperaturaCelsius t_celsius, md.humedadRelativa hR, md.viento viento FROM medicion as md INNER JOIN estacion as est on md.idestacion=est.idestacion INNER JOIN responsable as resp on resp.idresponsable=md.idresponsable INNER JOIN tipoestacion as test on test.idtipoEstacion=md.idtipoestacion INNER JOIN tiempo as tp on tp.idtiempo = md.idtiempo where test.idtipoEstacion=4; select * from vista_medicion_page_digital; select * from vista_medicion_page_analogico; select * from vista_medicion_page_profesional; select * from vista_medicion_page_portatil;
true
f9978629c5839e234e4759e18ddde94947648d30
SQL
yaldapersian84/roihunter
/src/main/resources/db/migration/V1__init.sql
UTF-8
3,167
3.6875
4
[]
no_license
-- ---------------------------------------------------------------------------- -- Schema db_fb_user_mng -- ---------------------------------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `db_fb_user_mng` ; -- ---------------------------------------------------------------------------- -- Table user_infos -- ---------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `user_infos` ( `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `fb_id` VARCHAR(255) NULL DEFAULT NULL, `gender` VARCHAR(255) NULL DEFAULT NULL, `name` VARCHAR(255) NULL DEFAULT NULL, `profile_pic` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `UK_50gyi0plo35jox882hpwumpdp` (`fb_id` ASC)) ENGINE = MyISAM DEFAULT CHARACTER SET = utf8; -- ---------------------------------------------------------------------------- -- Table user_photo_images -- ---------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `user_photo_images` ( `user_photo_id` BIGINT(20) NOT NULL, `user_image` VARCHAR(255) NOT NULL, PRIMARY KEY (`user_photo_id`, `user_image`)) ENGINE = MyISAM DEFAULT CHARACTER SET = utf8; -- ---------------------------------------------------------------------------- -- Table user_photos -- ---------------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `user_photos` ( `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `album_name` VARCHAR(255) NULL DEFAULT NULL, `created_time` VARCHAR(255) NULL DEFAULT NULL, `fb_id` VARCHAR(255) NULL DEFAULT NULL, `likes` INT(11) NULL DEFAULT NULL, `link` VARCHAR(255) NULL DEFAULT NULL, `name` LONGTEXT NULL DEFAULT NULL, `fk_info_id` BIGINT(20) NOT NULL, PRIMARY KEY (`id`), INDEX `user_photo_fk_info_id` (`fk_info_id` ASC)) ENGINE = MyISAM DEFAULT CHARACTER SET = utf8; SET FOREIGN_KEY_CHECKS = 1;
true
1b57036a572a74967288e7a3bb64eadfacb8f432
SQL
bikyeo/bikyeo
/src/main/webapp/META-INF/doc/event.sql
UTF-8
430
2.84375
3
[]
no_license
CREATE EVENT bikyeo.cyclereset ON SCHEDULE EVERY 24 HOUR STARTS STR_TO_DATE('2019-01-22 12:00:00 AM', '%Y-%m-%d %r') ON COMPLETION PRESERVE ENABLE DO BEGIN CALL bikyeo.cyclereset(); END # MySql event_scheduler 사용 여부 확인 show variables like 'event%' ; # Mysql event_scheduler 활성화 SET GLOBAL event_scheduler = ON ; # MySql EVENT 목록 보기 SHOW EVENTS ;
true
cc00c08f987a488c9c29f948c540466542656296
SQL
mc-bane/Blockchain-Robotics
/cFS/apps/ds/test_and_ground/asist/prc/scx_cpu1_ds_tbl3.prc
UTF-8
12,215
2.859375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
PROC scx_cpu1_ds_tbl3 ;******************************************************************************* ; Test Name: ds_tbl3 ; Test Level: Build Verification ; Test Type: Functional ; ; Test Description ; This procedure creates the initial CFS Data Storage (DS) Destination ; File and Packet Filter Table load image files. These files are currently ; used by the Filter and Reset No CDS test procedures. ; ; Prerequisite Conditions ; None. ; ; Assumptions and Constraints ; None. ; ; Change History ; Date Name Description ; 11/17/09 Walt Moleski Inital implemetation. ; 12/08/10 Walt Moleski Modified the procedure to use variables ; for the application name and ram disk. ; 01/31/17 Walt Moleski Updated for DS 2.5.0.0 using CPU1 for ; commanding and added a hostCPU variable ; for the utility procs to connect to the ; proper host IP address. ; ; Arguments ; None. ; ; Procedures Called ; Name Description ; ; Expected Test Results and Analysis ; ;********************************************************************** local logging = %liv (log_procedure) %liv (log_procedure) = FALSE #include "ut_statusdefs.h" #include "ut_cfe_info.h" #include "cfe_platform_cfg.h" #include "ds_platform_cfg.h" #include "ds_events.h" #include "ds_appdefs.h" write ";***********************************************************************" write "; Step 1.0: Define DS Destination File And Packet Filter Tables." write ";***********************************************************************" ;; Setup the appid based upon the CPU being used local fileAppid = 0x0F76 local filterAppid = 0x0F77 local seqFileMID = 0x0900 local timeFileMID = 0x0901 local oneFileMID = 0x0902 local xFileMID = 0x0903 local seqTimeFileMID = 0x0904 local timeSeqFileMID = 0x0905 local DSAppName = "DS" local fileTblName = DSAppName & "." & DS_DESTINATION_TBL_NAME local filterTblName = DSAppName & "." & DS_FILTER_TBL_NAME local hostCPU = "CPU3" ;; Setup the Destination File Table ;; Entry 1 SCX_CPU1_DS_DF_TBL_Description = "Filter Test" SCX_CPU1_DS_DF_TBL[0].Pathname = "/ram/" SCX_CPU1_DS_DF_TBL[0].Basename = "seq1" SCX_CPU1_DS_DF_TBL[0].Extension = ".dat" SCX_CPU1_DS_DF_TBL[0].FileNameType = DS_BY_COUNT SCX_CPU1_DS_DF_TBL[0].FileState = DS_ENABLED SCX_CPU1_DS_DF_TBL[0].FileSize = 1024 SCX_CPU1_DS_DF_TBL[0].FileAge = 600 SCX_CPU1_DS_DF_TBL[0].SeqCnt = 100 ;; Entry 2 SCX_CPU1_DS_DF_TBL_Description = "Filter Test" SCX_CPU1_DS_DF_TBL[1].Pathname = "/ram/" SCX_CPU1_DS_DF_TBL[1].Basename = "seq2" SCX_CPU1_DS_DF_TBL[1].Extension = ".dat" SCX_CPU1_DS_DF_TBL[1].FileNameType = DS_BY_COUNT SCX_CPU1_DS_DF_TBL[1].FileState = DS_ENABLED SCX_CPU1_DS_DF_TBL[1].FileSize = 1024 SCX_CPU1_DS_DF_TBL[1].FileAge = 600 SCX_CPU1_DS_DF_TBL[1].SeqCnt = 200 ;; Entry 3 SCX_CPU1_DS_DF_TBL_Description = "Filter Test" SCX_CPU1_DS_DF_TBL[2].Pathname = "/ram/" SCX_CPU1_DS_DF_TBL[2].Basename = "seq3" SCX_CPU1_DS_DF_TBL[2].Extension = ".dat" SCX_CPU1_DS_DF_TBL[2].FileNameType = DS_BY_COUNT SCX_CPU1_DS_DF_TBL[2].FileState = DS_ENABLED SCX_CPU1_DS_DF_TBL[2].FileSize = 1024 SCX_CPU1_DS_DF_TBL[2].FileAge = 600 SCX_CPU1_DS_DF_TBL[2].SeqCnt = 300 ;; Entry 4 SCX_CPU1_DS_DF_TBL_Description = "Filter Test" SCX_CPU1_DS_DF_TBL[3].Pathname = "/ram/" SCX_CPU1_DS_DF_TBL[3].Basename = "seq4" SCX_CPU1_DS_DF_TBL[3].Extension = ".dat" SCX_CPU1_DS_DF_TBL[3].FileNameType = DS_BY_COUNT SCX_CPU1_DS_DF_TBL[3].FileState = DS_ENABLED SCX_CPU1_DS_DF_TBL[3].FileSize = 1024 SCX_CPU1_DS_DF_TBL[3].FileAge = 600 SCX_CPU1_DS_DF_TBL[3].SeqCnt = 400 ;; Entry 5 SCX_CPU1_DS_DF_TBL[4].Pathname = "/ram/" SCX_CPU1_DS_DF_TBL[4].Basename = "time1" SCX_CPU1_DS_DF_TBL[4].Extension = "" SCX_CPU1_DS_DF_TBL[4].FileNameType = DS_BY_TIME SCX_CPU1_DS_DF_TBL[4].FileState = DS_ENABLED SCX_CPU1_DS_DF_TBL[4].FileSize = 1024 SCX_CPU1_DS_DF_TBL[4].FileAge = 60 SCX_CPU1_DS_DF_TBL[4].SeqCnt = 0 ;; Entry 6 SCX_CPU1_DS_DF_TBL[5].Pathname = "/ram/" SCX_CPU1_DS_DF_TBL[5].Basename = "time2" SCX_CPU1_DS_DF_TBL[5].Extension = "" SCX_CPU1_DS_DF_TBL[5].FileNameType = DS_BY_TIME SCX_CPU1_DS_DF_TBL[5].FileState = DS_ENABLED SCX_CPU1_DS_DF_TBL[5].FileSize = 1024 SCX_CPU1_DS_DF_TBL[5].FileAge = 60 SCX_CPU1_DS_DF_TBL[5].SeqCnt = 0 ;; Entry 7 SCX_CPU1_DS_DF_TBL[6].Pathname = "/ram/" SCX_CPU1_DS_DF_TBL[6].Basename = "time3" SCX_CPU1_DS_DF_TBL[6].Extension = "" SCX_CPU1_DS_DF_TBL[6].FileNameType = DS_BY_TIME SCX_CPU1_DS_DF_TBL[6].FileState = DS_ENABLED SCX_CPU1_DS_DF_TBL[6].FileSize = 1024 SCX_CPU1_DS_DF_TBL[6].FileAge = 60 SCX_CPU1_DS_DF_TBL[6].SeqCnt = 0 ;; Entry 8 SCX_CPU1_DS_DF_TBL[7].Pathname = "/ram/" SCX_CPU1_DS_DF_TBL[7].Basename = "time4" SCX_CPU1_DS_DF_TBL[7].Extension = "" SCX_CPU1_DS_DF_TBL[7].FileNameType = DS_BY_TIME SCX_CPU1_DS_DF_TBL[7].FileState = DS_ENABLED SCX_CPU1_DS_DF_TBL[7].FileSize = 1024 SCX_CPU1_DS_DF_TBL[7].FileAge = 60 SCX_CPU1_DS_DF_TBL[7].SeqCnt = 0 local maxEntry = DS_DEST_FILE_CNT - 1 ;; Clear the remaining entries in the table ;;for i = 8 to maxEntry do ;; SCX_CPU1_DS_DF_TBL[i].Pathname = "" ;; SCX_CPU1_DS_DF_TBL[i].Basename = "" ;; SCX_CPU1_DS_DF_TBL[i].Extension = "" ;; SCX_CPU1_DS_DF_TBL[i].FileNameType = 0 ;; SCX_CPU1_DS_DF_TBL[i].FileState = 0 ;; SCX_CPU1_DS_DF_TBL[i].FileSize = 0 ;; SCX_CPU1_DS_DF_TBL[i].FileAge = 0 ;; SCX_CPU1_DS_DF_TBL[i].SeqCnt = 0 ;;enddo ;;local endmnemonic = "SCX_CPU1_DS_DF_TBL[" & maxEntry & "].SeqCnt" local endmnemonic = "SCX_CPU1_DS_DF_TBL[7].SeqCnt" s create_tbl_file_from_cvt(hostCPU,fileAppid,"File Write Test File Table","ds_filtfile.tbl",fileTblName,"SCX_CPU1_DS_DF_TBL_Description",endmnemonic) ;; Setup the Packet Filter Table SCX_CPU1_DS_PF_TBL_Description = "Filter Test" ;; Entry 1 SCX_CPU1_DS_PF_TBL[0].MessageID = seqFileMID ;; File 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[0].Index = 0 SCX_CPU1_DS_PF_TBL[0].FilterParams[0].FilterType = DS_BY_COUNT SCX_CPU1_DS_PF_TBL[0].FilterParams[0].N_Value = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[0].X_Value = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[0].O_Value = 0 ;; File 2 SCX_CPU1_DS_PF_TBL[0].FilterParams[1].Index = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[1].FilterType = DS_BY_COUNT SCX_CPU1_DS_PF_TBL[0].FilterParams[1].N_Value = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[1].X_Value = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[1].O_Value = 0 ;; File 3 SCX_CPU1_DS_PF_TBL[0].FilterParams[2].Index = 2 SCX_CPU1_DS_PF_TBL[0].FilterParams[2].FilterType = DS_BY_COUNT SCX_CPU1_DS_PF_TBL[0].FilterParams[2].N_Value = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[2].X_Value = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[2].O_Value = 0 ;; File 4 SCX_CPU1_DS_PF_TBL[0].FilterParams[3].Index = 3 SCX_CPU1_DS_PF_TBL[0].FilterParams[3].FilterType = DS_BY_COUNT SCX_CPU1_DS_PF_TBL[0].FilterParams[3].N_Value = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[3].X_Value = 1 SCX_CPU1_DS_PF_TBL[0].FilterParams[3].O_Value = 0 ;; Entry 2 SCX_CPU1_DS_PF_TBL[1].MessageID = timeFileMID ;; File 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[0].Index = 4 SCX_CPU1_DS_PF_TBL[1].FilterParams[0].FilterType = DS_BY_TIME SCX_CPU1_DS_PF_TBL[1].FilterParams[0].N_Value = 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[0].X_Value = 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[0].O_Value = 0 ;; File 2 SCX_CPU1_DS_PF_TBL[1].FilterParams[1].Index = 5 SCX_CPU1_DS_PF_TBL[1].FilterParams[1].FilterType = DS_BY_TIME SCX_CPU1_DS_PF_TBL[1].FilterParams[1].N_Value = 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[1].X_Value = 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[1].O_Value = 0 ;; File 3 SCX_CPU1_DS_PF_TBL[1].FilterParams[2].Index = 6 SCX_CPU1_DS_PF_TBL[1].FilterParams[2].FilterType = DS_BY_TIME SCX_CPU1_DS_PF_TBL[1].FilterParams[2].N_Value = 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[2].X_Value = 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[2].O_Value = 0 ;; File 4 SCX_CPU1_DS_PF_TBL[1].FilterParams[3].Index = 7 SCX_CPU1_DS_PF_TBL[1].FilterParams[3].FilterType = DS_BY_TIME SCX_CPU1_DS_PF_TBL[1].FilterParams[3].N_Value = 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[3].X_Value = 1 SCX_CPU1_DS_PF_TBL[1].FilterParams[3].O_Value = 0 ;; Entry 3 SCX_CPU1_DS_PF_TBL[2].MessageID = oneFileMID ;; File 1 SCX_CPU1_DS_PF_TBL[2].FilterParams[0].Index = 0 SCX_CPU1_DS_PF_TBL[2].FilterParams[0].FilterType = DS_BY_COUNT SCX_CPU1_DS_PF_TBL[2].FilterParams[0].N_Value = 1 SCX_CPU1_DS_PF_TBL[2].FilterParams[0].X_Value = 3 SCX_CPU1_DS_PF_TBL[2].FilterParams[0].O_Value = 0 for j = 1 to DS_FILTERS_PER_PACKET-1 do SCX_CPU1_DS_PF_TBL[2].FilterParams[j].Index = DS_UNUSED SCX_CPU1_DS_PF_TBL[2].FilterParams[j].FilterType = DS_UNUSED SCX_CPU1_DS_PF_TBL[2].FilterParams[j].N_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[2].FilterParams[j].X_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[2].FilterParams[j].O_Value = DS_UNUSED enddo ;; Entry 4 SCX_CPU1_DS_PF_TBL[3].MessageID = xFileMID ;; File 1 SCX_CPU1_DS_PF_TBL[3].FilterParams[0].Index = 1 SCX_CPU1_DS_PF_TBL[3].FilterParams[0].FilterType = DS_BY_COUNT SCX_CPU1_DS_PF_TBL[3].FilterParams[0].N_Value = 1 SCX_CPU1_DS_PF_TBL[3].FilterParams[0].X_Value = 1 SCX_CPU1_DS_PF_TBL[3].FilterParams[0].O_Value = 0 for j = 1 to DS_FILTERS_PER_PACKET-1 do SCX_CPU1_DS_PF_TBL[3].FilterParams[j].Index = DS_UNUSED SCX_CPU1_DS_PF_TBL[3].FilterParams[j].FilterType = DS_UNUSED SCX_CPU1_DS_PF_TBL[3].FilterParams[j].N_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[3].FilterParams[j].X_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[3].FilterParams[j].O_Value = DS_UNUSED enddo ;; Entry 5 SCX_CPU1_DS_PF_TBL[4].MessageID = seqTimeFileMID ;; File 1 SCX_CPU1_DS_PF_TBL[4].FilterParams[0].Index = 4 SCX_CPU1_DS_PF_TBL[4].FilterParams[0].FilterType = DS_BY_COUNT SCX_CPU1_DS_PF_TBL[4].FilterParams[0].N_Value = 1 SCX_CPU1_DS_PF_TBL[4].FilterParams[0].X_Value = 1 SCX_CPU1_DS_PF_TBL[4].FilterParams[0].O_Value = 0 for j = 1 to DS_FILTERS_PER_PACKET-1 do SCX_CPU1_DS_PF_TBL[4].FilterParams[j].Index = DS_UNUSED SCX_CPU1_DS_PF_TBL[4].FilterParams[j].FilterType = DS_UNUSED SCX_CPU1_DS_PF_TBL[4].FilterParams[j].N_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[4].FilterParams[j].X_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[4].FilterParams[j].O_Value = DS_UNUSED enddo ;; Entry 6 SCX_CPU1_DS_PF_TBL[5].MessageID = timeSeqFileMID ;; File 1 SCX_CPU1_DS_PF_TBL[5].FilterParams[0].Index = 1 SCX_CPU1_DS_PF_TBL[5].FilterParams[0].FilterType = DS_BY_TIME SCX_CPU1_DS_PF_TBL[5].FilterParams[0].N_Value = 1 SCX_CPU1_DS_PF_TBL[5].FilterParams[0].X_Value = 1 SCX_CPU1_DS_PF_TBL[5].FilterParams[0].O_Value = 0 for j = 1 to DS_FILTERS_PER_PACKET-1 do SCX_CPU1_DS_PF_TBL[5].FilterParams[j].Index = DS_UNUSED SCX_CPU1_DS_PF_TBL[5].FilterParams[j].FilterType = DS_UNUSED SCX_CPU1_DS_PF_TBL[5].FilterParams[j].N_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[5].FilterParams[j].X_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[5].FilterParams[j].O_Value = DS_UNUSED enddo maxEntry = DS_PACKETS_IN_FILTER_TABLE - 1 local maxFilterParams = DS_FILTERS_PER_PACKET - 1 ;; Loop for the remaining entries defined in the table for entry = 6 to maxEntry do SCX_CPU1_DS_PF_TBL[entry].MessageID = DS_UNUSED for j = 0 to DS_FILTERS_PER_PACKET-1 do SCX_CPU1_DS_PF_TBL[entry].FilterParams[j].Index = DS_UNUSED SCX_CPU1_DS_PF_TBL[entry].FilterParams[j].FilterType = DS_UNUSED SCX_CPU1_DS_PF_TBL[entry].FilterParams[j].N_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[entry].FilterParams[j].X_Value = DS_UNUSED SCX_CPU1_DS_PF_TBL[entry].FilterParams[j].O_Value = DS_UNUSED enddo enddo endmnemonic = "SCX_CPU1_DS_PF_TBL[" & maxEntry & "].FilterParams[" & maxFilterParams & "].O_Value" s create_tbl_file_from_cvt(hostCPU,filterAppid,"Filter Test Filter Table","ds_filtfilter.tbl",filterTblName,"SCX_CPU1_DS_PF_TBL_Description",endmnemonic) %liv (log_procedure) = logging write ";*********************************************************************" write "; End procedure SCX_CPU1_ds_tbl3" write ";*********************************************************************" ENDPROC
true
a5f9152c05d67267008d96448dec5a3fef4852fc
SQL
DonnyZhao/pgml
/projects/titanic/models/staging/train/stg_train_fe_sex.sql
UTF-8
289
3.25
3
[ "MIT" ]
permissive
WITH base_0 AS ( SELECT * FROM {{ ref('stg_train_fe_baseline') }} ), dim_sex AS ( SELECT * FROM {{ ref('sex') }} ) select base.*, ds.sex_fe_1 FROM base_0 AS base INNER JOIN dim_sex AS ds ON base.passengerid = ds.passengerid
true
73e37723c882777ec3c37b2cbb06c8cb41937b61
SQL
endeavourhealth-discovery/DiscoveryQueryLibrary
/Projects/Waltham Forest Child Imms/Queries/wf_cohort.sql
UTF-8
827
3.6875
4
[ "Apache-2.0" ]
permissive
use data_extracts; drop procedure if exists createCohortWFChildImms; DELIMITER // CREATE PROCEDURE createCohortWFChildImms () BEGIN drop table if exists cohort; create table cohort as SELECT p.id as 'patient_id', p.id as 'group_by', age_years FROM ceg_compass_data.patient p JOIN ceg_compass_data.organization org on p.organization_id = org.id join ceg_compass_data.episode_of_care e on e.patient_id = p.id WHERE org.parent_organization_id in (315366836, 141517) -- All WF practices, new tpp has 881508960 as well -- and org.ods_code != 'F86018' and e.registration_type_id = 2 and e.date_registered <= now() and p.date_of_death IS NULL and (e.date_registered_end > now() or e.date_registered_end IS NULL) and (age_years < 20 or age_years is null); END// DELIMITER ;
true
c80b61d5190f32bfdd102da8a3f4e136d1759dfa
SQL
inselberge/Coworks.In
/database/custom_sprocs/User_Profile.sql
UTF-8
1,592
3.359375
3
[]
no_license
-- Find the user information quickly SELECT id, fullName, create_date FROM geekdom_members.viewUser WHERE id=587; CALL getUserBioByUserID('587'); -- User Bio SELECT id,description FROM geekdom_members.viewUser_Bio WHERE user_id=587; -- User Circle SELECT vuc.id, c.title, vuc.member_type FROM geekdom_members.viewUser_Circle vuc JOIN Circle c ON vuc.circle_id=c.id WHERE vuc.user_id=587; CALL getCirclesByUserID('587'); -- User Company SELECT vum.id as user_company_id, cm.id as company_id, cm.title as company_name FROM geekdom_members.viewUser_Company vum JOIN Company cm ON vum.company_id=cm.id WHERE user_id=587; CALL getUserCompanyByUserID('587'); -- User Contact TODO: clean User_Contact and remigrate information SELECT vuct.id,vuct.contact_description_id, cd.title as contact_description,vuct.contact_value FROM geekdom_members.viewUser_Contact vuct JOIN Contact_Description cd ON vuct.contact_description_id=cd.id WHERE user_id=587; -- User Coworking Space TODO: load this SELECT * FROM geekdom_members.viewUser_Coworking_Space WHERE user_id=587; -- User Office SELECT vuo.id, vuo.office_id, o.name as office_name FROM geekdom_members.viewUser_Office vuo JOIN Office o ON vuo.office_id=o.id WHERE user_id=587; -- User Tags SELECT concat('<a href="tag/',vut.tags_id,'" class="tag" title="click to find more users tagged with ',t.tag,'">',t.tag,'</a>') FROM geekdom_members.viewUser_Tags vut JOIN Tags t ON vut.tags_id=t.id WHERE user_id=587; CALL getUserTagsByUserID('587'); -- User Type SELECT * FROM geekdom_members.viewUser_Type WHERE user_id=587;
true
2733d2af8f05afaf94a88f632c1d8feee5f8aa70
SQL
nvipperl/Data-Analysis
/DillardsSalesSQL.sql
UTF-8
6,154
4.40625
4
[]
no_license
/*Customer behavior */ select count(transact.TRANSACTION_ID) as items,transact.cust_id, TRAN_DATE,store.STORE,TRAN_TYPE, DEPT_DESC, DEPTDEC_DESC, DEPTCENT_DESC,COLOR, sum(ORIG_PRICE) as orig_price , sum(TRAN_AMT) as sale_price , sum(TRAN_AMT)-sum(ORIG_PRICE) as discount,TENDER_TYPE from TRANSACT inner join sku on transact.sku = sku.SKU inner join DEPARTMENT on sku.dept =department.dept inner join CUSTOMER on customer.CUST_ID = transact.CUST_ID inner join store on store.store = transact.store where store.state = 'TX' and ORIG_PRICE>0 group by transact.cust_id,TRAN_DATE,store.STORE,TRAN_TYPE, DEPT_DESC, DEPTDEC_DESC, DEPTCENT_DESC,COLOR,TENDER_TYPE having count(transact.TRANSACTION_ID)>4 order by count(transact.TRANSACTION_ID) desc /* Sales analysis on Dillards stores */ select st.store,st.city,t.tran_date,sum(t.tran_amt) from store st inner join transact t on st.store=t.store where st.state='TX' and year(t.tran_date) in (2014,2015) group by st.store,st.city,t.tran_date select * from customer c inner join store st on c.preferred_store=st.store where c.zip_code in ('77060','77082') select st.store,count(1) as "Total Items Sold",count(distinct cust_id) as "Total Customers", count(distinct s.sku) as 'Distinct Items',count(distinct d.dept_desc) as 'Total Brands', count(distinct d.deptdec_desc) as 'Total Sub-categories', count(distinct d.deptcent_desc) as 'Total Categories' from store st inner join transact t on st.store=t.store inner join sku s on t.sku=s.sku inner join department d on s.dept=d.dept inner join sku_store ss on s.sku=ss.sku where st.city='Houston' and year(t.tran_date) in (2014,2015) group by st.store order by st.store /* Analysis on Dillard's profits */ /*Most successful department category in Texas? ( gross margin)*/ select sum(t.sale_price) as "Total Revenue",SUM(ss.retail) as "Total Cost of Units sold",d.DEPTCENT_DESC from transact t inner join sku_store ss on t.sku=ss.sku inner join sku s on s.sku=t.sku inner join DEPARTMENT d on d.dept=s.dept inner join store st on ss.store=st.store where st.state='TX' and t.ORIG_PRICE>0 group by d.DEPTCENT_DESC select sum(t.sale_price) as "Total Revenue",SUM(ss.retail) as "Total Cost of Units sold",d.DEPTCENT_DESC from transact t inner join sku_store ss on t.sku=ss.sku inner join sku s on s.sku=t.sku inner join DEPARTMENT d on d.dept=s.dept inner join store st on ss.store=st.store where st.state='TX' and t.ORIG_PRICE>0 AND YEAR(convert(date,t.TRAN_DATE))=2014 group by d.DEPTCENT_DESC select sum(t.sale_price) as "Total Revenue",SUM(ss.retail) as "Total Cost of Units sold",d.DEPTCENT_DESC from transact t inner join sku_store ss on t.sku=ss.sku inner join sku s on s.sku=t.sku inner join DEPARTMENT d on d.dept=s.dept inner join store st on ss.store=st.store where st.state='TX' and t.ORIG_PRICE>0 AND YEAR(convert(date,t.TRAN_DATE))=2015 group by d.DEPTCENT_DESC /*Most/Least successful brand*/ select sum(t.sale_price) as "Total Revenue",SUM(ss.retail) as "Total Cost of Units sold", d.DEPT_DESC from transact t inner join sku_store ss on t.sku=ss.sku inner join sku s on s.sku=t.sku inner join DEPARTMENT d on d.dept=s.dept inner join store st on ss.store=st.store where st.state='TX' and t.ORIG_PRICE>0 group by d.DEPT_DESC /*Performance of least successful brands over years (in 2014 and 2015)*/ select sum(t.sale_price) as "Total Revenue",SUM(ss.retail) as "Total Cost of Units sold",d.DEPT_DESC,d.DEPTCENT_DESC from transact t inner join sku_store ss on t.sku=ss.sku inner join sku s on s.sku=t.sku inner join DEPARTMENT d on d.dept=s.dept inner join store st on ss.store=st.store where st.state='TX' and t.ORIG_PRICE>0 AND YEAR(convert(date,t.TRAN_DATE))=2014 group by d.DEPT_DESC,d.DEPTCENT_DESC select sum(t.sale_price) as "Total Revenue",SUM(ss.retail) as "Total Cost of Units sold",d.DEPT_DESC,d.DEPTCENT_DESC from transact t inner join sku_store ss on t.sku=ss.sku inner join sku s on s.sku=t.sku inner join DEPARTMENT d on d.dept=s.dept inner join store st on ss.store=st.store where st.state='TX' and t.ORIG_PRICE>0 AND YEAR(convert(date,t.TRAN_DATE))=2015 group by d.DEPT_DESC,d.DEPTCENT_DESC /*No of SKUs released per brand over the years:*/ select sum(t.sale_price) as "Total Revenue",SUM(ss.retail) as "Total Cost of Units sold",d.DEPT_DESC,d.DEPTCENT_DESC,count(s.sku) from transact t inner join sku_store ss on t.sku=ss.sku inner join sku s on s.sku=t.sku inner join DEPARTMENT d on d.dept=s.dept inner join store st on ss.store=st.store where st.state='TX' and t.ORIG_PRICE>0 AND YEAR(convert(date,t.TRAN_DATE))=2014 and d.dept_desc in ('GIFTCARD','COSMETIC WORKROOM','MICHAEL KORS WOM FRA','D&G WOMENS FRAGRANCE','GIFTWRAP SUPPLY','D&G MENS FRAGRANCE','DONNA KARAN') group by d.DEPT_DESC,d.DEPTCENT_DESC select sum(t.sale_price) as "Total Revenue",SUM(ss.retail) as "Total Cost of Units sold",d.DEPT_DESC,d.DEPTCENT_DESC,count(s.sku) from transact t inner join sku_store ss on t.sku=ss.sku inner join sku s on s.sku=t.sku inner join DEPARTMENT d on d.dept=s.dept inner join store st on ss.store=st.store where st.state='TX' and t.ORIG_PRICE>0 AND YEAR(convert(date,t.TRAN_DATE))=2015 and d.dept_desc in ('GIFTCARD','COSMETIC WORKROOM','MICHAEL KORS WOM FRA','D&G WOMENS FRAGRANCE','GIFTWRAP SUPPLY','D&G MENS FRAGRANCE','DONNA KARAN') group by d.DEPT_DESC,d.DEPTCENT_DESC /* Analysis on Dillard's Departments*/ select count(TRANSACTION_ID) as items_sold,count(cust_ID) as count_customers, Tran_date, TRAN_TYPE, sum(ORIG_PRICE) as orig_MRP, sum(tran_amt) as sale_price, sum(orig_price)-sum(tRan_amt) as Discount, city , ZIP_CODE , d.DEPT, DEPT_DESC, DEPTCENT_DESC, DEPTDEC_DESC, CLASSIFICATION from TRANSACT t inner join STORE s on s.store = t.store inner join SKU k on k.SKU =t.SKU inner join DEPARTMENT d on d.DEPT = k.DEPT where STATE = 'TX' and orig_price>0 and year(TRAN_DATE) in (2014,2015) group by d.DEPT,DEPT_DESC, DEPTCENT_DESC, DEPTDEC_DESC, CLASSIFICATION , Tran_date, TRAN_TYPE,city , ZIP_CODE having count(TRANSACTION_ID)>9 order by count(TRANSACTION_ID) desc
true
dfa5b0c4bdfee5533eae242fb8f9dce8f2d89073
SQL
jenli810006995/SQL
/LeetCode/601. Human Traffic of Stadium/Human_Traffic_Stadium.sql
UTF-8
943
4.15625
4
[]
no_license
-- Write an SQL query to display the records with three or more rows with consecutive id's, and the number of people is greater than or equal to 100 for each. -- Return the result table ordered by visit_date in ascending order. select id, visit_date, people from Stadium where people >= 100 and ( id in (select id from Stadium where people >= 100) and id-1 in (select id from Stadium where people >= 100) and id-2 in (select id from Stadium where people >= 100) ) or ( id+2 in (select id from Stadium where people >= 100) and id+1 in (select id from Stadium where people >= 100) and id in (select id from Stadium where people >= 100) ) or ( id+1 in (select id from Stadium where people >= 100) and id in (select id from Stadium where people >= 100) and id-1 in (select id from Stadium where people >= 100) ) order by visit_date asc; -- Link: https://leetcode.com/problems/human-traffic-of-stadium/
true
8d8af331c5ecfc90e7996040eee749fb8d3cdf90
SQL
sunpigyu/yu
/汽车频道pc,手凤端new(有标题且pv>100).sql
UTF-8
937
3.4375
3
[]
no_license
--汽车频道pc端(有标题且pv>100) select distinct doc,title,pv,dt from web.auto_doc_20180521 where ci like '%auto%' and title !='None' order by dt,pv desc --汽车频道手凤端(有标题且pv>100) select distinct url, nvl(title, ' ') title, pv, to_char(day, 'yyyy-mm-dd') day from (select f.source, url, decode(chname, '', decode(ch, '0', '', ch), chname) path, pv, uv, title, day, rownum from wapnew.f_doc_20180521 f left join wapnew.d_path t on t.chpath = f.ch where day >= to_date('2018-03-01', 'yyyy-mm-dd') and day <=to_date('2018-05-20','yyyy-mm-dd') and f.url not like '%sharenews.%' and version = 'overall' and ch like 'http://iauto.ifeng.com/' || '%' ) where title is not null order by day ,pv desc
true
e3f1e8219652d6592d90947f4181d0b523870bea
SQL
Talos10/SOEN390-team-9
/scripts/createDB.sql
UTF-8
15,991
4.0625
4
[]
no_license
-- Create a local db user in order for the backend to be able to access the data. drop user if exists 'admin'@'localhost'; create user 'admin'@'localhost' identified by 'admin'; grant all privileges on * . * to 'admin'@'localhost'; ALTER USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin'; flush PRIVILEGES; drop schema if exists `soen_390_db`; create schema `soen_390_db`; USE `soen_390_db`; -- Table to store the users. CREATE TABLE `soen_390_db`.`user` ( `userID` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `role` VARCHAR(45) NOT NULL, `email` VARCHAR(45) NOT NULL, `password` CHAR(60) NOT NULL, `resetPasswordToken` VARCHAR(60), `resetPasswordExpires` BIGINT, UNIQUE INDEX `email_UNIQUE` (`email` ASC) VISIBLE, PRIMARY KEY (`userID`)) collate = utf8mb4_unicode_ci; -- Table to store the customers. CREATE TABLE `soen_390_db`.`customer` ( `customerId` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `email` VARCHAR(45) NOT NULL, `archived` TINYINT(1) NOT NULL DEFAULT 0, PRIMARY KEY (`customerId`)) collate = utf8mb4_unicode_ci; -- Table to store the raw materials, semi-finished goods, and finished goods all -- under one table. CREATE TABLE `soen_390_db`.`inventory_good` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `type` VARCHAR(45) NOT NULL, `processTime` INT NOT NULL, `quantity` INT NOT NULL DEFAULT 0, `uploadDate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `archived` TINYINT(1) NOT NULL DEFAULT 0, `cost` DECIMAL(10,2) NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `validItemType` CHECK (`type` IN ("raw", "semi-finished", "finished"))) collate = utf8mb4_unicode_ci; -- Table to store the raw goods (materials) needed to build the semi-finished goods. CREATE TABLE `soen_390_db`.`raw_good` ( `id` INT NOT NULL, `vendor` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `rawMaterialInventoryItemIDForeignKey` FOREIGN KEY (`id`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) collate = utf8mb4_unicode_ci; -- Table to store the semi-finished goods needed to build the finished goods. CREATE TABLE `soen_390_db`.`semi-finished_good` ( `id` INT NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `semiFinishedInventoryItemIDForeignKey` FOREIGN KEY (`id`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) collate = utf8mb4_unicode_ci; -- Table to store the finished goods that will be sold to the customers. CREATE TABLE `soen_390_db`.`finished_good` ( `id` INT NOT NULL, `price` DECIMAL(10,2) NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `finishedInventoryItemIDForeignKey` FOREIGN KEY (`id`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) collate = utf8mb4_unicode_ci; -- Table to store the various properties of the inventory items. CREATE TABLE `soen_390_db`.`property_of_good` ( `compositeId` INT NOT NULL, `name` VARCHAR(45) NOT NULL, `value` VARCHAR(45) NOT NULL, PRIMARY KEY (`compositeId`, `name`), CONSTRAINT `inventoryItemIDPropertyForeignKey` FOREIGN KEY (`compositeId`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) collate = utf8mb4_unicode_ci; CREATE TABLE `soen_390_db`.`composition_of_good` ( `compositeId` INT NOT NULL, `componentId` INT NOT NULL, `quantity` INT NOT NULL, PRIMARY KEY (`compositeId`, `componentId`), CONSTRAINT `inventoryItemIDComposedOfForeignKey` FOREIGN KEY (`compositeId`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `madeFromInventoryItemIDComposedOfForeignKey` FOREIGN KEY (`componentId`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `notMadeFromSameItem` CHECK (`compositeId` != `componentId`)) collate = utf8mb4_unicode_ci; -- Table to store the different orders given by the manufacturing division -- in order to buy raw goods and to create semi-finished and finished goods. CREATE TABLE `soen_390_db`.`manufacturing_order` ( `orderId` INT NOT NULL AUTO_INCREMENT, `status` VARCHAR(45) NOT NULL, `totalCost` DECIMAL(10,2) NOT NULL, `creationDate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `startDate` DATETIME, `estimatedEndDate` DATETIME, `completionDate` DATETIME, PRIMARY KEY (`orderId`), CONSTRAINT `validItemStatus` CHECK (`status` IN ("confirmed", "cancelled", "processing", "completed"))) collate = utf8mb4_unicode_ci; -- Table to store the bought raw goods and to store the various semi-finished goods that -- the manufacturing division has given an order to produce for each manufacturing order. CREATE TABLE `soen_390_db`.`manufacturing_ordered_good` ( `orderId` INT NOT NULL, `compositeId` INT NOT NULL, `totalCost` DECIMAL(10,2) NOT NULL, `quantity` INT NOT NULL, PRIMARY KEY (`orderId`, `compositeId`), CONSTRAINT `manufacturingOrderIDForeignKey` FOREIGN KEY (`orderId`) REFERENCES `soen_390_db`.`manufacturing_order` (`orderId`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `orderedGoodInventoryItemIDForeignKey` FOREIGN KEY (`compositeId`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE) collate = utf8mb4_unicode_ci; -- Table to store the different orders of finished goods put in by customers. CREATE TABLE `soen_390_db`.`customer_order` ( `orderId` INT NOT NULL AUTO_INCREMENT, `customerId` INT NOT NULL, `status` VARCHAR(45) NOT NULL, `totalPrice` DECIMAL(10,2) NOT NULL, `creationDate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `completionDate` DATETIME, PRIMARY KEY (`orderId`), CONSTRAINT `customerIdForeignKey` FOREIGN KEY (`customerId`) REFERENCES `soen_390_db`.`customer` (`customerId`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `validItemStatusCustomerOrder` CHECK (`status` IN ("confirmed", "cancelled", "completed"))) collate = utf8mb4_unicode_ci; -- Table to store events CREATE TABLE `soen_390_db`.`event` ( `id` INT NOT NULL AUTO_INCREMENT, `date` DATE NOT NULL, `time` TIME NOT NULL, `title` VARCHAR(200) NOT NULL, PRIMARY KEY (`id`)) collate = utf8mb4_unicode_ci; -- Table to store goals CREATE TABLE `soen_390_db`.`goal` ( `id` INT NOT NULL AUTO_INCREMENT, `completed` BOOLEAN NOT NULL, `targetDate` DATE NOT NULL, `title` VARCHAR(200) NOT NULL, PRIMARY KEY (`id`)) collate = utf8mb4_unicode_ci; -- date is of the format yyyy-mm-dd and the price can be given with a maximum of two digits after the dot. -- Table to store the various finished goods that are associated with each customer order. CREATE TABLE `soen_390_db`.`customer_ordered_good` ( `orderId` INT NOT NULL, `compositeId` INT NOT NULL, `totalPrice` DECIMAL(10,2) NOT NULL, `quantity` INT NOT NULL, PRIMARY KEY (`orderId`, `compositeId`), CONSTRAINT `customerOrderIDForeignKey` FOREIGN KEY (`orderId`) REFERENCES `soen_390_db`.`customer_order` (`orderId`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `ordersInventoryItemIDForeignKey` FOREIGN KEY (`compositeId`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE) collate = utf8mb4_unicode_ci; -- Table to store the different machines that will be used to execute the orders. CREATE TABLE `soen_390_db`.`machine` ( `machineId` INT NOT NULL AUTO_INCREMENT, `status` VARCHAR(45) NOT NULL, `numberOrderCompleted` INT NOT NULL DEFAULT 0, PRIMARY KEY (`machineId`), CONSTRAINT `validMachineStatus` CHECK (`status` IN ("free", "busy"))) collate = utf8mb4_unicode_ci; -- Table where we store the order on which a machine is working on. CREATE TABLE `soen_390_db`.`schedule` ( `machineId` INT NOT NULL, `orderId` INT NOT NULL, PRIMARY KEY (`machineId`, `orderId`), CONSTRAINT `scheduleMachineIdForeignKey` FOREIGN KEY (`machineId`) REFERENCES `soen_390_db`.`machine` (`machineId`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `scheduleManufacturingOrderIdForeignKey` FOREIGN KEY (`orderId`) REFERENCES `soen_390_db`.`manufacturing_order` (`orderId`) ON DELETE CASCADE ON UPDATE NO ACTION) collate = utf8mb4_unicode_ci; -- Triggers beginning DELIMITER $$ CREATE TRIGGER before_machine_delete BEFORE DELETE ON machine FOR EACH ROW BEGIN declare matches integer; set matches = ( SELECT COUNT(*) FROM schedule as s WHERE s.machineId = OLD.machineId ); IF matches > 0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Cannot delete machine because it is currently busy with executing an order.'; end if; END$$ DELIMITER ; -- Triggers end -- date is of the format yyyy-mm-dd and the price can be given with a maximum of two digits after the dot. INSERT `customer` (`name`, `email`) VALUES ("Francois Legault", "legault@govt.qc.ca"), ("Jackie Chan", "chan@hotmail.com"), ("Pauline Marois", "marois@outlook.com"), ("Mike Johnson", "mikej@gmail.com"), ("Adam Doug", "adam@hotmail.com") ; INSERT `inventory_good` (`name`, `type`, `quantity`, `processTime`, `cost`) VALUES ("carbon fiber", "raw", 1000, 1440, 5), ("steel", "raw", 1000, 1440, 10.5), ("rubber", "raw", 700, 1440, 15.5), ("leather", "raw", 600, 720, 20.5), ("titanum dioxide", "raw", 500, 800, 30.5), ("ethylene glycol", "raw", 800, 30, 40.5), ("paint concentrate", "raw", 700, 5, 50.5), ("paint", "semi-finished", 500, 10, 55.5), ("bike seat", "semi-finished", 150, 60, 32.23), ("carbon frame", "semi-finished", 155, 24, 34.43), ("rubber tire", "semi-finished", 160, 365, 24.23), ("steel wheel frame", "semi-finished", 150, 10, 25.25), ("steel bike handles", "semi-finished", 150, 40, 26.25), ("bike gears", "semi-finished", 400, 400, 24.52), ("steel breaks", "semi-finished", 120, 100, 251.21), ("le sebastien", "finished", 40, 2000, 300) ; INSERT `raw_good` (`id`, `vendor`) VALUES (1, "Maxon Factory"), (2, "Steelworks Laval"), (3, "Rubber.co"), (4, "Tanning Frank"), (5, "Chemical Facility Quebec"), (6, "Chemical Facility Quebec"), (7, "Chemical Facility Quebec") ; INSERT `semi-finished_good` (`id`) VALUES (8), (9), (10), (11), (12), (13), (14), (15) ; INSERT `finished_good` (`id`, `price`) VALUES (16, 1245.99) ; INSERT `manufacturing_order` (`status`, `creationDate`, `totalCost`, `completionDate`) VALUES ("completed", '2021-01-10 13:17:17', 300, '2021-01-11 13:17:17'), ("completed", '2021-01-10 13:17:17', 300, '2021-01-11 13:17:17'), ("completed", '2021-02-10 13:17:17', 31, '2021-02-11 13:17:17'), ("completed", '2021-03-10 13:17:17', 300, '2021-03-11 13:17:17'), ("completed", '2021-04-10 13:17:17', 20.50, '2021-04-11 13:17:17'), ("completed", '2021-05-10 13:17:17', 51.50, '2021-05-11 13:17:17'), ("completed", '2021-06-10 13:17:17', 300, '2021-06-11 13:17:17'), ("completed", '2021-07-10 13:17:17', 332.23, '2021-07-11 13:17:17'), ("completed", '2021-08-10 13:17:17', 40.50, '2021-08-11 13:17:17'), ("completed", '2021-09-10 13:17:17', 55.50, '2021-09-11 13:17:17'), ("completed", '2021-10-10 13:17:17', 34.43, '2021-10-11 13:17:17'), ("completed", '2021-11-10 13:17:17', 24.23, '2021-11-11 13:17:17'), ("completed", '2021-12-10 13:17:17', 30.50, '2021-12-11 13:17:17'), ("completed", '2021-02-10 13:17:17', 50.50, '2021-02-11 13:17:17'), ("completed", '2021-05-10 13:17:17', 5, '2021-05-11 13:17:17'), ("completed", '2021-06-10 13:17:17', 10.50, '2021-06-11 13:17:17'), ("completed", '2021-09-10 13:17:17', 15.50, '2021-09-11 13:17:17'), ("completed", '2021-12-10 13:17:17', 20.50, '2021-12-11 13:17:17') ; INSERT `customer_order` (`customerId`, `status`, `creationDate`, `totalPrice`) VALUES (2, "cancelled", '2015-05-10 13:17:17', 1245.99) ; INSERT `customer_order` (`customerId`, `status`, `creationDate`, `totalPrice`, `completionDate`) VALUES (1, "completed", '2021-05-09 13:17:17', 1245.99, '2021-05-10 13:17:17'), (3, "completed", '2021-05-17 13:17:17', 2491.98, '2021-05-18 13:17:17'), (4, "completed", '2021-01-17 13:17:17', 1245.99, '2021-01-18 13:17:17'), (5, "completed", '2021-01-09 13:17:17', 1245.99, '2021-01-10 13:17:17'), (4, "completed", '2021-02-10 13:17:17', 3737.97, '2021-02-11 13:17:17'), (4, "completed", '2021-03-11 13:17:17', 1245.99, '2021-03-12 13:17:17'), (5, "completed", '2021-04-14 13:17:17', 1245.99, '2021-04-15 13:17:17'), (3, "completed", '2021-06-14 13:17:17', 1245.99, '2021-06-15 13:17:17'), (3, "completed", '2021-07-14 13:17:17', 2491.98, '2021-07-15 13:17:17'), (2, "completed", '2021-08-14 13:17:17', 1245.99, '2021-08-15 13:17:17'), (4, "completed", '2021-09-14 13:17:17', 2491.98, '2021-09-15 13:17:17'), (5, "completed", '2021-10-14 13:17:17', 1245.99, '2021-10-15 13:17:17'), (3, "completed", '2021-11-14 13:17:17', 1245.99, '2021-11-15 13:17:17'), (2, "completed", '2021-12-14 13:17:17', 1245.99, '2021-12-15 13:17:17'), (1, "completed", '2021-04-06 13:17:17', 1245.99, '2021-04-07 13:17:17'), (5, "completed", '2021-06-14 13:17:17', 2491.98, '2021-06-15 13:17:17'), (3, "completed", '2021-10-14 13:17:17', 1245.99, '2021-10-15 13:17:17') ; INSERT `composition_of_good` (`compositeId`, `componentId`, `quantity`) VALUES (8, 5, 1), (8, 6, 1), (8, 7, 1), (9, 2, 1), (9, 4, 1), (10, 1, 2), (11, 3, 2), (12, 2, 1), (13, 2, 1), (14, 2, 2), (15, 2, 1), (16, 8, 1), (16, 9, 1), (16, 10, 1), (16, 11, 2), (16, 12, 2), (16, 13, 2), (16, 14, 1), (16, 15, 2) ; INSERT `manufacturing_ordered_good` (`orderId`, `compositeId`, `quantity`, `totalCost`) VALUES (1, 16, 1, 300), (2, 16, 1, 300), (3, 1, 1, 5.00), (3, 2, 1, 10.50), (3, 3, 1, 15.50), (4, 16, 1, 300), (5, 4, 1, 20.50), (6, 12, 1, 25.25), (6, 13, 1, 26.25), (7, 16, 1, 300), (8, 16, 1, 300), (8, 9, 1, 32.23), (9, 6, 1, 40.50), (10, 8, 1, 55.50), (11, 10, 1, 34.43), (12, 11, 1, 24.23), (13, 5, 1, 30.50), (14, 7, 1, 50.50), (15, 1, 1, 5.00), (16, 2, 1, 10.50), (17, 3, 1, 15.50), (18, 4, 1, 20.50) ; INSERT `customer_ordered_good` (`orderId`, `compositeId`, `quantity`, `totalPrice`) VALUES (1, 16, 1, 1245.99), (2, 16, 1, 1245.99), (3, 16, 2, 2491.98), (4, 16, 1, 1245.99), (5, 16, 1, 1245.99), (6, 16, 3, 3737.97), (7, 16, 1, 1245.99), (8, 16, 1, 1245.99), (9, 16, 1, 1245.99), (10, 16, 2, 2491.98), (11, 16, 1, 1245.99), (12, 16, 2, 2491.98), (13, 16, 1, 1245.99), (14, 16, 1, 1245.99), (15, 16, 1, 1245.99), (16, 16, 1, 1245.99), (17, 16, 2, 2491.98), (18, 16, 1, 1245.99) ; INSERT `machine` (`status`, `numberOrderCompleted`) VALUES ("free", 5), ("free", 10), ("free", 2) ; INSERT `property_of_good` (`compositeId`, `name`, `value`) VALUES (4, "leather quality", "full-grain"), (8, "color", "red"), (10, "size", "18"), (14, "number of speeds", "12"), (16, "finish", "chrome"), (16, "color", "red"), (16, "number of speeds", "12") ; INSERT `event` (`date`, `time`, `title`) VALUES ("2021-03-30", "11:00:00", "CEO company wide meeting"), ("2021-04-01", "11:00:00", "Easter chocolate bunny giveaway"), ("2021-05-07", "11:00:00", "Meeting with vendors for new raw materials") ; INSERT `goal` (`completed`, `targetDate`, `title`) VALUES (TRUE, "2021-04-10", "Build 2000 bikes"), (FALSE, "2021-05-05", "Make $200 000 of profit"), (FALSE, "2021-12-01", "Sell 1000 bikes") ; -- run the line below by itself if you want to delete the adminuser from your sql db: -- drop user if exists 'admin'@'localhost'; -- https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql CREATE TABLE IF NOT EXISTS `soen_390_db`.`goods` ( `id` INT NOT NULL, `schema` INT NULL, `quality` VARCHAR(255) NULL, PRIMARY KEY (`id`), UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE, INDEX `schema_idx` (`schema` ASC) VISIBLE, CONSTRAINT `schema` FOREIGN KEY (`schema`) REFERENCES `soen_390_db`.`inventory_good` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); INSERT `goods` (`id`, `schema`) VALUES (1, 1), (2, 1), (5, 1), (6, 2);
true
df25582cbfde63ed45bfc0ee700e91cad610ea57
SQL
hskEvelin/Parcel-Config-Address
/scripts/dump-ms_parcel_address-201802141140.sql
UTF-8
4,896
3.28125
3
[]
no_license
-- MySQL dump 10.13 Distrib 5.7.21, for Linux (x86_64) -- -- Host: localhost Database: ms_parcel_address -- ------------------------------------------------------ -- Server version 5.7.21-0ubuntu0.16.04.1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `country` -- CREATE DATABASE ms_parcel_address; USE ms_parcel_address; DROP TABLE IF EXISTS `country`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `country` ( `id` int(11) NOT NULL AUTO_INCREMENT, `zone_id` int(11) NOT NULL, `country` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `country` -- LOCK TABLES `country` WRITE; /*!40000 ALTER TABLE `country` DISABLE KEYS */; INSERT INTO `country` VALUES (1,1,'Deutschland'),(2,2,'Belgien'),(3,2,'Dänemark'),(4,2,'Frankreich'),(5,2,'Luxemburg'),(6,2,'Monaco'),(7,2,'Niederlande'),(8,2,'Österreich'),(9,3,'Großbritannien'),(10,3,'Italien'),(11,3,'Polen'),(12,3,'Slowenien'),(13,3,'Spanien'),(14,3,'Tschechien'),(15,3,'Ungarn'),(16,4,'Estland'),(17,4,'Kroatien'),(18,4,'Lettland'),(19,4,'Litauen'),(20,4,'Portugal'),(21,4,'Schweden'),(22,4,'Slowakai'),(23,5,'Bulgarien'),(24,5,'Finnland'),(25,5,'Rumänien'); /*!40000 ALTER TABLE `country` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `pricetable` -- DROP TABLE IF EXISTS `pricetable`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `pricetable` ( `id` int(11) NOT NULL AUTO_INCREMENT, `zone_id` int(11) NOT NULL, `size_id` int(11) NOT NULL, `price` double NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `pricetable` -- LOCK TABLES `pricetable` WRITE; /*!40000 ALTER TABLE `pricetable` DISABLE KEYS */; INSERT INTO `pricetable` VALUES (1,1,1,3.89),(2,1,2,4.29),(3,1,3,5.89),(4,1,4,9.89),(5,1,5,15.99),(6,2,1,9.19),(7,2,2,11.49),(8,2,3,15.29),(9,2,4,18.49),(10,2,5,24.99),(11,3,1,12.39),(12,3,2,12.99),(13,3,3,18.29),(14,3,4,22.49),(15,3,5,29.99),(16,4,1,14.89),(17,4,2,18.79),(18,4,3,19.99),(19,4,4,27.19),(20,4,5,31.99),(21,5,1,17.89),(22,5,2,24.49),(23,5,3,25.99),(24,5,4,30.99),(25,5,5,43.49); /*!40000 ALTER TABLE `pricetable` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `size` -- DROP TABLE IF EXISTS `size`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `size` ( `id` int(11) NOT NULL AUTO_INCREMENT, `label` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `size` -- LOCK TABLES `size` WRITE; /*!40000 ALTER TABLE `size` DISABLE KEYS */; INSERT INTO `size` VALUES (1,'XS'),(2,'S'),(3,'M'),(4,'L'),(5,'XL'); /*!40000 ALTER TABLE `size` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `zone` -- DROP TABLE IF EXISTS `zone`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `zone` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `zone` -- LOCK TABLES `zone` WRITE; /*!40000 ALTER TABLE `zone` DISABLE KEYS */; INSERT INTO `zone` VALUES (1,'DE'),(2,'Euro1'),(3,'Euro2'),(4,'Euro3'),(5,'Euro4'); /*!40000 ALTER TABLE `zone` ENABLE KEYS */; UNLOCK TABLES; -- -- Dumping routines for database 'ms_parcel_address' -- /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2018-02-14 11:40:58
true
6d5f3553fec5dffa100aa77ac8b8606103a96656
SQL
lisandrascruz/ufrpe_search
/bd/coordenacoes.sql
UTF-8
2,690
3.21875
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.3.11 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: 11-Maio-2015 às 21:14 -- Versão do servidor: 5.6.24 -- PHP Version: 5.6.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: `ufrpe_search` -- -- -------------------------------------------------------- -- -- Estrutura da tabela `coordenacoes` -- CREATE TABLE IF NOT EXISTS `coordenacoes` ( `id` int(11) NOT NULL, `nome_coordenacao` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `email` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `telefone` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Extraindo dados da tabela `coordenacoes` -- INSERT INTO `coordenacoes` (`id`, `nome_coordenacao`, `email`, `telefone`) VALUES (1, 'Agronomia', 'coordenacao@ag.ufrpe.br', NULL), (2, 'Bacharelado em Administração', 'coordenacao@ba.ufrpe.br', NULL), (3, 'Bacharelado em Ciências Biológicas', 'coordenacao@bcb.ufrpe.br', NULL), (4, 'Bacharelado em Ciência da Computação', 'coordenacao@bcc.ufrpe.br', NULL), (5, 'Bacharelado em Ciências Sociais', 'coordenacao@bcs.ufrpe.br', NULL), (6, 'Bacharelado em Ciências Econômicas', 'coordenacao@bce.ufrpe.br', NULL), (7, 'Bacharelado em Economia Doméstica', 'coordenacao@bed.ufrpe.br', NULL), (8, 'Bacharelado em Sistemas de Informação', 'coordenacao@bsi.ufrpe.br', NULL), (9, 'Engenharia Agrícola e Ambiental', 'coordenacao@eagri.ufrpe.br', NULL), (10, 'Engenharia Florestal', 'coordenacao@efl.ufrpe.br', NULL), (11, 'Engenharia de Pesca', 'coordenacao@ep.ufrpe.br', NULL), (12, 'Bacharelado em Gastronomia', 'coordenacao@gsa.ufrpe.br', NULL), (13, 'Licenciatura em Educação Física', 'coordenacao@lef.ufrpe.br', NULL), (14, 'Licenciatura Plena em Ciências Biológicas', 'coordenacao@lcb.ufrpe.br', NULL), (15, 'Licenciatura Plena em Ciências Agrícolas', 'coordenacao@lca.ufrpe.br', NULL), (16, 'Licenciatura Plena em Computação', 'coordencao@lc.ufrpe.br', NULL), (17, 'Licenciatura Plena em Física', 'coordenacao@lf.ufrpe.br', NULL), (18, 'Licenciatura Plena', 'coordenacao@lh.ufrpe.br', NULL), (19, 'Licenciatura em Letras', 'coordenacao@ll.ufrpe.br', NULL), (20, 'Licenciatura Plena em Matemática', 'coordenacao@lm.ufrpe.br', NULL), (21, 'Licenciatura Plena em Pedagogia', 'coordenacao@lns.ufrpe.br', NULL), (22, 'Licenciatura Plena em Química', 'coordenacao@lq.ufrpe.br', NULL), (23, 'Medicina Veterinária', 'coordenacao@mv.ufrpe.br', NULL), (24, 'Zootecnia', 'coordenacao@cz.ufrpe.br', NULL); -- -- Indexes for dumped tables -- -- -- Indexes for table `coordenacoes` -- ALTER TABLE `coordenacoes` ADD UNIQUE KEY `id` (`id`); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true
031a6e1200f8ec140d5a8fdd61ca60f6c09b2356
SQL
janatumpa/My-Project
/db/promanagement.sql
UTF-8
13,852
2.9375
3
[]
no_license
-- phpMyAdmin SQL Dump -- version 4.5.4.1deb2ubuntu2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: May 09, 2017 at 11:37 AM -- Server version: 5.7.18-0ubuntu0.16.04.1 -- PHP Version: 5.6.30-7+deb.sury.org~xenial+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: `promanagement` -- -- -------------------------------------------------------- -- -- Table structure for table `pro_admin` -- CREATE TABLE `pro_admin` ( `admin_id` int(11) NOT NULL, `Name` varchar(255) COLLATE latin1_general_ci NOT NULL, `admin_username` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '', `admin_password` varchar(255) COLLATE latin1_general_ci NOT NULL DEFAULT '', `admin_type` varchar(50) COLLATE latin1_general_ci NOT NULL, `email` varchar(255) COLLATE latin1_general_ci NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- -- Dumping data for table `pro_admin` -- INSERT INTO `pro_admin` (`admin_id`, `Name`, `admin_username`, `admin_password`, `admin_type`, `email`) VALUES (1, 'MeMe Admin', 'projectmanage@2017', 'projectmanage@2017', 'admin', 'admin@gmail.com'); -- -------------------------------------------------------- -- -- Table structure for table `pro_category` -- CREATE TABLE `pro_category` ( `cat_id` int(11) NOT NULL, `category` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_category` -- INSERT INTO `pro_category` (`cat_id`, `category`) VALUES (1, 'Blog'), (2, 'Informative'), (3, 'E-Commerce'); -- -------------------------------------------------------- -- -- Table structure for table `pro_customer` -- CREATE TABLE `pro_customer` ( `C_id` int(11) NOT NULL, `S_id` int(11) NOT NULL, `Name` varchar(256) NOT NULL, `Company` varchar(256) NOT NULL, `Location` varchar(256) NOT NULL, `Phone` varchar(256) NOT NULL, `Email` varchar(256) NOT NULL, `Nature_of_business` varchar(256) NOT NULL, `Date` varchar(256) NOT NULL, `CusStatus` enum('Yes','No') NOT NULL DEFAULT 'No' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_customer` -- INSERT INTO `pro_customer` (`C_id`, `S_id`, `Name`, `Company`, `Location`, `Phone`, `Email`, `Nature_of_business`, `Date`, `CusStatus`) VALUES (1, 5, 'Barry Allen', 'Star Labs', 'Star City', '2254789654', 'barry@gmail.com', 'Laboratory Services', '2017-05-09 04:44:22', 'Yes'); -- -------------------------------------------------------- -- -- Table structure for table `pro_dev_notes` -- CREATE TABLE `pro_dev_notes` ( `nid` int(11) NOT NULL, `dev_id` int(11) NOT NULL, `proj_id` int(11) NOT NULL, `notes` blob NOT NULL, `adddate` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `pro_dev_registration` -- CREATE TABLE `pro_dev_registration` ( `D_id` int(11) NOT NULL, `DevReg_No` varchar(256) NOT NULL, `D_image` varchar(256) NOT NULL, `Dev_Name` varchar(256) NOT NULL, `D_Username` varchar(256) NOT NULL, `Developer_id` varchar(256) NOT NULL, `Email_Id` varchar(256) NOT NULL, `Phone_No` varchar(256) NOT NULL, `D_Gen` varchar(50) NOT NULL, `D_Marital` varchar(50) NOT NULL, `D_address` varchar(256) NOT NULL, `D_State` varchar(256) NOT NULL, `D_Zip` varchar(256) NOT NULL, `Designation` varchar(256) NOT NULL, `Pwd` varchar(256) NOT NULL, `RegistDate` date NOT NULL, `EmailVerification` varchar(256) NOT NULL DEFAULT '''Yes'',''No''', `D_FB` varchar(256) NOT NULL, `D_LI` varchar(256) NOT NULL, `D_TW` varchar(256) NOT NULL, `DevStatus` enum('Yes','No') NOT NULL DEFAULT 'No', `admin_user` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_dev_registration` -- INSERT INTO `pro_dev_registration` (`D_id`, `DevReg_No`, `D_image`, `Dev_Name`, `D_Username`, `Developer_id`, `Email_Id`, `Phone_No`, `D_Gen`, `D_Marital`, `D_address`, `D_State`, `D_Zip`, `Designation`, `Pwd`, `RegistDate`, `EmailVerification`, `D_FB`, `D_LI`, `D_TW`, `DevStatus`, `admin_user`) VALUES (1, 'MeMe170500001', '', 'Supratim Sen', '', 'MEME2017SUPRATIM', 'supratim.sen@memeinfotech.com', '9475642091', '', '', '', '', '', 'Php', 'c3VwcmF0aW0=', '2017-05-08', 'Yes', '', '', '', 'Yes', ''); -- -------------------------------------------------------- -- -- Table structure for table `pro_draft` -- CREATE TABLE `pro_draft` ( `Draft_Id` int(11) NOT NULL, `S_id` int(11) NOT NULL, `D_id` int(11) NOT NULL, `Admin_id` int(11) NOT NULL, `Email_Id` varchar(256) NOT NULL, `Subject` varchar(256) NOT NULL, `Message` blob NOT NULL, `Date` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `pro_inbox` -- CREATE TABLE `pro_inbox` ( `M_Id` int(11) NOT NULL, `S_id` int(11) NOT NULL, `D_id` int(11) NOT NULL, `Admin_id` int(11) NOT NULL, `Email_Id` varchar(256) NOT NULL, `Subject` varchar(256) NOT NULL, `Message` blob NOT NULL, `Date` datetime NOT NULL, `status` varchar(10) NOT NULL DEFAULT 'ur', `del_status` tinyint(4) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_inbox` -- INSERT INTO `pro_inbox` (`M_Id`, `S_id`, `D_id`, `Admin_id`, `Email_Id`, `Subject`, `Message`, `Date`, `status`, `del_status`) VALUES (1, 0, 0, 1, 'supratim.sen@memeinfotech.com', 'test message', 0x486920537570726174696d3c62723e, '2017-05-08 14:27:13', 'r', 0), (2, 5, 0, 0, 'supratim.sen@memeinfotech.com', 'test', 0x6869696920737570, '2017-05-08 14:51:01', 'r', 0); -- -------------------------------------------------------- -- -- Table structure for table `pro_project` -- CREATE TABLE `pro_project` ( `P_id` int(11) NOT NULL, `S_id` int(11) NOT NULL, `D_id` int(11) NOT NULL, `C_Name` varchar(256) NOT NULL, `Domain` varchar(256) NOT NULL, `Name` varchar(256) NOT NULL, `Type` varchar(256) NOT NULL, `Category` varchar(256) NOT NULL, `File_Upload` varchar(256) NOT NULL, `RegistDate` date NOT NULL, `assign_date` date NOT NULL, `ProStatus` enum('create','assign','working','complete','pending','live') NOT NULL DEFAULT 'pending' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_project` -- INSERT INTO `pro_project` (`P_id`, `S_id`, `D_id`, `C_Name`, `Domain`, `Name`, `Type`, `Category`, `File_Upload`, `RegistDate`, `assign_date`, `ProStatus`) VALUES (1, 5, 1, 'Barry Allen', 'flash', 'flash', 'Informative', 'Dynamin', '14943051510,2017-05-09_Pending Functionality.docx', '2017-05-09', '2017-05-09', 'working'); -- -------------------------------------------------------- -- -- Table structure for table `pro_project_message` -- CREATE TABLE `pro_project_message` ( `id` int(11) NOT NULL, `project_id` int(11) NOT NULL, `message` text NOT NULL, `date` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_project_message` -- INSERT INTO `pro_project_message` (`id`, `project_id`, `message`, `date`) VALUES (1, 1, '<h2>What is Lorem Ipsum?</h2>Lorem Ipsum&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br>', '2017-05-09 08:46:11'); -- -------------------------------------------------------- -- -- Table structure for table `pro_sale_registration` -- CREATE TABLE `pro_sale_registration` ( `S_id` int(11) NOT NULL, `SaleReg_No` varchar(256) NOT NULL, `S_image` varchar(256) NOT NULL, `Sale_Name` varchar(256) NOT NULL, `S_Username` varchar(256) NOT NULL, `Sale_id` varchar(255) NOT NULL, `EmailId` varchar(256) NOT NULL, `PhoneNo` varchar(256) NOT NULL, `S_Gen` varchar(50) NOT NULL, `S_Marital` varchar(256) NOT NULL, `S_address` varchar(256) NOT NULL, `S_State` varchar(256) NOT NULL, `S_Zip` varchar(256) NOT NULL, `Position` varchar(256) NOT NULL, `S_FB` varchar(50) NOT NULL, `S_LI` varchar(50) NOT NULL, `S_TW` varchar(50) NOT NULL, `Password` varchar(256) NOT NULL, `RegistDate` date NOT NULL, `EmailVerification` varchar(256) NOT NULL DEFAULT '''Yes'',''No''', `SaleStatus` varchar(256) NOT NULL DEFAULT '''Yes'',''No''', `admin_user` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_sale_registration` -- INSERT INTO `pro_sale_registration` (`S_id`, `SaleReg_No`, `S_image`, `Sale_Name`, `S_Username`, `Sale_id`, `EmailId`, `PhoneNo`, `S_Gen`, `S_Marital`, `S_address`, `S_State`, `S_Zip`, `Position`, `S_FB`, `S_LI`, `S_TW`, `Password`, `RegistDate`, `EmailVerification`, `SaleStatus`, `admin_user`) VALUES (5, 'MeMe170500001', '', 'Nandan Mishra', '', 'MeMe2017', 'nandan.mishra@memeinfotech.com', '98745633210', '', '', '', '', '', 'TL', '', '', '', 'MTIzNDU2', '2017-05-08', 'Yes', 'Yes', ''); -- -------------------------------------------------------- -- -- Table structure for table `pro_sent` -- CREATE TABLE `pro_sent` ( `M_Id` int(11) NOT NULL, `S_id` int(11) NOT NULL, `D_id` int(11) NOT NULL, `Admin_id` int(11) NOT NULL, `Email_Id` varchar(256) NOT NULL, `Subject` varchar(256) NOT NULL, `Message` blob NOT NULL, `Date` datetime NOT NULL, `status` varchar(10) NOT NULL DEFAULT 'ur', `del_status` tinyint(4) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_sent` -- INSERT INTO `pro_sent` (`M_Id`, `S_id`, `D_id`, `Admin_id`, `Email_Id`, `Subject`, `Message`, `Date`, `status`, `del_status`) VALUES (1, 0, 0, 1, 'supratim.sen@memeinfotech.com', 'test message', 0x486920537570726174696d3c62723e, '2017-05-08 14:27:13', 'ur', 0), (2, 5, 0, 0, 'supratim.sen@memeinfotech.com', 'test', 0x6869696920737570, '2017-05-08 14:51:01', 'ur', 0); -- -------------------------------------------------------- -- -- Table structure for table `pro_type` -- CREATE TABLE `pro_type` ( `type_id` int(11) NOT NULL, `type` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `pro_type` -- INSERT INTO `pro_type` (`type_id`, `type`) VALUES (1, 'Static'), (2, 'Dynamic'); -- -- Indexes for dumped tables -- -- -- Indexes for table `pro_admin` -- ALTER TABLE `pro_admin` ADD PRIMARY KEY (`admin_id`); -- -- Indexes for table `pro_category` -- ALTER TABLE `pro_category` ADD PRIMARY KEY (`cat_id`); -- -- Indexes for table `pro_customer` -- ALTER TABLE `pro_customer` ADD PRIMARY KEY (`C_id`); -- -- Indexes for table `pro_dev_notes` -- ALTER TABLE `pro_dev_notes` ADD PRIMARY KEY (`nid`); -- -- Indexes for table `pro_dev_registration` -- ALTER TABLE `pro_dev_registration` ADD PRIMARY KEY (`D_id`); -- -- Indexes for table `pro_draft` -- ALTER TABLE `pro_draft` ADD PRIMARY KEY (`Draft_Id`); -- -- Indexes for table `pro_inbox` -- ALTER TABLE `pro_inbox` ADD PRIMARY KEY (`M_Id`); -- -- Indexes for table `pro_project` -- ALTER TABLE `pro_project` ADD PRIMARY KEY (`P_id`); -- -- Indexes for table `pro_project_message` -- ALTER TABLE `pro_project_message` ADD PRIMARY KEY (`id`); -- -- Indexes for table `pro_sale_registration` -- ALTER TABLE `pro_sale_registration` ADD PRIMARY KEY (`S_id`); -- -- Indexes for table `pro_sent` -- ALTER TABLE `pro_sent` ADD PRIMARY KEY (`M_Id`); -- -- Indexes for table `pro_type` -- ALTER TABLE `pro_type` ADD PRIMARY KEY (`type_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `pro_admin` -- ALTER TABLE `pro_admin` MODIFY `admin_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `pro_category` -- ALTER TABLE `pro_category` MODIFY `cat_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `pro_customer` -- ALTER TABLE `pro_customer` MODIFY `C_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `pro_dev_notes` -- ALTER TABLE `pro_dev_notes` MODIFY `nid` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `pro_dev_registration` -- ALTER TABLE `pro_dev_registration` MODIFY `D_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `pro_draft` -- ALTER TABLE `pro_draft` MODIFY `Draft_Id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `pro_inbox` -- ALTER TABLE `pro_inbox` MODIFY `M_Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `pro_project` -- ALTER TABLE `pro_project` MODIFY `P_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `pro_project_message` -- ALTER TABLE `pro_project_message` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `pro_sale_registration` -- ALTER TABLE `pro_sale_registration` MODIFY `S_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `pro_sent` -- ALTER TABLE `pro_sent` MODIFY `M_Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `pro_type` -- ALTER TABLE `pro_type` MODIFY `type_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
true