text
stringlengths
6
9.38M
CREATE DATABASE `cupcake`; USE `cupcake`; DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int NOT NULL AUTO_INCREMENT, `email` varchar(90) NOT NULL, `password` varchar(45) NOT NULL, `role` varchar(20) NOT NULL DEFAULT 'customer', `saldo` int(11), PRIMARY KEY (`id`), UNIQUE KEY `email_UNIQUE` (`email`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; CREATE TABLE topping( topping_id int(30), topping varchar(50), price int NOT NULL, primary key(topping) ); CREATE TABLE bottom( bottom_id int(30), bottom varchar(50), price int NOT NULL, primary key(bottom) ); INSERT INTO bottom(bottom, price) VALUES("Chocolate","5"),("Blueberry","5"),("Rasberry","5"),("Crispy","6"),("Strawberry","6"),("Rum/Raisin","7"),("Orange","8"),("Lemon","8"),("Blue Cheese","9"); INSERT INTO topping(topping, price) VALUES("Chocolate","5"),("Vanilla","5"),("Nutmeg","5"),("Pistacio","6"),("Almond","7"); CREATE TABLE cupcakeorder( cupcake_id int NOT NULL AUTO_INCREMENT, order_id int NOT NULL, amount int NOT NULL, topping varchar(50) NOT NULL, bottom varchar(50) NOT NULL, price int NOT NULL, PRIMARY KEY(cupcake_id), FOREIGN KEY(order_id) REFERENCES orders(order_id), FOREIGN KEY(topping) REFERENCES topping(topping), FOREIGN KEY(bottom) REFERENCES bottom(bottom) ); LOCK TABLES `users` WRITE; INSERT INTO `users` VALUES (1,'barbie@world.dk','jensen','customer'), (2,'ken@world.com','jensen','customer'), (3,'robin@gotham.com','batman','employee'); UNLOCK TABLES;
DROP TABLE `mangobazar`.`category`; CREATE TABLE `mangobazar`.`category` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `name` VARCHAR(250) NOT NULL, PRIMARY KEY (`id`));
CREATE DATABASE mydb; CREATE TABLE department ( id int NOT NULL AUTO_INCREMENT, name varchar(20) NOT NULL, created datetime, updated datetime, PRIMARY KEY (id), UNIQUE (name) ) ENGINE=InnoDB; CREATE TABLE employee ( id int NOT NULL AUTO_INCREMENT, department_id int NULL, name varchar(20) NOT NULL, email varchar(20) NOT NULL, created datetime, updated datetime, PRIMARY KEY (id), UNIQUE (email), FOREIGN KEY (department_id) REFERENCES department(id) ) ENGINE=InnoDB; INSERT INTO department(name,created,updated) VALUES ('General Affairs', now(), now()), ('Human Resources', now(), now()), ('Development', now(), now()); INSERT INTO employee(name,department_id,email,created,updated) VALUES ('John', 1, 'john@hoge.com', now(), now()), ('Bob', 2, 'bob@hoge.com', now(), now()), ('Smith', 3, 'smith@hoge.com', now(), now());
-- This file should undo anything in `up.sql` ALTER TABLE `users` DROP COLUMN `updated_at`; ALTER TABLE `users DROP COLUMN `created_at`
/* Create db and establish schema */ DROP DATABASE baseball; CREATE DATABASE baseball; \c baseball; CREATE TYPE league AS ENUM ('American League', 'National League'); CREATE TABLE Teams ( name text NOT NULL, city text NOT NULL, league league NOT NULL, division text NOT NULL, id serial PRIMARY KEY --Serial implies "NOT NULL" ); CREATE TABLE Players ( name text NOT NULL, position text, team_id int REFERENCES Teams(id), --NOTE: this table is created second because it references Teams. id serial PRIMARY KEY ); CREATE VIEW v_americanLeague as select * from Teams where league = 'American League'; CREATE VIEW v_nationalLeague as select * from Teams where league = 'National League'; /* Populate db */ -- National League INSERT INTO Teams VALUES('Braves', 'Atlanta', 'National League', 'East'); INSERT INTO Teams VALUES('Mets', 'New York', 'National League', 'East'); INSERT INTO Teams VALUES('Marlins', 'Miami', 'National League', 'East'); INSERT INTO Teams VALUES('Cubs', 'Chicago', 'National League', 'Central'); INSERT INTO Teams VALUES('Cardinals', 'Saint Louis', 'National League', 'Central'); INSERT INTO Teams VALUES('Giants', 'San Francisco', 'National League', 'West'); INSERT INTO Teams VALUES('Dodgers', 'Los Angeles', 'National League', 'West'); --American League INSERT INTO Teams VALUES('Astros', 'Houston', 'American League', 'West'); INSERT INTO Teams VALUES('A''s', 'Oakland', 'American League', 'West'); INSERT INTO Teams VALUES('Mariners', 'Seatle', 'American League', 'West'); INSERT INTO Teams VALUES('Royals', 'Kansas City', 'American League', 'Central'); INSERT INTO Teams VALUES('Tigers', 'Detroit', 'American League', 'Central'); INSERT INTO Teams VALUES('Blue Jays', 'Toronto', 'American League', 'East'); INSERT INTO Teams VALUES('Orioles', 'Baltimore', 'American League', 'East'); --Players INSERT INTO Players VALUES('Freddie Freeman', 'First Base', 1); INSERT INTO Players VALUES('Andrelton Simmons', 'Shortstop', 1); INSERT INTO Players VALUES('Bartolo Colon', 'Pitcher', 2); INSERT INTO Players VALUES('Giancarlo Stanton', 'Outfield', 3); INSERT INTO Players VALUES('Jon Lester', 'Pitcher', 4); INSERT INTO Players VALUES('Matt Carpenter', 'Third Base', 5); INSERT INTO Players VALUES('Buster Posey', 'Catcher', 6); INSERT INTO Players VALUES('Yasiel Puig', 'Outfield', 7); INSERT INTO Players VALUES('Evan Gattis', 'Designated Hitter', 8); INSERT INTO Players VALUES('Billy Butler', 'Designated Hitter', 9); INSERT INTO Players VALUES('Mike Zunino', 'Catcher', 10); INSERT INTO Players VALUES('Omar Infante', 'Second Base', 11); INSERT INTO Players VALUES('Al Alburquerque', 'Pitcher', 12); INSERT INTO Players VALUES('Jose Bautista', 'Outfield', 13); INSERT INTO Players VALUES('Manny Machado', 'Third Base', 14); INSERT INTO Players VALUES('Kyle Wren', 'Outfield'); --Note Kyle Wren hasn't made the big leagues yet
-- phpMyAdmin SQL Dump -- version 2.11.6 -- http://www.phpmyadmin.net -- -- Serveur: localhost -- Généré le : Sam 04 Octobre 2008 à 13:56 -- Version du serveur: 5.0.51 -- Version de PHP: 5.2.6 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Base de données: `scoutvillejuif_scout` -- -- -------------------------------------------------------- -- -- Structure de la table `planning` -- CREATE TABLE `planning` ( `id` int(11) NOT NULL auto_increment, `lieu` text NOT NULL, `date` text NOT NULL, `heure` text NOT NULL, PRIMARY KEY (`id`), KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ; -- -- Contenu de la table `planning` -- INSERT INTO `planning` (`id`, `lieu`, `date`, `heure`) VALUES (5, 'Brunoy', '5', '15H'), (7, 'NDA', '24 Oout', '18H'), (13, 'Brunoy', '188', '15H'); -- -------------------------------------------------------- -- -- Structure de la table `planningf` -- CREATE TABLE `planningf` ( `id` int(11) NOT NULL auto_increment, `lieu` text NOT NULL, `date` text NOT NULL, `heure` text NOT NULL, PRIMARY KEY (`id`), KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; -- -- Contenu de la table `planningf` -- INSERT INTO `planningf` (`id`, `lieu`, `date`, `heure`) VALUES (5, 'Brunoy', '5', '15H'), (7, 'Brunoy', '5', '15H'), (13, 'Brunoy', '188', '15H'), (14, 'Brunoy', '4', '15H');
select "a"."line1", "city"."name" as "city", "a"."district", "country"."name" as "country" from "addresses" as "a" join "cities" as "city" using ("cityId") join "countries" as "country" using ("countryId");
 -- (1)查询DEPT表显示所有部门名称. select d.dname from dept d; -- (2)查询EMP表显示所有雇员名及其全年收入(月收入=工资+补助),处理NULL行,并指定列别名为"年收入"。(NVL(comm,0) comm取空值时用0替代) select e.ename,(e.sal+nvl(e.comm,0))*12 年收入 from emp e; -- (3)查询显示不存在雇员的所有部门号。 select d.deptno from emp e,dept d where e.deptno (+)= d.deptno group by d.deptno having count(e.empno)=0; select distinct d.deptno from emp e ,dept d where e.deptno (+)= d.deptno and e.empno is null; -- (1)查询EMP表显示工资超过2850的雇员姓名和工资。 select e.ename,e.sal from emp e where e.sal >2850; -- (2)查询EMP表显示工资不在1500~2850之间的所有雇员及工资。 select from emp e where e.sal<1500 or e.sal >2850; -- (3)查询EMP表显示代码为7566的雇员姓名及所在部门代码。 select e.ename,e.deptno from emp e where e.empno = 7566; -- (4)查询EMP表显示部门10和30中工资超过1500的雇员名及工资。 select e.ename,e.sal from emp e where e.deptno in(10,30) and e.sal>1500; -- (5)查询EMP表显示第2个字符为"A"的所有雇员名其工资。 select e.ename,e.sal from emp e where e.ename like '_A%'; -- (6)查询EMP表显示补助非空的所有雇员名及其补助。 select e.ename,e.comm from emp e where e.comm is not null; -- (1)查询EMP表显示所有雇员名、工资、雇佣日期,并以雇员名的升序进行排序。 select e.ename,e.sal,e.hiredate from emp e order by e.ename asc; -- (2)查询EMP表显示在1981年2月1日到1981年5月1日之间雇佣的雇员名、岗位及雇佣日期,并以雇佣日期进行排序。 select e.ename,e.job,e.hiredate from emp e where e.hiredate >=to_date('1981-2-1','yyyy-mm-dd') and e.hiredate <= to_date('1981-5-1','yyyy-mm-dd'); -- (3)查询EMP表显示获得补助的所有雇员名、工资及补助,并以工资升序和补助降序排序。 select e.ename,e.sal,e.comm from emp e where nvl(e.comm,0) >0 order by sal,e.comm desc;
CREATE TABLE IF NOT EXISTS transfers ( id uuid PRIMARY KEY, sender_login VARCHAR(40) NOT NULL REFERENCES accounts(login) ON UPDATE CASCADE, recipient_login VARCHAR(40) NOT NULL REFERENCES accounts(login) ON UPDATE CASCADE, comment TEXT, amount NUMERIC(20, 2) NOT NULL, date TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP )
/* ROW_NUMBER() works per partition ! */ SELECT ROW_NUMBER() OVER() AS rnum, dname FROM dept LIMIT 2; SELECT ROW_NUMBER() OVER() AS rnum, dname FROM dept LIMIT 2 OFFSET 2;
--1. --SQL objects are schemas, journals, catalogs, tables, aliases, views, indexes, etc. An object is any SQL Server resource. --Each object contains one or more counters that determine various aspects of the objects to monitor. --2. --An index is an on-disk structure associated with a table or view that speeds retrieval of rows from --the table or view. --Advantages: ---Speed up the select query ---Help to make a row unique or without duplicate ---Help to sort, aggregate and group data --Disadvantages ---Take additional disk space ---Slow down insert, update, and delete --3. --There are two types of indexes: clustered and non clustered --4. --Yes, under the unique constraints --5. --No, a clustered index can only be created on one table, because the data rows themselves --can be stored in only one order. --6. --Yes, indexes can be created on multiple columns and the order of columns do matter. --7. --Yes, indexes can be created on view --8. --Normalization is a database design technique that help to minimize data duplication and --to reduce data redundancy. --There are three steps to achieve normalization: --First normal form makes sure there's no multiple values in a single cell --Second normal form makes sure there's no partial dependency --Third normal form makes sure there's no transitive dependency --9. --Denormalization is about deliberately adding redundancy to improve performance. --Denormalization is used when there is a lot of tables involved in retreiving data. --10. --There are four types of data integrity: ---1.Row integrity, 2.Column integrity, 3.Referential integrity, 4.User-defined integrity --11. --Data integrity is enforced by 7 database constraints: ---Data type constraint, Default constraint, nullability constraint, primary key constraint, ---unique constraint, foreign key constraint, check constraint --12. -- Primary key vs Unique cosntraint -- 1. Unique can accept one null value but primary key does not accept any -- 2. One table can have multiple unique constraints but only one primary key -- 3. Primary key will sort the data by default but unique key will not -- 4. Primary key will by default create clustered index and unique key will create non clustered index --13. --A foreign key (FK) is a column or combination of columns that is used to establish and enforce a link between the data in two tables. --You can create a foreign key by defining a FOREIGN KEY constraint when you create or modify a table. --14. --Yes, a table can have multiple foreign keys --15. --Foreign keys can be null or duplicate --16. --Indexes cannot be created on table variables, but can be created on temporary tables. --17. --By definition transactions are a logical unit of work. Usually include at least one statement --It changes the databse from one consistent state to another --Write queries for following scenarios --1. select c.iname, sum(o.order_id) TotalOrder from customer c join order o on c.cust_id = o.cust_id where year(o.order_date) = 2002 group by c.iname --2. select * from person where lastname like 'A%' --3. select m.name, count(*) from person p left join (select * from person p where manager_id is null) m on p.person_id = m.manager_id group by m.name --4. --Triggers are caused to be executed by insert, delete and update --5. create table Company(company_id int primary key, company_name varchar(20) not null) create table Division(division_id int primary key, division_name varchar(20) not null, company_id int foreign key references company(company_id)) create table Loc(location_id int primary key, address varchar(20) not null, division_id int foreign key references division(division_id)) create table Contacts(mail varchar(50) primary key, division_id int foreign key references division(division_id), location_id int foreign key references loc(location_id))
# Explore SQL data with SQL scripts # Here are a few sample SQL scripts that can be used to explore data stores in SQL Server. # Get the count of observations per day SELECT CONVERT(date, <date_columnname>) as date, count(*) as c from <tablename> group by CONVERT(date, <date_columnname>) # Get the levels in a categorical column select distinct <column_name> from <databasename> # Get the number of levels in combination of two categorical columns select <column_a>, <column_b>,count(*) from <tablename> group by <column_a>, <column_b> # Get the distribution for numerical columns select <column_name>, count(*) from <tablename> group by <column_name> # Take from: https://azure.microsoft.com/en-us/documentation/articles/machine-learning-data-science-explore-data-sql-server/
create or replace view v1_hdjh004_zbbh as ( select czde397, to_char(wm_concat(zbbh)) as zbbh from (select jsde115 as czde397, to_char(wm_concat(de151)) as zbbh from (select distinct jsde115, b.de151 from zb010 a, zb006 b where jsde013 = 25 and a.jsde107 = b.jsde107 and a.jsde115<>-1 and a.jsde117='HDJH004') group by jsde115 union all select jsde115 as czde397, to_char(wm_concat(zbde151)) as zbbh from (select distinct jsde115, a.zbde151 from jh001 a, jh003 b where jsde013 = 25 and a.JSDE201 = b.JSDE201 and b.jsde115<>-1 and b.jsde117='HDJH004') group by jsde115) group by czde397 /*select jsde115 as czde397, to_char(wm_concat(b.de151)) as zbbh from zb010 a, zb006 b where jsde013 = 25 and a.jsde107 = b.jsde107 group by jsde115 union all select jsde115 as czde397, to_char(wm_concat(a.zbde151)) as zbbh from jh001 a, jh003 b where jsde013 = 25 and a.JSDE201 = b.JSDE201 group by jsde115*/ );
-- aas-std.sql -- gather AAS metrics from AWR @clear_for_spool set term off spool aas-std-lks.csv prompt begin_time,end_time,instance_number,elapsed_seconds,AAS with data as ( select to_char(h.begin_time,'yyyy-mm-dd hh24:mi:ss') begin_time , to_char(h.end_time,'yyyy-mm-dd hh24:mi:ss') end_time , (h.end_time - h.begin_time) * 86400 elapsed_seconds , h.instance_number , round(h.value,2) aas from dba_hist_sysmetric_history h where h.metric_name = 'Average Active Sessions' order by h.snap_id ) select begin_time || ',' || end_time || ',' || instance_number || ',' || elapsed_seconds || ',' || aas from data / spool off set term on @clears
--PROBLEM 06 SELECT * FROM Planes WHERE [NAME] LIKE '%tr%' ORDER BY Id,[Name],Seats,Range
-- -------------------------------------------------------- -- Хост: 127.0.0.1 -- Версия сервера: 5.7.13-log - 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' */; -- Дамп структуры для таблица test.snapshots CREATE TABLE IF NOT EXISTS `snapshots` ( `type` varchar(255) NOT NULL, `refreshdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `needUpdate` tinyint(1) unsigned NOT NULL, `status` varchar(255) NOT NULL, `snapshotId` varchar(255) NOT NULL, `userId` int(10) unsigned NOT NULL, PRIMARY KEY (`type`,`userId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- Экспортируемые данные не выделены. -- Дамп структуры для таблица test.snapshot_adgroups CREATE TABLE IF NOT EXISTS `snapshot_adgroups` ( `adGroupId` bigint(20) unsigned NOT NULL DEFAULT '0', `name` varchar(255) NOT NULL, `campaignId` bigint(20) unsigned NOT NULL DEFAULT '0', `defaultBid` float unsigned NOT NULL, `state` varchar(255) NOT NULL, `userId` int(10) unsigned NOT NULL, PRIMARY KEY (`adGroupId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; -- Экспортируемые данные не выделены. -- Дамп структуры для таблица test.snapshot_campaigns CREATE TABLE IF NOT EXISTS `snapshot_campaigns` ( `campaignId` bigint(20) unsigned NOT NULL DEFAULT '0', `name` varchar(255) NOT NULL, `campaignType` varchar(255) NOT NULL, `targetingType` varchar(255) NOT NULL, `premiumBidAdjustment` varchar(255) NOT NULL, `dailyBudget` float unsigned NOT NULL, `startDate` date NOT NULL, `state` varchar(255) NOT NULL, `userId` int(10) unsigned NOT NULL, PRIMARY KEY (`campaignId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; -- Экспортируемые данные не выделены. -- Дамп структуры для таблица test.snapshot_keywords CREATE TABLE IF NOT EXISTS `snapshot_keywords` ( `keywordId` bigint(20) unsigned NOT NULL DEFAULT '0', `adGroupId` bigint(20) unsigned NOT NULL DEFAULT '0', `campaignId` bigint(20) unsigned NOT NULL DEFAULT '0', `keywordText` varchar(255) NOT NULL, `matchType` varchar(255) NOT NULL, `state` varchar(255) NOT NULL, `bid` float unsigned NOT NULL, `userId` int(10) unsigned NOT NULL, PRIMARY KEY (`keywordId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; -- Экспортируемые данные не выделены. -- Дамп структуры для таблица test.snapshot_productads CREATE TABLE IF NOT EXISTS `snapshot_productads` ( `adId` bigint(20) unsigned NOT NULL DEFAULT '0', `adGroupId` bigint(20) unsigned NOT NULL DEFAULT '0', `campaignId` bigint(20) unsigned NOT NULL DEFAULT '0', `asin` varchar(255) NOT NULL, `sku` varchar(255) NOT NULL, `state` varchar(255) NOT NULL, `userId` int(10) unsigned NOT NULL, PRIMARY KEY (`adId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- Экспортируемые данные не выделены. /*!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 */;
drop table admin; create table admin ( adminno varchar2(25), fname varchar2(20), lname varchar2(20), country varchar2(25), password varchar2(20), gender varchar2(1), primary key (adminno) ); insert into admin values ('kapil_sharma','Kapil','Sharma','India','hellojiit','M'); insert into admin values ('aakash_jain','Aakash','Jain','India','hellojiit','M'); insert into admin values ('shubhanshu12','Shubhanshu','Kumar','India','hellojiit','M'); insert into admin values ('vivek_singh','Vivek','Singh','India','hellojiit','M'); commit;
--修改日期:2012.12.07 --修改人:周兵 --修改内容:自动生成余额 --修改原因:需求需要 --增加表字段 update bt_param set reverse1='0,否;1,是(不覆盖手工生成的余额);2,是(覆盖手工生成的余额)' where code ='autoBuildHisBal' and sys_code = 'adm' and name = '自动更新离线账户历史余额'; DECLARE VN_COUNT NUMBER; VC_STR VARCHAR2(1000); BEGIN --查看该表中该字段是否存在 SELECT COUNT(*) INTO VN_COUNT FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'BIS_ACC_HIS_BAL' AND COLUMN_NAME = 'ISAUTOMATICBAL'; --如果小于1则说明不存在,则新增此字段 IF VN_COUNT < 1 THEN VC_STR := ' ALTER TABLE BIS_ACC_HIS_BAL ADD ISAUTOMATICBAL CHAR(1)'; EXECUTE IMMEDIATE VC_STR; END IF; END; / comment on column BIS_ACC_HIS_BAL.ISAUTOMATICBAL is '为1的时候是自动生成余额,为空的时候是手动生成'; DECLARE VN_COUNT NUMBER; VC_STR VARCHAR2(1000); BEGIN --查看该表中该字段是否存在 SELECT COUNT(*) INTO VN_COUNT FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'Bis_Acc_His_Dtl' AND COLUMN_NAME = 'ISAUTOMATICDTL'; --如果小于1则说明不存在,则新增此字段 IF VN_COUNT < 1 THEN VC_STR := ' ALTER TABLE Bis_Acc_His_Dtl ADD ISAUTOMATICDTL CHAR(1)'; EXECUTE IMMEDIATE VC_STR; END IF; END; / comment on column Bis_Acc_His_Dtl.ISAUTOMATICDTL is '为1的时候是此明细记录为自动生成余额,为空的时候是手动生成余额'; DECLARE VN_COUNT NUMBER; BEGIN SELECT COUNT(*) INTO VN_COUNT FROM bt_sys_res WHERE res_name = '计算离线账户历史余额' and sys_code = 'bankacc' and res_level = 2; IF VN_COUNT = 0 THEN insert into bt_sys_res (RES_CODE, RES_NAME, SYS_CODE, FATHER_CODE, RES_URL, FUNC_FLAG, RES_TYPE, LINK_TARGET, STATUS, RES_ORDER, RMK, REVERSE1, REVERSE2, REVERSE3, REVERSE4, REVERSE5, REVERSE6, REVERSE7, REVERSE8, REVERSE9, REVERSE10, RES_LEVEL, RES_ROLE) values (( select max(res_code)+1 from bt_sys_res ) , '计算离线账户历史余额', 'bankacc', ( select min(res_code) from bt_sys_res r where r.res_name = '录入余额' and r.sys_code = 'bankacc' ), '/bankacc/automaticBal.jsp', '0', '1', '0', '0', 10, ' ', '', '', '', '', '', null, null, null, null, null, 2, ''); END IF; END; / commit; update Bis_Acc_His_Dtl set ISAUTOMATICDTL='1'; comment on column Bis_Acc_His_Dtl.ISAUTOMATICDTL is '默认把所有的明细设置为自动生成'; commit; --更新余额表里面错误的bif_code update bis_acc_his_bal a set bif_code = (select b.bif_code from bt_bank b where b.bank_code = a.bif_code ) where a.bif_code in (select aa.bif_code from bis_acc_his_bal aa , bt_bank ab where aa.bif_code = ab.bank_code ); commit;
CREATE OR REPLACE PROCEDURE plch_show_orders IS CURSOR c_orders (as_status plch_orders.status%TYPE) IS SELECT order_id FROM plch_orders WHERE UPPER(status) = UPPER(as_status) ORDER BY status, order_date DESC; rec_orders c_orders%ROWTYPE; BEGIN OPEN c_orders('OPEN'); LOOP FETCH c_orders INTO rec_orders; EXIT WHEN c_orders%NOTFOUND; DBMS_OUTPUT.PUT_LINE(rec_orders.order_id); END LOOP; CLOSE c_orders; OPEN c_orders('CLOSED'); LOOP FETCH c_orders INTO rec_orders; EXIT WHEN c_orders%NOTFOUND; DBMS_OUTPUT.PUT_LINE(rec_orders.order_id); END LOOP; CLOSE c_orders; END; / SET SERVEROUTPUT ON BEGIN plch_show_orders; END;
IF db_id('AwfulInputs') IS NOT NULL DROP DATABASE [AwfulInputs]
DROP TABLE IF EXISTS users; CREATE TABLE users ( id INTEGER PRIMARY KEY, fname TEXT NOT NULL, lname TEXT NOT NULL ); DROP TABLE IF EXISTS questions; CREATE TABLE questions ( id INTEGER PRIMARY KEY, title TEXT NOT NULL, body TEXT NOT NULL, user_id INTEGER NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ); DROP TABLE IF EXISTS question_follows; CREATE TABLE question_follows ( id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL, question_id INTEGER NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) FOREIGN KEY (question_id) REFERENCES questions(id) ); DROP TABLE IF EXISTS replies; CREATE TABLE replies ( id INTEGER PRIMARY KEY, body TEXT NOT NULL , question_id INTEGER NOT NULL, parent_id INTEGER NULL, user_id INTEGER NOT NULL, FOREIGN KEY (question_id) REFERENCES questions(id) FOREIGN KEY (parent_id) REFERENCES replies(id) FOREIGN KEY (user_id) REFERENCES users(id) ); DROP TABLE IF EXISTS question_likes; CREATE TABLE question_likes ( id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL, question_id INTEGER NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) FOREIGN KEY (question_id) REFERENCES questions(id) ); INSERT INTO users(fname, lname) VALUES ('John', 'Smith'), ('James', 'Santos'), ('Tanner', 'Lane'); INSERT INTO questions(title, body, user_id) VALUES ('im confused', 'plz help', (SELECT id FROM users WHERE fname='James' AND lname='Santos')), ('Does this work', 'Is this merge sort better than Kelly''s?', 3); INSERT INTO question_follows(user_id, question_id) VALUES (2, 1); INSERT INTO replies(body, question_id, parent_id, user_id) VALUES ('Read the documentation, please.', 1, NULL, 2), ('I can''t read.', 1, 1, 2); INSERT INTO question_likes(user_id, question_id) VALUES (3, 1);
alter table a_asset_acct drop constraint a_asset_acct_pkey; alter table a_asset_acct add constraint a_asset_acct_pkey primary key (a_asset_acct_id); alter table c_order drop constraint c_order_m_freightcategory_id_fkey; alter table c_order add constraint mfreightcategory_order foreign key(m_freightcategory_id) references m_freightcategory(m_freightcategory_id);
/* Создание таблицы дочерних клиентов */ CREATE TABLE /*PREFIX*/CLIENT_CHILDS ( CLIENT_ID VARCHAR(32) NOT NULL, CHILD_ID VARCHAR(32) NOT NULL, PRIMARY KEY (CLIENT_ID,CHILD_ID), FOREIGN KEY (CLIENT_ID) REFERENCES /*PREFIX*/CLIENTS (CLIENT_ID), FOREIGN KEY (CHILD_ID) REFERENCES /*PREFIX*/CLIENTS (CLIENT_ID) ) -- /* Создание просмотра дочерних клиентов */ CREATE VIEW /*PREFIX*/S_CLIENT_CHILDS ( CLIENT_ID, CHILD_ID, CLIENT_USER_NAME, CHILD_USER_NAME, CHILD_SURNAME, CHILD_NAME, CHILD_PATRONYMIC ) AS SELECT CC.*, A1.USER_NAME AS CLIENT_USER_NAME, A2.USER_NAME AS CHILD_USER_NAME, A2.SURNAME AS CHILD_SURNAME, A2.NAME AS CHILD_USER_NAME, A2.PATRONYMIC AS CHILD_PATRONYMIC FROM /*PREFIX*/CLIENT_CHILDS CC JOIN /*PREFIX*/CLIENTS C1 ON C1.CLIENT_ID=CC.CLIENT_ID JOIN /*PREFIX*/ACCOUNTS A1 ON A1.ACCOUNT_ID=CC.CLIENT_ID JOIN /*PREFIX*/CLIENTS C2 ON C2.CLIENT_ID=CC.CHILD_ID JOIN /*PREFIX*/ACCOUNTS A2 ON A2.ACCOUNT_ID=CC.CHILD_ID -- /* Создание процедуры добавления дочернего клиента */ CREATE PROCEDURE /*PREFIX*/I_CLIENT_CHILD ( CLIENT_ID VARCHAR(32), CHILD_ID VARCHAR(32) ) AS BEGIN INSERT INTO /*PREFIX*/CLIENT_CHILDS (CLIENT_ID,CHILD_ID) VALUES (:CLIENT_ID,:CHILD_ID); END; -- /* Создание процедуры изменения дочернего у клиента */ CREATE PROCEDURE /*PREFIX*/U_CLIENT_CHILD ( CLIENT_ID VARCHAR(32), CHILD_ID VARCHAR(32), OLD_CLIENT_ID VARCHAR(32), OLD_CHILD_ID VARCHAR(32) ) AS BEGIN UPDATE /*PREFIX*/CLIENT_CHILDS SET CLIENT_ID=:CLIENT_ID, CHILD_ID=:CHILD_ID WHERE CLIENT_ID=:OLD_CLIENT_ID AND CHILD_ID=:OLD_CHILD_ID; END; -- /* Создание процедуры удаления дочернего у клиента */ CREATE PROCEDURE /*PREFIX*/D_CLIENT_CHILD ( OLD_CLIENT_ID VARCHAR(32), OLD_CHILD_ID VARCHAR(32) ) AS BEGIN DELETE FROM /*PREFIX*/CLIENT_CHILDS WHERE CLIENT_ID=:OLD_CLIENT_ID AND CHILD_ID=:OLD_CHILD_ID; END; -- /* Фиксация изменений */ COMMIT
/* Navicat MySQL Data Transfer Source Server : localhost_3306 Source Server Version : 50726 Source Host : localhost:3306 Source Database : newti Target Server Type : MYSQL Target Server Version : 50726 File Encoding : 65001 Date: 2020-11-23 17:34:38 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for t_brand -- ---------------------------- DROP TABLE IF EXISTS `t_brand`; CREATE TABLE `t_brand` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '名称', `image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `letter` char(1) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '品牌首字母', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- ---------------------------- -- Records of t_brand -- ----------------------------
CREATE table `users` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, PRIMARY KEY(`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE versioning.VersioningTransfer ( VersioningTransferID BIGINT NOT NULL , VersioningDestination NVARCHAR(20) NOT NULL , SchemaName SYSNAME NOT NULL , TableName SYSNAME NOT NULL , VersioningID_Reserved_Start BIGINT NOT NULL , VersioningID_Reserved_End BIGINT NOT NULL , VersioningID_Reserved_Timestamp DATETIME NOT NULL CONSTRAINT DF_VersioningTransfer_VersioningID_Reserved_Timestamp DEFAULT GETUTCDATE() , VersioningID_Transfered_Timestamp DATETIME NULL , CONSTRAINT PK_VersioningTransfer PRIMARY KEY ([VersioningTransferID] ASC) )
-- phpMyAdmin SQL Dump -- version 4.8.4 -- https://www.phpmyadmin.net/ -- -- Servidor: 127.0.0.1:3306 -- Tiempo de generación: 09-01-2021 a las 04:55:36 -- Versión del servidor: 5.7.24 -- Versión de PHP: 7.2.14 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de datos: `ejemplo` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `usuario` -- DROP TABLE IF EXISTS `usuario`; CREATE TABLE IF NOT EXISTS `usuario` ( `Id_User` int(10) NOT NULL AUTO_INCREMENT, `Usuario` varchar(100) NOT NULL, `Contrasena` varchar(100) NOT NULL, `Tipo` varchar(100) NOT NULL, PRIMARY KEY (`Id_User`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; -- -- Volcado de datos para la tabla `usuario` -- INSERT INTO `usuario` (`Id_User`, `Usuario`, `Contrasena`, `Tipo`) VALUES (1, 'ruyhiddenBlack@gmail.com', '12345678910', 'Admin'), (2, 'ruyhiddenBlack@gmail.com', '12345678910', 'Admin'); 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 */;
/*2013-01-25 修改视图,取数的公式 */ create or replace view v_fc_acc_balance_month as select fc_acc.corp_code, fc_acc.net_code, fc_acc.cur_code, to_char(fc_acc_balance.balance_date,'yyyymm') as month_code, sum(fc_acc_balance.debit_money - fc_acc_balance.rush_debit_money ) as debit_money, sum((fc_acc_balance.debit_money - fc_acc_balance.rush_debit_money ) * bt_currency.cur_exrate) as natural_debit_money, sum(fc_acc_balance.credit_money - fc_acc_balance.rush_credit_money ) as credit_money, sum((fc_acc_balance.credit_money - fc_acc_balance.rush_credit_money ) * bt_currency.cur_exrate) as natural_credit_money, sum(fc_acc_balance.debit_money - fc_acc_balance.rush_debit_money - fc_acc_balance.tr_debit_money) as tr_debit_money, sum((fc_acc_balance.debit_money - fc_acc_balance.rush_debit_money - fc_acc_balance.tr_debit_money) * bt_currency.cur_exrate) as natural_tr_debit_money, sum(fc_acc_balance.credit_money - fc_acc_balance.rush_credit_money - fc_acc_balance.tr_credit_money) as tr_credit_money, sum((fc_acc_balance.credit_money - fc_acc_balance.rush_credit_money - fc_acc_balance.tr_credit_money)* bt_currency.cur_exrate) as natural_tr_credit_money, abs(sum(fc_acc_balance.debit_money - fc_acc_balance.rush_debit_money)) + abs(sum(fc_acc_balance.credit_money - fc_acc_balance.rush_credit_money)) as balance, abs(sum(fc_acc_balance.debit_money - fc_acc_balance.rush_debit_money - fc_acc_balance.tr_debit_money)) + abs(sum(fc_acc_balance.credit_money - fc_acc_balance.rush_credit_money - fc_acc_balance.tr_credit_money)) as tr_balance, (abs(sum(fc_acc_balance.debit_money - fc_acc_balance.rush_debit_money)) + abs(sum(fc_acc_balance.credit_money - fc_acc_balance.rush_credit_money)))*bt_currency.cur_exrate as natural_balance, (abs(sum(fc_acc_balance.debit_money - fc_acc_balance.rush_debit_money - fc_acc_balance.tr_debit_money)) + abs(sum(fc_acc_balance.credit_money - fc_acc_balance.rush_credit_money - fc_acc_balance.tr_credit_money)))*bt_currency.cur_exrate as natural_tr_balance, count(*) as days, sum(fc_acc_balance.balance) / count (*) as aver_balance, sum(bt_currency.cur_exrate * fc_acc_balance.balance) as natural_balance_aver, sum(bt_currency.cur_exrate * fc_acc_balance.balance) / count (*) as natural_aver_balance from bt_currency,fc_acc_balance,fc_acc where fc_acc_balance.account = fc_acc.blnctr_acc and fc_acc.cur_code = bt_currency.cur_code group by fc_acc.net_code, fc_acc.corp_code, fc_acc.cur_code,bt_currency.cur_exrate, to_char(fc_acc_balance.balance_date,'yyyymm');
-- phpMyAdmin SQL Dump -- version 4.7.9 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Mar 26, 2019 at 08:40 PM -- Server version: 10.1.31-MariaDB -- PHP Version: 7.2.3 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `registration` -- -- -------------------------------------------------------- -- -- Table structure for table `answers` -- CREATE TABLE `answers` ( `id` int(11) NOT NULL, `q_one` varchar(1000) NOT NULL, `q_two` varchar(1000) NOT NULL, `q_three` varchar(1000) NOT NULL, `q_four` varchar(1000) NOT NULL, `q_five` varchar(1000) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `answers` -- INSERT INTO `answers` (`id`, `q_one`, `q_two`, `q_three`, `q_four`, `q_five`) VALUES (1, 'hello', 'hey', 'khfjh', '5d4f', 'lkfh'), (2, '', '', '', '', ''), (3, '', '', '', '', ''), (4, 'khda', 'ksld', 'lks', 'lkd', 'lkh'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` int(11) NOT NULL, `username` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `password` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `username`, `email`, `password`) VALUES (1, 'rishikraj', 'sss@hh.com', 'e10adc3949ba59abbe56e057f20f883e'), (2, '123', '123@f.com', '202cb962ac59075b964b07152d234b70'); -- -- Indexes for dumped tables -- -- -- Indexes for table `answers` -- ALTER TABLE `answers` ADD PRIMARY KEY (`id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `answers` -- ALTER TABLE `answers` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; 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 */;
CREATE DATABASE book_change; USE book_change; CREATE TABLE usuario ( in_usuario_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, va_nome VARCHAR(250) NOT NULL, dt_data_nascimento date DEFAULT NULL, va_celular VARCHAR(15) NOT NULL, va_telefone VARCHAR(15) DEFAULT NULL, va_email VARCHAR(250) NOT NULL UNIQUE, va_password VARCHAR(250) NOT NULL, en_genero enum('masculino','feminino','nao-informado'), va_cpf VARCHAR(14) DEFAULT NULL, CONSTRAINT usuario_pkey PRIMARY KEY(in_usuario_id), CONSTRAINT chk_en_genero CHECK (en_genero = 'masculino' or en_genero = 'feminino' or en_genero = 'nao-informado') ); CREATE TABLE usuario_imagem ( in_usuario_imagem_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, in_usuario_id INTEGER UNSIGNED NOT NULL UNIQUE, te_path TEXT NOT NULL, CONSTRAINT usuario_imagem_pkey PRIMARY KEY(in_usuario_imagem_id), CONSTRAINT usuario_imagem_in_usuario_fkey FOREIGN KEY (in_usuario_id) REFERENCES usuario (in_usuario_id) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE endereco ( in_endereco_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, in_usuario_id INTEGER UNSIGNED NOT NULL UNIQUE, logradouro VARCHAR(250) NOT NULL, bairro VARCHAR(250) NOT NULL, cidade VARCHAR(250) NOT NULL, estado VARCHAR(2) NOT NULL, numero int(11) NOT NULL, complemento VARCHAR(50) DEFAULT NULL, ponto_referencia VARCHAR(250) DEFAULT NULL, CONSTRAINT endereco_pkey PRIMARY KEY(in_endereco_id), CONSTRAINT endereco_in_usuario_fkey FOREIGN KEY (in_usuario_id) REFERENCES usuario (in_usuario_id) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE anuncio ( in_anuncio_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, in_usuario_id INTEGER UNSIGNED NOT NULL, va_titulo_livro VARCHAR(250) NOT NULL, va_autor_livro VARCHAR(50) NOT NULL, va_ano_livro VARCHAR(4) DEFAULT NULL, en_estado enum('novo', 'usado') NOT NULL, en_tipo_anuncio enum('venda', 'troca') NOT NULL, en_status_anuncio enum('ativo', 'desativado') NOT NULL, en_status_endereco_visivel enum('ativo', 'desativado') NOT NULL, te_descricao TEXT NOT NULL, dt_data_criacao DATETIME NOT NULL, CONSTRAINT anuncio_pkey PRIMARY KEY(in_anuncio_id), CONSTRAINT chk_en_estado CHECK (en_estado = 'novo' or en_estado = 'usado'), CONSTRAINT chk_en_tipo_anuncio CHECK (en_tipo_anuncio = 'venda' or en_tipo_anuncio = 'troca'), CONSTRAINT chk_en_status_anuncio CHECK (en_status_anuncio = 'ativo' or en_status_anuncio = 'desativado'), CONSTRAINT chk_en_status_endereco_visivel CHECK (en_status_endereco_visivel = 'ativo' or en_status_endereco_visivel = 'desativado'), CONSTRAINT anuncio_in_usuario_fkey FOREIGN KEY (in_usuario_id) REFERENCES usuario (in_usuario_id) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE anuncio_imagem ( in_anuncio_imagem_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, in_anuncio_id INTEGER UNSIGNED NOT NULL, te_path TEXT NOT NULL, CONSTRAINT anuncio_imagem_pkey PRIMARY KEY(in_anuncio_imagem_id), CONSTRAINT anuncio_imagem_in_anuncio_fkey FOREIGN KEY (in_anuncio_id) REFERENCES anuncio (in_anuncio_id) ON DELETE CASCADE ON UPDATE CASCADE ); CREATE TABLE genero ( in_genero_id INTEGER UNSIGNED NOT NULL, va_genero VARCHAR(50) NOT NULL, CONSTRAINT genero_pkey PRIMARY KEY(in_genero_id) ); CREATE TABLE genero_anuncio ( in_genero_anuncio_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, in_anuncio_id INTEGER UNSIGNED NOT NULL, in_genero_id INTEGER UNSIGNED NOT NULL, CONSTRAINT genero_anuncio_pkey PRIMARY KEY (in_genero_anuncio_id), CONSTRAINT genero_anuncio_in_anuncio_fkey FOREIGN KEY (in_anuncio_id) REFERENCES anuncio (in_anuncio_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT genero_anuncio_in_genero_fkey FOREIGN KEY (in_genero_id) REFERENCES genero (in_genero_id) ON DELETE CASCADE ON UPDATE CASCADE ); /* procedures */ DELIMITER $$ CREATE PROCEDURE `insere_usuario`( in_usuario_id INT, va_nome VARCHAR(250), dt_data_nascimento DATE, va_celular VARCHAR(15), va_telefone VARCHAR(15), va_email VARCHAR(250), va_password VARCHAR(250), en_genero ENUM('masculino','feminino','nao-informado'), va_cpf VARCHAR(14) ) BEGIN INSERT INTO usuario VALUES (in_usuario_id, va_nome, dt_data_nascimento, va_celular, va_telefone, va_email, va_password, en_genero, va_cpf); END $$ DELIMITER ; DELIMITER $$ CREATE PROCEDURE `delete_usuario` (id INT) BEGIN DELETE FROM usuario WHERE in_usuario_id = id; END $$ DELIMITER ; /* genero */ INSERT INTO genero VALUES (1,'romance'), (2,'drama'), (3,'comédia'), (4,'terror'), (5,'poesia'), (6,'fantasia'), (7,'ficção-cientifíca'), (8,'distopia'), (9,'infanto-juvenil'), (10,'outros'); /* usuario */ INSERT INTO usuario VALUES (1,'Gabriel Neves','1994-09-10','81973066251','','gabriel-silva_2011@hotmail.com','$2a$10$wmC7bsWoTPu2FfEUbgtb2.Wxeucxadt23Dh/j2qFfcH.iFOvhSOBK','masculino', ''); INSERT INTO usuario VALUES (2,'Felipe Silva','1993-10-09','611054432622','','felipesilva@hotmail.com','$2a$10$wmC7bsWoTPu2FfEUbgtb2.Wxeucxadt23Dh/j2qFfcH.iFOvhSOBK','masculino', ''); INSERT INTO usuario VALUES (3,'Carlos Alberto','1984-09-11','80306581766','','carlosalberto@hotmail.com','$2a$10$wmC7bsWoTPu2FfEUbgtb2.Wxeucxadt23Dh/j2qFfcH.iFOvhSOBK','masculino', ''); INSERT INTO usuario VALUES (4,'Rafael Nascimento','1992-11-10','711150554810','','rafaelnascimento@hotmail.com','$2a$10$wmC7bsWoTPu2FfEUbgtb2.Wxeucxadt23Dh/j2qFfcH.iFOvhSOBK','masculino', ''); INSERT INTO usuario VALUES (5,'Rafaela Costa','1992-11-10','27177940374714','','rafaelacosta@hotmail.com','$2a$10$wmC7bsWoTPu2FfEUbgtb2.Wxeucxadt23Dh/j2qFfcH.iFOvhSOBK','feminino', ''); /* endereco */ INSERT INTO endereco VALUES(1,1,'Travesssa Santa Rosa','Centro','Igarassu','PE',94,'C',''); INSERT INTO endereco VALUES(2,2,'Avenida costa souza','Centro','Recife','PE',99,'D',''); INSERT INTO endereco VALUES(3,3,'Rua Rosa e Silva','Centro','Abreu e Lima','PE',8084,'APTO 15',''); INSERT INTO endereco VALUES(4,4,'Avenida Paulista','Centro','São Paulo','PE',1010,'E',''); INSERT INTO endereco VALUES(5,5,'Rua costa azul','Centro','Rio de Janeiro','PE',1004,'EE',''); /* anuncio */ INSERT INTO anuncio VALUES (1,1, 'A culpa é das Estrelas','John Green',2014,'novo','troca','ativo','desativado','Hazel Grace Lancaster e Augustus Waters são dois adolescentes que se conhecem em um grupo de apoio para pacientes com câncer. Por causa da doença, Hazel sempre descartou a ideia de se envolver amorosamente, mas acaba cedendo ao se apaixonar por Augustus.','2019-05-08 01:40:00'); INSERT INTO anuncio VALUES (2,2, 'A Cabana','William P. Young',2017,'novo','venda','ativo','ativo','Um homem vive atormentado após perder a sua filha mais nova, cujo corpo nunca foi encontrado, mas sinais de que ela teria sido violentada e assassinada são encontrados em uma cabana nas montanhas.','2019-05-08 01:40:00'); /* genero_anuncio */ INSERT INTO genero_anuncio VALUES(1,1,2), (2,1,3); INSERT INTO genero_anuncio VALUES(3,2,2), (4,2,6); /* select */ select usuario.va_nome, usuario.in_usuario_id, anuncio.va_titulo_livro, anuncio.va_autor_livro, anuncio.va_ano_livro, anuncio.en_estado, anuncio.te_descricao, genero.va_genero, anuncio.dt_data_criacao from usuario inner join anuncio on anuncio.in_usuario_id = usuario.in_usuario_id inner join genero_anuncio on genero_anuncio.in_anuncio_id = anuncio.in_anuncio_id inner join genero on genero.in_genero_id = genero_anuncio.in_genero_id /*where usuario.in_usuario_id = 1*/ select genero_anuncio.in_genero_id, anuncio.in_anuncio_id, anuncio.va_titulo_livro, anuncio.va_autor_livro, anuncio.va_ano_livro, anuncio.en_estado, anuncio.te_descricao, genero.va_genero, anuncio.dt_data_criacao from anuncio inner join genero_anuncio on genero_anuncio.in_anuncio_id = anuncio.in_anuncio_id inner join genero on genero.in_genero_id = genero_anuncio.in_genero_id inner join ( select genero_anuncio.in_genero_id, genero_anuncio.in_anuncio_id from genero inner join genero_anuncio on genero_anuncio.in_genero_id = genero.in_genero_id where genero_anuncio.in_anuncio_id = 3 ) as mini_query on mini_query.in_genero_id = genero_anuncio.in_genero_id and anuncio.in_anuncio_id <> mini_query.in_anuncio_id
-- MySQL dump 10.13 Distrib 5.7.12, for osx10.9 (x86_64) -- -- Host: localhost Database: crowdsensingdb -- ------------------------------------------------------ -- Server version 5.7.17 /*!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 `logs` -- DROP TABLE IF EXISTS `logs`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `logs` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, `message` varchar(25) NOT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `notifications` -- DROP TABLE IF EXISTS `notifications`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `notifications` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, `link` varchar(50) NOT NULL, `content` text NOT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `postsurvey_questions` -- DROP TABLE IF EXISTS `postsurvey_questions`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `postsurvey_questions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(255) DEFAULT NULL, `question_type` varchar(50) DEFAULT NULL, `answer_choices` varchar(255) DEFAULT NULL, `required` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `postsurvey_questions` -- LOCK TABLES `postsurvey_questions` WRITE; /*!40000 ALTER TABLE `postsurvey_questions` DISABLE KEYS */; INSERT INTO `postsurvey_questions` VALUES (1,'How long did the main tasks (excluding pre and post surveys) take? Please count only the actual time you spent on the task, not the intermittent time you might have spent on other tasks.','text','duration in hours:minutes, e.g., 00:30 for thirty minutes',1),(2,'How do you rate the difficulty of main tasks?','multiple_choice','Very easy|Easy|Medium|High|Very high',1),(3,'Please provide any additional comments you have below','text','Optional comments',0); /*!40000 ALTER TABLE `postsurvey_questions` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `postsurvey_responses` -- DROP TABLE IF EXISTS `postsurvey_responses`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `postsurvey_responses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `question_id` int(11) NOT NULL, `description` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `presurvey_questions` -- DROP TABLE IF EXISTS `presurvey_questions`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `presurvey_questions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(255) DEFAULT NULL, `question_type` varchar(50) DEFAULT NULL, `answer_choices` varchar(255) DEFAULT NULL, `required` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `presurvey_questions` -- LOCK TABLES `presurvey_questions` WRITE; /*!40000 ALTER TABLE `presurvey_questions` DISABLE KEYS */; INSERT INTO `presurvey_questions` VALUES (1,'What is your gender?','multiple_choice_radio','Male|Female|Other',1),(2,'Which of the following categories includes your age?','multiple_choice_radio','18 to 24|25 to 34|35 to 45|45 to 54|55 or older',1),(3,'What is the highest level of school you have completed or the highest degree you have received?','multiple_choice','Less than high school degree|High school degree or equivalent (e.g., GED)|Some college but no degree|Bachelor degree|Graduate degree',1),(4,'How do you rate your proficiency in using smartphones?','multiple_choice_radio','Very low|Low|Medium|High|Very high',1),(5,'Please use the text box if you need to clarify any of your answers above','text','Optional clarifications',0); /*!40000 ALTER TABLE `presurvey_questions` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `presurvey_responses` -- DROP TABLE IF EXISTS `presurvey_responses`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `presurvey_responses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `question_id` int(11) NOT NULL, `description` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `routine_responses` -- DROP TABLE IF EXISTS `routine_responses`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `routine_responses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uid` int(11) DEFAULT NULL, `day` varchar(15) DEFAULT NULL, `beginTime` varchar(10) DEFAULT NULL, `endTime` varchar(10) DEFAULT NULL, `location` varchar(45) DEFAULT NULL, `activity` varchar(45) DEFAULT NULL, `musicPlayerApp` varchar(45) DEFAULT NULL, `ringerManagerApp` varchar(45) DEFAULT NULL, `app3` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=152 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `statuses` -- DROP TABLE IF EXISTS `statuses`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `statuses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `seq_no` int(11) NOT NULL, `title` varchar(25) NOT NULL, `filename` varchar(20) NOT NULL, `next_seq` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `statuses` -- LOCK TABLES `statuses` WRITE; /*!40000 ALTER TABLE `statuses` DISABLE KEYS */; INSERT INTO `statuses` VALUES (1,1,'Presurvey','presurvey.jsp',2),(2,2,'Main Instructions','debrief.jsp',4),(3,2,'Add Routine','routine.jsp',4),(4,4,'Post-Survey','postsurvey.jsp',5),(5,5,'Completion','completed.jsp',5); /*!40000 ALTER TABLE `statuses` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `users` -- DROP TABLE IF EXISTS `users`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mturk_id` varchar(20) NOT NULL, `created_at` datetime NOT NULL, `completion` tinyint(4) NOT NULL COMMENT '0 = not completed, 1 = completed.', `state` int(11) NOT NULL DEFAULT '1' COMMENT '0 = new user, 1 = presurvey, 2 = personality, 3 = creativity, 10 = prereqs completed.', `completion_code` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2017-02-04 12:15:25
/* Navicat MySQL Data Transfer Source Server : VPS Source Server Version : 50509 Source Host : 95.143.32.54:3306 Source Database : world_dev Target Server Type : MYSQL Target Server Version : 50509 File Encoding : 65001 Date: 2012-01-11 16:58:38 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `autobroadcast` -- ---------------------------- DROP TABLE IF EXISTS `autobroadcast`; CREATE TABLE `autobroadcast` ( `id` int(11) NOT NULL AUTO_INCREMENT, `text` longtext NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of autobroadcast -- ----------------------------
DO $$ BEGIN BEGIN ALTER TABLE sys_user ADD COLUMN lms_id character varying; EXCEPTION WHEN duplicate_column THEN RAISE NOTICE 'column lms_id already exists in sys_user.'; END; END; $$
create table party_member_100 ( c_id INT, p_id VARCHAR(1) ); insert into party_member_100 (c_id, p_id) values (1, '3'); insert into party_member_100 (c_id, p_id) values (2, '1'); insert into party_member_100 (c_id, p_id) values (3, '5'); insert into party_member_100 (c_id, p_id) values (4, '2'); insert into party_member_100 (c_id, p_id) values (5, '1'); insert into party_member_100 (c_id, p_id) values (6, '3'); insert into party_member_100 (c_id, p_id) values (7, '5'); insert into party_member_100 (c_id, p_id) values (8, '3'); insert into party_member_100 (c_id, p_id) values (9, '6'); insert into party_member_100 (c_id, p_id) values (10, '5'); insert into party_member_100 (c_id, p_id) values (11, '2'); insert into party_member_100 (c_id, p_id) values (12, '3'); insert into party_member_100 (c_id, p_id) values (13, '4'); insert into party_member_100 (c_id, p_id) values (14, '1'); insert into party_member_100 (c_id, p_id) values (15, '6'); insert into party_member_100 (c_id, p_id) values (16, '5'); insert into party_member_100 (c_id, p_id) values (17, '3'); insert into party_member_100 (c_id, p_id) values (18, '6'); insert into party_member_100 (c_id, p_id) values (19, '1'); insert into party_member_100 (c_id, p_id) values (20, '3'); insert into party_member_100 (c_id, p_id) values (21, '6'); insert into party_member_100 (c_id, p_id) values (22, '2'); insert into party_member_100 (c_id, p_id) values (23, '1'); insert into party_member_100 (c_id, p_id) values (24, '5'); insert into party_member_100 (c_id, p_id) values (25, '1'); insert into party_member_100 (c_id, p_id) values (26, '3'); insert into party_member_100 (c_id, p_id) values (27, '1'); insert into party_member_100 (c_id, p_id) values (28, '2'); insert into party_member_100 (c_id, p_id) values (29, '5'); insert into party_member_100 (c_id, p_id) values (30, '4'); insert into party_member_100 (c_id, p_id) values (31, '2'); insert into party_member_100 (c_id, p_id) values (32, '2'); insert into party_member_100 (c_id, p_id) values (33, '4'); insert into party_member_100 (c_id, p_id) values (34, '2'); insert into party_member_100 (c_id, p_id) values (35, '4'); insert into party_member_100 (c_id, p_id) values (36, '3'); insert into party_member_100 (c_id, p_id) values (37, '1'); insert into party_member_100 (c_id, p_id) values (38, '4'); insert into party_member_100 (c_id, p_id) values (39, '4'); insert into party_member_100 (c_id, p_id) values (40, '4'); insert into party_member_100 (c_id, p_id) values (41, '6'); insert into party_member_100 (c_id, p_id) values (42, '1'); insert into party_member_100 (c_id, p_id) values (43, '3'); insert into party_member_100 (c_id, p_id) values (44, '4'); insert into party_member_100 (c_id, p_id) values (45, '1'); insert into party_member_100 (c_id, p_id) values (46, '3'); insert into party_member_100 (c_id, p_id) values (47, '1'); insert into party_member_100 (c_id, p_id) values (48, '2'); insert into party_member_100 (c_id, p_id) values (49, '6'); insert into party_member_100 (c_id, p_id) values (50, '2'); insert into party_member_100 (c_id, p_id) values (51, '5'); insert into party_member_100 (c_id, p_id) values (52, '3'); insert into party_member_100 (c_id, p_id) values (53, '4'); insert into party_member_100 (c_id, p_id) values (54, '2'); insert into party_member_100 (c_id, p_id) values (55, '1'); insert into party_member_100 (c_id, p_id) values (56, '5'); insert into party_member_100 (c_id, p_id) values (57, '5'); insert into party_member_100 (c_id, p_id) values (58, '2'); insert into party_member_100 (c_id, p_id) values (59, '3'); insert into party_member_100 (c_id, p_id) values (60, '1'); insert into party_member_100 (c_id, p_id) values (61, '3'); insert into party_member_100 (c_id, p_id) values (62, '2'); insert into party_member_100 (c_id, p_id) values (63, '3'); insert into party_member_100 (c_id, p_id) values (64, '5'); insert into party_member_100 (c_id, p_id) values (65, '4'); insert into party_member_100 (c_id, p_id) values (66, '6'); insert into party_member_100 (c_id, p_id) values (67, '5'); insert into party_member_100 (c_id, p_id) values (68, '5'); insert into party_member_100 (c_id, p_id) values (69, '1'); insert into party_member_100 (c_id, p_id) values (70, '1'); insert into party_member_100 (c_id, p_id) values (71, '1'); insert into party_member_100 (c_id, p_id) values (72, '1'); insert into party_member_100 (c_id, p_id) values (73, '5'); insert into party_member_100 (c_id, p_id) values (74, '5'); insert into party_member_100 (c_id, p_id) values (75, '4'); insert into party_member_100 (c_id, p_id) values (76, '1'); insert into party_member_100 (c_id, p_id) values (77, '1'); insert into party_member_100 (c_id, p_id) values (78, '3'); insert into party_member_100 (c_id, p_id) values (79, '4'); insert into party_member_100 (c_id, p_id) values (80, '3'); insert into party_member_100 (c_id, p_id) values (81, '2'); insert into party_member_100 (c_id, p_id) values (82, '2'); insert into party_member_100 (c_id, p_id) values (83, '6'); insert into party_member_100 (c_id, p_id) values (84, '3'); insert into party_member_100 (c_id, p_id) values (85, '5'); insert into party_member_100 (c_id, p_id) values (86, '2'); insert into party_member_100 (c_id, p_id) values (87, '6'); insert into party_member_100 (c_id, p_id) values (88, '2'); insert into party_member_100 (c_id, p_id) values (89, '1'); insert into party_member_100 (c_id, p_id) values (90, '5'); insert into party_member_100 (c_id, p_id) values (91, '5'); insert into party_member_100 (c_id, p_id) values (92, '4'); insert into party_member_100 (c_id, p_id) values (93, '4'); insert into party_member_100 (c_id, p_id) values (94, '3'); insert into party_member_100 (c_id, p_id) values (95, '3'); insert into party_member_100 (c_id, p_id) values (96, '2'); insert into party_member_100 (c_id, p_id) values (97, '4'); insert into party_member_100 (c_id, p_id) values (98, '2'); insert into party_member_100 (c_id, p_id) values (99, '5'); insert into party_member_100 (c_id, p_id) values (100, '5');
create domain description as varchar(60); create domain currency as numeric(15,2); create domain percent as numeric(15,4); drop table if exists produtos, operacoes; create table produtos ( id serial primary key, descricao description, preco currency ); create table operacoes ( id serial primary key, descricao description );
select count(*) from (select `ps_suppkey`, count(*) from `partsupp` group by `ps_suppkey` order by fetch next 20 rows only) as `t1`
-- -- MySQL 5.1.44 -- Thu, 10 Feb 2011 20:15:07 +0000 -- DROP TABLE IF EXISTS `accessgroups`; CREATE TABLE `accessgroups` ( `id` int(11) not null, `name` varchar(50), `commands` longtext, `worlds` varchar(255) default '*', PRIMARY KEY (`id`), UNIQUE KEY (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; DROP TABLE IF EXISTS `accesslevels`; CREATE TABLE `accesslevels` ( `id` int(11) not null, `name` varchar(50), `usernameformat` varchar(255) default '^0{$username}', `accessgroups` varchar(255), `admingroup` tinyint(1) default '0', `canbuild` tinyint(1) default '1', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; DROP TABLE IF EXISTS `homes`; CREATE TABLE `homes` ( `id` int(10) unsigned not null auto_increment, `name` varchar(50), `userid` int(11), `username` varchar(50) not null, `world` varchar(50) not null, `x` double not null, `y` double not null, `z` double not null, `rotX` float not null, `rotY` float not null, PRIMARY KEY (`id`), UNIQUE KEY (`name`,`userid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; DROP TABLE IF EXISTS `kits`; CREATE TABLE `kits` ( `id` int(11) not null, `name` varchar(50) not null, `items` longtext not null, `minaccesslevel` int(11) default '0', `delay` int(11) default '0', PRIMARY KEY (`id`), UNIQUE KEY (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(11) not null auto_increment, `username` varchar(255) not null, `usernameformat` varchar(255), `password` varchar(255) , `email` varchar(255) , `ip` varchar(255), `firstlogin` int(11) not null default '0', `lastlogin` int(11) not null default '0', `onlinetime` int(11) not null default '0', `ipbantime` int(11) not null default '0', `bantime` int(11) not null default '0', `mutetime` int(11) not null default '0', `commands` longtext , `canbuild` tinyint(1) not null default '0', `isadmin` tinyint(1) not null default '0', `accesslevel` int(11) not null default '0', PRIMARY KEY (`id`), UNIQUE KEY (`username`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; DROP TABLE IF EXISTS `warps`; CREATE TABLE `warps` ( `id` int(10) unsigned not null auto_increment, `name` varchar(50) not null, `groupname` varchar(255) default 'default', `world` varchar(50) not null, `x` double not null, `y` double not null, `z` double not null, `rotX` float not null, `rotY` float not null, `minaccesslevel` int(11) default '0', PRIMARY KEY (`id`), UNIQUE KEY (`name`,`groupname`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; DROP TABLE IF EXISTS `kits_delay`; CREATE TABLE `kits_delay` ( `userid` INT NOT NULL , `name` VARCHAR( 255 ) NOT NULL , `time` INT NOT NULL ) ENGINE = MYISAM ;
CREATE TABLE [clothing].[Stock] ( [StockID] INT IDENTITY (1, 1) NOT NULL, [ItemID] INT NOT NULL, [SizeID] INT NOT NULL, [InventoryID] INT NOT NULL, PRIMARY KEY CLUSTERED ([StockID]), CONSTRAINT [FK_clothing.Stock_clothing.Items_ItemID] FOREIGN KEY ([ItemID]) REFERENCES [clothing].[Items] ([ItemID]) ON DELETE CASCADE, CONSTRAINT [FK_clothing.Stock_clothing.Sizes_SizeID] FOREIGN KEY ([SizeID]) REFERENCES [clothing].[Sizes] ([SizeID]) ON DELETE CASCADE, CONSTRAINT [FK_clothing.Stock_clothing.Inventory_InventoryID] FOREIGN KEY ([InventoryID]) REFERENCES [clothing].[Inventory] ([InventoryID]) ON DELETE CASCADE)
use dblaferme; delimiter drop database dblaferme drop function if exists getconso; create function getconso(elevage int, plante text) returns int deterministic begin return (select a.qtx from alimentation a inner join plante p on p.idplante = a.fkplante and p.nom like plante inner join animal an on an.idanimal = a.fkanimal inner join elevage e on e.fkanimal = an.idanimal and e.idelevage = elevage ); end drop database dblaferme delimiter ; select getconso(6, 'millet');
If (SELECT count(*) FROM Story.StorySection) = 0 BEGIN SET IDENTITY_INSERT Story.StorySection ON INSERT INTO Story.StorySection ([Id], [Description], [HierarchyLevel],[Order],[ParentHierarchyElementId],[StoryId]) VALUES (1,N'Act one', 1,1,-1,1), (2,N'Act two', 1,2,-1,1), (3,N'Act three', 1,3,-1,1); SET IDENTITY_INSERT Story.StorySection OFF END
-- Restriciones de integridad -- Email de una persona validado por expresion regular ALTER TABLE persona ADD CONSTRAINT chk_persona_email CHECK (REGEXP_LIKE (email,'^[A-Za-z]+[A-Za-z0-9.]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$')); -- A lo mas el guia tendra un descuento del 30% ALTER TABLE guia ADD CONSTRAINT chk_guia_aumento_porcentaje CHECK (aumento_porcentaje BETWEEN 0 AND 0.30); -- Las fechas de la promocion consistentes, asi como el rango del porcentaje ALTER TABLE promocion ADD CONSTRAINT chk_promocion_fechas_descuento CHECK (desde <= hasta AND desc_porcentaje BETWEEN 0 AND 1); -- la calificacion posible esta entre 0 y 10 ALTER TABLE estudiante_materia ADD CONSTRAINT chk_es_mat_cal CHECK (calificacion BETWEEN 0 AND 10); -- a lo mas habria dos banos en un autobus ALTER TABLE autobus ADD CONSTRAINT chk_autobus_wc CHECK (wc BETWEEN 0 AND 2); -- No puede haber mas lugares reservados del total de plazas ALTER TABLE viaje ADD CONSTRAINT chk_viaje_reservados CHECK (reservados <= lugares);
-- you should take values for {RESOURCE_ID} and {ATTRIBUTE_ID} from Applications Manager web interface --- min, max, avg values of response time for server - last 24hrs select floor(min(minvalue)) as minv, floor(max(maxvalue)) as maxv, floor(sum(total)/sum(totalcount)) as avgv from AM_RESPONSETIME_MinMaxAvgData where resid = {RESOURCE_ID} and attributeid = {ATTRIBUTE_ID} and duration = 1 and floor(archivedtime / 1000) > UNIX_TIMESTAMP() - 60*60*24 --- min, max, avg values of used memory for tomcat server - last 24hrs select floor(min(minvalue)/1024) as minv, floor(max(maxvalue)/1024) as maxv, floor(sum(total)/sum(totalcount)/1024) as avgv from AM_JVM_MinMaxAvgData where resid = {RESOURCE_ID} and attributeid = {ATTRIBUTE_ID} and duration = 1 and floor(archivedtime / 1000) > UNIX_TIMESTAMP() - 60*60*24 --- min, max, avg values of response for webservice - last 24hrs select floor(min(minvalue)) as minv, floor(max(maxvalue)) as maxv, floor(sum(total)/sum(totalcount)) as avgv from AM_WEBSERVICES_RESPONSETIME_MinMaxAvgData where resid = {RESOURCE_ID} and attributeid = {ATTRIBUTE_ID} and duration = 1 and floor(archivedtime / 1000) > UNIX_TIMESTAMP() - 60*60*24
CREATE procedure spr_list_Bank as select BankCode, "Bank Code" = BankCode, "Bank Name" = BankName, "Active" = Active from BankMaster
-- Database generated with pgModeler (PostgreSQL Database Modeler). -- pgModeler version: 0.9.1 -- PostgreSQL version: 10.0 -- Project Site: pgmodeler.io -- Model Author: --- -- Database creation must be done outside a multicommand file. -- These commands were put in this file only as a convenience. -- -- object: new_database | type: DATABASE -- -- -- DROP DATABASE IF EXISTS new_database; -- CREATE DATABASE new_database; -- -- ddl-end -- -- -- object: public."Property" | type: TABLE -- -- DROP TABLE IF EXISTS public."Property" CASCADE; CREATE TABLE public."Property"( "Property No" varchar(3) NOT NULL, "Street" varchar(30), "Post Code" char(7), "Number of Bedrooms" Integer, "Number of Bathromms" Integer, "Daily Rental Rate" decimal, "Owner ID_Owner" varchar(5), "Property Type ID_Property Type" varchar(5), "City ID_City" varchar(5), CONSTRAINT "Property_pk" PRIMARY KEY ("Property No") ); -- ddl-end -- ALTER TABLE public."Property" OWNER TO postgres; -- ddl-end -- -- object: public."Owner" | type: TABLE -- -- DROP TABLE IF EXISTS public."Owner" CASCADE; CREATE TABLE public."Owner"( "Owner ID" varchar(3) NOT NULL, "Owner Name" varchar(30), "Owner Email" varchar(30), CONSTRAINT "Owner_pk" PRIMARY KEY ("Owner ID") ); -- ddl-end -- ALTER TABLE public."Owner" OWNER TO postgres; -- ddl-end -- -- object: public."Client" | type: TABLE -- -- DROP TABLE IF EXISTS public."Client" CASCADE; CREATE TABLE public."Client"( "Client ID" varchar(3) NOT NULL, "Client Name" varchar(30), "Client Email" varchar(30), CONSTRAINT "Client_pk" PRIMARY KEY ("Client ID") ); -- ddl-end -- ALTER TABLE public."Client" OWNER TO postgres; -- ddl-end -- -- object: public."Invoice" | type: TABLE -- -- DROP TABLE IF EXISTS public."Invoice" CASCADE; CREATE TABLE public."Invoice"( "Invoice Number" varchar(5) NOT NULL, "Invoice Date" date, "Rental Start Date" date, "Rental Charge" decimal, "Tax Owing" decimal, "Number of Days" decimal, "Rental Amount Owing" decimal, "Property No_Property" varchar(5), "Client ID_Client" varchar(5), CONSTRAINT "Invoice_pk" PRIMARY KEY ("Invoice Number") ); -- ddl-end -- ALTER TABLE public."Invoice" OWNER TO postgres; -- ddl-end -- -- object: public."Calendar Year" | type: TABLE -- -- DROP TABLE IF EXISTS public."Calendar Year" CASCADE; CREATE TABLE public."Calendar Year"( "Calendar Year" varchar(4) NOT NULL, CONSTRAINT "Calendar Year_pk" PRIMARY KEY ("Calendar Year") ); -- ddl-end -- ALTER TABLE public."Calendar Year" OWNER TO postgres; -- ddl-end -- -- object: public."Property Expense" | type: TABLE -- -- DROP TABLE IF EXISTS public."Property Expense" CASCADE; CREATE TABLE public."Property Expense"( "Property Expense ID" varchar(3) NOT NULL, "Property Tax" decimal, "Electricity Cost" decimal, "Heating Cost" decimal, "Advertising Cost" decimal, "Cleaning Cost" decimal, "Total Expense" decimal, "Property No_Property" varchar(5), "Calendar Year_Calendar Year" varchar(4), CONSTRAINT "Property Expense_pk" PRIMARY KEY ("Property Expense ID") ); -- ddl-end -- ALTER TABLE public."Property Expense" OWNER TO postgres; -- ddl-end -- -- object: public."Property Type" | type: TABLE -- -- DROP TABLE IF EXISTS public."Property Type" CASCADE; CREATE TABLE public."Property Type"( "Property Type ID" varchar(3) NOT NULL, "Property Type" varchar(15), CONSTRAINT "Property Type_pk" PRIMARY KEY ("Property Type ID") ); -- ddl-end -- ALTER TABLE public."Property Type" OWNER TO postgres; -- ddl-end -- -- object: public."Country" | type: TABLE -- -- DROP TABLE IF EXISTS public."Country" CASCADE; CREATE TABLE public."Country"( "Country ID" varchar(5) NOT NULL, "Country" varchar(20), CONSTRAINT "Country_pk" PRIMARY KEY ("Country ID") ); -- ddl-end -- ALTER TABLE public."Country" OWNER TO postgres; -- ddl-end -- -- object: public."Province" | type: TABLE -- -- DROP TABLE IF EXISTS public."Province" CASCADE; CREATE TABLE public."Province"( "Province ID" varchar(3) NOT NULL, "Province" varchar(20), "Country ID_Country" varchar(5), CONSTRAINT "Province_pk" PRIMARY KEY ("Province ID") ); -- ddl-end -- ALTER TABLE public."Province" OWNER TO postgres; -- ddl-end -- -- object: public."City" | type: TABLE -- -- DROP TABLE IF EXISTS public."City" CASCADE; CREATE TABLE public."City"( "City ID" varchar(3) NOT NULL, "City" varchar(20), "Province ID_Province" varchar(5), CONSTRAINT "City_pk" PRIMARY KEY ("City ID") ); -- ddl-end -- ALTER TABLE public."City" OWNER TO postgres; -- ddl-end -- -- object: "Owner_fk" | type: CONSTRAINT -- -- ALTER TABLE public."Property" DROP CONSTRAINT IF EXISTS "Owner_fk" CASCADE; ALTER TABLE public."Property" ADD CONSTRAINT "Owner_fk" FOREIGN KEY ("Owner ID_Owner") REFERENCES public."Owner" ("Owner ID") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end -- -- object: "Property Type_fk" | type: CONSTRAINT -- -- ALTER TABLE public."Property" DROP CONSTRAINT IF EXISTS "Property Type_fk" CASCADE; ALTER TABLE public."Property" ADD CONSTRAINT "Property Type_fk" FOREIGN KEY ("Property Type ID_Property Type") REFERENCES public."Property Type" ("Property Type ID") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end -- -- object: "Property_fk" | type: CONSTRAINT -- -- ALTER TABLE public."Property Expense" DROP CONSTRAINT IF EXISTS "Property_fk" CASCADE; ALTER TABLE public."Property Expense" ADD CONSTRAINT "Property_fk" FOREIGN KEY ("Property No_Property") REFERENCES public."Property" ("Property No") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end -- -- object: "Property_fk" | type: CONSTRAINT -- -- ALTER TABLE public."Invoice" DROP CONSTRAINT IF EXISTS "Property_fk" CASCADE; ALTER TABLE public."Invoice" ADD CONSTRAINT "Property_fk" FOREIGN KEY ("Property No_Property") REFERENCES public."Property" ("Property No") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end -- -- object: "Client_fk" | type: CONSTRAINT -- -- ALTER TABLE public."Invoice" DROP CONSTRAINT IF EXISTS "Client_fk" CASCADE; ALTER TABLE public."Invoice" ADD CONSTRAINT "Client_fk" FOREIGN KEY ("Client ID_Client") REFERENCES public."Client" ("Client ID") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end -- -- object: "Calendar Year_fk" | type: CONSTRAINT -- -- ALTER TABLE public."Property Expense" DROP CONSTRAINT IF EXISTS "Calendar Year_fk" CASCADE; ALTER TABLE public."Property Expense" ADD CONSTRAINT "Calendar Year_fk" FOREIGN KEY ("Calendar Year_Calendar Year") REFERENCES public."Calendar Year" ("Calendar Year") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end -- -- object: "Country_fk" | type: CONSTRAINT -- -- ALTER TABLE public."Province" DROP CONSTRAINT IF EXISTS "Country_fk" CASCADE; ALTER TABLE public."Province" ADD CONSTRAINT "Country_fk" FOREIGN KEY ("Country ID_Country") REFERENCES public."Country" ("Country ID") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end -- -- object: "Province_fk" | type: CONSTRAINT -- -- ALTER TABLE public."City" DROP CONSTRAINT IF EXISTS "Province_fk" CASCADE; ALTER TABLE public."City" ADD CONSTRAINT "Province_fk" FOREIGN KEY ("Province ID_Province") REFERENCES public."Province" ("Province ID") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end -- -- object: "City_fk" | type: CONSTRAINT -- -- ALTER TABLE public."Property" DROP CONSTRAINT IF EXISTS "City_fk" CASCADE; ALTER TABLE public."Property" ADD CONSTRAINT "City_fk" FOREIGN KEY ("City ID_City") REFERENCES public."City" ("City ID") MATCH FULL ON DELETE SET NULL ON UPDATE CASCADE; -- ddl-end --
# patch_53_54_c.sql # # title: Move analysis_id from identity_xref to object_xref # # description: # Add analysis_xref column to object_xref, copy values from identity_xref, remove column from identity_xref. # Will allow all object_xref relationships to have an analysis, not just those from sequence matching. ALTER TABLE object_xref ADD COLUMN analysis_id SMALLINT UNSIGNED DEFAULT NULL; UPDATE object_xref ox, identity_xref ix SET ox.analysis_id=ix.analysis_id WHERE ox.object_xref_id=ix.object_xref_id; ALTER TABLE object_xref ADD KEY analysis_idx (analysis_id); ALTER TABLE identity_xref DROP KEY analysis_idx; ALTER TABLE identity_xref DROP COLUMN analysis_id; # patch identifier INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'patch', 'patch_53_54_c.sql|identity_object_analysis_move');
CREATE DATABASE exercicio1 COLLATE 'utf8mb4_unicode_ci';
-- select statements select * from student; select * from course; select * from enrolled; -- null middle names select * from student where middleInitial is null; -- how many students in Ohio select count(*) from student where state = 'OH'; -- oldest/youngest birthday options select max(birthday) from student; select * from student order by birthday desc; -- age of all students select birthday, year(birthday), curdate(), year(curdate()), (year (curdate()) - year (birthday)) as Age from student order by age; -- age of oldest student select firstName, lastName, (year(curdate()) - year(birthday)) as Age from student where birthday = (select min(birthday) from student); -- THIS IS THE BEST FILTER select * from student s where s.birthday = (select min(birthday) from student); select firstname, lastname, birthday from student where birthday = (select min(birthday) from student); -- how many courses select count(*) from course where subject = 'socialStudies'; select * from course where subject = 'math'; -- list all subjects starting with the letter M. % is wildcard. can also insert characters before and after, or inbetween. select * from course where subject like 'm%'; -- 3 way join select * from enrolled e join course c on c.ID = e.courseID join student s on s.ID = e.studentID; -- number of students per state select state, count(*) from student group by state; select s.state 'State', count(s.state) as 'Student Count' from student s group by s.state; -- outer join,all students plus enrollments select s.ID, s.firstName, s.lastName, e.studentID, e.courseID, e.grade, c.name from student s left join enrolled e on e.studentID = s.ID left join course c on c.ID = e.courseID; -- number of students per course (not done) select * from enrolled e join student s on s.ID = e.studentID;
insert into units (type, unit_name, description, owner_id, ppd, zip_code, img1, img2, img3, img4, subtype, contact_info, contact_info2) values($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) returning *;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * Author: Miry * Created: 2/12/2016 */ CREATE TABLE CONDUCTOR(ID_CONDUCTOR INTEGER,NOMBRE VARCHAR2(30),DIR VARCHAR2(50), TEL VARCHAR2(15), EXPERIENCIA INTEGER, SALUD VARCHAR2(20), CONSTRAINT PK_ID_CONDUCTOR PRIMARY KEY(ID_CONDUCTOR)); CREATE PROCEDURE GUARDAR_CONDUCTOR( MY_ID_CONDUCTOR NUMBER, MY_NOMBRE VARCHAR2, MY_DIR VARCHAR2, MY_TEL VARCHAR2, MY_EXPERIENCIA NUMBER, MY_SALUD VARCHAR2 )IS BEGIN INSERT INTO CONDUCTOR(ID_CONDUCTOR,NOMBRE,DIR,TEL,EXPERIENCIA,SALUD) VALUES(MY_ID_CONDUCTOR,MY_NOMBRE,MY_DIR,MY_TEL,MY_EXPERIENCIA,MY_SALUD); END ; INTO hr.cliente(id,nombres,apellidos,fecha_afiliacion)
/* Warnings: - The primary key for the `Issue` table will be changed. If it partially fails, the table could be left without primary key constraint. - The primary key for the `Pair` table will be changed. If it partially fails, the table could be left without primary key constraint. - You are about to drop the column `teams_id` on the `Pair` table. All the data in the column will be lost. - The primary key for the `Team` table will be changed. If it partially fails, the table could be left without primary key constraint. - The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint. - You are about to drop the column `belong_id` on the `User` table. All the data in the column will be lost. - The primary key for the `UserIssue` table will be changed. If it partially fails, the table could be left without primary key constraint. - You are about to drop the `IssueGroup` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `Belong` table. If the table is not empty, all the data it contains will be lost. - Added the required column `belong` to the `Pair` table without a default value. This is not possible if the table is not empty. - Added the required column `team_id` to the `Pair` table without a default value. This is not possible if the table is not empty. - Added the required column `belong` to the `Team` table without a default value. This is not possible if the table is not empty. - Added the required column `status` to the `User` table without a default value. This is not possible if the table is not empty. */ -- DropForeignKey ALTER TABLE "User" DROP CONSTRAINT "User_belong_id_fkey"; -- DropForeignKey ALTER TABLE "User" DROP CONSTRAINT "User_pair_id_fkey"; -- DropForeignKey ALTER TABLE "Pair" DROP CONSTRAINT "Pair_teams_id_fkey"; -- DropForeignKey ALTER TABLE "Issue" DROP CONSTRAINT "Issue_issue_group_id_fkey"; -- DropForeignKey ALTER TABLE "UserIssue" DROP CONSTRAINT "UserIssue_issue_id_fkey"; -- DropForeignKey ALTER TABLE "UserIssue" DROP CONSTRAINT "UserIssue_user_id_fkey"; -- AlterTable ALTER TABLE "Issue" DROP CONSTRAINT "Issue_pkey", ALTER COLUMN "id" DROP DEFAULT, ALTER COLUMN "id" SET DATA TYPE TEXT, ALTER COLUMN "issue_group_id" DROP DEFAULT, ADD PRIMARY KEY ("id"); DROP SEQUENCE "Issue_id_seq"; -- AlterTable ALTER TABLE "Pair" DROP CONSTRAINT "Pair_pkey", DROP COLUMN "teams_id", ADD COLUMN "belong" BOOLEAN NOT NULL, ADD COLUMN "team_id" TEXT NOT NULL, ALTER COLUMN "id" DROP DEFAULT, ALTER COLUMN "id" SET DATA TYPE TEXT, ADD PRIMARY KEY ("id"); DROP SEQUENCE "Pair_id_seq"; -- AlterTable ALTER TABLE "Team" DROP CONSTRAINT "Team_pkey", ADD COLUMN "belong" BOOLEAN NOT NULL, ALTER COLUMN "id" DROP DEFAULT, ALTER COLUMN "id" SET DATA TYPE TEXT, ADD PRIMARY KEY ("id"); DROP SEQUENCE "Team_id_seq"; -- AlterTable ALTER TABLE "User" DROP CONSTRAINT "User_pkey", DROP COLUMN "belong_id", ADD COLUMN "status" INTEGER NOT NULL, ALTER COLUMN "id" DROP DEFAULT, ALTER COLUMN "id" SET DATA TYPE TEXT, ALTER COLUMN "pair_id" DROP DEFAULT, ALTER COLUMN "pair_id" SET DATA TYPE TEXT, ADD PRIMARY KEY ("id"); DROP SEQUENCE "User_id_seq"; -- AlterTable ALTER TABLE "UserIssue" DROP CONSTRAINT "UserIssue_pkey", ALTER COLUMN "id" DROP DEFAULT, ALTER COLUMN "id" SET DATA TYPE TEXT, ALTER COLUMN "user_id" SET DATA TYPE TEXT, ALTER COLUMN "issue_id" SET DATA TYPE TEXT, ALTER COLUMN "progress" DROP DEFAULT, ADD PRIMARY KEY ("id"); DROP SEQUENCE "UserIssue_id_seq"; -- DropTable DROP TABLE "IssueGroup"; -- DropTable DROP TABLE "Belong"; -- AddForeignKey ALTER TABLE "User" ADD FOREIGN KEY ("pair_id") REFERENCES "Pair"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Pair" ADD FOREIGN KEY ("team_id") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "UserIssue" ADD FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "UserIssue" ADD FOREIGN KEY ("issue_id") REFERENCES "Issue"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- Create the synonym create or replace synonym FSSR_FSJK for FS10.FSJK;
insert into student (email_address, student_id) values('bart.simpson@oit.edu', 9); insert into student (email_address, student_id) values('ralph.wiggum@oit.edu', 10); insert into student (email_address, student_id) values('lisa.simpson@oit.edu', 11); insert into student (email_address, student_id) values('milhouse.vanhouten@oit.edu', 12);
SET @@AUTOCOMMIT = 1; DROP DATABASE IF EXISTS dsa; CREATE DATABASE dsa; USE dsa; CREATE TABLE Product ( product_id CHAR(4) NOT NULL PRIMARY KEY, price DECIMAL(4, 2), size INT, name varchar(100), description VARCHAR(200) ); CREATE TABLE Cart ( product_id CHAR(4) NOT NULL PRIMARY KEY, quantity INT, FOREIGN KEY (product_id) REFERENCES Product(product_id) ); CREATE TABLE Invoice ( invoice_no INT AUTO_INCREMENT PRIMARY KEY, holder_name VARCHAR(25), card_number CHAR(16), expiry CHAR(5), cvv CHAR(3), total DECIMAL(8, 2) ) AUTO_INCREMENT = 1; CREATE TABLE ProductInvoice ( invoice_no INT, product_id CHAR(4), quantity INT, FOREIGN KEY (invoice_no) REFERENCES Invoice(invoice_no), FOREIGN KEY (product_id) REFERENCES Product(product_id), PRIMARY KEY (invoice_no, product_id) ); CREATE TABLE SubscriberEmails ( email VARCHAR(50), PRIMARY KEY (email) ); CREATE user IF NOT EXISTS dbadmin@localhost; GRANT all privileges ON *.* TO dbadmin@localhost; INSERT INTO Product VALUES ("M001", 73.56, 055, "Blue Dream", "Hybrid"); INSERT INTO Product VALUES ("M002", 40.15, 171, "OG Kush", "Hybrid"); INSERT INTO Product VALUES ("M003", 95.48, 023, "Pineapple Express", "Hybrid"); INSERT INTO Product VALUES ("M004", 07.32, 144, "White Widow", "Hybrid"); INSERT INTO Product VALUES ("M005", 19.82, 084, "AK-47", "Hybrid"); INSERT INTO Product VALUES ("M006", 52.73, 066, "Blue Diesel", "Hybrid"); INSERT INTO Product VALUES ("M007", 16.18, 086, "Black Jack", "Hybrid"); INSERT INTO Product VALUES ("M008", 29.38, 036, "Key Lime Pie", "Hybrid"); INSERT INTO Product VALUES ("M009", 61.57, 142, "Northern Lights", "Indica"); INSERT INTO Product VALUES ("M010", 59.74, 035, "Bubba Kush", "Indica"); INSERT INTO Product VALUES ("M011", 94.05, 171, "Black Mamba", "Indica"); INSERT INTO Product VALUES ("M012", 16.52, 109, "Death Star", "Indica"); INSERT INTO Product VALUES ("M013", 11.27, 180, "Purple Haze", "Sativa"); INSERT INTO Product VALUES ("M014", 44.82, 082, "Sunshine", "Sativa"); INSERT INTO Product VALUES ("M015", 97.82, 097, "Dutch Hawaiian", "Sativa"); INSERT INTO Product VALUES ("E001", 20.53, 024, "Berocca", "Description needed"); INSERT INTO Product VALUES ("E002", 69.10, 111, "Gummies", "Description needed"); INSERT INTO Product VALUES ("E003", 93.57, 026, "CBD Oil Tincture", "Description needed"); INSERT INTO Product VALUES ("E004", 73.87, 063, "Brownies", "Vegan, Gluten Free Infused Brownies"); INSERT INTO Product VALUES ("E005", 81.73, 020, "Tea Bags", "Description needed");
-- Your database schema. Use the Schema Designer at http://localhost:8001/ to add some tables. CREATE TABLE tweets ( id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL, author TEXT NOT NULL, content TEXT NOT NULL );
/* Navicat MySQL Data Transfer Source Server : localhost_3306 Source Server Version : 50554 Source Host : localhost:3306 Source Database : phpwamp Target Server Type : MYSQL Target Server Version : 50554 File Encoding : 65001 Date: 2019-03-01 11:55:55 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `stock_user_recharge` -- ---------------------------- DROP TABLE IF EXISTS `stock_user_recharge`; CREATE TABLE `stock_user_recharge` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned NOT NULL COMMENT '用户ID;表stock_user字段user_id字段', `trade_no` varchar(64) NOT NULL COMMENT '订单编号', `out_trade_no` varchar(128) DEFAULT NULL COMMENT '外部订单号', `amount` decimal(11,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '充值金额', `actual` decimal(11,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '实际到账', `poundage` decimal(11,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '充值手续费', `type` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '充值方式:0支付宝,1微信,2-连连支付', `state` tinyint(4) NOT NULL DEFAULT '0' COMMENT '充值状态:0待付款,1成功,-1失败', `create_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '充值时间', `update_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '审核时间', PRIMARY KEY (`id`), UNIQUE KEY `trade_no` (`trade_no`), KEY `user_id` (`user_id`), KEY `state` (`state`) ) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='充值记录表'; -- ---------------------------- -- Records of stock_user_recharge -- ----------------------------
--liquibase formatted sql DROP TABLE subcategory CASCADE ;
select a.dbid,a.name,a.type, c.lc_value,a.version,b.version, a.state,a.work_directory,a.command_line from cfg_application a, cfg_app_prototype b,cfg_locale c where a.app_prototype_dbid = b.dbid and a.type = c.lc_subtype and c.lc_description = 'Enum_CfgAppType' order by a.name
INSERT IGNORE INTO cozinha (id,nome) VALUES (1,'Tailandesa'); INSERT IGNORE INTO cozinha (id,nome) VALUES (2,'Indiana'); INSERT IGNORE INTO cozinha (id,nome) VALUES (3,'Brasileira'); INSERT IGNORE INTO forma_pagamento(id,descricao) VALUES(1,'Crédito'); INSERT IGNORE INTO forma_pagamento(id,descricao) VALUES(2,'Débito'); INSERT IGNORE INTO forma_pagamento(id,descricao) VALUES(3,'Dinheiro'); INSERT IGNORE INTO forma_pagamento(id,descricao) VALUES(4,'Ticket'); INSERT IGNORE INTO permissao (id,nome,descricao) VALUES(1,'Consultar Pedidos','Permissão de consultar histórico de pedidos'); INSERT IGNORE INTO permissao (id,nome,descricao) VALUES(2,'Consultar Restaurantes','Permissão de consultar restaurantes'); INSERT IGNORE INTO estado (id,nome) VALUES (1,'Acre'); INSERT IGNORE INTO estado (id,nome) VALUES (2,'Alagoas'); INSERT IGNORE INTO estado (id,nome) VALUES (3,'Amazonas'); INSERT IGNORE INTO estado (id,nome) VALUES (4,'Amapá'); INSERT IGNORE INTO estado (id,nome) VALUES (5,'Bahia'); INSERT IGNORE INTO estado (id,nome) VALUES (6,'Ceará'); INSERT IGNORE INTO estado (id,nome) VALUES (7,'Distrito Federal'); INSERT IGNORE INTO estado (id,nome) VALUES (8,'Espírito Santo'); INSERT IGNORE INTO estado (id,nome) VALUES (9,'Goiás'); INSERT IGNORE INTO estado (id,nome) VALUES (10,'Maranhão'); INSERT IGNORE INTO estado (id,nome) VALUES (11,'Minas Gerais'); INSERT IGNORE INTO estado (id,nome) VALUES (12,'Mato Grosso do Sul'); INSERT IGNORE INTO estado (id,nome) VALUES (13,'Mato Grosso'); INSERT IGNORE INTO estado (id,nome) VALUES (14,'Pará'); INSERT IGNORE INTO estado (id,nome) VALUES (15,'Paraíba'); INSERT IGNORE INTO estado (id,nome) VALUES (16,'Paraná'); INSERT IGNORE INTO estado (id,nome) VALUES (17,'Pernambuco'); INSERT IGNORE INTO estado (id,nome) VALUES (18,'Piauí'); INSERT IGNORE INTO estado (id,nome) VALUES (19,'Rio de Janeiro'); INSERT IGNORE INTO estado (id,nome) VALUES (20,'Rio Grande do Norte'); INSERT IGNORE INTO estado (id,nome) VALUES (21,'Rio Grande do Sul'); INSERT IGNORE INTO estado (id,nome) VALUES (22,'Rondônia'); INSERT IGNORE INTO estado (id,nome) VALUES (23,'Roraima'); INSERT IGNORE INTO estado (id,nome) VALUES (24,'Santa Catarina'); INSERT IGNORE INTO estado (id,nome) VALUES (25,'São Paulo'); INSERT IGNORE INTO estado (id,nome) VALUES (26,'Sergipe'); INSERT IGNORE INTO estado (id,nome) VALUES (27,'Tocantins'); INSERT IGNORE INTO cidade (id,nome,estado_id) VALUES (1,'Recife',17); INSERT IGNORE INTO cidade (id,nome,estado_id) VALUES (2,'Campina Grande',15); INSERT IGNORE INTO restaurante (id,endereco_bairro, endereco_cep, endereco_complemento, endereco_logradouro, endereco_numero, nome, taxa_frete, id_cozinha, endereco_cidade_id,data_cadastro,data_atualizacao) VALUES (1,'Centro','55700000','','av capibaribe','581','Portal do Derby',6.90,1,1,utc_timestamp,utc_timestamp); INSERT IGNORE INTO restaurante (id,endereco_bairro, endereco_cep, endereco_complemento, endereco_logradouro, endereco_numero, nome, taxa_frete, id_cozinha, endereco_cidade_id,data_cadastro,data_atualizacao) VALUES (2,'Casa Forte','51700030','','av vitoria regia','512','Taysunan',7.90,2,2,utc_timestamp,utc_timestamp); INSERT IGNORE INTO restaurante (id,endereco_bairro, endereco_cep, endereco_complemento, endereco_logradouro, endereco_numero, nome, taxa_frete, id_cozinha, endereco_cidade_id,data_cadastro,data_atualizacao) VALUES (3,'Caxangá','51021060','','av simoes barbosa','1122','Capiba Bar',4.90,1,1,utc_timestamp,utc_timestamp); INSERT IGNORE INTO restaurante_forma_pagamento (restaurante_id,forma_pagamento_id) values (1,1),(1,2),(1,3),(2,1),(2,2),(3,1); INSERT IGNORE INTO produto (id,ativo,descricao,nome,preco,id_restaurante) VALUES(1,true,'macarrão frito','shop suey',23.90,1); INSERT IGNORE INTO produto (id,ativo,descricao,nome,preco,id_restaurante) VALUES(2,true,'churrasco de primeira','picanha argentina',49.90,2);
truncate table cs110; truncate table csgl_bmlinkinfo; truncate table csgl_dxpfxxb; delete csgl_dxkhxxb; truncate table csgl_dxwh; truncate table csgl_lbjxfxx; truncate table csgl_sbmz; truncate table csgl_zxjbxx; truncate table csgl_zxjbxx; truncate table dtj_ryinfo; truncate table fxpg_zrzt; truncate table gabm_hjxxxg; truncate table gabm_xlldrk; truncate table ggyj_center; truncate table gsbm_xlldrk; truncate table gsbm_ygryrk; truncate table hmgc_jgbmxx; truncate table jtbm_xlldrk; truncate table mzbm_lhtb; truncate table mzbm_mzbmtb; truncate table mzbm_ylsy; truncate table rlzy_xlldrk; truncate table sys_jlrzdy; truncate table wsbm_ldrkhy; truncate table wsbm_ldrktb; truncate table wsbm_xsetb; truncate table wsbm_xsjyxxtb; truncate table wsbm_zyxxtb; truncate table xwxx_xzzbxx; truncate table zfcj_czfldrkhyzm; truncate table zfcj_fwzl; truncate table zfcj_gdld; truncate table zfcj_jzgd; truncate table zfcj_ldrkgf; truncate table zzww_bmlinkinfo; truncate table zzww_dxpfxxb; delete zzww_dxkhxxb; truncate table zzww_dxwh; truncate table zzww_lbjxfxx; truncate table zzww_sbmz; truncate table zzww_zxjbzfxx; delete sys_deptinfo;
# ************************************************************ # Sequel Pro SQL dump # Version 4541 # # http://www.sequelpro.com/ # https://github.com/sequelpro/sequelpro # # Host: 127.0.0.1 (MySQL 5.7.23) # Database: capstone # Generation Time: 2019-04-15 00:28:13 +0000 # ************************************************************ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; # Dump of table admin_info # ------------------------------------------------------------ DROP TABLE IF EXISTS `admin_info`; CREATE TABLE `admin_info` ( `admin_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `username` text NOT NULL, `password` text NOT NULL, `active` tinyint(1) NOT NULL, PRIMARY KEY (`admin_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; LOCK TABLES `admin_info` WRITE; /*!40000 ALTER TABLE `admin_info` DISABLE KEYS */; INSERT INTO `admin_info` (`admin_id`, `username`, `password`, `active`) VALUES (1,'username','secret',1), (2,'lyndon','password',1); /*!40000 ALTER TABLE `admin_info` ENABLE KEYS */; UNLOCK TABLES; # Dump of table cart # ------------------------------------------------------------ DROP TABLE IF EXISTS `cart`; CREATE TABLE `cart` ( `cart_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `item_id` int(11) NOT NULL, `userID` int(11) NOT NULL, `quantity` int(11) DEFAULT NULL, PRIMARY KEY (`cart_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; # Dump of table categories # ------------------------------------------------------------ DROP TABLE IF EXISTS `categories`; CREATE TABLE `categories` ( `category_id` int(11) NOT NULL AUTO_INCREMENT, `category` varchar(72) NOT NULL, PRIMARY KEY (`category_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; LOCK TABLES `categories` WRITE; /*!40000 ALTER TABLE `categories` DISABLE KEYS */; INSERT INTO `categories` (`category_id`, `category`) VALUES (16,'Asus'), (15,'Dell'), (14,'Apple'), (17,'Test'); /*!40000 ALTER TABLE `categories` ENABLE KEYS */; UNLOCK TABLES; # Dump of table current_sessions # ------------------------------------------------------------ DROP TABLE IF EXISTS `current_sessions`; CREATE TABLE `current_sessions` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `sessionID` text NOT NULL, `admin_id` int(11) NOT NULL, `login_time` int(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; # Dump of table items # ------------------------------------------------------------ DROP TABLE IF EXISTS `items`; CREATE TABLE `items` ( `category` int(11) NOT NULL, `item_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL DEFAULT '', `description` varchar(9999) NOT NULL DEFAULT '', `price` double NOT NULL, `quantity` varchar(16) NOT NULL, `sku` varchar(32) NOT NULL, `picture` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`item_id`), KEY `category` (`category`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; LOCK TABLES `items` WRITE; /*!40000 ALTER TABLE `items` DISABLE KEYS */; INSERT INTO `items` (`category`, `item_id`, `title`, `description`, `price`, `quantity`, `sku`, `picture`) VALUES (14,31,'Macbook Pro','<p>This is a <em>mac book pro</em></p>',1499.99,'993','1235243','macbookpro.jpeg'), (16,32,'Asus Laptop','<p>This is a <em>asus laptop</em></p>',999.99,'966','8716813','asusVivobook15.png'), (15,34,'Dell 15.6 Laptop','<p>This is a dell laptop</p>',799.99,'29','123556','dellInspiron.jpg'); /*!40000 ALTER TABLE `items` ENABLE KEYS */; UNLOCK TABLES; # Dump of table items_sold # ------------------------------------------------------------ DROP TABLE IF EXISTS `items_sold`; CREATE TABLE `items_sold` ( `sell_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `item_id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `sell_price` int(11) NOT NULL, `sell_quantity` int(11) NOT NULL, PRIMARY KEY (`sell_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; LOCK TABLES `items_sold` WRITE; /*!40000 ALTER TABLE `items_sold` DISABLE KEYS */; INSERT INTO `items_sold` (`sell_id`, `item_id`, `order_id`, `sell_price`, `sell_quantity`) VALUES (17,31,16,1500,3), (18,32,16,1000,10), (19,31,17,1500,1), (20,31,18,1500,1), (21,32,18,1000,1), (22,32,19,1000,19); /*!40000 ALTER TABLE `items_sold` ENABLE KEYS */; UNLOCK TABLES; # Dump of table order_info # ------------------------------------------------------------ DROP TABLE IF EXISTS `order_info`; CREATE TABLE `order_info` ( `order_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `firstName` varchar(30) NOT NULL DEFAULT '', `lastName` varchar(30) NOT NULL DEFAULT '', `phone` varchar(10) NOT NULL DEFAULT '', `email` varchar(50) NOT NULL DEFAULT '', `userID` int(11) NOT NULL, PRIMARY KEY (`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; LOCK TABLES `order_info` WRITE; /*!40000 ALTER TABLE `order_info` DISABLE KEYS */; INSERT INTO `order_info` (`order_id`, `firstName`, `lastName`, `phone`, `email`, `userID`) VALUES (16,'Lyndon','Jardine','9023221325','w0287543@nscc.ca',12), (17,'Lyndon','Jardine','902123456','w0287543@nscc.ca',12), (18,'asdf','asdf','asdf','asdf@asdf.com',12), (19,'asdf','jardine','zxcv','lyndon.jardine@gmail.com',12); /*!40000 ALTER TABLE `order_info` ENABLE KEYS */; UNLOCK TABLES; # Dump of table users # ------------------------------------------------------------ DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `sessionID` varchar(255) NOT NULL DEFAULT '', `user_ip` varchar(50) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` (`id`, `sessionID`, `user_ip`) VALUES (10,'59t07ro853vv55pgqi25lmotai','::1'), (11,'mia931t96ehdnt30et1mv21k6i','::1'), (12,'qgkjo5bhgb0b4dmrj6vuggnld5','::1'); /*!40000 ALTER TABLE `users` ENABLE KEYS */; UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
CREATE OR REPLACE PUBLIC SYNONYM ti_endorsements_pkg FOR orient.ti_endorsements_pkg;
CREATE PROCEDURE [sp_put_SODocFooter]( @Product_Code [nvarchar](15), @Quantity Decimal(18,6), @SalePrice Decimal(18,6), @SaleTax Decimal(18,6), @Discount Decimal(18,6), @SONumber [int], @TaxSuffered Decimal(18,6)=0.0, @TaxSuffApplicableOn Int=0, @TaxSuffPartOff Decimal(18,6)=0.0, @TaxApplicableOn Int=0, @TaxPartOff Decimal(18,6)=0.0 ) AS INSERT INTO [SODetailReceived]( [Product_Code], [Quantity], [SalePrice], [SaleTax], [Discount], [SONumber], [TaxSuffered], [TaxSuffApplicableOn], [TaxSuffPartOff], [TaxApplicableOn], [TaxPartOff] ) VALUES ( @Product_Code, @Quantity, @SalePrice, @SaleTax, @Discount, @SONumber, @TaxSuffered, @TaxSuffApplicableOn, @TaxSuffPartOff, @TaxApplicableOn, @TaxPartOff )
-- create sequence -- create sequence if not exists seq_transaction start with 1 increment by 1 maxvalue 99999999; -- create table transaction create table if not exists transactions ( id int auto_increment primary key, username varchar(10) not null, userid varchar(10) not null, transaction_date varchar(20) not null, transaction_amount decimal(10,2) not null, transaction_iof decimal(10,2) not null, status int not null default 0 ); -- create table statistic create table if not exists statisticss ( id int auto_increment primary key, username varchar(10) not null, sumvalue varchar(20) not null );
-- Run like: -- psql sandcrawler < dump_regrobid_pdf_petabox.sql -- cat dump_regrobid_pdf_petabox.2020-02-03.json | sort -S 4G | uniq -w 40 | cut -f2 > dump_regrobid_pdf_petabox.2020-02-03.uniq.json BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE READ ONLY DEFERRABLE; COPY ( SELECT petabox.sha1hex, row_to_json(petabox) FROM petabox WHERE EXISTS (SELECT grobid.sha1hex FROM grobid WHERE petabox.sha1hex = grobid.sha1hex AND grobid.grobid_version IS NULL) ) TO '/grande/snapshots/dump_regrobid_pdf_petabox.2020-02-03.json' WITH NULL ''; ROLLBACK;
create table prescriptions ( id serial primary key, sha text, pct text, practice text, bnfcode text, bnfname text, chemical_code text, chemical_name text, product text, generic text, equivalent text, items integer, nic numeric(10,2), act_cost numeric(10,2), quantity integer, period integer, year integer, month integer, xgrid integer, ygrid integer, postcode text )
CREATE TABLE `items_ordered` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `order_id` bigint(20) NOT NULL, `item_id` bigint(20) NOT NULL, `price_of_item` decimal(19,6) NOT NULL, `number_of_items` bigint(20) NOT NULL, PRIMARY KEY (`id`), KEY `order_id_fk_idx` (`order_id`), CONSTRAINT `order_id_fk` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
with mth as (select *, (avg_cena - lag(avg_cena)over(order by mth)) / lag(avg_cena)over(order by mth) mom from (select date_trunc('month',to_date(data,'YYYY-MM-DD')) mth , avg(zamkniecie) avg_cena from xpdusd_d group by 1 order by 1 ) c), dates as (select generate_series('2016-01-01'::date, '2019-12-01'::date, interval'1 month') as data ), merge_tab as (select *, rank()over(partition by mth order by data) nr, avg(mom)over() trend, sum(case when mth = '2018-11-01'::date then avg_cena else 0 end)over()last_cena from dates d left join mth m on m.mth = d.data order by 1) select data, round(case when avg_cena is null then power(1 + trend,nr) * last_cena else avg_cena end ,2) avg_cena from merge_tab
Create database Library use Library Create table Author ( id int not null primary key identity(1,1), Name varchar(50) not null, LastName varchar(50) not null, BirthDate date not null, AuthorGender bit not null ) Create table Gender ( id int not null primary key identity(1,1), NameGender varchar(50) not null unique ) Create table Book ( id int not null primary key identity(1,1), Title varchar(100) not null, ReleaseDate date not null, Editorial varchar(100) not null default 'IBSN', Author int not null, Gender int not null, Constraint Fk_Author_Book foreign key(Author) references Author(id), Constraint FK_Gender_Book foreign key(Gender) references Gender(id) ) Insert into Author values('Juan Emilio', 'Bosch Gaviņo', '30-06-1909', 1) Select * from Author insert into Book (Title, ReleaseDate, Author, Gender) values('La Maņosa', '12-08-1936', 1,1) Select * from Book insert into Gender values('Novela') Select * from Gender
-- phpMyAdmin SQL Dump -- version 4.9.1 -- https://www.phpmyadmin.net/ -- -- Host: localhost -- Generation Time: Nov 15, 2020 at 09:11 AM -- Server version: 8.0.18 -- PHP Version: 7.3.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 */; -- -- Database: `cook` -- -- -------------------------------------------------------- -- -- Table structure for table `category` -- CREATE TABLE `category` ( `id` int(11) NOT NULL, `catName` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, `parentCategoryId` int(11) DEFAULT NULL, `status` int(5) DEFAULT '0', `createdTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `orders` -- CREATE TABLE `orders` ( `orderId` int(11) NOT NULL, `userid` int(25) DEFAULT NULL, `transactionNo` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `transactionStatus` varchar(80) COLLATE utf8mb4_general_ci DEFAULT NULL, `orderDetails` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `orderStatus` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `refund` varchar(40) COLLATE utf8mb4_general_ci DEFAULT 'NO', `paymentTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `products` -- CREATE TABLE `products` ( `id` int(11) NOT NULL, `catId` int(11) DEFAULT NULL, `menuName` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, `description` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, `calories` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `protein` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `fat` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `carbohydrates` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `fibre` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `productImage` varchar(225) COLLATE utf8mb4_general_ci DEFAULT NULL, `costPrice` float(10,2) DEFAULT NULL, `regularPrice` float(10,2) DEFAULT NULL, `sellPrice` float(10,2) DEFAULT NULL, `createdTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `siteconfig` -- CREATE TABLE `siteconfig` ( `siteEmail` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL, `siteMobile` bigint(255) DEFAULT NULL, `smtpHost` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `smtpEmail` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `smtpUsername` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `smtpPassword` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `smtpSecType` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `smtpPort` smallint(255) DEFAULT NULL, `activePaymentMethod` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `paytmMID` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `paytmMkey` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `paytmWebsite` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `paytmIndustryType` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `paytmChannelID` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `paytmTransUrl` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL, `paytmStatusUrl` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL, `razorpayKeyId` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL, `razorpayKeySecret` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` int(11) NOT NULL, `name` longtext COLLATE utf8mb4_general_ci, `ipaddress` varchar(16) COLLATE utf8mb4_general_ci DEFAULT NULL, `incart` varchar(180) COLLATE utf8mb4_general_ci DEFAULT NULL, `mobile` varchar(80) COLLATE utf8mb4_general_ci DEFAULT NULL, `email` varchar(80) COLLATE utf8mb4_general_ci DEFAULT NULL, `regTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `lastlogin` datetime DEFAULT NULL, `deviceType` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL, `secretKey` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -- Indexes for dumped tables -- -- -- Indexes for table `category` -- ALTER TABLE `category` ADD PRIMARY KEY (`id`); -- -- Indexes for table `orders` -- ALTER TABLE `orders` ADD PRIMARY KEY (`orderId`); -- -- Indexes for table `products` -- ALTER TABLE `products` ADD PRIMARY KEY (`id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `category` -- ALTER TABLE `category` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `orders` -- ALTER TABLE `orders` MODIFY `orderId` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `products` -- ALTER TABLE `products` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 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 */;
alter table car add column batch varchar(128);
CREATE Procedure sp_GetOldItemInvoiceQty(@Invoiceid Int, @Prodid nvarchar(30), @batchid nvarchar(20), @saleprice Decimal(18,6), @TaxSuffered Decimal(18,6) = 0, @TaxSuffApplicable Integer = 0, @TaxSuffPartOff Decimal(18,6) = 0) as if (@batchid<>'NA') begin Select Sum(Quantity) from Invoicedetail where Invoiceid=@Invoiceid and Product_code=@Prodid and Batch_Number=@batchid and Saleprice=@saleprice Group by serial -- TaxDetails stored only in the top row and not all rows -- and TaxSuffApplicableOn = @TaxSuffApplicable -- and TaxSuffPartOff = @TaxSuffPartOff -- and TaxSuffered2 = @TaxSuffered end else begin Select Sum(Quantity) from Invoicedetail where Invoiceid=@Invoiceid and Product_code=@Prodid and Saleprice=@saleprice end
CREATE OR REPLACE PROCEDURE SSHARM17."assignPrimarySupporter" ( "patientSSN" IN VARCHAR2, "hsSSN" IN VARCHAR2, "authorizationDate" IN DATE) AS primaryOccurence INTEGER; BEGIN SELECT COUNT (*) INTO primaryOccurence FROM PATIENTTOHEALTHSUPPORTER p WHERE p.PATIENTSSN = "patientSSN" AND p.PRIMARYSECONDARY = 'Primary'; IF primaryOccurence > 0 THEN RAISE PROGRAM_ERROR; END IF; INSERT INTO PATIENTTOHEALTHSUPPORTER (HSSSN, PATIENTSSN, AUTHORIZATIONDATE, PRIMARYSECONDARY) VALUES ("hsSSN", "patientSSN", "authorizationDate", 'Primary'); END;
USE pokeTrainers_db; -- Insert rows into table 'pokeTrainers_db' INSERT INTO trainers ( -- columns to insert data into matchName, img, attr ) VALUES ( 'Brock', "brock.jpg", '5,3,5,4,5,5,1,5,3,2,4' ), ( 'Misty', "misty.jpg", '3,5,1,2,3,4,3,2,3,2,4' ), ( 'Ash', "ash.jpg", '1,4,3,2,5,2,1,5,5,3,1' ), ( 'Gary', "gary.jpg", '4,2,5,5,4,2,5,4,1,2,3' ), ( "Ash's Mom", "AshMom.jpg", '4,3,4,1,4,5,2,5,1,1,2' ), ( 'Professor Oak', "oak.jpg", '4,3,3,3,5,5,3,3,1,2,4' ), ( 'Jessie', "jessie.jpg", '3,4,3,3,4,2,5,3,5,1,4' ), ( 'Erika', "erika.jpg", '4,3,3,2,5,1,3,5,5,2,1' ), ( 'Claire', "clair.jpg", '2,1,5,3,2,4,4,4,4,1,3' ), ( 'James', "james.jpg", '3,4,4,2,1,2,0,0,0,3,2' ); INSERT INTO questions (question) VALUES ('How badly do you want to be the best that every was?'),('You lose pokemon battles a lot (like a lot), do you give up and try something else?'),('You like to grow your hair out long'),('Are you afraid of death?'),('Do you care about carbs?'),('Is climate change real?'),('Do you believe in dinosaurs ?'),('Would you ever shoplift?'),('Do you believe in ghosts?'),('Do you believe in the seattle freeze?');
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; DROP SCHEMA IF EXISTS `shop` ; CREATE SCHEMA IF NOT EXISTS `shop` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; USE `shop` ; -- ----------------------------------------------------- -- Table `mydb`.`produkt` -- ----------------------------------------------------- DROP TABLE IF EXISTS `shop`.`produkt` ; CREATE TABLE IF NOT EXISTS `shop`.`produkt` ( `idprodukt` INT NOT NULL AUTO_INCREMENT, `idkat` VARCHAR(45) NULL, `nazwa` VARCHAR(45) NULL, `cena` DECIMAL(15,2) NULL, `opis` VARCHAR(500) NULL, PRIMARY KEY (`idprodukt`)) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; START TRANSACTION; USE `shop`; INSERT INTO `produkt` (`idkat`,`nazwa`, `cena`,`opis`) VALUES ('widly','Widły', 35, 'Trójząb Neptuna świetnie sprawdza się w ogrodzie.'); INSERT INTO `produkt` (`idkat`,`nazwa`, `cena`,`opis`) VALUES ('grabie','Grabie', 27, 'Grabie, jak to grabie, zawsze grabią do siebie.'); INSERT INTO `produkt` (`idkat`,`nazwa`, `cena`,`opis`) VALUES ('kosa','Kosa', 49, 'Trafiła kosa na kamień.'); INSERT INTO `produkt` (`idkat`,`nazwa`, `cena`,`opis`) VALUES ('cep','Cep', 13, 'Konstrukcja prosta, jak kłębek drutu.'); INSERT INTO `produkt` (`idkat`,`nazwa`, `cena`,`opis`) VALUES ('proca','Proca', 5, 'Scelas z procy, zamknij ocy.'); INSERT INTO `produkt` (`idkat`,`nazwa`, `cena`,`opis`) VALUES ('miotla','Miotła', 27, 'Szur, szur, lecim na Szczecin.'); INSERT INTO `produkt` (`idkat`,`nazwa`, `cena`,`opis`) VALUES ('brona','Brona', 135, 'Czesanie z przedziałkiem.'); INSERT INTO `produkt` (`idkat`,`nazwa`, `cena`,`opis`) VALUES ('kierpce','Kierpce', 13, 'Idzie luty, obuj buty.'); COMMIT;
--1.회원별 주문 상품 통계 --회원아이디 상품번호 상품갯수 구매금액 --(조건:주문건이 없더라도 회원출력) SELECT U.USER_ID, OG.GOOD_SEQ, OG.ORDER_AMOUNT, OG.ORDER_PRICE FROM ORDERS O, USERS U, ORDERS_GOODS OG WHERE U.USER_SEQ = O.USER_SEQ(+) AND O.ORDER_CODE = OG.ORDER_CODE(+) order by user_id, good_seq; --2.업체별 공급 상품 리스트 --업체번호 업체명 상품번호 상품명 --(조건:상품이 없더라도 업체명 출력) select c.com_seq, c.com_name, a.good_seq,a.good_name from goods a, company_goods b, company c where a.good_seq(+)=b.good_seq and b.com_seq(+)=c.com_seq order by com_seq asc, good_seq asc ; --3.회원관리 --정규직/비정규직 구분하여 출력 --조건1:정규직이면A,비정규직이면B로 출력 --조건2:급여(1일 8시간 한달:20일 기준으로 계산) --회원번호 회원명 정규/비정규여부 월급여 SELECT U.USER_SEQ, U.USER_NAME, 'P' as PF, p.tsal * 8 * 20 as sal FROM PARTTIME P, USERS U WHERE U.USER_SEQ = P.USER_SEQ union SELECT U.USER_SEQ, U.USER_NAME, 'F' as PF, f.asal FROM FULLTIME F, USERS U WHERE U.USER_SEQ = F.USER_SEQ ; --4.상품/주문관리 --주문된 상품별 판매량, 판매금액 출력 --조건:판매량이 높은 순으로 정렬 --상품번호 상품명 총판매량 총판매금액 SELECT G.GOOD_SEQ, G.GOOD_NAME, SUM(OG.ORDER_AMOUNT) AS SUMAMT, SUM(OG.ORDER_PRICE) AS SUMPRICE FROM ORDERS_GOODS OG, GOODS G WHERE G.GOOD_SEQ = OG.GOOD_SEQ GROUP BY G.GOOD_SEQ, G.GOOD_NAME ORDER BY SUMAMT DESC; --5. 사용자별 구매 통계 --회원아이디 총구매횟수 총구매금액 --조건1 : 구매금액이 높은 순 출력 SELECT U.USER_SEQ, COUNT(O.USER_SEQ) AS CNT, SUM(O.TOT_PRICE) AS SUMPRICE FROM USERS U, ORDERS O WHERE U.USER_SEQ = O.USER_SEQ GROUP BY U.USER_SEQ ORDER BY SUMPRICE DESC; --6. 휴먼회원 통계 --구매실적이 전혀 없는 회원 목록 출력 --회원아이디 회원명 SELECT USER_ID, USER_NAME FROM USERS WHERE USER_SEQ NOT IN (SELECT USER_SEQ FROM ORDERS); --7. 전체 회원 목록 중 휴먼 회원이 차지하는 비율? --조건1 : 관리자 제외 --조건2: 휴먼회원은 구매 실적이 전혀 없는 회원 -- 회원수 휴먼회원비율 --------- -- 2/5 40% SELECT HCNT||'/'||UCNT AS 회원수, HCNT/UCNT*100||'%' AS 비율 FROM (SELECT COUNT(1) AS HCNT FROM USERS WHERE USER_SEQ NOT IN (SELECT USER_SEQ FROM ORDERS)) H, (SELECT COUNT(1) UCNT FROM USERS) U; --8. 각 회원별로 매니저-회원 관계를 출력하시오 --조건1: 관리자 제외 --조건2: 매니저번호 오름차순 회원번호 오름차순 정렬 --매니저 회원 --lee kim --lee park --prak hong SELECT U.USER_SEQ, U.USER_ID, M.USER_SEQ AS MGR_SEQ, M.USER_ID AS MGR_ID FROM USERS U, USERS M WHERE U.MGR_SEQ = M.USER_SEQ; --n00005 4 14000 --n00011 4 40000 --9. 주문/상품/업체 대시보드 현황판 -- 총주문수량 총주문금액 총회원수 총업체수 총상품수 -- 58 1025000 5 7 12 -- AMT PRICE UCNT CCNT GCNT ---------- ---------- ---------- ---------- ---------- -- 48 244000 5 7 10 SELECT (select count(1) from orders) AS AMT, (select sum(tot_price) from orders) AS PRICE, (select count(1) from users) AS UCNT , (select count(1) from company) AS CCNT , (select count(1) from goods) AS GCNT FROM DUAL; --10.월별 판매 실적.... -- 1월 2월 3월 4월 -- 20000 12000 50000 select sum(decode ( to_char(order_date, 'MM'), '01', 1, 0 )) as m01, sum(decode ( to_char(order_date, 'MM'), '02', 1, 0 )) as m02, sum(decode ( to_char(order_date, 'MM'), '03', 1, 0 )) as m03, sum(decode ( to_char(order_date, 'MM'), '04', 1, 0 )) as m04, sum(decode ( to_char(order_date, 'MM'), '05', 1, 0 )) as m05, sum(decode ( to_char(order_date, 'MM'), '06', 1, 0 )) as m06, sum(decode ( to_char(order_date, 'MM'), '07', 1, 0 )) as m07, sum(decode ( to_char(order_date, 'MM'), '08', 1, 0 )) as m08, sum(decode ( to_char(order_date, 'MM'), '09', 1, 0 )) as m09, sum(decode ( to_char(order_date, 'MM'), '10', 1, 0 )) as m10, sum(decode ( to_char(order_date, 'MM'), '11', 1, 0 )) as m11, sum(decode ( to_char(order_date, 'MM'), '12', 1, 0 )) as m12 from orders;
DROP DATABASE moviez; CREATE DATABASE moviez; \c moviez CREATE TABLE moviez ( id serial8 primary key, title varchar(150), year int4 , rated varchar(50) , released varchar(20) , runtime varchar(9) , genre varchar(50) , director varchar(30) , writer text , actors varchar(200) , plot text, imdbID varchar(20) );
# --- !Ups ALTER TABLE organization ADD COLUMN show_custodia BOOLEAN default false not null; ALTER TABLE organization ADD COLUMN show_attendance BOOLEAN default true not null; ALTER TABLE organization ADD COLUMN short_name VARCHAR(255) default '' not null; ALTER TABLE organization ADD COLUMN custodia_password VARCHAR(255) default '' not null; update organization set short_name='TRVS' where id=1; update organization set short_name='PFS' where id=2; update organization set short_name='Fairhaven' where id=3; update organization set short_name='TCS' where id=4; update organization set short_name='MLC' where id=5; update organization set short_name='TOS' where id=6; update organization set short_name='HSS' where id=7; update organization set short_name='CSS' where id=8; update organization set short_name='Sandbox' where id=9; create role custodia login password '123'; grant select on all tables in schema public to custodia; create schema if not exists overseer; grant all on schema overseer to custodia; grant all on all tables in schema overseer to custodia; grant all on all sequences in schema overseer to custodia; create schema if not exists demo; grant all on schema demo to custodia; grant all on all sequences in schema demo to custodia; grant all on all tables in schema demo to custodia; # --- !Downs ALTER TABLE organization DROP COLUMN show_custodia; ALTER TABLE organization DROP COLUMN show_attendance; ALTER TABLE organization DROP COLUMN short_name; ALTER TABLE organization DROP COLUMN custodia_password; revoke select on all tables in schema public from custodia; revoke all on schema overseer from custodia; revoke all on all tables in schema overseer from custodia; revoke all on all sequences in schema overseer from custodia; revoke all on schema demo from custodia; revoke all on all sequences in schema demo from custodia; revoke all on all tables in schema demo from custodia; drop role custodia;
-- phpMyAdmin SQL Dump -- version 4.8.5 -- https://www.phpmyadmin.net/ -- -- Servidor: 127.0.0.1 -- Tiempo de generación: 23-05-2019 a las 22:06:09 -- Versión del servidor: 10.1.39-MariaDB -- Versión de PHP: 7.3.5 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de datos: `test_bg` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `amigos` -- CREATE TABLE `amigos` ( `id_amigos` int(10) NOT NULL, `nombre` varchar(50) COLLATE utf8_spanish_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci; -- -- Volcado de datos para la tabla `amigos` -- INSERT INTO `amigos` (`id_amigos`, `nombre`) VALUES (1, 'Hugo Chavez'), (2, 'Alvaro Uribe'), (3, 'Juan Manuel Santos'), (4, 'Barack Obama'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `usuarios` -- CREATE TABLE `usuarios` ( `id_usuario` int(20) NOT NULL, `nombre` varchar(50) COLLATE utf8_spanish_ci NOT NULL, `telefono` int(30) NOT NULL, `email` varchar(50) COLLATE utf8_spanish_ci NOT NULL, `id_amigos` int(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci; -- -- Volcado de datos para la tabla `usuarios` -- INSERT INTO `usuarios` (`id_usuario`, `nombre`, `telefono`, `email`, `id_amigos`) VALUES (1, 'Henry Alexander Perez', 7127532, 'haperez86@gmail.com', 3), (2, 'Jeison Perez', 4658915, 'jperez@gmail.com', 1), (3, 'Alex', 7127532, 'alex@gmail.com', 4); -- -- Índices para tablas volcadas -- -- -- Indices de la tabla `amigos` -- ALTER TABLE `amigos` ADD PRIMARY KEY (`id_amigos`); -- -- Indices de la tabla `usuarios` -- ALTER TABLE `usuarios` ADD PRIMARY KEY (`id_usuario`), ADD KEY `id_amigos` (`id_amigos`); -- -- AUTO_INCREMENT de las tablas volcadas -- -- -- AUTO_INCREMENT de la tabla `amigos` -- ALTER TABLE `amigos` MODIFY `id_amigos` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT de la tabla `usuarios` -- ALTER TABLE `usuarios` MODIFY `id_usuario` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- Restricciones para tablas volcadas -- -- -- Filtros para la tabla `usuarios` -- ALTER TABLE `usuarios` ADD CONSTRAINT `usuarios_ibfk_1` FOREIGN KEY (`id_amigos`) REFERENCES `amigos` (`id_amigos`); 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 */;
Create Procedure mERP_sp_Update_TaxDesc(@TaxCode int,@TaxDesc nVarchar(255)) As Begin Update Tax Set Tax_Description = @TaxDesc Where Tax_Code = @TaxCode End
-- Solo superior SET SEARCH_PATH TO markus; DROP TABLE IF EXISTS q3; -- You must not change this table definition. CREATE TABLE q3 ( assignment_id integer, description varchar(100), num_solo integer, average_solo real, num_collaborators integer, average_collaborators real, average_students_per_submission real ); -- You may find it convenient to do this for each of the views -- that define your intermediate steps. (But give them better names!) DROP VIEW IF EXISTS solo_groups CASCADE; DROP VIEW IF EXISTS solo_group_assignment CASCADE; DROP VIEW IF EXISTS assignment_max_mark CASCADE; DROP VIEW IF EXISTS solo_group_mark CASCADE; DROP VIEW IF EXISTS solo_group_tmark CASCADE; DROP VIEW IF EXISTS solo_group_ass_avg CASCADE; DROP VIEW IF EXISTS non_solo_group CASCADE; DROP VIEW IF EXISTS non_solo_group_assignment CASCADE; DROP VIEW IF EXISTS assignment_collaborators CASCADE; DROP VIEW IF EXISTS non_solo_mark CASCADE; DROP VIEW IF EXISTS non_solo_tmark CASCADE; DROP VIEW IF EXISTS non_solo_group_ass_avg CASCADE; DROP VIEW IF EXISTS student_count_assignment CASCADE; DROP VIEW IF EXISTS group_count_assignment CASCADE; DROP VIEW IF EXISTS avg_std_per_group CASCADE; DROP VIEW IF EXISTS answer_1 CASCADE; DROP VIEW IF EXISTS answer_2 CASCADE; DROP VIEW IF EXISTS answer_3 CASCADE; DROP VIEW IF EXISTS answer CASCADE; -- Define views for your intermediate steps here. -- Question Three -- Find the assignments where the average grade of those who worked alone is greater than the average grade earned by groups. -- For each, report the assignment ID and description, the number of students declared to be working alone and their average grade -- the number of students (not groups) delcared to be working in groups and the average grade across those (groups) not students. -- Finally, the average number of students incolved in each group. -- Find the groups with only one member (solo) create view solo_groups as select group_id from Membership group by group_id having count(username) = 1; -- Find the corresponding assignments create view solo_group_assignment as select assignment_id, group_id from solo_groups natural join AssignmentGroup; -- Find the average mark that these solo groups got -- Find the maximum possible mark that each assignment is out of create view assignment_max_mark as select assignment_id, cast (sum(out_of * weight) as float) as max_mark from RubricItem group by assignment_id; -- Find the mark that the solo groups got create view solo_group_mark as select assignment_id, group_id, mark from solo_group_assignment natural left join Result; -- Find the true mark that the solo groups got in percentage create view solo_group_tmark as select assignment_id, group_id, (mark / max_mark)*100.0 as true_mark from solo_group_mark natural left join assignment_max_mark; -- Find the average that the solo groups got across the assignment create view solo_group_ass_avg as select assignment_id, avg(true_mark) as average_solo from solo_group_tmark group by assignment_id; -- number of collaborators -- Find the group of students who worked together create view non_solo_group as select group_id, count(*) as numberofMember from Membership group by group_id having count(username)>1; -- Find the assignments that these team players belong create view non_solo_group_assignment as select assignment_id, group_id, numberofMember from non_solo_group natural join AssignmentGroup; -- Find the number of collaborators for each assignment through a sum create view assignment_collaborators as select assignment_id, sum(numberofMember) as num_collaborators from non_solo_group_assignment group by assignment_id; -- average_collaborators -- Find the mark that the group who worked together got create view non_solo_mark as select distinct assignment_id, group_id, mark from non_solo_group_assignment natural left join Result; -- Find the percentage that these groups got create view non_solo_tmark as select distinct assignment_id, group_id, (mark / max_mark) *100.0 as true_mark from non_solo_mark natural join assignment_max_mark; -- Find the average for these groups across assignments create view non_solo_group_ass_avg as select assignment_id, avg(true_mark) as average_collaborators from non_solo_tmark where true_mark is not null group by assignment_id; -- average students per group -- Find the number of students who worked on each assignment create view student_count_assignment as select distinct assignment_id, count(*) as numberofStudents from AssignmentGroup natural join Membership group by assignment_id; -- Find the total number of groups for each assignment create view group_count_assignment as select distinct assignment_id, count(*) as numberofGroups from AssignmentGroup group by assignment_id; -- Calculate the number of students per group that each assignment would have create view avg_std_per_group as select distinct assignment_id, (numberofStudents*1.0 / numberofGroups*1.0) as average_students_per_submission from student_count_assignment natural join group_count_assignment; -- Putting the answers together (in thise case we get the number of students who worked as solo) create view answer_1 as select distinct assignment_id, description, count(group_id) as num_solo from Assignment natural join solo_group_assignment group by assignment_id, description; -- Putting the answers together (in this case we get the average for these solo grops ) create view answer_2 as select distinct assignment_id, description, num_solo, average_solo from answer_1 natural left join solo_group_ass_avg; -- Here we add in the average that the team players got create view answer_3 as select distinct assignment_id, description, num_solo, average_solo, num_collaborators,average_collaborators from answer_2 natural left join non_solo_group_ass_avg natural left join assignment_collaborators; -- Now we going in the number of students that each assignment would have create view answer as select distinct assignment_id, description, num_solo, average_solo, num_collaborators,average_collaborators, average_students_per_submission from answer_3 natural full join avg_std_per_group; -- Final answer INSERT INTO q3 (select * from answer); -- put a final query here so that its results will go into the table.
-- Provide a query that shows the total sales per country. Select sum(i.total), c.Country from Customer as c join Invoice as i on c.CustomerId = i.CustomerId group by c.Country
{{ config( materialized='table', tags='raw' ) }} select * from {{ source('sf_sample_data', 'orders') }}
-- 3.2-2 SELECT sname FROM Sailors WHERE sid in (select sid from Reserves WHERE bid=103) -- 3.2-3 SELECT DISTINCT sid FROM Reserves WHERE bid in (SELECT bid FROM Boats WHERE Color="Red") ; -- 3.2-4 SELECT sname FROM Sailors WHERE sid IN ( SELECT DISTINCT sid FROM Reserves WHERE bid in ( SELECT bid FROM Boats WHERE Color="Red" ) ); -- 3.2-5 SELECT DISTINCT Color FROM Boats WHERE bid in ( SELECT bid FROM Reserves WHERE sid = ( SELECT sid FROM Sailors WHERE sname="Lubber" ) ); -- 3.2-6.1 SELECT DISTINCT sname FROM Sailors WHERE sid IN ( SELECT DISTINCT sid FROM Reserves ); -- 3.2-6.2 -- 3.2-7 -- 3.2-8
/* To CREATE or REPLECE a PROCEDURE - in your own schema, you must have the CREATE PROCEDURE system privilege - in another user's schema, you must have the CREATE ANY PROCEDURE system privilege. You can DROP a procedure when either of this conditions is met: - the procedure is in your own schema and you have the CREATE PROCEDURE system privilege - you have the DROP ANY PROCEDURE system privilege. You can ALTER a PROCEDURE when either of this conditions is met: - the procedure is in your own schema - you have ALTER ANY PROCEDURE system privilege. ALTER PROCEDURE procedure_name COMPILE [ DEBUG ] [ compiler_parameter_clause ] [ [ REUSE ] [ SETTINGS ] ] COMPILE Specify COMPILE to recompile the procedure. The COMPILE keyword is required. the database recompiles the procedure regardless of whether it is valid or invalid. the database first recompiles objects upon which the procedure depends, if any of those objects are invalid. the database also invalidates any local objects that depend upon the procedure, such as procedures that call the recompiled procedure or package bodies that define procedures that call the recompiled procedure. If the database recompiles the procedure successfully, then the procedure becomes valid. If recompiling the procedure results in compilation errors, then the database returns an error and the procedure remains invalid. You can see the associated compiler error messages with the SQL*Plus command SHOW ERRORS. During recompilation, the database drops all persistent compiler switch settings, retrieves them again from the session, and stores them at the end of compilation. To avoid this process, specify the REUSE SETTINGS clause. DEBUG Specify DEBUG to instruct the PL/SQL compiler to generate and store the code for use by the PL/SQL debugger. Specifying this clause is the same as specifying PLSQL_DEBUG = TRUE in the compiler_parameters_clause. COMPILE_PARAMETER_CLAUSE Use this clause to specify a value for one of the PL/SQL persistent compiler parameters. The value of these initialization parameters at the time of compilation is stored with the unit's metadata. You can learn the value of such a parameter by querying the appropriate *_PLSQL_OBJECT_SETTINGS view. The PL/SQL persistent parameters are PLSQL_OPTIMIZE_LEVEL, PLSQL_CODE_TYPE, PLSQL_DEBUG, PLSQL_WARNINGS, PLSQL_CCFLAGS, and NLS_LENGTH_SEMANTICS. You can specify each parameter only once in each statement. Each setting is valid only for the current library unit being compiled and does not affect other compilations in this session or system. To affect the entire session or system, you must set a value for the parameter using the ALTER SESSION or ALTER SYSTEM statement. If you omit any parameter from this clause and you specify REUSE SETTINGS, then if a value was specified for the parameter in an earlier compilation of this library unit, the database uses that earlier value. If you omit any parameter and either you do not specify REUSE SETTINGS or no value has been specified for the parameter in an earlier compilation, then the database obtains the value for that parameter from the session environment. Restriction on the compiler_parameters_clause You cannot set a value for the PLSQL_DEBUG parameter if you also specify DEBUG, because both clauses set the PLSQL_DEBUG parameter, and you can specify a value for each parameter only once. REUSE SETTINGS Specify REUSE SETTINGS to prevent Oracle from dropping and reacquiring compiler switch settings. With this clause, Oracle preserves the existing settings and uses them for the recompilation of any parameters for which values are not specified elsewhere in this statement. For backward compatibility, the database sets the persistently stored value of the PLSQL_COMPILER_FLAGS initialization parameter to reflect the values of the PLSQL_CODE_TYPE and PLSQL_DEBUG parameters that result from this statement. */
EXECUTE DBMS_CONNECTION_POOL.START_POOL()
SELECT * FROM LOCATION_GU; SELECT * FROM LOCATION_SI; DROP TABLE LOCATION_GU; DROP TABLE LOCATION_SI;
SELECT m.title AS movie, r.rating AS rating FROM movies m JOIN ratings r ON r.movie_id = m.id WHERE year = 2010 ORDER BY 2 DESC, 1;
/* Navicat MySQL Data Transfer Source Server : 税务云平台 Source Server Type : MySQL Source Server Version : 50727 Source Host : 192.168.248.157:3306 Source Schema : cloudgo-business Target Server Type : MySQL Target Server Version : 50727 File Encoding : 65001 Date: 15/10/2019 21:29:06 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for CG_CREDIT_DETAIL -- ---------------------------- DROP TABLE IF EXISTS `CG_CREDIT_DETAIL`; CREATE TABLE `CG_CREDIT_DETAIL` ( `F_GUID` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'GUID\r\n', `F_ZTLX` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '主体类型(法人)', `F_ZZJGDM` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '组织机构代码/身份证号', `F_XZXK` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '行政许可(计数)', `F_XZCF` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '行政处罚(计数)', `F_SXHMD` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '守信红名单(计数)', `F_HMD` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '失信黑名单(计数)', `F_ZDGZMD` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '重点关注名单(计数)', `F_FROM` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '数据来源 eg:信用中国' ) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; SET FOREIGN_KEY_CHECKS = 1;
/* ** Question: https://leetcode.com/problems/department-highest-salary/ */ -- method 1, Oracle SELECT d.Name AS Department, t1.Name AS Employee, t1.Salary AS Salary FROM ( SELECT e.Id, e.Name, e.Salary, e.DepartmentId, RANK() OVER (PARTITION BY e.DepartmentId ORDER BY e.Salary DESC) AS pos FROM Employee e ) t1 INNER JOIN Department d ON t1.DepartmentId = d.Id WHERE t1.pos = 1; -- method 2, Oracle -- An important concept related to this method is the usage of IN sytanx -- Reference (PostgreSQL): https://www.postgresql.org/docs/current/functions-subquery.html#FUNCTIONS-SUBQUERY-IN SELECT d.Name AS Department, e.Name AS Employee, e.Salary FROM Employee e INNER JOIN Department d ON e.DepartmentId = d.Id WHERE (e.DepartmentId, e.Salary) IN ( SELECT DepartmentId, MAX(Salary) FROM Employee GROUP BY DepartmentId ); -- method 3, MySQL SELECT d.Name as 'Department', e.Name AS 'Employee', e.Salary FROM ( SELECT DepartmentId, MAX(Salary) AS 'max_salary' FROM Employee GROUP BY DepartmentId ) t1 INNER JOIN Employee e ON t1.max_salary = e.Salary AND t1.DepartmentId = e.DepartmentId INNER JOIN Department d on t1.DepartmentId = d.Id ORDER BY 'Department';
alter table customers drop constraint FK_8ty10pw947q1idxbhrm6sw3yr; alter table items drop constraint FK_av4mlxut8m30ehlvx8n8v8w8n; alter table items drop constraint FK_ioqq7ta9p1ewxjrdwe9p3duc1; alter table orders drop constraint FK_astys1dv61mdlp0n0wx0574r2; drop table if exists addresses cascade; drop table if exists customers cascade; drop table if exists items cascade; drop table if exists orders cascade; drop table if exists products cascade; drop sequence address_seq; drop sequence customer_seq; drop sequence item_seq; drop sequence order_seq; drop sequence product_seq; create table addresses ( id int8 not null, city varchar(255), state varchar(255), street varchar(255), zipCode varchar(255), primary key (id) ); create table customers ( id int8 not null, birthDay timestamp, firstName varchar(255), gender int4, lastName varchar(255), address_id int8, primary key (id) ); create table items ( id int8 not null, count int4 not null, order_id int8, product_id int8, primary key (id) ); create table orders ( id int8 not null, date timestamp, customer_id int8, primary key (id) ); create table products ( id int8 not null, description varchar(255), name varchar(255), price numeric(19, 2), primary key (id) ); alter table customers add constraint FK_8ty10pw947q1idxbhrm6sw3yr foreign key (address_id) references addresses; alter table items add constraint FK_av4mlxut8m30ehlvx8n8v8w8n foreign key (order_id) references orders; alter table items add constraint FK_ioqq7ta9p1ewxjrdwe9p3duc1 foreign key (product_id) references products; alter table orders add constraint FK_astys1dv61mdlp0n0wx0574r2 foreign key (customer_id) references customers; create sequence address_seq; create sequence customer_seq; create sequence item_seq; create sequence order_seq; create sequence product_seq;
Create Procedure mERP_sp_Update_InvProcess_XMLAck(@RecdInvID int, @Status Int) As Begin Update tbl_mERP_RecdDocAck Set ProcessAckStatus = @Status, ProcessAckDateTime =GetDate() Where DocTrackID = (Select Top 1 IsNull(RecdXMLAckDocID,0) as ID From InvoiceAbstractReceived Where InvoiceID = @RecdInvID) And IsNull(ProcessAckStatus,0) = 0 End
ALTER TABLE `#__md_tower` ADD `mod_user_id` INT(11) NULL AFTER `incl_corresp`, ADD `mod_date` TIMESTAMP NULL AFTER `mod_user_id`; -- -- Table structure for table `#__md_tower_history` -- CREATE TABLE IF NOT EXISTS `#__md_tower_history` ( `history_id` int(11) NOT NULL AUTO_INCREMENT, `id` int(3) NOT NULL, `district_id` int(1) DEFAULT NULL, `place` varchar(40) DEFAULT NULL, `designation` varchar(40) DEFAULT NULL, `bells` int(2) DEFAULT NULL, `tenor` varchar(20) DEFAULT NULL, `grid_ref` varchar(8) DEFAULT NULL, `ground_floor` tinyint(1) DEFAULT NULL, `anti_clockwise` tinyint(1) DEFAULT NULL, `unringable` tinyint(1) DEFAULT NULL, `email` varchar(100) DEFAULT NULL, `street` varchar(100) DEFAULT NULL, `town` varchar(50) DEFAULT NULL, `county` varchar(50) DEFAULT NULL, `post_code` varchar(10) DEFAULT NULL, `country` varchar(2) DEFAULT NULL, `longitude` decimal(35,14) DEFAULT NULL, `latitude` decimal(35,14) DEFAULT NULL, `website` varchar(200) DEFAULT NULL, `church_website` varchar(200) DEFAULT NULL, `doves_guide` varchar(200) DEFAULT NULL, `contact_person` varchar(25) DEFAULT NULL, `email2` int(4) DEFAULT NULL, `tower_description` varchar(200) DEFAULT NULL, `wc` tinyint(1) DEFAULT NULL, `sunday_ringing` varchar(100) DEFAULT NULL, `active` tinyint(1) DEFAULT NULL, `correspondent_id` int(4) DEFAULT NULL, `captain_id` int(5) DEFAULT NULL, `web_tower_id` int(3) DEFAULT NULL, `multi_towers` tinyint(1) DEFAULT NULL, `practice_night` varchar(17) DEFAULT NULL, `practice_details` varchar(200) DEFAULT NULL, `field1` varchar(4) DEFAULT NULL, `incl_capt` tinyint(1) DEFAULT NULL, `incl_corresp` tinyint(1) DEFAULT NULL, `mod_user_id` int(11) DEFAULT NULL, `mod_date` timestamp NULL DEFAULT NULL, PRIMARY KEY (`history_id`), KEY `tower_history_id_i1` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=268 ; CREATE TRIGGER `md_tower_delete_trigger` BEFORE DELETE ON `#__md_tower` FOR EACH ROW insert into #__md_tower_history SELECT null, #__md_tower.* FROM #__md_tower WHERE #__md_tower.id = OLD.id; CREATE TRIGGER `md_tower_update_trigger` BEFORE UPDATE ON `#__md_tower` FOR EACH ROW insert into #__md_tower_history SELECT null, #__md_tower.* FROM #__md_tower WHERE #__md_tower.id = NEW.id
-- phpMyAdmin SQL Dump -- version 4.4.15.7 -- http://www.phpmyadmin.net -- -- Хост: 127.0.0.1:3306 -- Время создания: Янв 31 2017 г., 19:49 -- Версия сервера: 5.6.31 -- Версия PHP: 5.6.23 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 */; -- -- База данных: `it-organizations` -- -- -------------------------------------------------------- -- -- Структура таблицы `employees` -- CREATE TABLE IF NOT EXISTS `employees` ( `id` int(4) NOT NULL COMMENT 'Inner identification', `firstName` varchar(255) NOT NULL COMMENT 'First name', `middleName` varchar(255) NOT NULL COMMENT 'Middle name', `lastName` varchar(255) NOT NULL COMMENT 'Last name', `date` date NOT NULL COMMENT 'Date of birth', `inn` int(9) NOT NULL COMMENT 'VAT identification number', `snils` bigint(11) NOT NULL COMMENT 'Insurance individual account number', `idOrganization` int(4) NOT NULL COMMENT 'Identification number of organization' ) ENGINE=InnoDB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `employees` -- INSERT INTO `employees` (`id`, `firstName`, `middleName`, `lastName`, `date`, `inn`, `snils`, `idOrganization`) VALUES (1, 'Vasiliy', 'Ivanovich', 'Rybak', '1992-05-09', 159453018, 56980124561, 1), (2, 'Dmitriy', 'Alexeevich', 'Pushkin', '1990-06-14', 951140780, 64501298703, 1), (3, 'Alexandr', 'Potapovich', 'Rosenbaum', '1984-10-03', 100285468, 15948703215, 1), (4, 'Darya', 'Evgenyevna', 'Kryuk', '1995-12-21', 784789154, 14784956874, 5), (20, 'Dmitriy', 'Maksimovich', 'Ulaschik', '1977-02-09', 345654737, 37536856752, 17), (21, 'Denis', 'Alexeevich', 'Mikhailov', '1987-01-10', 642565462, 24565475462, 12), (42, 'Olga', 'Valeryevna', 'Kopipastovna', '1977-06-08', 234164575, 24564785685, 5), (43, 'Denis', 'Mikchailovich', 'Antonov', '1976-06-16', 345134636, 47568276585, 40), (44, 'Boris', 'Antonovich', 'Popov', '1988-11-02', 413452475, 53675686749, 42), (64, 'Feofan', 'Potapovich', 'Belobrys', '1990-06-24', 345546536, 96748528538, 39); -- -------------------------------------------------------- -- -- Структура таблицы `organizations` -- CREATE TABLE IF NOT EXISTS `organizations` ( `id` int(4) NOT NULL COMMENT 'Inner identification', `name` varchar(255) NOT NULL COMMENT 'Name of organization', `ogrn` bigint(13) NOT NULL COMMENT 'Primary state registration number', `oktmo` int(8) NOT NULL COMMENT 'State classification of territories of municipal formations' ) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `organizations` -- INSERT INTO `organizations` (`id`, `name`, `ogrn`, `oktmo`) VALUES (1, 'EPAM', 6931761371059, 24540941), (2, 'IBA Group', 4561723845101, 72797856), (3, 'Wargaming', 5576154907954, 48470433), (4, 'Itransition', 1963844659801, 44258246), (5, 'BELHARD', 3537086530154, 32575814), (6, 'iTechArt Group', 5994363631845, 32652683), (7, 'ISsoft', 8462248686532, 93390832), (8, 'Exadel', 7117623798851, 61066298), (9, 'SoftClub', 7327036660014, 50176175), (10, 'ScienceSoft', 3979765349951, 19315658), (11, 'SaM Solutions', 1462689841182, 61715230), (12, 'A1QA', 7756696284480, 80079703), (13, 'Системные технологии', 1479570277878, 39563766), (14, 'Корпорация Галактика', 1084669461984, 79877809), (15, 'Сбербанк-Технологии', 2225988311894, 56731038), (16, 'Godel Technologies Europe', 8116950374410, 44113497), (17, 'Qulix Systems', 1680424089654, 90371368), (18, 'SCAND', 7289213644118, 85711888), (19, 'Altoros Development', 6972538009961, 24881892), (20, 'Novacom a Softline Company', 9462412087102, 56432227), (21, 'Oxagile', 5770355884812, 37689453), (22, 'Artezio', 9101320421135, 38454618), (23, 'EffectiveSoft Ltd.', 6287568088655, 45369039), (24, 'Elilink Consulting', 6355879354531, 79620252), (25, 'Intetics', 3996423574587, 62383663), (26, 'LeverX', 7441026071147, 41158307), (27, 'Softeq Development', 2028176731684, 47501443), (28, 'CodeSWAT', 5832011279967, 10883354), (29, 'VRP Consulting', 8356219441021, 69904594), (30, 'Playtika', 2391332189810, 53242036), (31, 'NetCracker', 4738231401249, 99266577), (32, 'BelitSoft', 5965962811245, 33432784), (33, 'Epol Soft', 9309083909854, 66796450), (34, 'Ciklum', 8335797121104, 32433935), (35, 'Яндекс', 3963691050048, 37820909), (36, 'Gurtam', 1465256372268, 70582692), (37, 'Skywind Group', 2165011911110, 76670197), (38, 'instinctools', 8313744921441, 78749177), (39, 'Softeq Flash Solutions', 7996111504484, 87289514), (40, 'HiQo Solutions', 9998397330298, 33381323), (41, 'Apalon', 7149184390028, 23941377), (42, 'Viber', 4087275800146, 66064972), (43, 'Vizor Games', 7767873459898, 43549270), (44, 'Synesis', 6923292184581, 81994992), (45, 'EIS Group', 9873886520127, 22159508), (46, 'Specific-Group', 3797651920184, 55713300), (47, 'OCSICO', 5446857061548, 64134555), (48, 'Andersen', 7911056855548, 57335549), (49, 'Intellectsoft', 3026735091125, 49653708), (50, 'IHS Markit', 2539467478972, 13971793); -- -- Индексы сохранённых таблиц -- -- -- Индексы таблицы `employees` -- ALTER TABLE `employees` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id_UNIQUE` (`id`), ADD UNIQUE KEY `inn_UNIQUE` (`inn`), ADD UNIQUE KEY `snils_UNIQUE` (`snils`); -- -- Индексы таблицы `organizations` -- ALTER TABLE `organizations` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id_UNIQUE` (`id`), ADD UNIQUE KEY `name_UNIQUE` (`name`), ADD UNIQUE KEY `oktmo_UNIQUE` (`oktmo`), ADD UNIQUE KEY `ogrn_UNIQUE` (`ogrn`); -- -- AUTO_INCREMENT для сохранённых таблиц -- -- -- AUTO_INCREMENT для таблицы `employees` -- ALTER TABLE `employees` MODIFY `id` int(4) NOT NULL AUTO_INCREMENT COMMENT 'Inner identification',AUTO_INCREMENT=65; -- -- AUTO_INCREMENT для таблицы `organizations` -- ALTER TABLE `organizations` MODIFY `id` int(4) NOT NULL AUTO_INCREMENT COMMENT 'Inner identification',AUTO_INCREMENT=51; /*!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 */;
CREATE TABLE PERSONS( id INT not null IDENTITY(1,1) , personFirstName varchar(25), personSecondName varchar(25), personThirdName varchar(25), personFamilyName varchar(25), personSex number, personStatus number, personBirthdate varchar(25), personIdType number, personIdNo varchar(25) , personEmail varchar(25), personMobile varchar(25), personAddress varchar(50) ); CREATE TABLE GROUP_PERMISSIONS( ID NUMBER NOT NULL, GROUP_NAME VARCHAR(100), EMPLOYEES VARCHAR(500) ); ALTER TABLE GROUP_PERMISSIONS ADD PRIMARY KEY (ID); CREATE TABLE WORKFLOW( ID NUMBER NOT NULL, PRIORITY NUMBER NOT NULL, GROUP_ID NUMBER, ACTION varchar(2) ); ALTER TABLE WORKFLOW ADD PRIMARY KEY (ID,PRIORITY); ALTER TABLE WORKFLOW ADD FOREIGN KEY (GROUP_ID) REFERENCES GROUP_PERMISSIONS(ID); CREATE TABLE APPROVAL_PATH( USER_NID NUMBER NOT NULL, WORKFLOW NUMBER NOT NULL ); ALTER TABLE APPROVAL_PATH ADD PRIMARY KEY(USER_NID,WORKFLOW); -- ALTER TABLE APPROVAL_PATH -- ADD FOREIGN KEY (WORKFLOW) -- REFERENCES WORKFLOW(workflow_ID);
insert into users values(1, 'jake', 'bern', 'xxxx', 20); insert into users values(2, 'George', 'Goldstein', 'xxxx', 20); insert into users values(3, 'Billy', 'Maise', 'xxxx', 19);
CREATE procedure sp_acc_get_Others_CreditNote(@DocumentID int) as select AccountsMaster.AccountID, AccountsMaster.AccountName, NoteValue, DocumentDate, Memo, DocumentID, DocRef, case When Status & 64 <> 0 Then dbo.LookupDictionaryItem('Cancelled',Default) When Memo <> N'' and status is null and isnull(RefDocid,0) = 0 Then LTrim(Rtrim(Memo)) when isnull(status & 128,0 ) = 128 and isnull(RefDocid,0) <> 0 then dbo.LookupDictionaryItem('Amended',Default) when isnull(status & 128,0 ) = 128 and Balance = 0 then dbo.LookupDictionaryItem('Amended',Default) when isnull(status & 128,0 ) = 0 and isnull(RefDocid,0) <> 0 then dbo.LookupDictionaryItem('Amendment',Default) Else '' end, Cancel_Memo,'Account' = dbo.getaccountname(isnull(CreditNote.AccountID,0)),DocumentReference,DocSerialType from CreditNote, AccountsMaster where CreditID = @DocumentID and AccountsMaster.AccountID = CreditNote.Others
-- sample SQL statements for the NodeMeta CREATE TABLE NodeMeta ( id int, user_id int, update_time , session_id int, class_id int, )
set echo on; col sql_redo format a160 col container_name format a16 set lines 200 select container_name, commit_scn, sql_redo from replicated_txns order by id,commit_scn;
--修改日期:2012.12.5 --修改人:李程 --修改内容:用途代码名为“信贷管理”,不符合系统格式,也不利于维护。本脚本将系统原有的用途代码为“信贷管理”的数据更新为系统默认的自增长的用途代码。 --修改原因:user00035746广州建筑-信贷管理用途维护问题。 DECLARE VN_COUNT NUMBER; BEGIN select COUNT(*) INTO VN_COUNT from cms_pl_purpose where purpose_code = '信贷管理'; IF VN_COUNT > 0 THEN LOOP Exit When(VN_COUNT=0); update cms_pl_purpose set purpose_code = (select gen_value from tb_generator where gen_name='BT_PURPOSE_ID') where id = (select min(id) from cms_pl_purpose where purpose_code = '信贷管理'); update tb_generator set gen_value=( select gen_value+1 from tb_generator where gen_name='BT_PURPOSE_ID' ) where gen_name='BT_PURPOSE_ID'; VN_COUNT:=VN_COUNT-1; END LOOP; END IF; END; / COMMIT;
-- MySQL dump 10.13 Distrib 5.6.27, for osx10.8 (x86_64) -- -- Host: localhost Database: muse_dev -- ------------------------------------------------------ -- Server version 5.6.27-enterprise-commercial-advanced /*!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 `actionType` -- DROP TABLE IF EXISTS `actionType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `actionType` ( `actionTypeId` int(11) NOT NULL AUTO_INCREMENT, `actionType` varchar(255) NOT NULL, PRIMARY KEY (`actionTypeId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `actionType` -- LOCK TABLES `actionType` WRITE; /*!40000 ALTER TABLE `actionType` DISABLE KEYS */; /*!40000 ALTER TABLE `actionType` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `artifact` -- DROP TABLE IF EXISTS `artifact`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `artifact` ( `artifactId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `artifactName` varchar(255) NOT NULL, `displayId` int(11) NOT NULL, PRIMARY KEY (`artifactId`), KEY `displayId` (`displayId`), CONSTRAINT `artifact_ibfk_1` FOREIGN KEY (`displayId`) REFERENCES `display` (`displayId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `artifact` -- LOCK TABLES `artifact` WRITE; /*!40000 ALTER TABLE `artifact` DISABLE KEYS */; /*!40000 ALTER TABLE `artifact` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `artifactTags` -- DROP TABLE IF EXISTS `artifactTags`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `artifactTags` ( `artifactId` int(11) NOT NULL, `tagId` int(11) NOT NULL, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `proCreated` tinyint(4) DEFAULT NULL, PRIMARY KEY (`artifactId`,`tagId`), KEY `tagId` (`tagId`), CONSTRAINT `artifacttags_ibfk_1` FOREIGN KEY (`artifactId`) REFERENCES `artifact` (`artifactId`), CONSTRAINT `artifacttags_ibfk_2` FOREIGN KEY (`tagId`) REFERENCES `tag` (`tagId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `artifactTags` -- LOCK TABLES `artifactTags` WRITE; /*!40000 ALTER TABLE `artifactTags` DISABLE KEYS */; /*!40000 ALTER TABLE `artifactTags` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `display` -- DROP TABLE IF EXISTS `display`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `display` ( `displayId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `displayName` varchar(255) NOT NULL, `exhibitId` int(11) NOT NULL, PRIMARY KEY (`displayId`), KEY `exhibitId` (`exhibitId`), CONSTRAINT `display_ibfk_1` FOREIGN KEY (`exhibitId`) REFERENCES `exhibit` (`exhibitId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `display` -- LOCK TABLES `display` WRITE; /*!40000 ALTER TABLE `display` DISABLE KEYS */; /*!40000 ALTER TABLE `display` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `displayTags` -- DROP TABLE IF EXISTS `displayTags`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `displayTags` ( `displayId` int(11) NOT NULL, `tagId` int(11) NOT NULL, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `proCreated` tinyint(4) DEFAULT NULL, PRIMARY KEY (`displayId`,`tagId`), KEY `tagId` (`tagId`), CONSTRAINT `displaytags_ibfk_1` FOREIGN KEY (`displayId`) REFERENCES `display` (`displayId`), CONSTRAINT `displaytags_ibfk_2` FOREIGN KEY (`tagId`) REFERENCES `tag` (`tagId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `displayTags` -- LOCK TABLES `displayTags` WRITE; /*!40000 ALTER TABLE `displayTags` DISABLE KEYS */; /*!40000 ALTER TABLE `displayTags` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `exhibit` -- DROP TABLE IF EXISTS `exhibit`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `exhibit` ( `exhibitId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `exhibitName` varchar(255) NOT NULL, `museumId` int(11) NOT NULL, PRIMARY KEY (`exhibitId`), KEY `museumId` (`museumId`), CONSTRAINT `exhibit_ibfk_1` FOREIGN KEY (`museumId`) REFERENCES `museum` (`museumId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `exhibit` -- LOCK TABLES `exhibit` WRITE; /*!40000 ALTER TABLE `exhibit` DISABLE KEYS */; /*!40000 ALTER TABLE `exhibit` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `exhibitTags` -- DROP TABLE IF EXISTS `exhibitTags`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `exhibitTags` ( `exhibitId` int(11) NOT NULL, `tagId` int(11) NOT NULL, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `proCreated` tinyint(4) DEFAULT NULL, PRIMARY KEY (`exhibitId`,`tagId`), KEY `tagId` (`tagId`), CONSTRAINT `exhibittags_ibfk_1` FOREIGN KEY (`exhibitId`) REFERENCES `exhibit` (`exhibitId`), CONSTRAINT `exhibittsgs_ibfk_2` FOREIGN KEY (`tagId`) REFERENCES `tag` (`tagId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `exhibitTags` -- LOCK TABLES `exhibitTags` WRITE; /*!40000 ALTER TABLE `exhibitTags` DISABLE KEYS */; /*!40000 ALTER TABLE `exhibitTags` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `groupMembers` -- DROP TABLE IF EXISTS `groupMembers`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `groupMembers` ( `groupId` int(11) NOT NULL, `userId` int(11) NOT NULL, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, PRIMARY KEY (`groupId`,`userId`), KEY `userId` (`userId`), CONSTRAINT `visitorgroupmemeber_ibfk_1` FOREIGN KEY (`groupId`) REFERENCES `groups` (`groupId`), CONSTRAINT `visitorgroupmemeber_ibfk_2` FOREIGN KEY (`userId`) REFERENCES `users` (`userId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `groupMembers` -- LOCK TABLES `groupMembers` WRITE; /*!40000 ALTER TABLE `groupMembers` DISABLE KEYS */; /*!40000 ALTER TABLE `groupMembers` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `groups` -- DROP TABLE IF EXISTS `groups`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `groups` ( `groupId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `groupName` varchar(255) NOT NULL, PRIMARY KEY (`groupId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `groups` -- LOCK TABLES `groups` WRITE; /*!40000 ALTER TABLE `groups` DISABLE KEYS */; /*!40000 ALTER TABLE `groups` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `interactions` -- DROP TABLE IF EXISTS `interactions`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `interactions` ( `interactionId` int(11) NOT NULL AUTO_INCREMENT, `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `userId` int(11) NOT NULL, `artifactId` int(11) NOT NULL, PRIMARY KEY (`interactionId`), KEY `userId` (`userId`), KEY `artifactId` (`artifactId`), CONSTRAINT `interactions_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`userId`), CONSTRAINT `interactions_ibfk_2` FOREIGN KEY (`artifactId`) REFERENCES `artifact` (`artifactId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `interactions` -- LOCK TABLES `interactions` WRITE; /*!40000 ALTER TABLE `interactions` DISABLE KEYS */; /*!40000 ALTER TABLE `interactions` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `museum` -- DROP TABLE IF EXISTS `museum`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `museum` ( `museumId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `museumName` varchar(255) NOT NULL, PRIMARY KEY (`museumId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `museum` -- LOCK TABLES `museum` WRITE; /*!40000 ALTER TABLE `museum` DISABLE KEYS */; /*!40000 ALTER TABLE `museum` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `plan` -- DROP TABLE IF EXISTS `plan`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `plan` ( `planId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `proCreated` tinyint(4) DEFAULT NULL, `planTypeId` int(11) NOT NULL, PRIMARY KEY (`planId`), KEY `planTypeId` (`planTypeId`), CONSTRAINT `plan_ibfk_1` FOREIGN KEY (`planTypeId`) REFERENCES `planType` (`planTypeId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `plan` -- LOCK TABLES `plan` WRITE; /*!40000 ALTER TABLE `plan` DISABLE KEYS */; /*!40000 ALTER TABLE `plan` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `planArtifacts` -- DROP TABLE IF EXISTS `planArtifacts`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `planArtifacts` ( `planId` int(11) NOT NULL, `artifactId` int(11) NOT NULL, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, PRIMARY KEY (`planId`,`artifactId`), KEY `artifactId` (`artifactId`), CONSTRAINT `planartifacts_ibfk_1` FOREIGN KEY (`planId`) REFERENCES `plan` (`planId`), CONSTRAINT `planartifacts_ibfk_2` FOREIGN KEY (`artifactId`) REFERENCES `artifact` (`artifactId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `planArtifacts` -- LOCK TABLES `planArtifacts` WRITE; /*!40000 ALTER TABLE `planArtifacts` DISABLE KEYS */; /*!40000 ALTER TABLE `planArtifacts` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `planContributors` -- DROP TABLE IF EXISTS `planContributors`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `planContributors` ( `planId` int(11) NOT NULL, `userId` int(11) NOT NULL, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, PRIMARY KEY (`planId`,`userId`), KEY `userId` (`userId`), CONSTRAINT `plancontributors_ibfk_1` FOREIGN KEY (`planId`) REFERENCES `plan` (`planId`), CONSTRAINT `plancontributors_ibfk_2` FOREIGN KEY (`userId`) REFERENCES `users` (`userId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `planContributors` -- LOCK TABLES `planContributors` WRITE; /*!40000 ALTER TABLE `planContributors` DISABLE KEYS */; /*!40000 ALTER TABLE `planContributors` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `planType` -- DROP TABLE IF EXISTS `planType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `planType` ( `planTypeId` int(11) NOT NULL AUTO_INCREMENT, `planType` varchar(255) NOT NULL, PRIMARY KEY (`planTypeId`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `planType` -- LOCK TABLES `planType` WRITE; /*!40000 ALTER TABLE `planType` DISABLE KEYS */; INSERT INTO `planType` VALUES (1,'Visitor Defined'),(2,'Curator Defined'); /*!40000 ALTER TABLE `planType` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `tag` -- DROP TABLE IF EXISTS `tag`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tag` ( `tagId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `tagName` varchar(255) NOT NULL, `proCreated` tinyint(4) DEFAULT NULL, PRIMARY KEY (`tagId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `tag` -- LOCK TABLES `tag` WRITE; /*!40000 ALTER TABLE `tag` DISABLE KEYS */; /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `userType` -- DROP TABLE IF EXISTS `userType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `userType` ( `userTypeId` int(11) NOT NULL AUTO_INCREMENT, `userType` varchar(255) NOT NULL, PRIMARY KEY (`userTypeId`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `userType` -- LOCK TABLES `userType` WRITE; /*!40000 ALTER TABLE `userType` DISABLE KEYS */; INSERT INTO `userType` VALUES (1,'Visitor'),(2,'Curator'); /*!40000 ALTER TABLE `userType` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `users` -- DROP TABLE IF EXISTS `users`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `users` ( `userId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `userName` varchar(255) NOT NULL, `userType` int(11) NOT NULL, `login` varchar(255) NOT NULL, `password` varchar(255) DEFAULT NULL, PRIMARY KEY (`userId`), KEY `userType` (`userType`), CONSTRAINT `user_ibfk_1` FOREIGN KEY (`userType`) REFERENCES `userType` (`userTypeId`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `users` -- LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` VALUES (5,1,'2015-11-02 21:43:20',NULL,'John',1,'user1','password'); /*!40000 ALTER TABLE `users` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `visit` -- DROP TABLE IF EXISTS `visit`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `visit` ( `visitId` int(11) NOT NULL AUTO_INCREMENT, `active` tinyint(4) NOT NULL DEFAULT '1', `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updateTime` timestamp NULL DEFAULT NULL, `groupId` int(11) NOT NULL, `museumId` int(11) NOT NULL, PRIMARY KEY (`visitId`), KEY `groupId` (`groupId`), KEY `museumId` (`museumId`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`groupId`) REFERENCES `groups` (`groupId`), CONSTRAINT `visit_ibfk_2` FOREIGN KEY (`museumId`) REFERENCES `museum` (`museumId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `visit` -- LOCK TABLES `visit` WRITE; /*!40000 ALTER TABLE `visit` DISABLE KEYS */; /*!40000 ALTER TABLE `visit` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2015-12-01 21:18:28