sql
stringlengths 6
1.05M
|
|---|
CREATE OR REPLACE VIEW OSP$AWARD_SCIENCE_CODE(MIT_AWARD_NUMBER,
SEQUENCE_NUMBER,
SPECIAL_REVIEW_NUMBER,
SPECIAL_REVIEW_CODE,
APPROVAL_TYPE_CODE,
PROTOCOL_NUMBER,
APPLICATION_DATE,
APPROVAL_DATE,
COMMENTS,
UPDATE_USER,
UPDATE_TIMESTAMP)
AS SELECT
B.AWARD_NUMBER,
B.SEQUENCE_NUMBER,
A.SPECIAL_REVIEW_NUMBER,
A.SPECIAL_REVIEW_CODE,
A.APPROVAL_TYPE_CODE,
A.PROTOCOL_NUMBER,
A.APPLICATION_DATE,
A.APPROVAL_DATE,
A.COMMENTS,
A.UPDATE_USER,
A.UPDATE_TIMESTAMP
FROM AWARD_SPECIAL_REVIEW A,AWARD B
where A.AWARD_ID=B.AWARD_ID;
|
-- gameobject_involvedrelation
-- By Mikadmin <NAME>
-- Quest Added in patch 4.3.0
DELETE FROM `gameobject_involvedrelation` WHERE (`quest`=29643);
|
<reponame>Ambal/mangos<gh_stars>1-10
ALTER TABLE db_version CHANGE COLUMN required_10289_01_mangos_creature_template required_10289_02_mangos_creature_model_info bit;
ALTER TABLE creature_model_info ADD COLUMN modelid_alternative mediumint(8) unsigned NOT NULL default '0' AFTER modelid_other_gender;
ALTER TABLE creature_model_info ADD COLUMN modelid_other_team mediumint(8) unsigned NOT NULL default '0' AFTER modelid_alternative;
|
<reponame>df7cb/postgresql-uctext<filename>sql/uctext.sql
create extension uctext;
select null::uctext;
select ''::uctext;
select 'abc123'::uctext;
select 'ABC123'::uctext;
select 'moo'::uctext = 'moo'::text, 'moo'::text = 'moo'::uctext;
select 'moo'::uctext = 'MOO'::text, 'MOO'::text = 'moo'::uctext;
create table log (
call uctext,
loc uctext
);
copy log from stdin;
oz1dae jo65ag
EA4AOC IN80DD
UW8SM KN28IV
M0HMO IO82QN
IK6BAK JN63KR
EW6DM KO35UU
9A1FL JN74OC
IK2YCW JN55KE
dl3rar jn68iv
UY5QQ KN77MO
S57SWR JN76AA
PE1FTV JO21QI
ON6AT JO10UW
OH3FM KP21GM
MM9I IO75
DL4RCE JN68ax
DJ5AN JO32MH
S53EOP JN76OH
OH2KW KP20IJ
IV3HAX JN66OB
I4JED JN54
UX7QV kn87dl
RG9A MO04EW
SV2BFN KN10LN
DL6UAA JO62td
dl6rdm jn68hv
oe2e jn67ls
YU5R KN04PF
DL8NFA JN59MP
YL3CU KO06MM
DL8MKG JO52NU
IV3DMJ JN66GB
F6AGM JN13AT
EA4BAS IN80HL
SO0A KO00
UY5VA KN87
OK1KSL JO70BF
9A5X JN86EH
DA0KOL JO43WH
YO4NF KN44HD
CX7SS GF25LQ
YO4FPF KN44HE
UY5VA kn87
SV3DCX KM08VF
DJ4MH JO42BB
pe1ftv jo21qi
CT1BXT IM59PF
DF4XX JO53CN
UT8IM KN87SC
PY7XC HI21ES
DK5KK JO31LL
CX2AQ GF25MQ
DL4NWM JN59SM
DQ9Y JO31CO
DF4XG JO43WI
aa3b fn20re
kb8o en81wj
w3ll fm19rl
n2bj en61am
n4qs em56px
k2zw fn65
va3df en92vv
s51i jn76xl
\.
select * from log where call = 'pe1ftv';
select * from log where call = 'PE1FTV';
select * from log where call between 'dl0a' and 'dl9zzz';
explain select * from log where call between 'dl0a' and 'dl9zzz';
create index on log (call);
analyze log;
set enable_seqscan = off;
select * from log where call = 'pe1ftv';
select * from log where call = 'PE1FTV';
explain select * from log where call = 'pe1ftv';
select * from log where call between 'dl0a' and 'dl9zzz';
explain select * from log where call between 'dl0a' and 'dl9zzz';
|
<filename>src/main/db/procedures/START_CAMUNDA_PROCESS.sql
create or replace procedure start_camunda_process(proposalId IN number, budget IN number, category IN VARCHAR2, username IN VARCHAR2 ) is
l_body clob := '';
l_clob clob := '';
l_email VARCHAR2(240);
begin
l_email := APEX_UTIL.GET_EMAIL(p_username => username);
apex_web_service.g_request_headers.delete();
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/json';
APEX_JSON.initialize_clob_output;
apex_json.open_object; -- {
apex_json.write('businessKey', 'proposalProcessAPEX');
apex_json.open_object('variables'); -- "variables": {
apex_json.open_object('requester'); -- "requester" : {
apex_json.write('value', l_email);
apex_json.write('type', 'String');
APEX_JSON.CLOSE_OBJECT ();
apex_json.open_object('budget'); -- "budget" : {
apex_json.write('value', budget);
apex_json.write('type', 'Integer');
APEX_JSON.CLOSE_OBJECT ();
apex_json.open_object('category'); -- "category" : {
apex_json.write('value', category);
apex_json.write('type', 'String');
APEX_JSON.CLOSE_OBJECT ();
apex_json.open_object('proposalId'); -- "proposalId" : {
apex_json.write('value', proposalId);
apex_json.write('type', 'Integer');
apex_json.close_all; -- }}
l_body := APEX_JSON.get_clob_output;
APEX_JSON.free_output;
l_clob := apex_web_service.make_rest_request(
p_url => 'https://emmentaler.herokuapp.com/rest/process-definition/digibp-tobe:1:5fd1940f-a40a-11ea-b8c5-3262e10564e6/start',
p_http_method => 'POST',
p_body => l_body
);
print_clob_to_output (l_clob);
-- {"links":[{"method":"GET","href":"https://emmentaler.herokuapp.com/rest/process-instance/23c47805-9e4d-11ea-9fe5-3e17a72f504f","rel":"self"}],"id":"23c47805-9e4d-11ea-9fe5-3e17a72f504f","definitionId":"digibp-tobe:2:dfaedcba-9de2-11ea-9c51-da029e11a7df","
-- businessKey":"proposalProcessAPEX","caseInstanceId":null,"ended":false,"suspended":false,"tenantId":null}
insert into antrag_camunda (CAMUNDA_BODY,ANTRAG_ID) values (l_clob, proposalId );
update antrag_camunda set INSTANCE_INFORMATION = json_value(instance_information, '$.id' returning VARCHAR2) where antrag_id = proposalId;
end start_camunda_process;
|
<gh_stars>0
delimiter $$
DROP PROCEDURE IF EXISTS ShowTickInfo $$
CREATE PROCEDURE ShowTickInfo(IN id VARCHAR(5))
BEGIN
IF EXISTS (SELECT tick FROM Prices WHERE tick = id) THEN
SELECT *
FROM Prices JOIN Volume ON Prices.tick = Volume.tick AND Prices.date = Volume.date
JOIN Misc ON Prices.tick = Misc.tick AND Prices.date = Misc.date
JOIN AdjPrices ON Prices.tick = AdjPrices.tick AND Prices.date = AdjPrices.date
WHERE Prices.tick = id;
ELSE
SELECT 'ERROR: Tick NOT FOUND' AS 'Result';
END IF;
END$$
delimiter ;
delimiter $$
DROP PROCEDURE IF EXISTS FindTickerWithDate $$
CREATE procedure FindTickerWithDate(IN id VARCHAR(5), IN dt VARCHAR(10))
BEGIN
IF EXISTS (SELECT tick FROM Prices WHERE tick = id) AND EXISTS (SELECT date FROM Prices WHERE dt = date) THEN
SELECT *
FROM Prices JOIN Volume ON Prices.tick = Volume.tick AND Prices.date = Volume.date
JOIN Misc ON Prices.tick = Misc.tick AND Prices.date = Misc.date
JOIN AdjPrices ON Prices.tick = AdjPrices.tick AND Prices.date = AdjPrices.date
WHERE Prices.date = dt AND Prices.tick = id;
ELSE
SELECT 'ERROR: UPDATE FAILED INVALID Ticker OR Date' AS 'Result';
END IF;
END$$
delimiter ;
delimiter $$
DROP PROCEDURE IF EXISTS FindTickerWithDateRange $$
CREATE procedure FindTickerWithDateRange(IN id VARCHAR(5), IN dt1 VARCHAR(10), IN dt2 VARCHAR(10))
BEGIN
IF EXISTS (SELECT tick FROM Prices WHERE tick = id) THEN
SELECT *
FROM Prices JOIN Volume ON Prices.tick = Volume.tick AND Prices.date = Volume.date
JOIN Misc ON Prices.tick = Misc.tick AND Prices.date = Misc.date
JOIN AdjPrices ON Prices.tick = AdjPrices.tick AND Prices.date = AdjPrices.date
WHERE (Prices.date >= dt1 AND Prices.date <= dt2) AND Prices.tick = id;
ELSE
SELECT 'ERROR: UPDATE FAILED INVALID Ticker OR Date' AS 'Result';
END IF;
END$$
delimiter ;
delimiter $$
DROP PROCEDURE IF EXISTS GreaterClosePrice $$
CREATE procedure GreaterClosePrice(IN cPrice FLOAT)
BEGIN
IF EXISTS (SELECT close FROM Prices WHERE close >= cPrice) THEN
SELECT DISTINCT(Prices.tick)
FROM Prices
WHERE Prices.close >= cPrice
ORDER BY Prices.tick ASC;
ELSE
SELECT 'ERROR: UPDATE FAILED INVALID Closing Price' AS 'Result';
END IF;
END$$
delimiter ;
delimiter $$
DROP PROCEDURE IF EXISTS LesserClosePrice $$
CREATE procedure LesserClosePrice(IN cPrice FLOAT)
BEGIN
IF EXISTS (SELECT close FROM Prices WHERE close <= cPrice) THEN
SELECT DISTINCT(Prices.tick)
FROM Prices
WHERE Prices.close <= cPrice
ORDER BY Prices.tick ASC;
ELSE
SELECT 'ERROR: UPDATE FAILED INVALID Closing Price' AS 'Result';
END IF;
END$$
delimiter ;
delimiter $$
DROP PROCEDURE IF EXISTS GreaterOpeningPrice $$
CREATE procedure GreaterOpeningPrice(IN oPrice FLOAT)
BEGIN
IF EXISTS (SELECT open FROM Prices WHERE open >= oPrice) THEN
SELECT DISTINCT(Prices.tick)
FROM Prices
WHERE Prices.open >= oPrice
ORDER BY Prices.tick ASC;
ELSE
SELECT 'ERROR: UPDATE FAILED INVALID Opening Price' AS 'Result';
END IF;
END$$
delimiter ;
delimiter $$
DROP PROCEDURE IF EXISTS LesserOpenPrice $$
CREATE procedure LesserOpenPrice(IN oPrice FLOAT)
BEGIN
IF EXISTS (SELECT open FROM Prices WHERE open <= oPrice) THEN
SELECT DISTINCT(Prices.tick)
FROM Prices
WHERE Prices.open <= oPrice
ORDER BY Prices.tick ASC;
ELSE
SELECT 'ERROR: UPDATE FAILED INVALID Opening Price' AS 'Result';
END IF;
END$$
delimiter ;
delimiter $$
DROP PROCEDURE IF EXISTS PercentGrowth $$
CREATE procedure PercentGrowth(IN growth FLOAT)
BEGIN
IF EXISTS (SELECT tick FROM Prices) THEN
SELECT Prices.tick, Prices.date
FROM Prices
WHERE Prices.close/Prices.open >= (1+growth)
ORDER BY Prices.tick ASC;
ELSE
SELECT 'ERROR: UPDATE FAILED INVALID Opening Price' AS 'Result';
END IF;
END$$
delimiter ;
|
drop table sec_user_authorities_AUD;
drop table sec_user_authorities;
drop table sec_user_roles_AUD;
drop table sec_user_roles;
drop table sec_user_groups_AUD;
drop table sec_user_groups;
drop table sec_user_tokens_AUD;
drop table sec_user_tokens;
drop table sec_users;
drop table sec_users_AUD;
drop table sec_group_authorities_AUD;
drop table sec_group_authorities;
drop table sec_group_AUD;
drop table sec_group;
drop table sec_role_authorities_AUD;
drop table sec_role_authorities;
drop table sec_role_AUD;
drop table sec_role;
drop table sec_authority_AUD;
drop table sec_authority;
drop table sec_function_AUD;
drop table sec_function;
drop table sec_module_AUD;
drop table sec_module;
drop table sec_application_AUD;
drop table sec_application;
drop table pub_block_annotations_AUD;
drop table pub_block_annotations;
drop table pub_blocks_AUD;
drop table pub_blocks;
drop table pub_author_identifiers_AUD;
drop table pub_author_identifiers;
drop table pub_authors_AUD;
drop table pub_authors;
drop table pub_centre_identifiers_AUD;
drop table pub_centre_identifiers;
drop table pub_centres_AUD;
drop table pub_centres;
drop table pub_file_articles_AUD;
drop table pub_file_articles;
drop table pub_files_AUD;
drop table pub_files;
drop table pub_publication_identifiers_AUD
drop table pub_publication_identifiers;
drop table pub_publications_AUD
drop table pub_publications;
drop table pub_journals_issues_AUD;
drop table pub_journals_issues;
drop table pub_journals_AUD;
drop table pub_journals;
drop table pub_reference_identifiers_AUD;
drop table pub_reference_identifiers;
drop table pub_references_AUD;
drop table pub_references;
drop table pub_terms_AUD
drop table pub_terms;
drop table pub_article_texts_AUD;
drop table pub_article_texts;
drop table pub_article_terms_AUD;
drop table pub_article_terms;
drop table pub_article_authors_AUD;
drop table pub_article_authors;
drop table pub_article_dates_AUD;
drop table pub_article_dates;
drop table pub_article_identifiers_AUD;
drop table pub_article_identifiers;
drop table pub_article_keywords_AUD;
drop table pub_article_keywords;
drop table pub_article_permissions_AUD;
drop table pub_article_permissions;
drop table pub_article_properties_AUD;
drop table pub_article_properties;
drop table pub_article_publication_AUD;
drop table pub_article_publication;
drop table pub_article_publication_loc_AUD;
drop table pub_article_publication_loc;
drop table pub_articles_AUD;
drop table pub_articles;
drop table cfg_parameters_AUD;
drop table cfg_parameters;
drop table cfg_revisions;
|
INSERT INTO cluster_features
VALUES (
'00000020-0020-0020-0020-000000000300',
'libgfapi_supported',
'4.1',
1,
'Native Access on gluster storage domain'
);
|
<reponame>abdoulboubacar/maconso-api<filename>state.sql
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (1, 345, 345, 0.1494, 1, '2017-04-28 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (2, 350, 5, 0.1494, 1, '2017-04-29 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (3, 355, 5, 0.1494, 1, '2017-04-30 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (4, 375, 20, 0.1494, 1, '2017-05-03 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (5, 400, 25, 0.1494, 1, '2017-05-06 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (6, 425, 25, 0.1494, 1, '2017-05-09 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (7, 430, 5, 0.1494, 1, '2017-05-10 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (8, 450, 20, 0.1494, 1, '2017-05-15 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (9, 473, 23, 0.1494, 1, '2017-05-19 21:43:21.436000');
INSERT INTO public.energie_state (id, value, diff, unit_price, deal_id, date) VALUES (10, 500, 27, 0.1494, 1, '2017-05-25 21:43:21.436000');
|
<gh_stars>1-10
INSERT INTO Configuration (Field, Value) VALUES ('CONHOST', 'CONvergence Dev');
INSERT INTO Configuration (Field, Value) VALUES ('ADMINEMAIL', '');
INSERT INTO Configuration (Field, Value) VALUES ('FEEDBACK_EMAIL', '');
INSERT INTO Configuration (Field, Value) VALUES ('SECURITY_EMAIL', '');
INSERT INTO Configuration (Field, Value) VALUES ('HELP_EMAIL', '');
INSERT INTO Configuration (Field, Value) VALUES ('NOREPLY_EMAIL', '');
INSERT INTO Configuration (Field, Value) VALUES ('ADMINACCOUNTS', '3218,42966');
INSERT INTO Configuration (Field, Value) VALUES ('DUMPSECURE', 'MPfKCJuEn7ZN2ypDc564NNXHAeGq6mc8dcNVYfXhg4FKq85d6K');
INSERT INTO Configuration (Field, Value) VALUES ('TIMEZONE', 'America/Chicago');
INSERT INTO Configuration (Field, Value) VALUES ('DBSchemaVersion', '0');
INSERT INTO Configuration (Field, Value) VALUES ('CONCOMHOURS', '60');
INSERT INTO Configuration (Field, Value) VALUES ('PASSWORDEXPIRE', '+1 year');
INSERT INTO Configuration (Field, Value) VALUES ('MAXLOGINFAIL', '5');
INSERT INTO Configuration (Field, Value) VALUES ('PASSWORDRESET', <PASSWORD>');
|
<reponame>nipunn1313/crates.io
CREATE EXTENSION IF NOT EXISTS pgcrypto;
ALTER TABLE api_tokens
ALTER COLUMN token
TYPE bytea USING decode(token, 'escape');
CREATE UNIQUE INDEX ON api_tokens (token);
|
<filename>updates/mimeo--1.2.1--1.2.2.sql
-- New function "check_missing_source_tables()" can show tables that exist on the configured data sources that are not configured for replication.
-- Provides monitoring capability for situations where all tables on source should be replicated.
-- Optional parameter to check one specific data source. Otherwise, all sources listed in dblink_mapping_mimeo table are checked.
-- Returns a record value so WHERE conditions can be used to ignore tables that aren't desired.
-- New function "check_source_columns()" can show columns that exist on source tables that do not exist on the destination
-- Provides monitoring capability for data source tables to see if columns have been added or types changed.
-- Does not check if destination has columns that source does not (therefore does not check if columns were dropped on source but not on destination).
-- Accounts for when the "filter" configuration option is used to only grab specific columns.
-- Optional parameter to check one specific data source. Otherwise, all sources listed in dblink_mapping_mimeo table are checked.
-- Returns a record value so WHERE conditions can be used to ignore tables and/or columns that don't matter for your situation.
-- Fix bug during index creation when dblink is not installed in a schema called "dblink" (Github Issue #6).
-- Added note to documentation about how to add/remove columns with DML replication and avoid errors.
-- Added pg_tap tests for new monitoring functions & snapshot column change replication.
/*
* Check data sources to see what tables exist there that are not set up for mimeo replication
* Provides monitoring capability for situations where all tables on source should be replicated.
* Returns a record value so that a WHERE condition can be used to ignore tables that aren't desired.
* If p_data_source_id value is not given, all configured sources are checked.
*/
CREATE FUNCTION check_missing_source_tables(p_data_source_id int DEFAULT NULL, OUT schemaname text, OUT tablename text, OUT data_source int) RETURNS SETOF record
LANGUAGE plpgsql SECURITY DEFINER
AS $$
DECLARE
v_dblink_schema text;
v_exists int;
v_row_dblink record;
v_row_missing record;
BEGIN
IF p_data_source_id IS NOT NULL THEN
SELECT count(*) INTO v_exists FROM @extschema@.dblink_mapping_mimeo WHERE data_source_id = p_data_source_id;
IF v_exists < 1 THEN
RAISE EXCEPTION 'Given data_source_id (%) does not exist in @extschema@.dblink_mapping_mimeo config table', p_data_source_id;
END IF;
END IF;
SELECT nspname INTO v_dblink_schema FROM pg_namespace n, pg_extension e WHERE e.extname = 'dblink' AND e.extnamespace = n.oid;
FOR v_row_dblink IN SELECT data_source_id FROM @extschema@.dblink_mapping_mimeo
LOOP
-- Allow a parameter to choose which data sources are checked. If parameter is NULL, check them all.
IF p_data_source_id IS NOT NULL THEN
IF p_data_source_id <> v_row_dblink.data_source_id THEN
CONTINUE;
END IF;
END IF;
EXECUTE 'SELECT '||v_dblink_schema||'.dblink_connect(''mimeo_missing'', @extschema@.auth('||v_row_dblink.data_source_id||'))';
CREATE TEMP TABLE current_source_tables_tmp (schemaname text, tablename text);
EXECUTE 'INSERT INTO current_source_tables_tmp SELECT schemaname, tablename FROM '||v_dblink_schema||'.dblink(''mimeo_missing'',
''SELECT schemaname, tablename AS tablename FROM pg_catalog.pg_tables WHERE schemaname NOT IN (''''pg_catalog'''', ''''information_schema'''', ''''@extschema@'''')'') t (schemaname text, tablename text)';
CREATE TEMP TABLE current_dest_tables_tmp AS
SELECT source_table FROM @extschema@.refresh_config_snap WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table FROM @extschema@.refresh_config_inserter WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table FROM @extschema@.refresh_config_updater WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table FROM @extschema@.refresh_config_dml WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table FROM @extschema@.refresh_config_logdel WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table FROM @extschema@.refresh_config_table WHERE dblink = v_row_dblink.data_source_id;
FOR v_row_missing IN
SELECT s.schemaname, s.tablename
FROM current_source_tables_tmp s
LEFT OUTER JOIN current_dest_tables_tmp d ON s.schemaname||'.'||s.tablename = d.source_table
WHERE d.source_table IS NULL
ORDER BY s.schemaname, s.tablename
LOOP
schemaname := v_row_missing.schemaname;
tablename := v_row_missing.tablename;
data_source = v_row_dblink.data_source_id;
RETURN NEXT;
END LOOP;
EXECUTE 'SELECT '||v_dblink_schema||'.dblink_disconnect(''mimeo_missing'')';
DROP TABLE IF EXISTS current_source_tables_tmp;
DROP TABLE IF EXISTS current_dest_tables_tmp;
END LOOP;
END
$$;
/*
* Check tables on data sources to see if columns have been added or types changed.
* Returns a record value so that a WHERE condition can be used to ignore tables that aren't desired.
* If p_data_source_id value is not given, all configured sources are checked.
*/
CREATE FUNCTION check_source_columns(p_data_source_id int DEFAULT NULL
, OUT dest_schemaname text
, OUT dest_tablename text
, OUT src_schemaname text
, OUT src_tablename text
, OUT missing_column_name text
, OUT missing_column_type text
, OUT data_source int) RETURNS SETOF record
LANGUAGE plpgsql
AS $$
DECLARE
v_dblink_schema text;
v_exists int;
v_row_dblink record;
v_row_table record;
v_row_col record;
BEGIN
IF p_data_source_id IS NOT NULL THEN
SELECT count(*) INTO v_exists FROM @extschema@.dblink_mapping_mimeo WHERE data_source_id = p_data_source_id;
IF v_exists < 1 THEN
RAISE EXCEPTION 'Given data_source_id (%) does not exist in @extschema@.dblink_mapping_mimeo config table', p_data_source_id;
END IF;
END IF;
SELECT nspname INTO v_dblink_schema FROM pg_namespace n, pg_extension e WHERE e.extname = 'dblink' AND e.extnamespace = n.oid;
FOR v_row_dblink IN SELECT data_source_id FROM @extschema@.dblink_mapping_mimeo
LOOP
-- Allow a parameter to choose which data sources are checked. If parameter is NULL, check them all.
IF p_data_source_id IS NOT NULL THEN
IF p_data_source_id <> v_row_dblink.data_source_id THEN
CONTINUE;
END IF;
END IF;
EXECUTE 'SELECT '||v_dblink_schema||'.dblink_connect(''mimeo_col_check'', @extschema@.auth('||v_row_dblink.data_source_id||'))';
FOR v_row_table IN
( SELECT source_table, dest_table, filter, type FROM @extschema@.refresh_config_snap WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table, dest_table, filter, type FROM @extschema@.refresh_config_inserter WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table, dest_table, filter, type FROM @extschema@.refresh_config_updater WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table, dest_table, filter, type FROM @extschema@.refresh_config_dml WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table, dest_table, filter, type FROM @extschema@.refresh_config_logdel WHERE dblink = v_row_dblink.data_source_id
UNION
SELECT source_table, dest_table, filter, type FROM @extschema@.refresh_config_table WHERE dblink = v_row_dblink.data_source_id )
ORDER BY 1,2
LOOP
FOR v_row_col IN
EXECUTE 'SELECT attname, atttypid, atttypmod, schemaname, tablename FROM '||v_dblink_schema||'.dblink(''mimeo_col_check'',
''SELECT a.attname::text, a.atttypid, a.atttypmod, n.nspname AS schemaname, c.relname AS tablename
FROM pg_attribute a
JOIN pg_class c ON c.oid = a.attrelid
JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE a.attrelid = '''''||v_row_table.source_table||'''''::regclass
AND a.attnum > 0
AND attisdropped = false
ORDER BY 1,2'') t (attname text, atttypid oid, atttypmod int, schemaname text, tablename text)'
LOOP
IF v_row_col.attname <> ANY (v_row_table.filter) THEN
CONTINUE;
END IF;
SELECT count(*) INTO v_exists
FROM pg_attribute
WHERE attrelid = v_row_table.dest_table::regclass
AND attnum > 0
AND attisdropped = false
AND attname = v_row_col.attname
AND atttypid = v_row_col.atttypid
AND atttypmod = v_row_col.atttypmod;
-- if column doesn't exist, means it's missing on destination.
IF v_exists < 1 THEN
IF v_row_table.type = 'snap' THEN
SELECT schemaname, viewname INTO dest_schemaname, dest_tablename FROM pg_catalog.pg_views WHERE schemaname||'.'||viewname = v_row_table.dest_table;
ELSE
SELECT schemaname, tablename INTO dest_schemaname, dest_tablename FROM pg_catalog.pg_tables WHERE schemaname||'.'||tablename = v_row_table.dest_table;
END IF;
src_schemaname := v_row_col.schemaname;
src_tablename := v_row_col.tablename;
missing_column_name := v_row_col.attname;
missing_column_type := format_type(v_row_col.atttypid, v_row_col.atttypmod)::text;
data_source := v_row_dblink.data_source_id;
RETURN NEXT;
END IF;
END LOOP; -- end v_row_col
END LOOP; -- end v_row_table
EXECUTE 'SELECT '||v_dblink_schema||'.dblink_disconnect(''mimeo_col_check'')';
END LOOP; -- end v_row_dblink
END
$$;
/*
* Create index(es) on destination table
*/
CREATE OR REPLACE FUNCTION create_index(p_destination text, p_snap text DEFAULT NULL, p_debug boolean DEFAULT false) RETURNS void
LANGUAGE plpgsql SECURITY DEFINER
AS $$
DECLARE
v_conf text;
v_dblink int;
v_dblink_name text;
v_dblink_schema text;
v_dest_table text;
v_dest_table_name text;
v_filter text;
v_link_exists boolean;
v_old_search_path text;
v_repl_index oid;
v_remote_index_sql text;
v_row record;
v_source_table text;
v_src_table_name text;
v_statement text;
v_type text;
BEGIN
v_dblink_name := @extschema@.check_name_length('create_index_dblink_'||p_destination);
SELECT nspname INTO v_dblink_schema FROM pg_namespace n, pg_extension e WHERE e.extname = 'dblink' AND e.extnamespace = n.oid;
SELECT current_setting('search_path') INTO v_old_search_path;
EXECUTE 'SELECT set_config(''search_path'',''@extschema@,'||v_dblink_schema||''',''false'')';
SELECT dest_table
, type
, dblink
, filter
INTO v_dest_table
, v_type
, v_dblink
, v_filter
FROM refresh_config
WHERE dest_table = p_destination;
IF NOT FOUND THEN
RAISE EXCEPTION 'ERROR: This table is not set up for replication: %', p_destination;
END IF;
EXECUTE 'SELECT source_table FROM refresh_config_'||v_type||' WHERE dest_table = '||quote_literal(v_dest_table) INTO v_source_table;
IF p_snap IS NOT NULL AND p_snap NOT IN ('snap1', 'snap2') THEN
RAISE EXCEPTION 'Invalid value for p_snap parameter given to create_index() function';
END IF;
PERFORM dblink_connect(v_dblink_name, @extschema@.auth(v_dblink));
-- Reset search_path on remote connection to ensure schema is included in table name in index creation statement
-- set_config returns a record value, so can't just use dblink_exec
SELECT set_config INTO v_conf FROM dblink(v_dblink_name, 'SELECT set_config(''search_path'', '''', false)::text') t (set_config text);
v_dest_table_name := split_part(v_dest_table, '.', 2);
SELECT tablename INTO v_src_table_name
FROM dblink(v_dblink_name, 'SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname ||''.''|| tablename = '||quote_literal(v_source_table)) t (tablename text);
-- Gets primary key or unique index used by updater/dml/logdel replication (same function is called in their makers).
-- Should only loop once, but just easier to keep code consistent with below method
FOR v_row IN SELECT indexrelid, key_type, indkey_names, statement FROM fetch_replication_key(v_source_table, v_dblink_name)
LOOP
EXIT WHEN v_row.indexrelid IS NULL; -- function still returns a row full of nulls when nothing found
IF v_row.key_type = 'primary' THEN
v_statement := 'ALTER TABLE '||v_dest_table || COALESCE('_'||p_snap, '')||' ADD CONSTRAINT '||
COALESCE(p_snap||'_', '')|| v_dest_table_name ||'_'||array_to_string(v_row.indkey_names, '_')||'_pk
PRIMARY KEY ('||array_to_string(v_row.indkey_names, ',')||')';
ELSIF v_row.key_type = 'unique' THEN
v_statement := v_row.statement;
-- Replace source table name with destination
v_statement := replace(v_statement, ' ON '||v_source_table, ' ON '||v_dest_table || COALESCE('_'||p_snap, ''));
-- If source index name contains the table name, replace it with the destination table.
v_statement := regexp_replace(v_statement, '(INDEX \w*)'||v_src_table_name||'(\w* ON)', '\1'||v_dest_table_name||'\2');
-- If it's a snap table, prepend to ensure unique index name.
-- This is done separately from above replace because it must always be done even if the index name doesn't contain the source table
IF p_snap IS NOT NULL THEN
v_statement := replace(v_statement, 'UNIQUE INDEX ' , 'UNIQUE INDEX '||p_snap||'_');
END IF;
END IF;
PERFORM gdb(p_debug, 'statement: ' || v_statement);
EXECUTE v_statement;
v_repl_index = v_row.indexrelid;
END LOOP;
-- Get all indexes other than one obtained above.
-- Cannot set these indexes when column filters are in use because there's no easy way to check columns in expression indexes.
IF v_filter IS NULL THEN
v_remote_index_sql := 'select c.relname AS src_table, pg_get_indexdef(i.indexrelid) as statement
FROM pg_catalog.pg_index i
JOIN pg_catalog.pg_class c ON i.indrelid = c.oid
WHERE i.indrelid = '||quote_literal(v_source_table)||'::regclass
AND i.indisprimary IS false
AND i.indisvalid';
IF v_repl_index IS NOT NULL THEN
v_remote_index_sql := v_remote_index_sql ||' AND i.indexrelid <> '||v_repl_index;
END IF;
FOR v_row IN EXECUTE 'SELECT src_table, statement FROM dblink('||quote_literal(v_dblink_name)||', '||quote_literal(v_remote_index_sql)||') t (src_table text, statement text)' LOOP
v_statement := v_row.statement;
-- Replace source table name with destination
v_statement := replace(v_statement, ' ON '||v_source_table, ' ON '||v_dest_table || COALESCE('_'||p_snap, ''));
-- If source index name contains the table name, replace it with the destination table.
v_statement := regexp_replace(v_statement, '(INDEX \w*)'||v_src_table_name||'(\w* ON)', '\1'||v_dest_table_name||'\2');
-- If it's a snap table, prepend to ensure unique index name.
-- This is done separately from above replace because it must always be done even if the index name doesn't contain the source table
IF p_snap IS NOT NULL THEN
v_statement := replace(v_statement, 'E INDEX ' , 'E INDEX '||p_snap||'_');
END IF;
PERFORM gdb(p_debug, 'statement: ' || v_statement);
EXECUTE v_statement;
END LOOP;
END IF;
PERFORM dblink_disconnect(v_dblink_name);
EXECUTE 'SELECT set_config(''search_path'','''||v_old_search_path||''',''false'')';
EXCEPTION
WHEN QUERY_CANCELED OR OTHERS THEN
EXECUTE 'SELECT '||v_dblink_schema||'.dblink_get_connections() @> ARRAY['||quote_literal(v_dblink_name)||']' INTO v_link_exists;
IF v_link_exists THEN
EXECUTE 'SELECT '||v_dblink_schema||'.dblink_disconnect('||quote_literal(v_dblink_name)||')';
END IF;
EXECUTE 'SELECT set_config(''search_path'','''||v_old_search_path||''',''false'')';
RAISE EXCEPTION '%', SQLERRM;
END
$$;
|
select oid, gp_segment_id, conname from pg_constraint where conrelid = 'pg_part_table_1_prt_2_2_prt_usa'::regclass and conname ~'usa';
select oid, gp_segment_id, conname from gp_dist_random('pg_constraint') where conrelid = 'pg_part_table_1_prt_2_2_prt_usa'::regclass and conname ~'usa';
|
<filename>dbmyapp.sql
-- --------------------------------------------------------
-- Host: 127.0.0.1
-- Server version: 10.4.6-MariaDB - mariadb.org binary distribution
-- Server OS: Win64
-- HeidiSQL Version: 10.2.0.5599
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- Dumping structure for table dbmyapp.tbuser
CREATE TABLE IF NOT EXISTS `tbuser` (
`cliduser` int(10) NOT NULL AUTO_INCREMENT,
`clname` varchar(50) NOT NULL DEFAULT '0',
`clemail` varchar(50) NOT NULL DEFAULT '0',
`cldate` varchar(50) NOT NULL DEFAULT '0',
PRIMARY KEY (`cliduser`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
-- Dumping data for table dbmyapp.tbuser: ~3 rows (approximately)
/*!40000 ALTER TABLE `tbuser` DISABLE KEYS */;
INSERT INTO `tbuser` (`cliduser`, `clname`, `clemail`, `cldate`) VALUES
(1, '<NAME>', '<EMAIL>', '09-Mar-2020'),
(2, '<NAME>', '<EMAIL>', '10-Mar-2020'),
(3, '<NAME>', '<EMAIL>', '10-Mar-2020'),
(4, '<NAME>', '<EMAIL>', '02-Mar-2020');
/*!40000 ALTER TABLE `tbuser` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: csv_with_lat_lon; Type: TABLE; Schema: public; Owner: development_cartodb_user_1; Tablespace:
--
CREATE TABLE csv_with_lat_lon (
mean_lateness text,
late_count text,
longitude text,
latitude text,
created_at timestamp without time zone DEFAULT now(),
updated_at timestamp without time zone DEFAULT now(),
the_geom geometry(Geometry,4326),
cartodb_id integer NOT NULL,
the_geom_webmercator geometry(Geometry,3857)
);
ALTER TABLE public.csv_with_lat_lon OWNER TO development_cartodb_user_1;
--
-- Name: csv_with_lat_lon_cartodb_id_seq; Type: SEQUENCE; Schema: public; Owner: development_cartodb_user_1
--
CREATE SEQUENCE csv_with_lat_lon_cartodb_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.csv_with_lat_lon_cartodb_id_seq OWNER TO development_cartodb_user_1;
--
-- Name: csv_with_lat_lon_cartodb_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: development_cartodb_user_1
--
ALTER SEQUENCE csv_with_lat_lon_cartodb_id_seq OWNED BY csv_with_lat_lon.cartodb_id;
--
-- Name: cartodb_id; Type: DEFAULT; Schema: public; Owner: development_cartodb_user_1
--
ALTER TABLE ONLY csv_with_lat_lon ALTER COLUMN cartodb_id SET DEFAULT nextval('csv_with_lat_lon_cartodb_id_seq'::regclass);
--
-- Data for Name: csv_with_lat_lon; Type: TABLE DATA; Schema: public; Owner: development_cartodb_user_1
--
COPY csv_with_lat_lon (mean_lateness, late_count, longitude, latitude, created_at, updated_at, the_geom, cartodb_id, the_geom_webmercator) FROM stdin;
0 0 16.5607329 48.1199611 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E61000008F4AFB308C8F304066A5A4E25A0F4840 1 0101000020110F000088F7845A4C213C41D232DCD53C5F5741
0 0 -75.96557 4.58971 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E6100000EBFF1CE6CBFD52C0247F30F0DC5B1240 2 0101000020110F0000A53F3F12202160C1F7A1BFEEBD371F41
0 0 7.6493752 45.1974684 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E61000007655FBCFF5981E4029FFFFA446994640 3 0101000020110F0000F57EB31A89FC2941631D6DA62D905541
0 0 -58.5363498 -34.8222787 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E6100000AB1B391CA7444DC04459AE6D406941C0 4 0101000020110F0000F4BCC42983DB58C1F41A18D775954FC1
0 0 -6.2443635 53.4269294 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E61000002A58E36C3AFA18C0B759619FA5B64A40 5 0101000020110F00003DB1F4BA9E3625C1E3EFE284D6F05A41
0 0 5.3810421 43.2976116 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E6100000BE9877E62F86154083740C2318A64540 6 0101000020110F0000E816A7BBCD4722415505D168D16F5441
0 0 2.0797638 41.300621 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E6100000CB3C03345BA30040D3BEB9BF7AA64440 7 0101000020110F00008ACD3CFAF1420C419EB9E734444A5341
0 0 -75.9976624 37.8250646 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E6100000BA1C65B3D9FF52C02D0B81B79BE94240 8 0101000020110F0000881B8EA2DE2260C12A2EA7ACFD5F5141
4.166666666666666 7 2.5711 49.004 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E6100000FDF675E09C9104408D976E1283804840 9 0101000020110F00003926CE2B167811410FFDCD0875F05741
0 0 30.808439 36.922395 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E61000009ACFB9DBF5CE3E40397F130A11764240 10 0101000020110F0000D042EDDE652A4A41FF1684CA81E45041
0 0 33.6112819 34.8703004 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E610000081913C7C3ECE40400DD9E500666F4140 11 0101000020110F0000F2359C64CB8B4C41FEBF76B62EA24F41
50 3 -43.3719988 -22.9869915 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E61000005C131CA89DAF45C013EE9579ABFC36C0 12 0101000020110F000062F18C34FD6A52C122B215C7961144C1
0 0 -84.208889 9.993611 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E6100000A0DFF76F5E0D55C047E4BB94BAFC2340 13 0101000020110F0000EE93995431E161C1302C3ECAD70F3141
6.779661016949152 4 11.7815595 48.3539793 2011-10-04 12:33:22.327 2011-10-04 12:33:29.332 0101000020E610000098C1189128902740017B96314F2D4840 14 0101000020110F000072644C341D0334416B4006EE6E855741
\.
--
-- Name: csv_with_lat_lon_cartodb_id_seq; Type: SEQUENCE SET; Schema: public; Owner: development_cartodb_user_1
--
SELECT pg_catalog.setval('csv_with_lat_lon_cartodb_id_seq', 156, false);
--
-- Name: csv_with_lat_lon_pkey; Type: CONSTRAINT; Schema: public; Owner: development_cartodb_user_1; Tablespace:
--
ALTER TABLE ONLY csv_with_lat_lon
ADD CONSTRAINT csv_with_lat_lon_pkey PRIMARY KEY (cartodb_id);
ALTER TABLE csv_with_lat_lon CLUSTER ON csv_with_lat_lon_pkey;
--
-- Name: csv_with_lat_lon_the_geom_idx; Type: INDEX; Schema: public; Owner: development_cartodb_user_1; Tablespace:
--
CREATE INDEX csv_with_lat_lon_the_geom_idx ON csv_with_lat_lon USING gist (the_geom);
--
-- Name: csv_with_lat_lon_the_geom_webmercator_idx; Type: INDEX; Schema: public; Owner: development_cartodb_user_1; Tablespace:
--
CREATE INDEX csv_with_lat_lon_the_geom_webmercator_idx ON csv_with_lat_lon USING gist (the_geom_webmercator);
--
-- Name: test_quota; Type: TRIGGER; Schema: public; Owner: development_cartodb_user_1
--
CREATE TRIGGER test_quota BEFORE INSERT OR UPDATE ON csv_with_lat_lon FOR EACH STATEMENT EXECUTE PROCEDURE cdb_checkquota('1', '104857600', 'public');
--
-- Name: test_quota_per_row; Type: TRIGGER; Schema: public; Owner: development_cartodb_user_1
--
CREATE TRIGGER test_quota_per_row BEFORE INSERT OR UPDATE ON csv_with_lat_lon FOR EACH ROW EXECUTE PROCEDURE cdb_checkquota('0.001', '104857600', 'public');
--
-- Name: track_updates; Type: TRIGGER; Schema: public; Owner: development_cartodb_user_1
--
CREATE TRIGGER track_updates AFTER INSERT OR DELETE OR UPDATE OR TRUNCATE ON csv_with_lat_lon FOR EACH STATEMENT EXECUTE PROCEDURE cdb_tablemetadata_trigger();
--
-- Name: update_the_geom_webmercator_trigger; Type: TRIGGER; Schema: public; Owner: development_cartodb_user_1
--
CREATE TRIGGER update_the_geom_webmercator_trigger BEFORE INSERT OR UPDATE OF the_geom ON csv_with_lat_lon FOR EACH ROW EXECUTE PROCEDURE update_the_geom_webmercator();
--
-- Name: update_updated_at_trigger; Type: TRIGGER; Schema: public; Owner: development_cartodb_user_1
--
CREATE TRIGGER update_updated_at_trigger BEFORE UPDATE ON csv_with_lat_lon FOR EACH ROW EXECUTE PROCEDURE update_updated_at();
--
-- Name: csv_with_lat_lon; Type: ACL; Schema: public; Owner: development_cartodb_user_1
--
REVOKE ALL ON TABLE csv_with_lat_lon FROM PUBLIC;
REVOKE ALL ON TABLE csv_with_lat_lon FROM development_cartodb_user_1;
GRANT ALL ON TABLE csv_with_lat_lon TO development_cartodb_user_1;
GRANT SELECT ON TABLE csv_with_lat_lon TO tileuser;
GRANT SELECT ON TABLE csv_with_lat_lon TO publicuser;
--
-- PostgreSQL database dump complete
--
|
-- @testpoint: opengauss关键字tstime非保留),作为索引名,部分测试点合理报错
--前置条件,创建一个表
drop table if exists explain_test;
create table explain_test(id int,name varchar(10));
--关键字不带引号-成功
drop index if exists tstime;
create index tstime on explain_test(id);
drop index tstime;
--关键字带双引号-成功
drop index if exists "tstime";
create index "tstime" on explain_test(id);
drop index "tstime";
--关键字带单引号-合理报错
drop index if exists 'tstime';
create index 'tstime' on explain_test(id);
--关键字带反引号-合理报错
drop index if exists `tstime`;
create index `tstime` on explain_test(id);
--清理环境
drop table if exists explain_test;
|
<filename>aryaEstructura.sql
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 14-10-2021 a las 15:37:13
-- Versión del servidor: 10.4.14-MariaDB
-- Versión de PHP: 7.4.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: `arya`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `academiclevels`
--
CREATE TABLE `academiclevels` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `accounts`
--
CREATE TABLE `accounts` (
`id` bigint(20) UNSIGNED NOT NULL,
`code_one` int(11) NOT NULL,
`code_two` int(11) NOT NULL,
`code_three` int(11) NOT NULL,
`code_four` int(11) NOT NULL,
`code_five` int(11) NOT NULL,
`period` int(11) NOT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
`level` int(11) NOT NULL,
`balance_previus` decimal(64,2) NOT NULL,
`rate` decimal(64,2) DEFAULT NULL,
`coin` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `account_historials`
--
CREATE TABLE `account_historials` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_account` bigint(20) UNSIGNED NOT NULL,
`date_begin` date NOT NULL,
`date_end` date NOT NULL,
`period` int(11) NOT NULL,
`balance_previous` decimal(64,2) NOT NULL,
`balance_current` decimal(64,2) NOT NULL,
`debe` decimal(64,2) NOT NULL,
`haber` decimal(64,2) NOT NULL,
`debe_coin` decimal(64,2) DEFAULT NULL,
`haber_coin` decimal(64,2) DEFAULT NULL,
`rate` decimal(64,2) DEFAULT NULL,
`coin` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `anticipos`
--
CREATE TABLE `anticipos` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_client` bigint(20) UNSIGNED DEFAULT NULL,
`id_provider` bigint(20) UNSIGNED DEFAULT NULL,
`id_account` bigint(20) UNSIGNED NOT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`id_quotation` bigint(20) UNSIGNED DEFAULT NULL,
`id_expense` bigint(20) UNSIGNED DEFAULT NULL,
`date` date NOT NULL,
`amount` decimal(64,2) NOT NULL,
`rate` decimal(64,2) NOT NULL,
`coin` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`reference` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `anticipo_quotations`
--
CREATE TABLE `anticipo_quotations` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_quotation` bigint(20) UNSIGNED NOT NULL,
`id_anticipo` bigint(20) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `branches`
--
CREATE TABLE `branches` (
`id` bigint(20) UNSIGNED NOT NULL,
`company_id` bigint(20) UNSIGNED NOT NULL,
`parroquia_id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`direction` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone2` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL,
`person_contact` varchar(160) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone_contact` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`observation` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `charge_orders`
--
CREATE TABLE `charge_orders` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_client` bigint(20) UNSIGNED DEFAULT NULL,
`id_provider` bigint(20) UNSIGNED DEFAULT NULL,
`id_branch` bigint(20) UNSIGNED DEFAULT NULL,
`id_user` bigint(20) UNSIGNED DEFAULT NULL,
`date` date NOT NULL,
`reference` varchar(60) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`amount` decimal(64,2) NOT NULL,
`rate` decimal(64,2) NOT NULL,
`coin` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `clients`
--
CREATE TABLE `clients` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_vendor` bigint(20) UNSIGNED DEFAULT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`type_code` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
`cedula_rif` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`direction` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`city` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`country` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone1` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone2` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`days_credit` int(11) NOT NULL,
`amount_max_credit` decimal(64,2) DEFAULT NULL,
`percentage_retencion_iva` decimal(64,2) DEFAULT NULL,
`percentage_retencion_islr` decimal(64,2) DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `colors`
--
CREATE TABLE `colors` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `comision_types`
--
CREATE TABLE `comision_types` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `companies`
--
CREATE TABLE `companies` (
`id` bigint(20) UNSIGNED NOT NULL,
`login` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`code_rif` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`razon_social` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`period` varchar(4) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`address` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL,
`franqueo_postal` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`tax_1` decimal(15,2) NOT NULL DEFAULT 0.00,
`tax_2` decimal(15,2) NOT NULL DEFAULT 0.00,
`tax_3` decimal(15,2) NOT NULL DEFAULT 0.00,
`retention_islr` decimal(15,2) NOT NULL DEFAULT 0.00,
`tipoinv_id` bigint(20) UNSIGNED NOT NULL,
`tiporate_id` bigint(20) UNSIGNED NOT NULL,
`rate` decimal(64,2) NOT NULL,
`rate_petro` decimal(64,2) NOT NULL,
`foto_company` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`pie_pagina` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `detail_vouchers`
--
CREATE TABLE `detail_vouchers` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_account` bigint(20) UNSIGNED NOT NULL,
`id_header_voucher` bigint(20) UNSIGNED DEFAULT NULL,
`id_invoice` bigint(20) UNSIGNED DEFAULT NULL,
`id_expense` bigint(20) UNSIGNED DEFAULT NULL,
`user_id` bigint(20) UNSIGNED NOT NULL,
`tasa` decimal(64,2) NOT NULL,
`debe` decimal(64,2) NOT NULL,
`haber` decimal(64,2) NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`date_end` date DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `employees`
--
CREATE TABLE `employees` (
`id` bigint(20) UNSIGNED NOT NULL,
`position_id` bigint(20) UNSIGNED NOT NULL,
`salary_types_id` bigint(20) UNSIGNED NOT NULL,
`profession_id` bigint(20) UNSIGNED NOT NULL,
`estado_id` bigint(20) UNSIGNED NOT NULL,
`municipio_id` bigint(20) UNSIGNED NOT NULL,
`parroquia_id` bigint(20) UNSIGNED NOT NULL,
`branch_id` bigint(20) UNSIGNED DEFAULT NULL,
`id_empleado` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`apellidos` varchar(160) COLLATE utf8mb4_unicode_ci NOT NULL,
`nombres` varchar(160) COLLATE utf8mb4_unicode_ci NOT NULL,
`fecha_ingreso` date NOT NULL,
`fecha_egreso` date DEFAULT NULL,
`fecha_nacimiento` date NOT NULL,
`direccion` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
`monto_pago` double(64,2) NOT NULL,
`email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`telefono1` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`acumulado_prestaciones` double(64,2) NOT NULL,
`acumulado_utilidades` double(64,2) NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`code_employee` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`amount_utilities` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `estados`
--
CREATE TABLE `estados` (
`id` bigint(20) UNSIGNED NOT NULL,
`descripcion` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `expenses_and_purchases`
--
CREATE TABLE `expenses_and_purchases` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_provider` bigint(20) UNSIGNED NOT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`id_islr_concept` bigint(20) UNSIGNED DEFAULT NULL,
`invoice` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`serie` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`observation` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`date` date NOT NULL,
`date_delivery_note` date DEFAULT NULL,
`date_payment` date DEFAULT NULL,
`retencion_iva` decimal(64,2) DEFAULT NULL,
`retencion_islr` decimal(64,2) DEFAULT NULL,
`anticipo` decimal(64,2) DEFAULT NULL,
`iva_percentage` int(11) DEFAULT NULL,
`credit_days` int(11) DEFAULT NULL,
`base_imponible` decimal(64,2) DEFAULT NULL,
`amount` decimal(64,2) DEFAULT NULL,
`amount_iva` decimal(64,2) DEFAULT NULL,
`amount_with_iva` decimal(64,2) DEFAULT NULL,
`coin` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`rate` decimal(64,2) DEFAULT NULL COMMENT 'Tasa',
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `expenses_details`
--
CREATE TABLE `expenses_details` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_expense` bigint(20) UNSIGNED NOT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`id_inventory` bigint(20) UNSIGNED DEFAULT NULL,
`id_account` bigint(20) UNSIGNED DEFAULT NULL,
`id_branch` bigint(20) UNSIGNED DEFAULT NULL,
`description` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`exento` tinyint(1) NOT NULL,
`islr` tinyint(1) NOT NULL,
`amount` decimal(64,2) NOT NULL,
`price` decimal(64,2) NOT NULL,
`rate` decimal(64,2) NOT NULL COMMENT 'Tasa',
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `expense_payments`
--
CREATE TABLE `expense_payments` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_expense` bigint(20) UNSIGNED DEFAULT NULL,
`id_account` bigint(20) UNSIGNED DEFAULT NULL,
`payment_type` int(11) NOT NULL,
`amount` decimal(64,2) NOT NULL,
`reference` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `failed_jobs`
--
CREATE TABLE `failed_jobs` (
`id` bigint(20) UNSIGNED NOT NULL,
`connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
`queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
`payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `general_nomina`
--
CREATE TABLE `general_nomina` (
`id` bigint(20) UNSIGNED NOT NULL,
`date_begin` date NOT NULL,
`date_end` date NOT NULL,
`tax_unit` decimal(8,2) NOT NULL,
`days_utilities_minimun` int(11) NOT NULL,
`days_utilities_maximun` int(11) NOT NULL,
`vacation_bonus_days` int(11) NOT NULL,
`sso` decimal(8,2) NOT NULL,
`faov` decimal(8,2) NOT NULL,
`pie` decimal(8,2) NOT NULL,
`sso_company` decimal(8,2) NOT NULL,
`faov_company` decimal(8,2) NOT NULL,
`pie_company` decimal(8,2) NOT NULL,
`days_benefits` int(11) NOT NULL,
`cestaticket` int(11) NOT NULL,
`cestaticket_amount` decimal(64,2) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `header_vouchers`
--
CREATE TABLE `header_vouchers` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_anticipo` bigint(20) UNSIGNED DEFAULT NULL,
`id_payment_order` bigint(20) UNSIGNED DEFAULT NULL,
`reference` varchar(60) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`description` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`date` date NOT NULL,
`centro_cos` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `historic_transports`
--
CREATE TABLE `historic_transports` (
`id` bigint(20) UNSIGNED NOT NULL,
`employee_id` bigint(20) UNSIGNED NOT NULL,
`transport_id` bigint(20) UNSIGNED NOT NULL,
`user_id` bigint(20) UNSIGNED NOT NULL,
`date_begin` date NOT NULL,
`date_end` date DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `index_bcvs`
--
CREATE TABLE `index_bcvs` (
`id` bigint(20) UNSIGNED NOT NULL,
`period` varchar(4) COLLATE utf8mb4_unicode_ci NOT NULL,
`month` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`rate` decimal(64,2) NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `inventary_types`
--
CREATE TABLE `inventary_types` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `inventories`
--
CREATE TABLE `inventories` (
`id` bigint(20) UNSIGNED NOT NULL,
`product_id` bigint(20) UNSIGNED NOT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`code` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`amount` int(11) NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `islr_concepts`
--
CREATE TABLE `islr_concepts` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
`value` decimal(5,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `modelos`
--
CREATE TABLE `modelos` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `multipayments`
--
CREATE TABLE `multipayments` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_quotation` bigint(20) UNSIGNED NOT NULL,
`id_header` bigint(20) UNSIGNED NOT NULL,
`id_payment` bigint(20) UNSIGNED NOT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `multipayment_expenses`
--
CREATE TABLE `multipayment_expenses` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_expense` bigint(20) UNSIGNED NOT NULL,
`id_header` bigint(20) UNSIGNED NOT NULL,
`id_payment` bigint(20) UNSIGNED NOT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `municipios`
--
CREATE TABLE `municipios` (
`id` bigint(20) UNSIGNED NOT NULL,
`descripcion` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`estado_id` bigint(20) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `nominas`
--
CREATE TABLE `nominas` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_profession` bigint(20) UNSIGNED NOT NULL,
`description` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`date_begin` date NOT NULL,
`date_end` date DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `nomina_calculations`
--
CREATE TABLE `nomina_calculations` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_nomina` bigint(20) UNSIGNED NOT NULL,
`id_nomina_concept` bigint(20) UNSIGNED NOT NULL,
`id_employee` bigint(20) UNSIGNED NOT NULL,
`number_receipt` int(11) NOT NULL,
`type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`amount` decimal(64,2) NOT NULL,
`hours` int(11) DEFAULT NULL,
`days` int(11) DEFAULT NULL,
`cantidad` decimal(64,2) DEFAULT NULL,
`voucher` int(11) DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `nomina_concepts`
--
CREATE TABLE `nomina_concepts` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_formula_q` bigint(20) UNSIGNED DEFAULT NULL,
`id_formula_m` bigint(20) UNSIGNED DEFAULT NULL,
`id_formula_s` bigint(20) UNSIGNED DEFAULT NULL,
`id_account_debe` bigint(20) UNSIGNED DEFAULT NULL,
`id_account_haber` bigint(20) UNSIGNED DEFAULT NULL,
`abbreviation` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`order` int(11) NOT NULL,
`description` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`sign` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`calculate` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`minimum` decimal(64,2) DEFAULT NULL,
`maximum` decimal(64,2) DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `nomina_formulas`
--
CREATE TABLE `nomina_formulas` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `nomina_types`
--
CREATE TABLE `nomina_types` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `parroquias`
--
CREATE TABLE `parroquias` (
`id` bigint(20) UNSIGNED NOT NULL,
`descripcion` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`municipio_id` bigint(20) UNSIGNED NOT NULL,
`estado_id` bigint(20) UNSIGNED NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `payment_orders`
--
CREATE TABLE `payment_orders` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_client` bigint(20) UNSIGNED DEFAULT NULL,
`id_provider` bigint(20) UNSIGNED DEFAULT NULL,
`id_branch` bigint(20) UNSIGNED DEFAULT NULL,
`id_user` bigint(20) UNSIGNED DEFAULT NULL,
`date` date NOT NULL,
`reference` varchar(60) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`amount` decimal(64,2) NOT NULL,
`rate` decimal(64,2) NOT NULL,
`coin` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `payment_types`
--
CREATE TABLE `payment_types` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`credit_days` int(11) NOT NULL,
`pide_ref` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`small_box` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`nature` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`point` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `positions`
--
CREATE TABLE `positions` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `products`
--
CREATE TABLE `products` (
`id` bigint(20) UNSIGNED NOT NULL,
`segment_id` bigint(20) UNSIGNED NOT NULL,
`subsegment_id` bigint(20) UNSIGNED DEFAULT NULL,
`twosubsegment_id` bigint(20) UNSIGNED DEFAULT NULL,
`threesubsegment_id` bigint(20) UNSIGNED DEFAULT NULL,
`unit_of_measure_id` bigint(20) UNSIGNED DEFAULT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`code_comercial` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`type` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`price` decimal(64,2) NOT NULL,
`price_buy` decimal(64,2) NOT NULL,
`cost_average` decimal(64,2) NOT NULL,
`photo_product` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`money` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL,
`exento` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`islr` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`special_impuesto` decimal(64,2) NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `professions`
--
CREATE TABLE `professions` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `providers`
--
CREATE TABLE `providers` (
`id` bigint(20) UNSIGNED NOT NULL,
`code_provider` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`razon_social` varchar(80) COLLATE utf8mb4_unicode_ci NOT NULL,
`direction` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`city` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
`country` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone1` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone2` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`has_credit` tinyint(1) NOT NULL,
`days_credit` int(11) NOT NULL,
`amount_max_credit` double(64,2) NOT NULL,
`porc_retencion_iva` double(5,2) NOT NULL,
`porc_retencion_islr` double(5,2) NOT NULL,
`balance` double(64,2) NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `quotations`
--
CREATE TABLE `quotations` (
`id` bigint(20) UNSIGNED NOT NULL,
`number_invoice` bigint(20) DEFAULT NULL,
`number_delivery_note` bigint(20) DEFAULT NULL,
`number_order` bigint(20) DEFAULT NULL,
`id_client` bigint(20) UNSIGNED NOT NULL,
`id_vendor` bigint(20) UNSIGNED DEFAULT NULL,
`id_transport` bigint(20) UNSIGNED DEFAULT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`serie` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`date_quotation` date NOT NULL,
`date_billing` date DEFAULT NULL,
`date_delivery_note` date DEFAULT NULL,
`date_order` date DEFAULT NULL,
`anticipo` decimal(64,2) DEFAULT NULL,
`iva_percentage` int(11) DEFAULT NULL,
`observation` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`note` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`credit_days` int(11) DEFAULT NULL,
`coin` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`bcv` decimal(64,2) DEFAULT NULL COMMENT 'Tasa de cambio a bolivares del banco central de venezuela',
`retencion_iva` decimal(64,2) DEFAULT NULL,
`retencion_islr` decimal(64,2) DEFAULT NULL,
`base_imponible` decimal(64,2) DEFAULT NULL,
`amount` decimal(64,2) DEFAULT NULL,
`amount_iva` decimal(64,2) DEFAULT NULL,
`amount_with_iva` decimal(64,2) DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `quotation_payments`
--
CREATE TABLE `quotation_payments` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_quotation` bigint(20) UNSIGNED DEFAULT NULL,
`id_account` bigint(20) UNSIGNED DEFAULT NULL,
`payment_type` int(11) NOT NULL,
`amount` decimal(64,2) NOT NULL,
`rate` decimal(64,2) NOT NULL,
`credit_days` int(11) DEFAULT NULL,
`reference` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `quotation_products`
--
CREATE TABLE `quotation_products` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_quotation` bigint(20) UNSIGNED NOT NULL,
`id_inventory` bigint(20) UNSIGNED NOT NULL,
`amount` int(11) NOT NULL,
`discount` decimal(64,2) NOT NULL,
`price` decimal(64,2) NOT NULL,
`rate` decimal(64,2) NOT NULL,
`retiene_iva` tinyint(1) NOT NULL,
`retiene_islr` tinyint(1) NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `rate_types`
--
CREATE TABLE `rate_types` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `receipt_vacations`
--
CREATE TABLE `receipt_vacations` (
`id` bigint(20) UNSIGNED NOT NULL,
`employee_id` bigint(20) UNSIGNED NOT NULL,
`date_begin` date NOT NULL,
`date_end` date NOT NULL,
`days_vacations` int(11) NOT NULL,
`bono_vacations` int(11) NOT NULL,
`days_feriados` int(11) NOT NULL,
`lph` decimal(64,2) NOT NULL,
`sso` decimal(64,2) NOT NULL,
`seguro_paro_forzoso` decimal(64,2) NOT NULL,
`ultimo_sueldo` decimal(64,2) NOT NULL,
`total_pagar` decimal(64,2) NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `roles`
--
CREATE TABLE `roles` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(2) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `salary_types`
--
CREATE TABLE `salary_types` (
`id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `segments`
--
CREATE TABLE `segments` (
`id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `subsegments`
--
CREATE TABLE `subsegments` (
`id` bigint(20) UNSIGNED NOT NULL,
`segment_id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `tasas`
--
CREATE TABLE `tasas` (
`id` bigint(20) UNSIGNED NOT NULL,
`id_user` bigint(20) UNSIGNED NOT NULL,
`date_begin` date NOT NULL,
`date_end` date DEFAULT NULL,
`amount` decimal(64,2) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `three_subsegments`
--
CREATE TABLE `three_subsegments` (
`id` bigint(20) UNSIGNED NOT NULL,
`twosubsegment_id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `transports`
--
CREATE TABLE `transports` (
`id` bigint(20) UNSIGNED NOT NULL,
`modelo_id` bigint(20) UNSIGNED NOT NULL,
`color_id` bigint(20) UNSIGNED NOT NULL,
`user_id` bigint(20) UNSIGNED NOT NULL,
`type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`placa` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`photo_transport` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `two_subsegments`
--
CREATE TABLE `two_subsegments` (
`id` bigint(20) UNSIGNED NOT NULL,
`subsegment_id` bigint(20) UNSIGNED NOT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `unit_of_measures`
--
CREATE TABLE `unit_of_measures` (
`id` bigint(20) UNSIGNED NOT NULL,
`code` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `users`
--
CREATE TABLE `users` (
`id` bigint(20) UNSIGNED NOT NULL,
`role_id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `vendors`
--
CREATE TABLE `vendors` (
`id` bigint(20) UNSIGNED NOT NULL,
`parroquia_id` bigint(20) UNSIGNED NOT NULL,
`comision_id` bigint(20) UNSIGNED NOT NULL,
`employee_id` bigint(20) UNSIGNED NOT NULL,
`user_id` bigint(20) UNSIGNED NOT NULL,
`code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`cedula_rif` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`surname` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone2` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`comision` decimal(64,2) NOT NULL,
`instagram` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`facebook` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`twitter` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`especification` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`observation` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(1) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `academiclevels`
--
ALTER TABLE `academiclevels`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `accounts`
--
ALTER TABLE `accounts`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `account_historials`
--
ALTER TABLE `account_historials`
ADD PRIMARY KEY (`id`),
ADD KEY `account_historials_id_account_foreign` (`id_account`);
--
-- Indices de la tabla `anticipos`
--
ALTER TABLE `anticipos`
ADD PRIMARY KEY (`id`),
ADD KEY `anticipos_id_client_foreign` (`id_client`),
ADD KEY `anticipos_id_provider_foreign` (`id_provider`),
ADD KEY `anticipos_id_account_foreign` (`id_account`),
ADD KEY `anticipos_id_user_foreign` (`id_user`),
ADD KEY `anticipos_id_quotation_foreign` (`id_quotation`),
ADD KEY `anticipos_id_expense_foreign` (`id_expense`);
--
-- Indices de la tabla `anticipo_quotations`
--
ALTER TABLE `anticipo_quotations`
ADD PRIMARY KEY (`id`),
ADD KEY `anticipo_quotations_id_anticipo_foreign` (`id_anticipo`),
ADD KEY `anticipo_quotations_id_quotation_foreign` (`id_quotation`);
--
-- Indices de la tabla `branches`
--
ALTER TABLE `branches`
ADD PRIMARY KEY (`id`),
ADD KEY `branches_company_id_foreign` (`company_id`),
ADD KEY `branches_parroquia_id_foreign` (`parroquia_id`);
--
-- Indices de la tabla `charge_orders`
--
ALTER TABLE `charge_orders`
ADD PRIMARY KEY (`id`),
ADD KEY `charge_orders_id_client_foreign` (`id_client`),
ADD KEY `charge_orders_id_provider_foreign` (`id_provider`),
ADD KEY `charge_orders_id_branch_foreign` (`id_branch`),
ADD KEY `charge_orders_id_user_foreign` (`id_user`);
--
-- Indices de la tabla `clients`
--
ALTER TABLE `clients`
ADD PRIMARY KEY (`id`),
ADD KEY `clients_id_vendor_foreign` (`id_vendor`),
ADD KEY `clients_id_user_foreign` (`id_user`);
--
-- Indices de la tabla `colors`
--
ALTER TABLE `colors`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `comision_types`
--
ALTER TABLE `comision_types`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `companies`
--
ALTER TABLE `companies`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `companies_login_unique` (`login`),
ADD UNIQUE KEY `companies_email_unique` (`email`),
ADD UNIQUE KEY `companies_razon_social_unique` (`razon_social`),
ADD KEY `companies_tipoinv_id_foreign` (`tipoinv_id`),
ADD KEY `companies_tiporate_id_foreign` (`tiporate_id`);
--
-- Indices de la tabla `detail_vouchers`
--
ALTER TABLE `detail_vouchers`
ADD PRIMARY KEY (`id`),
ADD KEY `detail_vouchers_id_account_foreign` (`id_account`),
ADD KEY `detail_vouchers_id_header_voucher_foreign` (`id_header_voucher`),
ADD KEY `detail_vouchers_id_invoice_foreign` (`id_invoice`),
ADD KEY `detail_vouchers_id_expense_foreign` (`id_expense`),
ADD KEY `detail_vouchers_user_id_foreign` (`user_id`);
--
-- Indices de la tabla `employees`
--
ALTER TABLE `employees`
ADD PRIMARY KEY (`id`),
ADD KEY `employees_parroquia_id_foreign` (`parroquia_id`),
ADD KEY `employees_municipio_id_foreign` (`municipio_id`),
ADD KEY `employees_estado_id_foreign` (`estado_id`),
ADD KEY `employees_profession_id_foreign` (`profession_id`),
ADD KEY `employees_salary_types_id_foreign` (`salary_types_id`),
ADD KEY `employees_position_id_foreign` (`position_id`),
ADD KEY `employees_branch_id_foreign` (`branch_id`);
--
-- Indices de la tabla `estados`
--
ALTER TABLE `estados`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `estados_descripcion_unique` (`descripcion`);
--
-- Indices de la tabla `expenses_and_purchases`
--
ALTER TABLE `expenses_and_purchases`
ADD PRIMARY KEY (`id`),
ADD KEY `expenses_and_purchases_id_provider_foreign` (`id_provider`),
ADD KEY `expenses_and_purchases_id_user_foreign` (`id_user`),
ADD KEY `expenses_and_purchases_id_islr_concept_foreign` (`id_islr_concept`);
--
-- Indices de la tabla `expenses_details`
--
ALTER TABLE `expenses_details`
ADD PRIMARY KEY (`id`),
ADD KEY `expenses_details_id_expense_foreign` (`id_expense`),
ADD KEY `expenses_details_id_inventory_foreign` (`id_inventory`),
ADD KEY `expenses_details_id_account_foreign` (`id_account`),
ADD KEY `expenses_details_id_user_foreign` (`id_user`),
ADD KEY `expenses_details_id_branch_foreign` (`id_branch`);
--
-- Indices de la tabla `expense_payments`
--
ALTER TABLE `expense_payments`
ADD PRIMARY KEY (`id`),
ADD KEY `expense_payments_id_expense_foreign` (`id_expense`),
ADD KEY `expense_payments_id_account_foreign` (`id_account`);
--
-- Indices de la tabla `failed_jobs`
--
ALTER TABLE `failed_jobs`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `general_nomina`
--
ALTER TABLE `general_nomina`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `header_vouchers`
--
ALTER TABLE `header_vouchers`
ADD PRIMARY KEY (`id`),
ADD KEY `header_vouchers_id_anticipo_foreign` (`id_anticipo`);
--
-- Indices de la tabla `historic_transports`
--
ALTER TABLE `historic_transports`
ADD PRIMARY KEY (`id`),
ADD KEY `historic_transports_employee_id_foreign` (`employee_id`),
ADD KEY `historic_transports_transport_id_foreign` (`transport_id`),
ADD KEY `historic_transports_user_id_foreign` (`user_id`);
--
-- Indices de la tabla `index_bcvs`
--
ALTER TABLE `index_bcvs`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `inventary_types`
--
ALTER TABLE `inventary_types`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `inventary_types_description_unique` (`description`);
--
-- Indices de la tabla `inventories`
--
ALTER TABLE `inventories`
ADD PRIMARY KEY (`id`),
ADD KEY `inventories_product_id_foreign` (`product_id`),
ADD KEY `inventories_id_user_foreign` (`id_user`);
--
-- Indices de la tabla `islr_concepts`
--
ALTER TABLE `islr_concepts`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `modelos`
--
ALTER TABLE `modelos`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `multipayments`
--
ALTER TABLE `multipayments`
ADD PRIMARY KEY (`id`),
ADD KEY `multipayments_id_user_foreign` (`id_user`),
ADD KEY `multipayments_id_payment_foreign` (`id_payment`),
ADD KEY `multipayments_id_header_foreign` (`id_header`),
ADD KEY `multipayments_id_quotation_foreign` (`id_quotation`);
--
-- Indices de la tabla `multipayment_expenses`
--
ALTER TABLE `multipayment_expenses`
ADD PRIMARY KEY (`id`),
ADD KEY `multipayment_expenses_id_user_foreign` (`id_user`),
ADD KEY `multipayment_expenses_id_payment_foreign` (`id_payment`),
ADD KEY `multipayment_expenses_id_header_foreign` (`id_header`),
ADD KEY `multipayment_expenses_id_expense_foreign` (`id_expense`);
--
-- Indices de la tabla `municipios`
--
ALTER TABLE `municipios`
ADD PRIMARY KEY (`id`),
ADD KEY `municipios_estado_id_foreign` (`estado_id`);
--
-- Indices de la tabla `nominas`
--
ALTER TABLE `nominas`
ADD PRIMARY KEY (`id`),
ADD KEY `nominas_id_profession_foreign` (`id_profession`);
--
-- Indices de la tabla `nomina_calculations`
--
ALTER TABLE `nomina_calculations`
ADD PRIMARY KEY (`id`),
ADD KEY `nomina_calculations_id_nomina_foreign` (`id_nomina`),
ADD KEY `nomina_calculations_id_nomina_concept_foreign` (`id_nomina_concept`),
ADD KEY `nomina_calculations_id_employee_foreign` (`id_employee`);
--
-- Indices de la tabla `nomina_concepts`
--
ALTER TABLE `nomina_concepts`
ADD PRIMARY KEY (`id`),
ADD KEY `nomina_concepts_id_formula_q_foreign` (`id_formula_q`),
ADD KEY `nomina_concepts_id_formula_m_foreign` (`id_formula_m`),
ADD KEY `nomina_concepts_id_formula_s_foreign` (`id_formula_s`),
ADD KEY `nomina_concepts_id_account_debe_foreign` (`id_account_debe`),
ADD KEY `nomina_concepts_id_account_haber_foreign` (`id_account_haber`);
--
-- Indices de la tabla `nomina_formulas`
--
ALTER TABLE `nomina_formulas`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `nomina_types`
--
ALTER TABLE `nomina_types`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `parroquias`
--
ALTER TABLE `parroquias`
ADD PRIMARY KEY (`id`),
ADD KEY `parroquias_estado_id_foreign` (`estado_id`),
ADD KEY `parroquias_municipio_id_foreign` (`municipio_id`);
--
-- Indices de la tabla `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`);
--
-- Indices de la tabla `payment_orders`
--
ALTER TABLE `payment_orders`
ADD PRIMARY KEY (`id`),
ADD KEY `payment_orders_id_client_foreign` (`id_client`),
ADD KEY `payment_orders_id_provider_foreign` (`id_provider`),
ADD KEY `payment_orders_id_branch_foreign` (`id_branch`),
ADD KEY `payment_orders_id_user_foreign` (`id_user`);
--
-- Indices de la tabla `payment_types`
--
ALTER TABLE `payment_types`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `positions`
--
ALTER TABLE `positions`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`id`),
ADD KEY `products_segment_id_foreign` (`segment_id`),
ADD KEY `products_subsegment_id_foreign` (`subsegment_id`),
ADD KEY `products_twosubsegment_id_foreign` (`twosubsegment_id`),
ADD KEY `products_threesubsegment_id_foreign` (`threesubsegment_id`),
ADD KEY `products_unit_of_measure_id_foreign` (`unit_of_measure_id`),
ADD KEY `products_id_user_foreign` (`id_user`);
--
-- Indices de la tabla `professions`
--
ALTER TABLE `professions`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `providers`
--
ALTER TABLE `providers`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `quotations`
--
ALTER TABLE `quotations`
ADD PRIMARY KEY (`id`),
ADD KEY `quotations_id_client_foreign` (`id_client`),
ADD KEY `quotations_id_vendor_foreign` (`id_vendor`),
ADD KEY `quotations_id_transport_foreign` (`id_transport`),
ADD KEY `quotations_id_user_foreign` (`id_user`);
--
-- Indices de la tabla `quotation_payments`
--
ALTER TABLE `quotation_payments`
ADD PRIMARY KEY (`id`),
ADD KEY `quotation_payments_id_quotation_foreign` (`id_quotation`),
ADD KEY `quotation_payments_id_account_foreign` (`id_account`);
--
-- Indices de la tabla `quotation_products`
--
ALTER TABLE `quotation_products`
ADD PRIMARY KEY (`id`),
ADD KEY `quotation_products_id_quotation_foreign` (`id_quotation`),
ADD KEY `quotation_products_id_inventory_foreign` (`id_inventory`);
--
-- Indices de la tabla `rate_types`
--
ALTER TABLE `rate_types`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `rate_types_description_unique` (`description`);
--
-- Indices de la tabla `receipt_vacations`
--
ALTER TABLE `receipt_vacations`
ADD PRIMARY KEY (`id`),
ADD KEY `receipt_vacations_employee_id_foreign` (`employee_id`);
--
-- Indices de la tabla `roles`
--
ALTER TABLE `roles`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `salary_types`
--
ALTER TABLE `salary_types`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `segments`
--
ALTER TABLE `segments`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `subsegments`
--
ALTER TABLE `subsegments`
ADD PRIMARY KEY (`id`),
ADD KEY `subsegments_segment_id_foreign` (`segment_id`);
--
-- Indices de la tabla `tasas`
--
ALTER TABLE `tasas`
ADD PRIMARY KEY (`id`),
ADD KEY `tasas_id_user_foreign` (`id_user`);
--
-- Indices de la tabla `three_subsegments`
--
ALTER TABLE `three_subsegments`
ADD PRIMARY KEY (`id`),
ADD KEY `three_subsegments_twosubsegment_id_foreign` (`twosubsegment_id`);
--
-- Indices de la tabla `transports`
--
ALTER TABLE `transports`
ADD PRIMARY KEY (`id`),
ADD KEY `transports_modelo_id_foreign` (`modelo_id`),
ADD KEY `transports_color_id_foreign` (`color_id`),
ADD KEY `transports_user_id_foreign` (`user_id`);
--
-- Indices de la tabla `two_subsegments`
--
ALTER TABLE `two_subsegments`
ADD PRIMARY KEY (`id`),
ADD KEY `two_subsegments_subsegment_id_foreign` (`subsegment_id`);
--
-- Indices de la tabla `unit_of_measures`
--
ALTER TABLE `unit_of_measures`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`),
ADD KEY `users_role_id_foreign` (`role_id`);
--
-- Indices de la tabla `vendors`
--
ALTER TABLE `vendors`
ADD PRIMARY KEY (`id`),
ADD KEY `vendors_parroquia_id_foreign` (`parroquia_id`),
ADD KEY `vendors_comision_id_foreign` (`comision_id`),
ADD KEY `vendors_employee_id_foreign` (`employee_id`),
ADD KEY `vendors_user_id_foreign` (`user_id`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `academiclevels`
--
ALTER TABLE `academiclevels`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `accounts`
--
ALTER TABLE `accounts`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `account_historials`
--
ALTER TABLE `account_historials`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `anticipos`
--
ALTER TABLE `anticipos`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `anticipo_quotations`
--
ALTER TABLE `anticipo_quotations`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `branches`
--
ALTER TABLE `branches`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `charge_orders`
--
ALTER TABLE `charge_orders`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `clients`
--
ALTER TABLE `clients`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `colors`
--
ALTER TABLE `colors`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `comision_types`
--
ALTER TABLE `comision_types`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `companies`
--
ALTER TABLE `companies`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `detail_vouchers`
--
ALTER TABLE `detail_vouchers`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `employees`
--
ALTER TABLE `employees`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `estados`
--
ALTER TABLE `estados`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `expenses_and_purchases`
--
ALTER TABLE `expenses_and_purchases`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `expenses_details`
--
ALTER TABLE `expenses_details`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `expense_payments`
--
ALTER TABLE `expense_payments`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `failed_jobs`
--
ALTER TABLE `failed_jobs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `general_nomina`
--
ALTER TABLE `general_nomina`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `header_vouchers`
--
ALTER TABLE `header_vouchers`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `historic_transports`
--
ALTER TABLE `historic_transports`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `index_bcvs`
--
ALTER TABLE `index_bcvs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `inventary_types`
--
ALTER TABLE `inventary_types`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `inventories`
--
ALTER TABLE `inventories`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `islr_concepts`
--
ALTER TABLE `islr_concepts`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `modelos`
--
ALTER TABLE `modelos`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `multipayments`
--
ALTER TABLE `multipayments`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `multipayment_expenses`
--
ALTER TABLE `multipayment_expenses`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `municipios`
--
ALTER TABLE `municipios`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `nominas`
--
ALTER TABLE `nominas`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `nomina_calculations`
--
ALTER TABLE `nomina_calculations`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `nomina_concepts`
--
ALTER TABLE `nomina_concepts`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `nomina_formulas`
--
ALTER TABLE `nomina_formulas`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `nomina_types`
--
ALTER TABLE `nomina_types`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `parroquias`
--
ALTER TABLE `parroquias`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `payment_orders`
--
ALTER TABLE `payment_orders`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `payment_types`
--
ALTER TABLE `payment_types`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `positions`
--
ALTER TABLE `positions`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `products`
--
ALTER TABLE `products`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `professions`
--
ALTER TABLE `professions`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `providers`
--
ALTER TABLE `providers`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `quotations`
--
ALTER TABLE `quotations`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `quotation_payments`
--
ALTER TABLE `quotation_payments`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `quotation_products`
--
ALTER TABLE `quotation_products`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `rate_types`
--
ALTER TABLE `rate_types`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `receipt_vacations`
--
ALTER TABLE `receipt_vacations`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `roles`
--
ALTER TABLE `roles`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `salary_types`
--
ALTER TABLE `salary_types`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `segments`
--
ALTER TABLE `segments`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `subsegments`
--
ALTER TABLE `subsegments`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `tasas`
--
ALTER TABLE `tasas`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `three_subsegments`
--
ALTER TABLE `three_subsegments`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `transports`
--
ALTER TABLE `transports`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `two_subsegments`
--
ALTER TABLE `two_subsegments`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `unit_of_measures`
--
ALTER TABLE `unit_of_measures`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT de la tabla `vendors`
--
ALTER TABLE `vendors`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- Restricciones para tablas volcadas
--
--
-- Filtros para la tabla `account_historials`
--
ALTER TABLE `account_historials`
ADD CONSTRAINT `account_historials_id_account_foreign` FOREIGN KEY (`id_account`) REFERENCES `accounts` (`id`);
--
-- Filtros para la tabla `anticipos`
--
ALTER TABLE `anticipos`
ADD CONSTRAINT `anticipos_id_account_foreign` FOREIGN KEY (`id_account`) REFERENCES `accounts` (`id`),
ADD CONSTRAINT `anticipos_id_client_foreign` FOREIGN KEY (`id_client`) REFERENCES `clients` (`id`),
ADD CONSTRAINT `anticipos_id_expense_foreign` FOREIGN KEY (`id_expense`) REFERENCES `expenses_and_purchases` (`id`),
ADD CONSTRAINT `anticipos_id_provider_foreign` FOREIGN KEY (`id_provider`) REFERENCES `providers` (`id`),
ADD CONSTRAINT `anticipos_id_quotation_foreign` FOREIGN KEY (`id_quotation`) REFERENCES `quotations` (`id`),
ADD CONSTRAINT `anticipos_id_user_foreign` FOREIGN KEY (`id_user`) REFERENCES `users` (`id`);
--
-- Filtros para la tabla `anticipo_quotations`
--
ALTER TABLE `anticipo_quotations`
ADD CONSTRAINT `anticipo_quotations_id_anticipo_foreign` FOREIGN KEY (`id_anticipo`) REFERENCES `anticipos` (`id`),
ADD CONSTRAINT `anticipo_quotations_id_quotation_foreign` FOREIGN KEY (`id_quotation`) REFERENCES `quotations` (`id`);
--
-- Filtros para la tabla `branches`
--
ALTER TABLE `branches`
ADD CONSTRAINT `branches_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`),
ADD CONSTRAINT `branches_parroquia_id_foreign` FOREIGN KEY (`parroquia_id`) REFERENCES `parroquias` (`id`);
--
-- Filtros para la tabla `charge_orders`
--
ALTER TABLE `charge_orders`
ADD CONSTRAINT `charge_orders_id_branch_foreign` FOREIGN KEY (`id_branch`) REFERENCES `branches` (`id`),
ADD CONSTRAINT `charge_orders_id_client_foreign` FOREIGN KEY (`id_client`) REFERENCES `clients` (`id`),
ADD CONSTRAINT `charge_orders_id_provider_foreign` FOREIGN KEY (`id_provider`) REFERENCES `providers` (`id`),
ADD CONSTRAINT `charge_orders_id_user_foreign` FOREIGN KEY (`id_user`) REFERENCES `users` (`id`);
--
-- Filtros para la tabla `clients`
--
ALTER TABLE `clients`
ADD CONSTRAINT `clients_id_user_foreign` FOREIGN KEY (`id_user`) REFERENCES `users` (`id`),
ADD CONSTRAINT `clients_id_vendor_foreign` FOREIGN KEY (`id_vendor`) REFERENCES `vendors` (`id`);
--
-- Filtros para la tabla `companies`
--
ALTER TABLE `companies`
ADD CONSTRAINT `companies_tipoinv_id_foreign` FOREIGN KEY (`tipoinv_id`) REFERENCES `inventary_types` (`id`),
ADD CONSTRAINT `companies_tiporate_id_foreign` FOREIGN KEY (`tiporate_id`) REFERENCES `rate_types` (`id`);
--
-- Filtros para la tabla `employees`
--
ALTER TABLE `employees`
ADD CONSTRAINT `employees_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`),
ADD CONSTRAINT `employees_estado_id_foreign` FOREIGN KEY (`estado_id`) REFERENCES `estados` (`id`),
ADD CONSTRAINT `employees_municipio_id_foreign` FOREIGN KEY (`municipio_id`) REFERENCES `municipios` (`id`),
ADD CONSTRAINT `employees_parroquia_id_foreign` FOREIGN KEY (`parroquia_id`) REFERENCES `parroquias` (`id`),
ADD CONSTRAINT `employees_position_id_foreign` FOREIGN KEY (`position_id`) REFERENCES `positions` (`id`),
ADD CONSTRAINT `employees_profession_id_foreign` FOREIGN KEY (`profession_id`) REFERENCES `professions` (`id`),
ADD CONSTRAINT `employees_salary_types_id_foreign` FOREIGN KEY (`salary_types_id`) REFERENCES `salary_types` (`id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
SELECT x, SUM(z) AS zs FROM t1 WHERE zs > 0 GROUP BY x
|
<filename>Banco de dados/testesolusoftpopulado.sql
-- MySQL dump 10.13 Distrib 5.7.23, for Linux (x86_64)
--
-- Host: localhost Database: testesolusoft
-- ------------------------------------------------------
-- Server version 5.7.23-0ubuntu0.18.04.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `clientes`
--
DROP TABLE IF EXISTS `clientes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `clientes` (
`cli_codigo` int(11) NOT NULL AUTO_INCREMENT,
`cli_nome` varchar(100) DEFAULT NULL,
`cli_cpf` varchar(14) DEFAULT NULL,
`cli_sexo` varchar(10) DEFAULT NULL,
`cli_email` varchar(100) DEFAULT NULL,
`cli_status` varchar(10) DEFAULT 'ativo',
PRIMARY KEY (`cli_codigo`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `clientes`
--
LOCK TABLES `clientes` WRITE;
/*!40000 ALTER TABLE `clientes` DISABLE KEYS */;
INSERT INTO `clientes` VALUES (23,'<NAME>','555.666.666-66','Masculino','<EMAIL>','ativo'),(24,'<NAME>','555.222.222-22','Masculino','<EMAIL>','ativo'),(25,'<NAME>','222.226.262-26','Feminino','<EMAIL>','ativo'),(26,'<NAME>','555.888.999-99','Feminino','<EMAIL>','ativo'),(27,'<NAME>','773.222.111-22','Masculino','<EMAIL>','ativo');
/*!40000 ALTER TABLE `clientes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `pedidos`
--
DROP TABLE IF EXISTS `pedidos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pedidos` (
`ped_codigo` int(11) NOT NULL AUTO_INCREMENT,
`ped_codigo_cliente` int(11) DEFAULT NULL,
`ped_codigo_vendedor` int(11) DEFAULT NULL,
`ped_data` date DEFAULT NULL,
`ped_observacao` varchar(200) DEFAULT NULL,
`ped_forma_pagamento` varchar(10) DEFAULT NULL,
PRIMARY KEY (`ped_codigo`),
KEY `ped_codigo_cliente` (`ped_codigo_cliente`),
KEY `ped_codigo_vendedor` (`ped_codigo_vendedor`),
CONSTRAINT `pedidos_ibfk_1` FOREIGN KEY (`ped_codigo_cliente`) REFERENCES `clientes` (`cli_codigo`),
CONSTRAINT `pedidos_ibfk_2` FOREIGN KEY (`ped_codigo_vendedor`) REFERENCES `vendedores` (`ven_codigo`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `pedidos`
--
LOCK TABLES `pedidos` WRITE;
/*!40000 ALTER TABLE `pedidos` DISABLE KEYS */;
INSERT INTO `pedidos` VALUES (19,23,30,'2019-02-10','Produtos devem ser enviados para o endereço do cliente.','Dinheiro'),(20,23,30,'2019-02-10','Produtos devem ser enviados para o endereço do cliente.','Cartão'),(21,24,31,'2019-02-10','Produtos devem ser enviados para o endereço do cliente.','Cheque'),(22,24,31,'2019-02-10','Produtos devem ser enviados para o endereço do cliente.','Cheque'),(23,25,32,'2019-02-10','Produtos devem ser enviados para o endereço do cliente.','Cartão'),(24,26,33,'2019-02-10','Produtos devem ser enviados para o endereço do cliente.','Cartão'),(25,27,31,'2019-02-10','Produtos devem ser enviados para o endereço do cliente.','Cheque'),(26,25,33,'2018-09-14','Produtos devem ser enviados para o endereço do cliente.','Dinheiro'),(27,26,31,'2018-11-15','Produtos devem ser enviados para o endereço do cliente.','Cartão'),(28,24,33,'2019-01-10','Produtos devem ser enviados para o endereço do cliente.','Dinheiro'),(29,25,34,'2018-10-18','O pedido deve ser enviado para o endereço do cliente','Dinheiro');
/*!40000 ALTER TABLE `pedidos` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `produtos`
--
DROP TABLE IF EXISTS `produtos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `produtos` (
`pro_codigo` int(11) NOT NULL AUTO_INCREMENT,
`pro_nome` varchar(200) DEFAULT NULL,
`pro_cor` varchar(50) DEFAULT NULL,
`pro_tamanho` varchar(10) DEFAULT NULL,
`pro_valor` float DEFAULT NULL,
`pro_status` varchar(10) DEFAULT 'ativo',
PRIMARY KEY (`pro_codigo`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `produtos`
--
LOCK TABLES `produtos` WRITE;
/*!40000 ALTER TABLE `produtos` DISABLE KEYS */;
INSERT INTO `produtos` VALUES (5,'Teclado','Preto','Pequeno',200.99,'ativo'),(6,'Mouse','Preto','Pequeno',150.5,'ativo'),(7,'Monitor Full HD','Preto','Médio',635.99,'ativo'),(8,'Mesa para computador','Marrom','Grande',230.33,'ativo'),(9,'Estabilizador 500','Azul','Pequeno',160.67,'ativo');
/*!40000 ALTER TABLE `produtos` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `produtos_pedido`
--
DROP TABLE IF EXISTS `produtos_pedido`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `produtos_pedido` (
`pro_ped_codigo` int(11) NOT NULL AUTO_INCREMENT,
`pro_ped_codigo_pedido` int(11) DEFAULT NULL,
`pro_ped_codigo_produto` int(11) DEFAULT NULL,
PRIMARY KEY (`pro_ped_codigo`),
KEY `pro_ped_codigo_pedido` (`pro_ped_codigo_pedido`),
KEY `pro_ped_codigo_produto` (`pro_ped_codigo_produto`),
CONSTRAINT `produtos_pedido_ibfk_1` FOREIGN KEY (`pro_ped_codigo_pedido`) REFERENCES `pedidos` (`ped_codigo`),
CONSTRAINT `produtos_pedido_ibfk_2` FOREIGN KEY (`pro_ped_codigo_produto`) REFERENCES `produtos` (`pro_codigo`)
) ENGINE=InnoDB AUTO_INCREMENT=179 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `produtos_pedido`
--
LOCK TABLES `produtos_pedido` WRITE;
/*!40000 ALTER TABLE `produtos_pedido` DISABLE KEYS */;
INSERT INTO `produtos_pedido` VALUES (151,19,5),(152,19,6),(153,19,8),(154,20,8),(155,20,7),(156,20,9),(157,21,8),(158,21,6),(159,22,5),(160,22,9),(161,22,9),(162,23,5),(163,23,8),(164,24,5),(165,24,9),(166,24,5),(167,25,5),(168,25,8),(169,26,6),(170,26,8),(171,27,5),(172,27,8),(173,28,7),(174,28,6),(175,28,6),(176,29,5),(177,29,5),(178,29,8);
/*!40000 ALTER TABLE `produtos_pedido` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vendedores`
--
DROP TABLE IF EXISTS `vendedores`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `vendedores` (
`ven_codigo` int(11) NOT NULL AUTO_INCREMENT,
`ven_nome` varchar(100) DEFAULT NULL,
`ven_nascimento` date DEFAULT NULL,
`ven_comissao` float DEFAULT NULL,
`ven_status` varchar(10) DEFAULT 'ativo',
PRIMARY KEY (`ven_codigo`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `vendedores`
--
LOCK TABLES `vendedores` WRITE;
/*!40000 ALTER TABLE `vendedores` DISABLE KEYS */;
INSERT INTO `vendedores` VALUES (30,'<NAME>','2000-10-10',20,'ativo'),(31,'<NAME>','2000-05-05',25,'ativo'),(32,'<NAME>','2000-03-03',50,'ativo'),(33,'<NAME>','2000-02-02',25,'ativo'),(34,'<NAME>','2000-08-08',35,'ativo');
/*!40000 ALTER TABLE `vendedores` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-02-10 13:57:47
|
<reponame>Doarakko/otoko-banzuke<gh_stars>0
CREATE TABLE channels
(
channel_id text NOT NULL,
name text NOT NULL,
description text NOT NULL,
thumbnail_url text NOT NULL,
view_count int DEFAULT 0 NOT NULL,
video_count int DEFAULT 0 NOT NULL,
subscriber_count int DEFAULT 0 NOT NULL,
created_at TIMESTAMP DEFAULT now() NOT NULL,
updated_at TIMESTAMP DEFAULT now() NOT NULL,
PRIMARY KEY (channel_id)
);
-- ALTER TABLE channels DROP COLUMN playlist_id;
ALTER TABLE channels ALTER COLUMN view_count TYPE
bigint;
|
-- phpMyAdmin SQL Dump
-- version 4.2.3
-- http://www.phpmyadmin.net
--
-- Хост: localhost:3306
-- Время создания: Фев 27 2016 г., 14:59
-- Версия сервера: 5.5.34
-- Версия PHP: 5.5.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- База данных: `urlshortener_db`
--
CREATE DATABASE IF NOT EXISTS `urlshortener_db` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `urlshortener_db`;
-- --------------------------------------------------------
--
-- Структура таблицы `urls`
--
CREATE TABLE `urls` (
`id` bigint(20) NOT NULL,
`url_long` text NOT NULL,
`url_short` varchar(10) NOT NULL,
`created_at` datetime NOT NULL,
`counter` int(11) DEFAULT NULL,
`deleted_at` DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- Дамп данных таблицы `urls`
--
INSERT INTO `urls` (`id`, `url_long`, `url_short`, `created_at`, `counter`) VALUES
(1, 'http://google.ru', 'IQkt3usH', '2016-02-27 14:46:40', 0),
(2, 'http://google.com', 'behruz', '2016-02-27 14:56:59', 0);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `urls`
--
ALTER TABLE `urls`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `url_short` (`url_short`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `urls`
--
ALTER TABLE `urls`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
|
<reponame>ilyavovnenko/shops_categories_ms<gh_stars>0
-- +migrate Up
-- SQL in section 'Up' is executed when this migration is applied
CREATE TABLE attributes (
id bigint unsigned auto_increment primary key,
category_id bigint unsigned not null,
type enum ('string', 'text', 'integer' , 'float', 'boolean') not null,
level enum ('product', 'variation') null,
active tinyint default 1 not null,
mandatory tinyint default 0 not null,
multivalue tinyint default 0 not null,
priority tinyint null,
tech_name varchar(255) not null,
name varchar(255) not null,
default_value varchar(255) null,
validation json null,
created_at timestamp default NOW() not null,
updated_at timestamp default NOW() not null,
FOREIGN KEY (category_id) REFERENCES categories(id),
UNIQUE KEY (category_id,tech_name)
)
collate = utf8mb4_unicode_ci;
-- todo: add foreifn key for shop_id
create index idxName on attributes (name);
-- +migrate Down
-- SQL section 'Down' is executed when this migration is rolled back
DROP TABLE attributes;
|
<reponame>premieregaming/ignyte-ux-sandbox
DROP TABLE IF EXISTS public.post_likes;
CREATE TABLE public.post_likes (
post_id uuid not null,
user_id uuid not null
);
|
-- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Nov 03, 2019 at 06:56 AM
-- Server version: 5.7.26
-- PHP Version: 7.3.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `db_card`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_bio`
--
CREATE TABLE `tbl_bio` (
`ID` tinyint(4) NOT NULL,
`animeID` tinyint(4) DEFAULT NULL,
`Genres` varchar(200) DEFAULT NULL,
`Aired` varchar(60) DEFAULT NULL,
`Series` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `tbl_bio`
--
INSERT INTO `tbl_bio` (`ID`, `animeID`, `Genres`, `Aired`, `Series`) VALUES
(1, 1, 'Slice of Life, Comedy, Music, School', 'April 3, 2009', 'Season1, Season2, film'),
(2, 2, 'Action, Military, Mystery, Super Power, Drama, Fantasy, Shounen', 'Apr 7, 2013', 'Season1-3'),
(3, 3, 'Action, Sci-Fi, Mecha', 'Oct 4, 1995', '1 TV series, 3 films');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tbl_bio`
--
ALTER TABLE `tbl_bio`
ADD PRIMARY KEY (`ID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tbl_bio`
--
ALTER TABLE `tbl_bio`
MODIFY `ID` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
-- phpMyAdmin SQL Dump
-- version phpStudy 2014
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2015 年 01 月 24 日 17:14
-- 服务器版本: 5.5.40
-- PHP 版本: 5.3.29
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- 数据库: `wifitest`
--
-- --------------------------------------------------------
--
-- 表的结构 `wifi_access`
--
CREATE TABLE IF NOT EXISTS `wifi_access` (
`role_id` smallint(6) unsigned NOT NULL,
`node_id` smallint(6) unsigned NOT NULL,
`level` tinyint(1) NOT NULL,
`module` varchar(50) DEFAULT NULL,
KEY `groupId` (`role_id`),
KEY `nodeId` (`node_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_ad`
--
CREATE TABLE IF NOT EXISTS `wifi_ad` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) DEFAULT NULL COMMENT '上传作者ID',
`ad_pos` tinyint(4) NOT NULL DEFAULT '0' COMMENT '广告位置 0首页 ',
`ad_thumb` varchar(50) DEFAULT NULL COMMENT '广告缩略图',
`ad_sort` int(11) DEFAULT NULL COMMENT '广告排序',
`title` varchar(255) DEFAULT NULL,
`info` text,
`mode` tinyint(4) DEFAULT '0' COMMENT '0:图片 1 图文 2 链接',
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`state` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='广告表' AUTO_INCREMENT=17 ;
--
-- 转存表中的数据 `wifi_ad`
--
INSERT INTO `wifi_ad` (`id`, `uid`, `ad_pos`, `ad_thumb`, `ad_sort`, `title`, `info`, `mode`, `add_time`, `update_time`, `state`) VALUES
(6, 1, 0, '/upload/AD/541955786f847.jpg', 0, 'ropple智慧无线路由', '<p>\r\n <span style="color:#939393;font-family:''Microsoft Yahei'';font-size:16px;line-height:25px;background-color:#FFFFFF;"> </span> \r\n</p>\r\n<h3 style="font-size:24px;font-family:''Microsoft Yahei'';color:#24A0DC;background-color:#FFFFFF;">\r\n WiFi营销,亿万自媒体市场\r\n</h3>\r\n <span style="background-color:#FFFFFF;color:#939393;font-family:''Microsoft Yahei'';font-size:16px;line-height:25px;">支持包括微信、手机短信等多种认证方式,用户无需频繁询问复杂的WiFi密码,减少询问人力成本。用户通过认证时,自动成为你社交平台的粉丝。配合WiFi网站解决方案,实现精准广告投放、智能客户信息管理、自动品牌展示等功能。轻松将路人变成你的客户。</span> \r\n<p>\r\n <br />\r\n</p>\r\n<p>\r\n <span style="color:#939393;font-family:''Microsoft Yahei'';font-size:16px;line-height:25px;background-color:#FFFFFF;"> </span> \r\n</p>\r\n<h3 style="font-size:24px;font-family:''Microsoft Yahei'';color:#24A0DC;background-color:#FFFFFF;">\r\n 简单操作,展现广告\r\n</h3>\r\n<p style="color:#939393;font-family:''Microsoft Yahei'';font-size:16px;background-color:#FFFFFF;">\r\n 用户无需注册,即可方便享受商家提供的WiFi服务。无需频繁询问复杂的WiFi密码,减少人力成本。商家可配合WiFi网站解决方案,实现精准广告投放、智能客户信息管理、自动品牌展示等功能。轻松将路人变成您的客户,同时大幅度减少广告投入成本,为您带来更多的收益。\r\n</p>\r\n<h3 style="font-size:24px;font-family:''Microsoft Yahei'';color:#24A0DC;background-color:#FFFFFF;">\r\n 全行业方案支持\r\n</h3>\r\n<p style="color:#939393;font-family:''Microsoft Yahei'';font-size:16px;background-color:#FFFFFF;">\r\n “WIFI认证”适用于酒店、餐饮、娱乐休闲、展会、商场等场所,有客户的地方就可以使用“WIFI认证”,不论是推送广告还是展示商家主页,仅需一台Ropple云路由,便可对顾客进行精准营销!\r\n</p>\r\n<br />\r\n<p>\r\n <br />\r\n</p>', 1, '1410628352', '1410946424', 1),
(7, 1, 0, '/upload/AD/54c35fa9d964e.jpg', 1, '微信拍立得微信打印机', '<h3>\r\n 疯狂增加粉丝、低成本开发新客户\r\n 高效传播品牌、打造可持续后期营销\r\n</h3>\r\n<h3>\r\n <span style="line-height:1.5;font-size:16px;font-weight:normal;"><strong>什么是微信拍立得?</strong></span> \r\n</h3>\r\n<div style="margin:30px 0px 0px;padding:0px 60px 0px 0px;" class="lomo_introduce_describe">\r\n <p>\r\n 微信拍立得是帮助商家做好微信营销的创新型产品。\r\n </p>\r\n <p>\r\n 通过微信照片打印这一广受年轻人追捧的功能,快速帮助商家增加公众微信的粉丝。\r\n </p>\r\n</div>\r\n<p>\r\n 商家可以通过系统的营销方案达到持久营销的效果。\r\n</p>\r\n<p>\r\n <span style="line-height:1.5;"><br />\r\n</span> \r\n</p>\r\n<p>\r\n <span style="line-height:1.5;font-size:16px;"><strong>微信拍立得增粉原理</strong></span> \r\n</p>\r\n<p>\r\n <br />\r\n</p>\r\n<div style="margin:30px 0px 0px;padding:0px;" class="lomo_introduce_2_describe">\r\n <p>\r\n 要知道微信拍立得增粉原理,就要知道其打印照片步骤:\r\n </p>\r\n <p>\r\n 第一步:关注商家微信公众账号<br />\r\n第二步:发送想要打印的照片给商家公众号<br />\r\n第三步:发送验证码,打印照片\r\n </p>\r\n <p>\r\n 所以,如果用户想打印照片,他就会很自然的成为您的微信公众账号的粉丝了!\r\n </p>\r\n</div>\r\n<p>\r\n <br />\r\n</p>\r\n<p>\r\n <br />\r\n</p>\r\n<p>\r\n 核心价值1:低成本、疯狂增加粉丝\r\n</p>\r\n<p>\r\n <span style="line-height:1.5;"><br />\r\n</span> \r\n</p>\r\n<p>\r\n <span style="line-height:1.5;">通过微信传图,打印出自己喜欢的照片是一件非常酷,微信照片打印同时也是一件非常有意义的事情。</span> \r\n</p>\r\n<p>\r\n <span style="line-height:1.5;">现在的年轻人追求时尚,好玩。微信拍立得正是这样的产品,可以简单的吸引年轻时尚,高消费能力的用户。</span><span style="line-height:1.5;">根据现有运营数据,每台微信拍立得平均每天能为网站、企业带来80~500个微信粉丝,100~1000条互动信息,100~800张LOMO卡制作量。</span> \r\n</p>\r\n<p>\r\n <span style="line-height:1.5;"><br />\r\n</span> \r\n</p>\r\n<p>\r\n <span style="line-height:1.5;"> </span> \r\n</p>\r\n<p>\r\n 核心价值2:病毒式传播品牌\r\n</p>\r\n<p>\r\n <br />\r\n</p>\r\n<p>\r\n <span style="line-height:1.5;">微信拍立得</span><span style="line-height:1.5;">微信打印机</span><span style="line-height:1.5;">的界面可以设置商家视频或图片广告,在制作LOMO照片的过程中,商家的品牌得以友好的传播。</span><span style="line-height:1.5;">并且制作的每张LOMO卡上,均有由企业自行设置的LOGO及企业的公众微信二维码,便于品牌二次传播。</span><span style="line-height:1.5;">用户在同好友分享的过程中,您的品牌得以病毒式的传播。</span><span style="line-height:1.5;">微信拍立得</span><span style="line-height:1.5;">微信打印机</span><span style="line-height:1.5;">,您提升品牌价值的不二之选!</span> \r\n</p>\r\n<div style="margin:0px;padding:0px;" class="lomo_value_tittle">\r\n 核心价值3: 可持续的后期营销\r\n</div>\r\n<div style="margin:30px 0px 0px;padding:0px;" class="lomo_value_3_describe">\r\n <p>\r\n 我们都知道,获取一位新客户的成本是相当高的。而通过微信拍立得微信打印机,我们却只需要0.18元。\r\n </p>\r\n <p>\r\n 有了这些粉丝,我们就有了一个客户数据库,通过一些营销方案,我们可以轻松的和这些潜在用户互动。\r\n </p>\r\n <p>\r\n 时机成熟的时候,我们提出成交主张就会得到响应。这是微信拍立得最具价值的地方。\r\n </p>\r\n</div>\r\n<p>\r\n <br />\r\n</p>\r\n<p>\r\n <br />\r\n</p>', 1, '1410628630', '1422090153', 1),
(8, 1, 0, '/upload/AD/54147cbff2431.jpg', 4, '智慧无线生活', '<p>\r\n 智慧无线生活\r\n</p>\r\n<p>\r\n 智慧无线生活\r\n</p>\r\n<p>\r\n <span style="color:#009900;">智慧无线生活</span>\r\n</p>\r\n<p>\r\n <span style="color:#009900;">智慧无线生活</span>\r\n</p>\r\n<p>\r\n <span style="color:#009900;"></span>\r\n</p>', 1, '1410628800', '1410662608', 1),
(10, 5, 0, '/upload/AD/5419a33a259d7.jpg', 0, 'sdf', 'sdaf', 1, '1410966330', '1413248022', 1),
(11, 5, 0, '/upload/AD/5419a344defa1.jpg', 0, '123', '123', 1, '1410966340', '1413248027', 1),
(12, 8, 0, '/upload/AD/5437ce14ec67f.jpg', 0, '', '', 0, '1412943380', '1412943380', 1),
(13, 9, 0, '/upload/AD/543c76f4bd28d.jpg', 0, 'x', 'xx', 1, '1413248756', '1413248756', 1),
(14, 1, 0, '/upload/AD/54c35fbb71643.jpg', 0, '34', '34', 0, '1422090172', '1422090172', 1),
(15, 1, 0, '/upload/AD/54c35fcb9448f.png', 0, '454', '45454', 0, '1422090188', '1422090188', 1),
(16, 1, 0, '/upload/AD/54c35fdfa71eb.jpg', 0, '343', '343', 0, '1422090208', '1422090208', 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_adcount`
--
CREATE TABLE IF NOT EXISTS `wifi_adcount` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopid` int(11) DEFAULT NULL,
`aid` int(11) DEFAULT NULL COMMENT '广告ID',
`showup` int(11) DEFAULT NULL,
`hit` int(11) DEFAULT NULL,
`add_time` varchar(20) DEFAULT NULL,
`add_date` varchar(20) DEFAULT NULL,
`mode` tinyint(4) DEFAULT NULL COMMENT '类型 1 商户广告统计 99 运营商投放广告 ',
`agent` varchar(100) DEFAULT NULL,
`ip` varchar(16) DEFAULT NULL,
`browser` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6834 ;
--
-- 转存表中的数据 `wifi_adcount`
--
INSERT INTO `wifi_adcount` (`id`, `shopid`, `aid`, `showup`, `hit`, `add_time`, `add_date`, `mode`, `agent`, `ip`, `browser`) VALUES
(1494, 1, 20, 1, 0, '1410952948', '2014-09-17', 50, '1', NULL, NULL),
(1495, 1, 19, 1, 0, '1410952948', '2014-09-17', 50, '1', NULL, NULL);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_admin`
--
CREATE TABLE IF NOT EXISTS `wifi_admin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`role` int(11) DEFAULT '0',
`note` varchar(255) DEFAULT NULL,
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1' COMMENT '0:停用 1 正常',
`last_loginip` varchar(255) DEFAULT NULL,
`last_logintime` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- 转存表中的数据 `wifi_admin`
--
INSERT INTO `wifi_admin` (`id`, `user`, `password`, `role`, `note`, `add_time`, `update_time`, `state`, `last_loginip`, `last_logintime`) VALUES
(1, 'admin', '<PASSWORD>56e057f20f883e', 0, NULL, '1389750196', '1409202810', 1, '0.0.0.0', '1422090662');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_agent`
--
CREATE TABLE IF NOT EXISTS `wifi_agent` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`account` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`linker` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`info` text,
`money` decimal(11,2) DEFAULT '0.00' COMMENT '金额',
`fee` decimal(11,2) DEFAULT '0.00' COMMENT '代理费',
`level` int(11) DEFAULT NULL COMMENT '等级',
`province` varchar(255) DEFAULT NULL,
`city` varchar(255) DEFAULT NULL,
`area` varchar(255) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
`point_x` varchar(255) DEFAULT NULL,
`point_y` varchar(255) DEFAULT NULL,
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1' COMMENT '0:停用 1:启用',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- 转存表中的数据 `wifi_agent`
--
INSERT INTO `wifi_agent` (`id`, `account`, `password`, `linker`, `phone`, `name`, `info`, `money`, `fee`, `level`, `province`, `city`, `area`, `address`, `point_x`, `point_y`, `add_time`, `update_time`, `state`) VALUES
(1, 'admin', '<PASSWORD>3949ba59abbe56e057f20f883e', '张先生', '18633021234', '高级代理', NULL, '18000.00', '20000.00', 1, '北京市', '市辖区', '东城区', '', NULL, NULL, '1409139480', '1409139480', 1),
(2, 'admin2', 'e10adc3949ba59abbe56e057f20f883e', 'sdaf', '13412345678', '1234', NULL, '500.00', '23333.00', 1, '北京市', '市辖区', '东城区', '', NULL, NULL, '1413248444', '1413248444', 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_agentlevel`
--
CREATE TABLE IF NOT EXISTS `wifi_agentlevel` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`note` varchar(255) DEFAULT NULL,
`openpay` decimal(10,2) DEFAULT '0.00' COMMENT '开户金额',
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- 转存表中的数据 `wifi_agentlevel`
--
INSERT INTO `wifi_agentlevel` (`id`, `title`, `note`, `openpay`, `add_time`, `update_time`, `state`) VALUES
(1, '一', '', '500.00', '1409139431', '1409139431', 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_agentpay`
--
CREATE TABLE IF NOT EXISTS `wifi_agentpay` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`aid` int(11) DEFAULT NULL COMMENT '代理商ID',
`do` tinyint(4) DEFAULT NULL COMMENT '模式 0 扣款 1 充值',
`oldmoney` decimal(10,0) DEFAULT NULL COMMENT '原金额',
`nowmoney` decimal(10,0) DEFAULT NULL COMMENT '当前金额',
`paymoney` decimal(10,0) DEFAULT NULL COMMENT '支付金额',
`desc` varchar(255) DEFAULT NULL COMMENT '描述信息',
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
--
-- 转存表中的数据 `wifi_agentpay`
--
INSERT INTO `wifi_agentpay` (`id`, `aid`, `do`, `oldmoney`, `nowmoney`, `paymoney`, `desc`, `add_time`, `update_time`) VALUES
(1, 1, 1, NULL, NULL, '20000', '1111', '1409139565', '1409139565'),
(2, 1, 0, '20000', '19500', '500', '商户开户扣款', '1409721341', '1409721341'),
(3, 1, 0, '19500', '19000', '500', '商户开户扣款', '1409801953', '1409801953'),
(4, 1, 0, '19000', '18500', '500', '商户开户扣款', '1410880666', '1410880666'),
(5, 1, 0, '18500', '18000', '500', '商户开户扣款', '1412665504', '1412665504'),
(6, 2, 1, NULL, NULL, '1000', '1', '1413248689', '1413248689'),
(7, 2, 0, '1000', '500', '500', '商户开户扣款', '1413248692', '1413248692');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_agentpushset`
--
CREATE TABLE IF NOT EXISTS `wifi_agentpushset` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`aid` int(11) NOT NULL DEFAULT '0',
`pushflag` tinyint(4) DEFAULT NULL COMMENT '是否启用广告推送',
`showtime` int(11) DEFAULT '3',
`add_time` varchar(20) DEFAULT NULL,
`update_time` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`,`aid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- 转存表中的数据 `wifi_agentpushset`
--
INSERT INTO `wifi_agentpushset` (`id`, `aid`, `pushflag`, `showtime`, `add_time`, `update_time`) VALUES
(1, 1, 1, 6, '1413911664', '1413911664'),
(2, 2, 1, 6, '1413249458', '1413249458');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_arts`
--
CREATE TABLE IF NOT EXISTS `wifi_arts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) DEFAULT NULL,
`cid` int(11) DEFAULT NULL,
`title` varchar(50) DEFAULT NULL,
`titlepic` varchar(255) DEFAULT NULL,
`desc` varchar(200) DEFAULT NULL,
`info` text,
`topflag` tinyint(4) DEFAULT '0' COMMENT '0:否 1 是 是否置顶',
`add_time` varchar(20) DEFAULT NULL,
`update_time` varchar(20) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1' COMMENT '0: stop 1:ok',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
--
-- 转存表中的数据 `wifi_arts`
--
INSERT INTO `wifi_arts` (`id`, `uid`, `cid`, `title`, `titlepic`, `desc`, `info`, `topflag`, `add_time`, `update_time`, `state`) VALUES
(1, 1, 3, '微信营销,它是伴随着微信的火热应运而生的', '/upload/AD/5403e212ed8b1.png', '是网络经济时代企业面临着营销模式的创新,它不存在距离的限制', '<p>\r\n 微信营销,它是伴随着微信的火热应运而生的,是网络经济时代企业面临着营销模式的创新,它不存在距离的限制,用户可以订阅自己想要的信息,企业与商家通过提供信息,推广自己的品牌或产品,从而实现点对点的营销方式。满足3高直达5高。<br />\r\n<br />\r\n1、高到达率<br />\r\n2、高曝光率<br />\r\n3、高接受率<br />\r\n4、高精准度<br />\r\n5、高便利性<br />\r\n微信营销颇具实力,以上所述只是微信营销的显性优势,那些隐形优势还有待我们再去考究,微信营销让网络营销更具魅力!\r\n</p>\r\n<p>\r\n <br />\r\n</p>\r\n<p>\r\n <br />\r\n</p>\r\n<p>\r\n <br />\r\n</p>', 0, '1409540626', '1410948164', 1),
(2, 1, 3, '微信时代大量吸粉利器——微信拍立得', '/upload/AD/5406c8fab466e.jpg', '', '(微信打印机、微信即时印、印美图)登陆大西安了,由西安多特瑞互动科技(http://www.doterry.cn)独家引进,只需用微信扫一扫,瞬间增加微信公众平台的关注度和人气,便于后期微信营销的深化;现场打印的LOMO卡片印有主办方LOGO,信息传播的广度和深度进一步加强。 <br />\r\n第一步、去申请一个微信公众帐号,生成您的专属二维码。 <br />\r\n第二步、在活动现场、营销中心、店面大厅、汽车展馆等摆放一台微信趣拍自助印终端。在终端设备边上准备一个使用指南,印上供嘉宾扫描用的二维码。 <br />\r\n第三步、嘉宾来到活动现场时会主动去扫描二维码,成我们的粉丝。 <br />\r\n第四步、成为粉丝之后,嘉宾可以把自己的手机变成“拍立得”无论是客户现场拍摄的照片还是手机里原的照片,都可以以微信的方式传给我们的公众帐号,上传完成以后,我们会在他手机上生成一个随机的认证码在本地的手机输入认证码后,终端打印设备将在30秒内打印出印有活动广告LOGO 的专属照片。 <br />\r\n参加过微信即时印终端的嘉宾的反馈信息: <br />\r\n1、可以随意打印手机里原有照片或是打印现场与朋友合影照片,让人心情愉悦。 <br />\r\n2、嘉宾可以长期关注活动主办方,活动主办方也利用微信平台,及时发布活动信息。 <br />\r\n3、一场活动结束以后,嘉宾带走的是印有LOGO广告的照片,宣传面更广,且可以安排持续不断的以照片为主的活动,例如:凭当天活动现场的照片成交商品的可以有优惠,活动现场最佳拍摄作品评比等等。 <br />\r\n<div>\r\n <br />\r\n</div>', 0, '1409730810', '1410947840', 1),
(3, 1, 3, '你为什么需要微网站?', '/upload/AD/54198101aeca1.jpg', '微网站的具体功能有哪些?', '微网站的具体功能有哪些? <br />\r\n<br />\r\n 一、符合受众的浏览习惯,使客户获取最佳浏览体验。<br />\r\n 二、一键预定:实现快速下单,减少时间拖延带来的风险。<br />\r\n 三、一键分享:实现用户自行推广,病毒式传播营销。<br />\r\n 四、利用微信信息内容推送、微博广播功能,以及其他社交网络,实现精准营销。<br />\r\n 五、一键留言:快速反馈,方便企业完善服务。<br />\r\n 六、一键导航:实现精准位置导航,方便客户上面沟通,促进成交率。<br />\r\n 七、开放数据分析功能,对访客记录、分析,获取精准有效数据。<br />\r\n 八、内容符合微信的特点,简单高效,有吸引力。<br />\r\n 九、一键拨号:方便客户咨询,及时了解,促进交易。<br />\r\n 十、电子喜帖:专业为影楼与婚礼策划机构研发与定制,与现代年轻人思想结合,美观大方的版面配合背景音乐与视频,在新人好友中展现他们靓丽与喜庆的一面。<br />\r\n 十一、简洁大方,具有良好可拓展性。<br />\r\n 十二、提交订单:专业为销售企业研发与定制,实现快速下单,减少时间拖延带来的风险,线上线下互动转化提高转化率。<br />\r\n<br />\r\n <br />\r\n适用行业 :装饰建材、家装公司、餐饮、KTV、酒店、美容美发、汽车4S店、旅行社、航空公司、银行、教育、医疗保健等行业。<br />\r\n<div>\r\n <br />\r\n</div>', 1, '1410948033', '1410957569', 1),
(4, 1, 9, '特价促销新商品', '/upload/AD/54199f115a418.jpg', '', '特价促销新商品', 1, '1410948640', '1410965265', 1),
(5, 1, 9, '欢度10.1国庆节,所有商品一律8折起售', '/upload/AD/54199f2625650.jpg', '欢迎到店选购。', '欢度10.1国庆节,所有商品一律8折起售 欢迎到店选购。', 0, '1410948707', '1410965286', 1),
(6, 1, 11, '关于我们', '/upload/AD/54199ee545315.jpg', '', '<span style="color:#5B5B5B;font-family:Simsun;font-size:14px;line-height:19px;background-color:#FFFFFF;"> 百姓超市有限公司前称为(泉州百姓超市有限公司),公司1996年在泉州挂牌成立。自创建经营十年来,得到各级政府和广大消费者的认同,公司一贯以“便民、利民、为民”为企业宗旨,坚持“百姓超市、服务百姓”的服务理念,以优质的商品、优良的服务、创立了家喻户晓的本土品牌—“百姓企业”。 </span><br />\r\n<span style="color:#5B5B5B;font-family:Simsun;font-size:14px;line-height:19px;background-color:#FFFFFF;"> 随着传统流通格局的深刻变革,零售业出现两极分化的市场局面,连锁便利成为流通企业改革的主要导向。2003年公司针对市场变化,作出调整产业结构经营方向的重大抉择。借鉴国内社区便利连锁的成功例子,公司开始转向探索、发展社区便利店连锁经营。至今,公司已成功拥有社区便利店30多家,总投资近2000万元,总营业面积约近万平方米。管理产生效益,公司在发展经营的同时,不断完善企业管理制度,强化员工素质教育,提高员工综合素质,倡导企业文化,提升企业凝聚力。对每个员工而言,“百姓超市”不只是一个企业,它更象一个属于大家的“家”。目前公司拥有高素质高层管理人员20余人,中层管理人员50余人,员工300余人。 更让我们自豪的是企业不仅拥有员工财富,更拥有友好合作队伍(供应商)的大力支持。</span><br />\r\n<span style="color:#5B5B5B;font-family:Simsun;font-size:14px;line-height:19px;background-color:#FFFFFF;"> 公司本着“服务社区、贴近生活”的经营模式,真正做到为社区居民服务的目标。正是公司正确的经营方针的指引,团结奋斗的员工共同协作,企业近年来佳绩连创,捷报频传,同时“保真的商品、真诚的服务”赢得了消费者的信赖和赞誉。社区居民的消费需求,给企业创造良好的发展空间,公司将抓住市场发展机遇, 增加泉州市场的社区覆盖率,减少盲区。 同时扩展视野,将发展方向延伸到周边地区。在2009 年公司将扩大连锁加盟,预计2010年发展趋势将达到100家分店,2012年门店总数达到200家甚至更多。 市场是无限的,企业将不断改进,适应市场发展空间,前景无法估量。让“百姓”这块金字招牌更辉煌!</span>', 0, '1410948860', '1410965221', 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_authlist`
--
CREATE TABLE IF NOT EXISTS `wifi_authlist` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`token` varchar(50) DEFAULT NULL,
`uid` int(11) DEFAULT NULL,
`shopid` int(11) DEFAULT NULL,
`routeid` int(11) DEFAULT NULL,
`mode` tinyint(4) DEFAULT NULL COMMENT '认证模式',
`mac` varchar(50) DEFAULT NULL,
`add_date` varchar(50) DEFAULT NULL COMMENT '日期',
`pingcount` int(4) DEFAULT '0' COMMENT '检测链接次数',
`login_time` varchar(50) DEFAULT NULL COMMENT '登录时间',
`login_ip` varchar(20) DEFAULT NULL,
`browser` varchar(50) DEFAULT NULL COMMENT '浏览器',
`agent` varchar(100) DEFAULT NULL COMMENT '机器消息',
`over_time` varchar(50) NOT NULL COMMENT '允许在线时长',
`update_time` varchar(50) DEFAULT NULL,
`last_time` varchar(50) DEFAULT NULL COMMENT '最后在线时间',
`incoming` varchar(255) NOT NULL DEFAULT '0',
`wxcode` varchar(12) DEFAULT NULL,
`wxopenid` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_authtpl`
--
CREATE TABLE IF NOT EXISTS `wifi_authtpl` (
`id` int(4) NOT NULL,
`tpname` varchar(10) DEFAULT NULL COMMENT '模板名称',
`keyname` varchar(30) DEFAULT NULL COMMENT '关键字名称',
`info` varchar(100) DEFAULT NULL,
`pic` varchar(50) DEFAULT NULL,
`shopid` int(11) DEFAULT '0' COMMENT '关联商户ID',
`state` tinyint(1) DEFAULT NULL,
`group` smallint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `wifi_authtpl`
--
INSERT INTO `wifi_authtpl` (`id`, `tpname`, `keyname`, `info`, `pic`, `shopid`, `state`, `group`) VALUES
(1001, '默认模板', 'default', NULL, 'default.jpg', NULL, 1, 1),
(1002, '默认模板2', 'wifiadv', NULL, 'wifiadv.jpg', NULL, 1, 1),
(1003, '默认模板3', 'wifiadv2', NULL, 'wifiadv2.jpg', NULL, 1, 1),
(1004, '默认模板4', 'wifiadv3', NULL, 'wifiadv3.jpg', NULL, 1, 1),
(1005, '默认模板5', 'wifiadv4', NULL, 'wifiadv4.jpg', NULL, 1, 1),
(1006, '默认模板6', 'newadv', NULL, 'newadv.jpg', NULL, 1, 1),
(1007, '默认模板7', 'wood', NULL, 'wood.jpg', NULL, 1, 1),
(1008, '默认模板8', 'bright', NULL, 'bright.jpg', NULL, 1, 1),
(1009, '默认模板9', 'newyear', NULL, 'newyear.jpg', NULL, 1, 1),
(1010, '划屏模板', 'huaping', NULL, 'huaping.jpg', NULL, 1, 1),
(1011, '倒计时模板', 'jishi', NULL, 'jishi.jpg', NULL, 1, 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_blacklist`
--
CREATE TABLE IF NOT EXISTS `wifi_blacklist` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopid` int(11) DEFAULT NULL,
`user` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`phone` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`mac` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`add_date` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`state` int(2) DEFAULT NULL,
`wxopenid` varchar(80) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `mac` (`mac`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_buttonset`
--
CREATE TABLE IF NOT EXISTS `wifi_buttonset` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopid` int(11) DEFAULT NULL,
`keyname` varchar(50) DEFAULT NULL COMMENT '关键字',
`eflag` tinyint(1) DEFAULT '0' COMMENT '启用标志 1:启用',
`icopath` varchar(100) DEFAULT NULL COMMENT '图标路径',
`fontcolor` varchar(10) DEFAULT NULL COMMENT '字体颜色',
`bgcolor` varchar(10) DEFAULT NULL COMMENT '背景色',
`extstyle` varchar(200) DEFAULT NULL COMMENT '扩展css',
`sort` int(3) DEFAULT NULL COMMENT '按钮排序',
`add_time` varchar(15) DEFAULT NULL,
`update_time` varchar(15) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_comment`
--
CREATE TABLE IF NOT EXISTS `wifi_comment` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopid` int(11) DEFAULT NULL,
`routeid` int(11) DEFAULT NULL,
`user` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL,
`content` varchar(300) DEFAULT NULL,
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_day`
--
CREATE TABLE IF NOT EXISTS `wifi_day` (
`id` int(11) NOT NULL,
`tname` varchar(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `wifi_day`
--
INSERT INTO `wifi_day` (`id`, `tname`) VALUES
(0, '00'),
(1, '01'),
(2, '02'),
(3, '03'),
(4, '04'),
(5, '05'),
(6, '06'),
(7, '07'),
(8, '08'),
(9, '09'),
(10, '10'),
(11, '11'),
(12, '12'),
(13, '13'),
(14, '14'),
(15, '15'),
(16, '16'),
(17, '17'),
(18, '18'),
(19, '19'),
(20, '20'),
(21, '21'),
(22, '22'),
(23, '23'),
(24, '24'),
(25, '25'),
(26, '26'),
(27, '27'),
(28, '28'),
(29, '29'),
(30, '30'),
(31, '31');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_hours`
--
CREATE TABLE IF NOT EXISTS `wifi_hours` (
`t` varchar(5) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `wifi_hours`
--
INSERT INTO `wifi_hours` (`t`) VALUES
('01'),
('02'),
('03'),
('04'),
('05'),
('06'),
('07'),
('08'),
('09'),
('10'),
('11'),
('12'),
('13'),
('14'),
('15'),
('16'),
('17'),
('18'),
('19'),
('20'),
('21'),
('22'),
('23'),
('24');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_join`
--
CREATE TABLE IF NOT EXISTS `wifi_join` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`server` varchar(500) DEFAULT NULL,
`host` varchar(50) DEFAULT NULL,
`ip` varchar(50) DEFAULT NULL,
`version` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_member`
--
CREATE TABLE IF NOT EXISTS `wifi_member` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(255) DEFAULT NULL COMMENT '帐号',
`password` varchar(255) DEFAULT NULL COMMENT '密码',
`mode` varchar(10) DEFAULT NULL COMMENT '认证模式 根据认证表ID 注册认证,手机认证,qq认证,微博认证等',
`shopid` int(11) DEFAULT NULL COMMENT '帐号ID',
`routeid` int(11) DEFAULT NULL COMMENT '路由ID',
`token` varchar(100) DEFAULT NULL COMMENT '使用口令',
`phone` varchar(255) DEFAULT NULL,
`qq` varchar(255) DEFAULT NULL,
`mac` varchar(255) DEFAULT NULL COMMENT 'mac地址',
`login_time` varchar(30) DEFAULT NULL COMMENT '路由登录时间',
`login_count` int(11) DEFAULT '0' COMMENT '路由登录次数',
`login_ip` varchar(50) DEFAULT NULL,
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`browser` varchar(255) DEFAULT NULL,
`online_time` varchar(255) DEFAULT NULL COMMENT '在线有效期',
`add_date` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_token` (`token`) USING BTREE,
KEY `index_shop` (`shopid`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=441 ;
--
-- 转存表中的数据 `wifi_member`
--
INSERT INTO `wifi_member` (`id`, `user`, `password`, `mode`, `shopid`, `routeid`, `token`, `phone`, `qq`, `mac`, `login_time`, `login_count`, `login_ip`, `add_time`, `update_time`, `browser`, `online_time`, `add_date`) VALUES
(440, '544a1c03e054e', '<PASSWORD>', '3', 1, 22, '2995aab6e58432118f2ea5b6c4487071', '13888888888', NULL, 'c4:6a:b7:db:d0:ad', '1414142979', 0, NULL, '1414142979', '1414142979', 'Safari', '1414145979', '2014-10-24');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_month`
--
CREATE TABLE IF NOT EXISTS `wifi_month` (
`id` int(11) NOT NULL,
`mon` varchar(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `wifi_month`
--
INSERT INTO `wifi_month` (`id`, `mon`) VALUES
(1, '01'),
(2, '02'),
(3, '03'),
(4, '04'),
(5, '05'),
(6, '06'),
(7, '07'),
(8, '08'),
(9, '09'),
(10, '10'),
(11, '11'),
(12, '12');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_nav`
--
CREATE TABLE IF NOT EXISTS `wifi_nav` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pid` int(11) DEFAULT '0' COMMENT '父ID',
`title` varchar(255) DEFAULT NULL COMMENT '栏目名称',
`mode` tinyint(4) DEFAULT NULL COMMENT '0:单页 1:列表 ',
`config` varchar(255) DEFAULT NULL COMMENT '配置json',
`img` varchar(255) DEFAULT NULL COMMENT '图片信息',
`sort` int(11) DEFAULT '0' COMMENT '排序',
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1' COMMENT '0:停用 1:启用',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_news`
--
CREATE TABLE IF NOT EXISTS `wifi_news` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`keyword` varchar(100) DEFAULT NULL,
`desc` varchar(200) DEFAULT NULL,
`title` varchar(50) DEFAULT NULL,
`info` text,
`mode` varchar(10) DEFAULT NULL,
`add_time` varchar(20) DEFAULT NULL,
`update_time` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
--
-- 转存表中的数据 `wifi_news`
--
INSERT INTO `wifi_news` (`id`, `keyword`, `desc`, `title`, `info`, `mode`, `add_time`, `update_time`) VALUES
(1, NULL, NULL, '代理商和平台账号添加推送广告置顶和审核功能!', '<a rel="nofollow" target="_blank">代理商和平台账号添加推送广告置顶和审核功能!</a>', '1', '1422089854', '1422089854'),
(2, NULL, NULL, '代理商平台添加在线路由实时查看监控功能', '<a rel="nofollow" target="_blank">代理商平台添加在线路由实时查看监控功能</a>', '1', '1422089863', '1422089863'),
(3, NULL, NULL, '增加路由器在线查看运行时长 剩余内存 cpu负载等功能', '<a rel="nofollow" target="_blank">增加路由器在线查看运行时长 剩余内存 cpu负载等功能</a>', '1', '1422089874', '1422089874'),
(4, NULL, NULL, '增加mac黑白名单管理功能', '<a rel="nofollow" target="_blank">增加mac黑白名单管理功能</a>', '1', '1422089890', '1422089890'),
(5, NULL, NULL, '商家账号添加微信一键认证密码认证、多套认证模板!', '<a rel="nofollow" target="_blank">商家账号添加微信一键认证密码认证、多套认证模板!</a>', '1', '1422089902', '1422089902'),
(6, NULL, NULL, '新增加认证成功页面显示认证时长功能。', '<u>新增加认证成功页面显示认证时长功能。</u>', '1', '1422089911', '1422089911'),
(7, NULL, NULL, '平台增加新版本检测和数据库清理功能。', '<a rel="nofollow" target="_blank">平台增加新版本检测和数据库清理功能。</a>', '1', '1422089924', '1422089924'),
(8, NULL, NULL, '修复商家、代理和平台账号编辑广告后服务器旧广告图片文件不删除问题!', '<a rel="nofollow" target="_blank">修复商家、代理和平台账号编辑广告后服务器旧广告图片文件不删除问题!</a>', '1', '1422089932', '1422089932'),
(9, NULL, NULL, '倒计时模板增加了全部的认证方式(之前只有一键).', '<a rel="nofollow" target="_blank">倒计时模板增加了全部的认证方式(之前只有一键).</a>', '1', '1422089940', '1422089940'),
(10, NULL, NULL, '微信关注认证取消关注断网功能已上线欢迎测试!', '<a rel="nofollow" target="_blank">微信关注认证取消关注断网功能已上线欢迎测试!</a>', '1', '1422089948', '1422089948');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_node`
--
CREATE TABLE IF NOT EXISTS `wifi_node` (
`id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`title` varchar(50) DEFAULT NULL,
`status` tinyint(1) DEFAULT '0',
`remark` varchar(255) DEFAULT NULL,
`sort` smallint(6) unsigned DEFAULT NULL,
`pid` smallint(6) unsigned NOT NULL,
`level` tinyint(1) unsigned NOT NULL,
`bmenu` tinyint(4) DEFAULT '0',
`single` tinyint(4) DEFAULT '0' COMMENT '是否还有子节点 0:否 1 是',
`ico` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `level` (`level`),
KEY `pid` (`pid`),
KEY `status` (`status`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_notice`
--
CREATE TABLE IF NOT EXISTS `wifi_notice` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) DEFAULT NULL,
`info` text,
`add_time` varchar(15) DEFAULT NULL,
`update_time` varchar(15) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
--
-- 转存表中的数据 `wifi_notice`
--
INSERT INTO `wifi_notice` (`id`, `title`, `info`, `add_time`, `update_time`) VALUES
(2, '微信关注认证取消关注断网功能已上线欢迎测试!', '<a rel="nofollow" target="_blank">微信关注认证取消关注断网功能已上线欢迎测试!</a>', '1422090041', '1422090041'),
(3, '倒计时模板增加了全部的认证方式(之前只有一键).', '<a rel="nofollow" target="_blank">倒计时模板增加了全部的认证方式(之前只有一键).</a>', '1422090051', '1422090051'),
(4, '商家账号添加微信一键认证密码认证、多套认证模板!', '<a rel="nofollow" target="_blank">商家账号添加微信一键认证密码认证、多套认证模板!</a>', '1422090063', '1422090063'),
(5, '增加路由器在线查看运行时长 剩余内存 cpu负载等功能', '<a rel="nofollow" target="_blank">增加路由器在线查看运行时长 剩余内存 cpu负载等功能</a>', '1422090073', '1422090073');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_pushadv`
--
CREATE TABLE IF NOT EXISTS `wifi_pushadv` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(50) DEFAULT NULL,
`mode` tinyint(4) DEFAULT '0' COMMENT '投放路径 ',
`pic` varchar(255) DEFAULT NULL COMMENT '广告存放路径',
`info` text COMMENT '备注',
`sort` int(11) DEFAULT '0' COMMENT '排序',
`trade` varchar(255) DEFAULT NULL,
`showcount` int(11) DEFAULT '0' COMMENT '展示次数',
`add_time` varchar(20) DEFAULT NULL,
`startdate` varchar(20) DEFAULT NULL,
`enddate` varchar(20) DEFAULT NULL,
`update_time` varchar(20) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1' COMMENT '0:停止 1 正常',
`aid` int(11) NOT NULL DEFAULT '0',
`shopid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=26 ;
--
-- 转存表中的数据 `wifi_pushadv`
--
INSERT INTO `wifi_pushadv` (`id`, `title`, `mode`, `pic`, `info`, `sort`, `trade`, `showcount`, `add_time`, `startdate`, `enddate`, `update_time`, `state`, `aid`, `shopid`) VALUES
(1, '123', 0, '/upload/PUSHAD/54354ecf9ae72.jpg', '123', 1, '#手机##咖啡厅#', 0, '1412779727', '1412697600', '1419955200', '1413951062', 1, 1, 1),
(22, 'sdfas', 0, '/upload/PUSHAD/543c78ac73ccf.jpg', 'sadf', 1, '#餐饮##手机##咖啡厅##足浴##KTV##购物商超##酒店宾馆##休闲娱乐#', 0, '1413249196', '1413216000', '1415894400', '1413249196', 1, 2, NULL),
(13, '代理商1广告位1 足浴', 0, '/upload/PUSHAD/5431628cd69d4.jpg', '<h2>\r\n 代理商广告位2代理商广告位2代理商广告位2代理商广告位2\r\n</h2>', 1, '#餐饮##手机##咖啡厅##足浴##KTV##购物商超##酒店宾馆##休闲娱乐#', 1, '1410629074', '1410624000', '1419955200', '1413956037', 1, 1, NULL),
(20, '代理广告位2 全行业', 0, '/upload/PUSHAD/5431627e95d64.jpg', '', 1, '#餐饮##手机##咖啡厅##足浴##KTV##购物商超##酒店宾馆##休闲娱乐#', 1, '1410918699', '1411142400', '1420646400', '1413950886', 1, 1, NULL),
(21, '平台广告2 全行业', 0, '/upload/PUSHAD/5418eb47b5183.jpg', '平台广告2 全行业平台广告2 全行业平台广告2 全行业', 1, '#餐饮##手机##咖啡厅##足浴##KTV##购物商超##酒店宾馆##休闲娱乐#', 1, '1410919239', '1410883200', '1415808000', '1413912337', 1, 0, NULL),
(9, '123', 0, '/upload/PUSHAD/543c78c9641fe.jpg', '123', 1, '#手机##咖啡厅##足浴##KTV##购物商超##酒店宾馆##休闲娱乐#', 0, '1413249225', '1413216000', '1415894400', '1413901694', 1, 2, 9);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_role`
--
CREATE TABLE IF NOT EXISTS `wifi_role` (
`id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`pid` smallint(6) DEFAULT NULL,
`status` tinyint(1) unsigned DEFAULT NULL,
`remark` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `pid` (`pid`),
KEY `status` (`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_role_user`
--
CREATE TABLE IF NOT EXISTS `wifi_role_user` (
`role_id` mediumint(9) unsigned DEFAULT NULL,
`user_id` char(32) DEFAULT NULL,
KEY `group_id` (`role_id`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_routemap`
--
CREATE TABLE IF NOT EXISTS `wifi_routemap` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopid` int(11) NOT NULL COMMENT '帐号ID',
`routename` varchar(255) DEFAULT NULL COMMENT '路由名称',
`gw_address` varchar(255) DEFAULT NULL,
`gw_port` varchar(255) DEFAULT NULL,
`gw_id` varchar(255) DEFAULT NULL COMMENT '网关ID',
`sortid` int(11) DEFAULT '0',
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`sys_uptime` varchar(255) DEFAULT NULL COMMENT '路由时间',
`sys_memfree` varchar(255) DEFAULT NULL,
`wifidog_uptime` varchar(255) DEFAULT NULL COMMENT '路由跟踪时间',
`sys_load` varchar(255) DEFAULT NULL,
`last_heartbeat_ip` varchar(255) DEFAULT NULL COMMENT '心跳包IP',
`last_heartbeat_time` varchar(255) DEFAULT NULL COMMENT '心跳时间',
`user_agent` varchar(255) DEFAULT NULL COMMENT '消息头',
`notes` varchar(255) DEFAULT NULL COMMENT '备注信息',
`state` tinyint(4) DEFAULT '1' COMMENT '0:停用 1:启用',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=26 ;
--
-- 转存表中的数据 `wifi_routemap`
--
INSERT INTO `wifi_routemap` (`id`, `shopid`, `routename`, `gw_address`, `gw_port`, `gw_id`, `sortid`, `add_time`, `update_time`, `sys_uptime`, `sys_memfree`, `wifidog_uptime`, `sys_load`, `last_heartbeat_ip`, `last_heartbeat_time`, `user_agent`, `notes`, `state`) VALUES
(12, 0, '1', '192.168.10.1', '2060', '000D0BFD5E23', 0, '1412750910', '1413042377', '598099', '33116', '598032', '0.21', NULL, '1412751841', 'wget', NULL, 1),
(22, 1, 'x', '192.168.10.1', '3000', 'ACA2139BB5E6', 0, '1413250032', '1413908671', '26842', '40128', '1682', '0.60', NULL, '1414143655', 'RippleTek 201404', NULL, 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_shop`
--
CREATE TABLE IF NOT EXISTS `wifi_shop` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`account` varchar(255) NOT NULL COMMENT '管理帐号',
`password` varchar(255) NOT NULL,
`shopname` varchar(255) DEFAULT NULL COMMENT '门店名称',
`pid` int(11) DEFAULT '0' COMMENT '代理商ID',
`mode` tinyint(4) DEFAULT '0' COMMENT '0:注册用户 1:代理商添加 ',
`logo` varchar(255) DEFAULT NULL,
`linker` varchar(255) DEFAULT NULL,
`phone` varchar(255) DEFAULT NULL COMMENT '联系电话',
`info` text COMMENT '门店描述',
`address` varchar(255) DEFAULT NULL,
`point_x` varchar(255) DEFAULT NULL,
`point_y` varchar(255) DEFAULT NULL,
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1' COMMENT '0:停用 1:启用',
`tpl_id` int(11) DEFAULT NULL,
`tpl_path` varchar(255) DEFAULT NULL COMMENT '模板地址',
`trade` varchar(255) DEFAULT NULL COMMENT '行业类型 #区分',
`province` varchar(255) DEFAULT NULL,
`city` varchar(255) DEFAULT NULL,
`area` varchar(255) DEFAULT NULL,
`maxcount` int(255) DEFAULT '0' COMMENT '认证使用次数',
`end_time` varchar(255) DEFAULT NULL COMMENT '帐号有效期',
`shopgroup` varchar(255) DEFAULT NULL COMMENT '商圈',
`shoplevel` varchar(255) DEFAULT NULL COMMENT '店铺消费水平 多组 用 #区分',
`routetype` tinyint(4) DEFAULT '0' COMMENT '0:单路由 1 多路由',
`authmode` varchar(255) DEFAULT NULL COMMENT '认证模式',
`authaction` tinyint(4) DEFAULT NULL,
`jumpurl` varchar(255) DEFAULT NULL,
`linkflag` tinyint(2) DEFAULT '0' COMMENT '0:限制注册上限 1 不限制使用',
`timelimit` int(11) DEFAULT '0',
`sh` int(4) DEFAULT '0' COMMENT '开始时段',
`eh` int(4) DEFAULT '23' COMMENT '结束时段',
`countflag` tinyint(1) NOT NULL DEFAULT '0',
`countmax` int(11) NOT NULL DEFAULT '0',
`duanxin` varchar(255) NOT NULL,
`ratelimit` int(4) NOT NULL DEFAULT '0',
`smscount` int(4) NOT NULL DEFAULT '0',
`token` varchar(50) DEFAULT NULL,
`temptime` int(4) NOT NULL DEFAULT '5',
`wxewm` varchar(255) DEFAULT NULL,
`djs` int(2) NOT NULL DEFAULT '10',
`wxsuccess` varchar(255) DEFAULT NULL,
`wxgzts` varchar(255) DEFAULT NULL,
`wxappid` varchar(80) DEFAULT NULL,
`threadurl` varchar(255) DEFAULT NULL,
`wxrzfs` int(2) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
--
-- 转存表中的数据 `wifi_shop`
--
INSERT INTO `wifi_shop` (`id`, `account`, `password`, `shopname`, `pid`, `mode`, `logo`, `linker`, `phone`, `info`, `address`, `point_x`, `point_y`, `add_time`, `update_time`, `state`, `tpl_id`, `tpl_path`, `trade`, `province`, `city`, `area`, `maxcount`, `end_time`, `shopgroup`, `shoplevel`, `routetype`, `authmode`, `authaction`, `jumpurl`, `linkflag`, `timelimit`, `sh`, `eh`, `countflag`, `countmax`, `duanxin`, `ratelimit`, `smscount`, `token`, `temptime`, `wxewm`, `djs`, `wxsuccess`, `wxgzts`, `wxappid`, `threadurl`, `wxrzfs`) VALUES
(1, 'qin', 'e10adc3949ba59abbe56e057f20f883e', '1234', 1, 0, NULL, '1222', '18995113232', NULL, '', NULL, NULL, '1410880914', '1422088141', 1, 1003, 'wifiadv2', '足浴', '北京市', '市辖区', '东城区', 600, '1410880914', NULL, '', 0, '#0##1##2##3={"user":"qdjazzinsland","pwd":"\\<PASSWORD>","ysid":"<PASSWORD>"}#<0', 1, 'http://www.baidu.com', 1, 0, 0, 23, 0, 0, '您的上网验证码:"$code"', 0, 100, '6542332f1fg436a0b069d45659c62a1a', 10, '/upload/WXEWM/54c355ad0e35c.jpg', 20, '嘉信通提醒您:已认证成功', '关注成功,您可以使用本店提供的wifi免费上网了!', 'wxb5ce30a97829af83=976aaae3e16b784b533d55c6726b2ab5', 'http://www.baidu.com', 1),
(5, 'qin2', 'e10adc3949ba59abbe56e057f20f883e', '1234', 1, 0, NULL, '1222', '18995113232', NULL, '', NULL, NULL, '1410880914', '1413898554', 1, 1003, 'wifiadv2', '足浴', '北京市', '市辖区', '东城区', 600, '1410880914', NULL, '', 0, '#0##2#<0', 3, '', 1, 0, 0, 23, 0, 0, '', 0, 0, NULL, 5, NULL, 10, NULL, NULL, NULL, NULL, 0),
(9, 'qin3', 'e10adc3949ba59abbe56e057f20f883e', '134', 2, 0, NULL, '234', '13456789012', NULL, '', NULL, NULL, '1413248692', '1413898544', 1, 1003, 'wifiadv2', '餐饮', '北京市', '市辖区', '东城区', 600, '1413248692', NULL, '#低端#', 0, '#0##1##2#<', 3, '', 0, 0, 0, 23, 0, 0, '', 0, 0, '6541d32f1df436a0b069de2259c62a1a', 5, NULL, 10, NULL, NULL, NULL, NULL, 0);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_sms`
--
CREATE TABLE IF NOT EXISTS `wifi_sms` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) DEFAULT NULL COMMENT '帐号ID',
`mode` tinyint(4) DEFAULT '0' COMMENT '0:马上发送 1:定时发送',
`phone` varchar(255) DEFAULT NULL,
`info` varchar(255) DEFAULT NULL,
`lens` int(11) DEFAULT NULL COMMENT '字数',
`unit` int(11) DEFAULT NULL COMMENT '短信条数',
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`send_time` varchar(255) DEFAULT NULL COMMENT '发送时间',
`ready_time` varchar(255) DEFAULT NULL COMMENT '预发送时间',
`state` tinyint(4) DEFAULT '0' COMMENT '0:为发送 1 已发送 2 发送失败 ',
`lostcount` int(11) DEFAULT NULL COMMENT '失败次数',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_smscfg`
--
CREATE TABLE IF NOT EXISTS `wifi_smscfg` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) DEFAULT NULL,
`user` varchar(50) DEFAULT NULL,
`password` varchar(50) DEFAULT NULL,
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1' COMMENT '0:停用 1 启用',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
--
-- 转存表中的数据 `wifi_smscfg`
--
INSERT INTO `wifi_smscfg` (`id`, `uid`, `user`, `password`, `add_time`, `update_time`, `state`) VALUES
(1, 1, 'jinguangxi1983', '12345<PASSWORD>', '1422088540', '1422088540', 1),
(2, 4, '23ns8', '123', '<PASSWORD>', '1410499272', 1),
(3, 8, 'aer', 'sadf', '1412690612', '1412690612', 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_smscount`
--
CREATE TABLE IF NOT EXISTS `wifi_smscount` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopid` int(11) DEFAULT NULL,
`mac` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`phone` varchar(25) CHARACTER SET utf8 DEFAULT NULL,
`add_date` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`add_time` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`smscode` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_tpl`
--
CREATE TABLE IF NOT EXISTS `wifi_tpl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tpl_name` varchar(255) DEFAULT NULL,
`tpl_path` varchar(255) DEFAULT NULL,
`group` varchar(10) DEFAULT NULL,
`state` tinyint(4) DEFAULT '1' COMMENT '0:停用 1 使用',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_tradead`
--
CREATE TABLE IF NOT EXISTS `wifi_tradead` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shopid` int(11) NOT NULL COMMENT '商户ID',
`mode` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_treenode`
--
CREATE TABLE IF NOT EXISTS `wifi_treenode` (
`id` int(11) NOT NULL,
`title` varchar(50) DEFAULT NULL COMMENT '名称',
`g` varchar(50) NOT NULL DEFAULT '' COMMENT '分组名称',
`m` varchar(50) NOT NULL DEFAULT '' COMMENT '模块名称',
`a` varchar(50) NOT NULL DEFAULT '' COMMENT 'action 名称',
`ico` varchar(50) DEFAULT NULL COMMENT '图标',
`pid` int(11) DEFAULT NULL COMMENT '0',
`level` tinyint(4) DEFAULT '1' COMMENT '层级 1,2,3',
`menuflag` tinyint(4) DEFAULT '1' COMMENT '0: 否 1 是',
`sort` int(11) DEFAULT '0' COMMENT '排序',
`single` tinyint(4) DEFAULT '1' COMMENT '是否单节点 0:否 1 是',
`remark` varchar(255) DEFAULT NULL,
`status` tinyint(4) DEFAULT '1' COMMENT '0 停用 1 启用',
PRIMARY KEY (`id`,`a`,`m`,`g`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `wifi_treenode`
--
INSERT INTO `wifi_treenode` (`id`, `title`, `g`, `m`, `a`, `ico`, `pid`, `level`, `menuflag`, `sort`, `single`, `remark`, `status`) VALUES
(1, 'WIFI管理', 'wifiadmin', 'Index', 'index', NULL, 0, 1, 0, 0, 1, NULL, 1),
(2, '首页', 'wifiadmin', 'index', 'index', 'icon-home', 1, 2, 1, 0, 1, NULL, 1),
(3, '密码修改', 'wifiadmin', 'index', 'pwd', '1', 2, 3, 0, 0, 1, NULL, 1),
(100, '系统管理', 'wifiadmin', 'System', 'index', 'icon-asterisk', 1, 2, 1, 0, 0, NULL, 1),
(101, '角色管理', 'wifiadmin', 'system', 'role', NULL, 100, 2, 1, 0, 1, NULL, 1),
(102, '添加角色', 'wifiadmin', 'system', 'addrole', NULL, 100, 2, 1, 0, 1, NULL, 1),
(103, '编辑角色', 'wifiadmin', 'system', 'editrole', NULL, 100, 3, 0, 0, 1, NULL, 1),
(104, '角色权限', 'wifiadmin', 'system', 'roleaccess', NULL, 100, 3, 0, 0, 1, NULL, 1),
(105, '用户管理', 'wifiadmin', 'system', 'userlist', NULL, 100, 2, 1, 0, 1, NULL, 1),
(106, '添加用户', 'wifiadmin', 'system', 'adduser', NULL, 100, 3, 1, 0, 1, NULL, 1),
(107, '编辑用户', 'wifiadmin', 'system', 'userlist', NULL, 100, 3, 1, 0, 1, NULL, 1),
(200, '网站管理', 'wifiadmin', '', '', 'icon-cogs', 1, 1, 1, 0, 0, NULL, 1),
(201, '网站设置', 'wifiadmin', 'system', 'index', NULL, 200, 3, 1, 0, 1, NULL, 1),
(202, '参数设置', 'wifiadmin', 'System', 'setting', NULL, 200, 1, 1, 0, 1, NULL, 1),
(300, '商户管理', 'wifiadmin', 'Shop', 'index', 'icon-group', 1, 1, 1, 0, 0, NULL, 1),
(301, '商户列表', 'wifiadmin', 'Shop', 'index', NULL, 300, 2, 1, 0, 1, NULL, 1),
(302, '添加商户', 'wifiadmin', 'shop', 'addshop', NULL, 300, 3, 1, 0, 1, NULL, 1),
(303, '编辑商户', 'wifiadmin', 'shop', 'editshop', NULL, 300, 1, 0, 0, 1, NULL, 1),
(400, '代理商管理', 'wifiadmin', 'agent', '', 'icon-user-md', 1, 2, 1, 0, 0, NULL, 1),
(401, '代理商等级', 'wifiadmin', 'agent', 'level', NULL, 400, 3, 1, 0, 1, NULL, 1),
(402, '代理商列表', 'wifiadmin', 'agent', 'index', NULL, 400, 3, 1, 2, 1, NULL, 1),
(403, '添加代理商', 'wifiadmin', 'agent', 'add', NULL, 400, 3, 1, 3, 1, NULL, 1),
(404, '编辑代理商', 'wifiadmin', 'agent', 'edit', NULL, 400, 3, 0, 4, 1, NULL, 1),
(405, '添加等级', 'wifiadmin', 'agent', 'addlevel', NULL, 400, 3, 1, 1, 1, NULL, 1),
(406, '删除代理商', 'wifiadmin', 'agent', 'del', NULL, 400, 3, 0, 5, 1, NULL, 1),
(407, '扣款记录', 'wifiadmin', 'agent', 'paylist', NULL, 400, 3, 1, 7, 1, NULL, 1),
(408, '帐号金额调整', 'wifiadmin', 'agent', 'dopay', NULL, 400, 3, 0, 0, 1, NULL, 1),
(500, '广告管理', 'wifiadmin', 'ad', 'index', 'icon-cloud', 1, 1, 1, 0, 0, NULL, 1),
(501, '广告列表', 'wifiadmin', 'ad', 'index', NULL, 500, 1, 1, 0, 1, NULL, 1),
(502, '编辑广告', 'wifiadmin', 'ad', 'editad', NULL, 500, 3, 0, 0, 1, NULL, 1),
(504, '删除广告', 'wifiadmin', 'ad', 'delad', NULL, 500, 3, 0, 0, 1, NULL, 1),
(505, '广告统计', 'wifiadmin', 'ad', 'rpt', NULL, 500, 1, 1, 0, 1, NULL, 1),
(600, '统计信息', 'wifiadmin', 'report', '', 'icon-bar-chart', 1, 2, 1, 0, 0, NULL, 1),
(601, '注册用户', 'wifiadmin', 'report', 'user', NULL, 600, 3, 1, 0, 1, NULL, 1),
(602, '上网记录', 'wifiadmin', 'report', 'online', '', 600, 3, 1, 0, 1, '', 1),
(603, '用户统计报表', 'wifiadmin', 'report', 'userchart', NULL, 600, 3, 1, 0, 1, NULL, 1),
(604, '上网统计报表', 'wifiadmin', 'report', 'authchart', NULL, 600, 3, 1, 0, 1, NULL, 1),
(605, '在线路由统计', 'wifiadmin', 'report', 'routechart', NULL, 600, 3, 1, 0, 1, NULL, 1),
(700, '信息管理', 'wifiadmin', 'notice', '', 'icon-bullhorn', 1, 1, 1, 0, 0, '', 1),
(701, '系统消息', 'wifiadmin', 'notice', 'index', '', 700, 3, 1, 0, 1, '', 1),
(702, '添加系统消息', 'wifiadmin', 'notice', 'add', '', 700, 3, 1, 2, 1, '', 1),
(703, '删除系统消息', 'wifiadmin', 'notice', 'del', '', 700, 3, 0, 3, 1, '', 1),
(704, '编辑系统消息', 'wifiadmin', 'notice', 'edit', '', 700, 3, 0, 4, 1, '', 1),
(705, '新闻管理', 'wifiadmin', 'news', 'index', '', 700, 3, 1, 4, 1, '', 1),
(706, '添加新闻', 'wifiadmin', 'news', 'add', '', 700, 3, 1, 5, 1, '', 1),
(800, '广告推送', 'wifiadmin', 'pushadv', 'index', 'icon-facetime-video', 1, 1, 1, 3, 0, NULL, 1),
(801, '推送设置', 'wifiadmin', 'pushadv', 'set', NULL, 800, 3, 1, 0, 1, NULL, 1),
(802, '推送广告管理', 'wifiadmin', 'pushadv', 'index', NULL, 800, 3, 1, 0, 1, NULL, 1),
(803, '添加推送广告', 'wifiadmin', 'pushadv', 'add', NULL, 800, 3, 1, 3, 1, NULL, 1),
(804, '编辑推送广告', 'wifiadmin', 'pushadv', 'edit', NULL, 800, 3, 0, 0, 1, NULL, 1),
(805, '删除推送广告', 'wifiadmin', 'pushadv', 'del', NULL, 800, 1, 0, 4, 1, NULL, 1),
(806, '广告推送统计', 'wifiadmin', 'Pushadv', 'rpt', NULL, 800, 3, 1, 5, 1, NULL, 1),
(108, '删除用户', 'wifiadmin', 'system', 'deluser', NULL, 100, 3, 0, 0, 1, NULL, 1),
(109, '删除角色', 'wifiadmin', 'System', 'delrole', NULL, 100, 3, 0, 0, 1, NULL, 1),
(606, '导出用户资料', 'wifiadmin', 'report', 'downuser', NULL, 600, 3, 0, 10, 1, NULL, 1),
(900, '路由器管理', 'wifiadmin', 'route', 'index', 'icon-sitemap', 1, 1, 1, 0, 0, '', 1),
(901, '路由列表', 'wifiadmin', 'route', 'index', '', 900, 3, 1, 0, 1, '', 1),
(307, '删除路由', 'wifiadmin', 'shop', 'delroute', NULL, 300, 3, 0, 0, 1, NULL, 1),
(903, '编辑路由', 'wifiadmin', 'route', 'edit', '', 900, 3, 0, 0, 1, '', 1),
(904, '删除路由', 'wifiadmin', 'route', 'del', '', 900, 3, 0, 0, 1, '', 1),
(304, '路由管理', 'wifiadmin', 'shop', 'routelist', NULL, 300, 1, 0, 0, 1, NULL, 1),
(305, '路由编辑', 'wifiadmin', 'shop', 'editroute', NULL, 300, 3, 0, 0, 1, NULL, 1),
(306, '添加路由', 'wifiadmin', 'shop', 'addroute', NULL, 300, 3, 0, 0, 1, NULL, 1),
(606, '微信用户统计', 'wifiadmin', 'report', 'userwx', NULL, 600, 3, 1, 0, 1, NULL, 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_wap`
--
CREATE TABLE IF NOT EXISTS `wifi_wap` (
`uid` int(11) NOT NULL,
`home_tpl` int(11) DEFAULT NULL,
`home_tpl_path` varchar(255) DEFAULT NULL,
`list_tpl` int(11) DEFAULT NULL,
`list_tpl_path` varchar(255) DEFAULT NULL,
`info_tpl` int(11) DEFAULT NULL,
`info_tpl_path` varchar(255) DEFAULT NULL,
`state` smallint(6) DEFAULT NULL,
`shopname` varchar(255) DEFAULT NULL,
`tel` varchar(20) DEFAULT NULL,
`info` text NOT NULL,
`point_x` varchar(20) DEFAULT NULL,
`point_y` varchar(20) DEFAULT NULL,
`pic` varchar(255) DEFAULT NULL,
`keyword` varchar(255) DEFAULT NULL,
`desc` varchar(255) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
`add_time` varchar(50) DEFAULT NULL,
`update_time` varchar(50) DEFAULT NULL,
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- 转存表中的数据 `wifi_wap`
--
INSERT INTO `wifi_wap` (`uid`, `home_tpl`, `home_tpl_path`, `list_tpl`, `list_tpl_path`, `info_tpl`, `info_tpl_path`, `state`, `shopname`, `tel`, `info`, `point_x`, `point_y`, `pic`, `keyword`, `desc`, `address`, `add_time`, `update_time`) VALUES
(1, 9, 'home_t3', 2, 'list_t1', 16, 'info_house', NULL, '亲亲小店', '18899996666', '国庆店庆双重庆,顺吉送礼好心情,国庆期间本店举行买手机 送话费、交话费送手机、买手机送礼品等活动,机会不多只有国庆,不要犹豫不要徘徊,犹豫徘徊就等于没来,赶快进店选购吧!', '106.290426', '38.463426', NULL, NULL, NULL, '北京市海淀区四里桥86号', '1412692305', '1412692305'),
(5, 9, 'home_t3', 12, 'list_hotel', 13, 'info_hotel', 1, '我的小店', '13567890123', '', '116.395645', '39.929986', NULL, NULL, NULL, '北京市', '1413247993', '1413247993'),
(9, 9, 'home_t3', NULL, NULL, NULL, NULL, 1, NULL, NULL, '', NULL, NULL, NULL, NULL, NULL, NULL, '1413249558', '1413249558');
-- --------------------------------------------------------
--
-- 表的结构 `wifi_wapcatelog`
--
CREATE TABLE IF NOT EXISTS `wifi_wapcatelog` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) DEFAULT NULL,
`mode` varchar(20) DEFAULT 'art' COMMENT '栏目类别',
`modematch` varchar(255) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`info` varchar(255) DEFAULT NULL,
`icopic` varchar(255) DEFAULT NULL,
`titlepic` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`sort` int(11) DEFAULT NULL,
`tel` varchar(50) DEFAULT NULL,
`point_x` varchar(20) DEFAULT NULL,
`point_y` varchar(20) DEFAULT NULL,
`add_time` varchar(255) DEFAULT NULL,
`update_time` varchar(255) DEFAULT NULL,
`state` tinyint(2) DEFAULT '1' COMMENT '0:停用 1 使用',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
--
-- 转存表中的数据 `wifi_wapcatelog`
--
INSERT INTO `wifi_wapcatelog` (`id`, `uid`, `mode`, `modematch`, `title`, `info`, `icopic`, `titlepic`, `url`, `sort`, `tel`, `point_x`, `point_y`, `add_time`, `update_time`, `state`) VALUES
(9, 1, '0', NULL, '促销商品', '', NULL, '/upload/AD/54194fbf64d9e.jpg', '', 0, '', '', '', '1410944959', '1410944959', 1),
(10, 1, '3', NULL, '联系我们', '本店地址', NULL, '/upload/AD/54195ce8ed841.jpg', '', 0, '', '106.256722', '38.489357', '1410948328', '1410948328', 1),
(3, 1, '0', NULL, '产品介绍', '', NULL, '/upload/AD/54194fdbaf554.jpg', '', 1, '', '', '', '1409540459', '1410944987', 1),
(11, 1, '0', NULL, '关于我们', '', NULL, '/upload/AD/54195d8fb1827.jpg', '', 0, '', '', '', '1410948495', '1410948495', 1),
(12, 5, '0', NULL, '关于我们', '', NULL, '/upload/AD/5419a2bcb828f.jpg', '', 0, '', '', '', '1410966204', '1410966204', 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_waptpl`
--
CREATE TABLE IF NOT EXISTS `wifi_waptpl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group` smallint(6) DEFAULT NULL COMMENT '0:首页 1 列表 2 图文',
`title` varchar(255) DEFAULT NULL,
`info` varchar(255) DEFAULT NULL,
`pic` varchar(255) DEFAULT NULL,
`tplpath` varchar(255) DEFAULT NULL,
`sort` int(11) DEFAULT '0',
`isdefault` smallint(6) DEFAULT '0' COMMENT '1 默认模板 0 不是默认',
`state` smallint(6) DEFAULT '1' COMMENT '0: 停用 1 启用',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;
--
-- 转存表中的数据 `wifi_waptpl`
--
INSERT INTO `wifi_waptpl` (`id`, `group`, `title`, `info`, `pic`, `tplpath`, `sort`, `isdefault`, `state`) VALUES
(2, 1, '默认模板', NULL, 'list1.png', 'list_t1', 0, 1, 1),
(6, 2, '科技模板', NULL, 'news_tech.png', 'info_tech', 1, 0, 1),
(8, 1, '默认模板3', NULL, 'list2.png', 'list_t2', 0, 0, 1),
(9, 0, '默认模板4', NULL, 'cate1.png', 'home_t3', 3, 0, 1),
(11, 0, '酒店主题模板', NULL, 'home_hotel.png', 'home_hotel', 0, 0, 1),
(12, 1, '酒店主题模板', NULL, 'list_hotel.png', 'list_hotel', 0, 0, 1),
(13, 2, '酒店主题模板', NULL, 'info_hotel.png', 'info_hotel', 0, 0, 1),
(15, 1, '房产主题模板', NULL, 'list_house.png', 'list_house', 0, 0, 1),
(16, 2, '房产主题', NULL, 'info_house.png', 'info_house', 0, 0, 1),
(17, 0, '主题模板10', NULL, 'home10.png', 'home_t10', 0, 0, 1),
(19, 0, '酒吧模板', NULL, 'home_s.png', 'home_bar', 0, 0, 1),
(20, 3, '默认模板1', NULL, 'shop_home_t1.png', 'home_t1', 0, 0, 1),
(21, 3, '默认模板2', NULL, NULL, 'index', 0, 0, 1);
-- --------------------------------------------------------
--
-- 表的结构 `wifi_wxdata`
--
CREATE TABLE IF NOT EXISTS `wifi_wxdata` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`shopid` int(12) NOT NULL,
`accesstoken` varchar(600) CHARACTER SET utf8 NOT NULL,
`expiresin` varchar(8) DEFAULT NULL,
`gzl` int(8) NOT NULL DEFAULT '0',
`qxl` int(8) NOT NULL DEFAULT '0',
`add_time` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`add_date` varchar(50) CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- 表的结构 `wifi_wxuser`
--
CREATE TABLE IF NOT EXISTS `wifi_wxuser` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`shopid` int(12) DEFAULT NULL,
`wxopenid` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`nickname` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`sex` varchar(4) CHARACTER SET utf8 DEFAULT NULL,
`city` varchar(15) CHARACTER SET utf8 DEFAULT NULL,
`province` varchar(15) CHARACTER SET utf8 DEFAULT NULL,
`headimgurl` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`subscribe_time` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<gh_stars>0
/*
Object: dbo.Query_100
Transaction: MAA:MAN
*/
CREATE PROCEDURE [dbo].[Query_100]
@HeaderID AS bigint
AS
SET NOCOUNT ON;
DECLARE @SQL AS nvarchar(MAX) = N'
INSERT INTO ipi.IPMembership
(RowID, ID, NID, SocietyCode, SocietyName, CCCode, RoleCode, RightCode, ValidFromDate, ValidFromTime, ValidToDate, ValidToTime
, SignDate, MemberShare, AmendDate, AmendTime)
SELECT A.RowID, R.ID, N.NID, A.SocietyCode, A.SocietyName, A.CCCode, A.RoleCode, A.RightCode, A.ValidFromDate, A.ValidFromTime, A.ValidToDate, A.ValidToTime
, A.SignDate, A.MemberShare, A.AmendDate, A.AmendTime
-- data rows
FROM dbo.[Row] AS A
-- tran header row
INNER JOIN dbo.[Row] AS H
ON H.RowCode = ''MAA''
AND H.HeaderID = A.HeaderID
INNER JOIN ipi.IP AS R
ON H.IPBN = R.IPBN
INNER JOIN ipi.IPName AS N
ON R.ID = N.ID
AND H.IPNN = N.IPNN
WHERE A.HeaderID = @HeaderID
AND A.RowCode = ''MAN''
AND A.HeaderCode = ''MAA'';
';
EXEC sp_executesql @SQL
, N'@HeaderID bigint'
, @HeaderID = @HeaderID;
GO
|
SET DEFINE OFF;
ALTER TABLE AFW_13_MENU ADD (
CONSTRAINT AFW_13_MENU_PK
PRIMARY KEY
(SEQNC)
ENABLE VALIDATE)
/
|
INSERT INTO [dbo].[Users]
VALUES (N'35cbb28b-7c43-434a-8b01-37e5e33a7fad',N'<EMAIL>', N'<EMAIL>', N'<EMAIL>', N'<EMAIL>', 0, N'AQAAAAEAACcQAAAAEDUzfNdBpI8aCiJv9r/cYhGqRzU8JDzFQppvvYK1wnI5KztrBehCqUf1w0UUMz7Q4w==', N'AD3HHBFDFG752ZAYZ3NMXQQA33DR425H', N'cf3815f1-b8f5-4963-abbf-1ff9c90f927b', NULL, 0, 0, NULL, 1, 0),
(N'89026b03-c62d-4309-bfec-ad2c1ea6c6d2', N'<EMAIL>', N'<EMAIL>', N'<EMAIL>', N'<EMAIL>', 0, N'AQAAAAEAACcQAAAAECZOxWaMnfhjcJeH5EerNTlFkXI+Ogb9mLoH4jetM/3dBWBUsa8wvnXv+IuTp3SECw==', N'44Y3TKY566U35V7DNXW7KAQVXK25V3HM', N'9bf29c30-8408-45e6-b2da-e1592e2429fa', NULL, 0, 0, NULL, 1, 0),
(N'd7d4c3cd-4ca2-416f-9aa2-fbc78434c032', N'<EMAIL>', N'<EMAIL>', N'<EMAIL>', N'<EMAIL>', 0, N'AQAAAAEAACcQAAAAEARZvIaBSHMS7pZGkLSs3DWhlLA0uu/yYhWkoaJZof+arJSwPkLWDEMVjOtSU6UPCQ==', N'JOJ4GOU744CQ5H7LXPCKUOY4C3FZSO3G', N'a3484f91-d2db-44a9-8162-3536d6e42cde', NULL, 0, 0, NULL, 1, 0);
|
CREATE TABLE "public"."student_final_signups"("student_id" integer NOT NULL, "final_id" integer NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("student_id","final_id") , FOREIGN KEY ("student_id") REFERENCES "public"."students"("id") ON UPDATE cascade ON DELETE cascade, FOREIGN KEY ("final_id") REFERENCES "public"."finals"("id") ON UPDATE cascade ON DELETE cascade);
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_student_final_signups_updated_at"
BEFORE UPDATE ON "public"."student_final_signups"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_student_final_signups_updated_at" ON "public"."student_final_signups"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';
|
<filename>IP and Scripts/Azure DW Load Scripts/Azure SQL DW Load Script Files/CTASLoad-Example.sql
/***This Artifact belongs to the Data Migration Jumpstart Engineering Team***/
-- STEP 1: Create a master key. Only necessary if one does not already exist.
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<PASSWORD>!';
GO
-- STEP 2: Create a database scoped credential
-- Azure Data Lake Credential
CREATE DATABASE SCOPED CREDENTIAL AzureCredential
WITH IDENTITY = '<AAD AppID>@https://login.microsoftonline.com/<subscriptionid>/oauth2/token',
SECRET = '<secret key>';
/* Blob Storage Credential
CREATE DATABASE SCOPED CREDENTIAL AzureCredential
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = 'your key here';
*/
-- STEP 3: Create an external data source - type HADOOP for ADLS
CREATE EXTERNAL DATA SOURCE AzureStorage
WITH (TYPE = HADOOP, LOCATION = 'adl://<adls name>.azuredatalakestore.net', CREDENTIAL = AzureCredential);
GO
/* Blob Storage Data Source - wabs syntax with Hadoop type
CREATE EXTERNAL DATA SOURCE AzureStorage
WITH (TYPE = HADOOP, LOCATION = 'wasbs://<EMAIL>.blob.core.windows.net',
CREDENTIAL = AzureCredential);
*/
-- STEP 4: Create an external file format
CREATE EXTERNAL FILE FORMAT TextFileFormat
WITH (FORMAT_TYPE = DELIMITEDTEXT, FORMAT_OPTIONS
(FIELD_TERMINATOR = '0x01', STRING_DELIMITER = '"', -- DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.fff',
USE_TYPE_DEFAULT = FALSE),
DATA_COMPRESSION = 'org.apache.hadoop.io.compress.GzipCodec'
);
GO
-- STEP 5: Create external table pointing to blob storage files
CREATE EXTERNAL TABLE [ext_ACCOUNT_FACT]
(
[ACCT_PK_ID] bigint NOT NULL,
[PERSON_PK_ID] bigint NOT NULL,
[SALES_PERSON_PK_ID] int NOT NULL,
[BATCH_ID] bigint NULL,
[START_TMSP] datetime NULL,
[END_TMSP] datetime NULL,
[ACCT_NAME] varchar(50) NULL,
[ACCT_FLAG] varchar(2) NULL,
[ACCT_STATUS] varchar(24) NULL,
[ACCT_STATUS_CHG_DATE] datetime NULL,
[ACCT_TYPE_CODE] varchar(30) NULL
)
WITH ( LOCATION='/data/test/', DATA_SOURCE = AzureStorage, FILE_FORMAT = TextFileFormat, REJECT_TYPE = VALUE, REJECT_VALUE = 0 );
GO
-- STEP 6: Create Table As Select (CTAS) operation - invokes Polybase to pull information out of one or more text files in ADLS into DW tables
-- note you need to split the input text files to take advantage of parallel load on the compute nodes
CREATE TABLE [POC_DM].[ACCOUNT_FACT]
WITH (DISTRIBUTION = HASH([ACCT_PK_ID]))
AS SELECT * FROM ext_ACCOUNT_FACT
OPTION (LABEL = 'CTAS : Load ACCOUNT_FACT');
GO
|
/*[[
Show current top activities
--[[
@ALIAS: TOP
@VERSION: 11.0={}
--]]
]]*/
-- db info
SET feed off digits 3
/* oratop s0a*/
PROMPT DB INFO:
PROMPT ========
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */*
FROM (SELECT sys_context('USERENV', 'DB_UNIQUE_NAME') dbnm FROM dual),
(SELECT NAME
FROM v$active_services
WHERE NAME = (SELECT SERVICE_NAME FROM v$session WHERE sid = (SELECT sys_context('USERENV', 'SID') FROM dual))
UNION ALL
SELECT 'SYS$USERS'
FROM DUAL
WHERE NOT EXISTS (SELECT NAME
FROM v$active_services
WHERE NAME = (SELECT SERVICE_NAME FROM v$session WHERE sid = (SELECT sys_context('USERENV', 'SID') FROM dual)))),
(SELECT to_number(SUBSTR(banner, 17, 2)) vers, SUBSTR(banner, 17, 3) cver FROM v$version WHERE substr(banner, 1, 3) = 'Ora'),
(SELECT SUBSTR(UPPER(VALUE), 1, 5) typd FROM v$parameter WHERE NAME = 'instance_type'),
(SELECT DECODE(VALUE, 'BASIC', 1, 0) stlv FROM v$parameter WHERE NAME = 'statistics_level'), (SELECT COUNT(*) dasm FROM v$asm_diskgroup);
-- memory configuration
/* oratop s1 */
PROMPT CONFIGURATION:
PROMPT ==============
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */ *
FROM (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
SUM(VALUE) taas
FROM gv$sysmetric
WHERE metric_name = 'Database Time Per Sec'
AND group_id = 3),
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
COUNT(*) sess, COUNT(DISTINCT username) duser
FROM gv$session
WHERE TYPE <> 'BACKGROUND'
AND username IS NOT NULL
AND SCHEMA# != 0),
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
to_char(MAX(end_time), 'hh24:mi:ss') dbts, SUM(VALUE) spga
FROM gv$sysmetric
WHERE metric_name = 'Total PGA Allocated'
AND group_id = 3), (SELECT (SYSDATE - startup_time) * 86400 uptm FROM v$instance),
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
SUM(VALUE) scpu, COUNT(DISTINCT inst_id) inst
FROM gv$osstat
WHERE stat_name = 'NUM_CPUS'),
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
SUM(VALUE) ssga
FROM gv$sga),
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
SUM(VALUE) prob
FROM GV$DIAG_INFO
WHERE NAME = 'Active Problem Count'),
(SELECT SUM(fra) reco FROM (SELECT SPACE_USED / GREATEST(SPACE_LIMIT, 1) * 100 fra FROM V$RECOVERY_FILE_DEST UNION SELECT 0 fra FROM dual)),
(SELECT initcap(substr(sys_context('USERENV', 'DATABASE_ROLE'), -7, 16)) dbro FROM dual),
(SELECT SUM(ar) dgar
FROM (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
sofar ar
FROM gv$recovery_progress
WHERE TYPE = 'Media Recovery'
AND ITEM = 'Active Apply Rate'
AND rownum = 1
UNION
SELECT 0 ar
FROM dual)),
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
MAX(VALUE) pgag
FROM gv$pgastat
WHERE NAME = 'aggregate PGA target parameter');
-- load details
/* oratop s2 */
PROMPT LOAD DETAILS:
PROMPT =============
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */
inid, hcpu, sgfr, utps, ucps, saas, mbps, ssrt, iorl, load, upga, aspq, dbcp, dbwa, iops, asct, isct, cpas, ioas, waas, dcpu, ncpu, logr, phyr, phyw,
temp, dbtm
FROM (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
inst_id inid, SUM(decode(metric_name, 'CPU Usage Per Sec', VALUE, 0)) dcpu,
SUM(decode(metric_name, 'Host CPU Utilization (%)', VALUE, 0)) hcpu, SUM(decode(metric_name, 'I/O Megabytes per Second', VALUE, 0)) mbps,
SUM(decode(metric_name, 'SQL Service Response Time', VALUE, 0)) ssrt,
SUM(decode(metric_name, 'Average Synchronous Single-Block Read Latency', VALUE, 0)) iorl,
SUM(decode(metric_name, 'Current OS Load', VALUE, 0)) load, SUM(decode(metric_name, 'Active Parallel Sessions', VALUE, 0)) aspq,
SUM(decode(metric_name, 'Database CPU Time Ratio', VALUE, 0)) dbcp, SUM(decode(metric_name, 'Database Wait Time Ratio', VALUE, 0)) dbwa,
SUM(decode(metric_name, 'I/O Requests per Second', VALUE, 0)) iops
FROM gv$sysmetric
WHERE metric_name IN ('CPU Usage Per Sec', 'Host CPU Utilization (%)', 'I/O Megabytes per Second', 'SQL Service Response Time',
'Average Synchronous Single-Block Read Latency', 'Current OS Load', 'Active Parallel Sessions', 'Database CPU Time Ratio',
'Database Wait Time Ratio', 'I/O Requests per Second')
AND group_id = 2
GROUP BY inst_id),
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
inst_id id1, SUM(decode(metric_name, 'Shared Pool Free %', VALUE, 0)) sgfr,
SUM(decode(metric_name, 'User Transaction Per Sec', VALUE, 0)) utps, SUM(decode(metric_name, 'User Calls Per Sec', VALUE, 0)) ucps,
SUM(decode(metric_name, 'Average Active Sessions', VALUE, 0)) saas, SUM(decode(metric_name, 'Total PGA Allocated', VALUE, 0)) upga,
SUM(decode(metric_name, 'Logical Reads Per Sec', VALUE, 0)) logr, SUM(decode(metric_name, 'Physical Reads Per Sec', VALUE, 0)) phyr,
SUM(decode(metric_name, 'Physical Writes Per Sec', VALUE, 0)) phyw, SUM(decode(metric_name, 'Temp Space Used', VALUE, 0)) temp,
SUM(decode(metric_name, 'Database Time Per Sec', VALUE, 0)) dbtm
FROM gv$sysmetric
WHERE metric_name IN
('Shared Pool Free %', 'User Transaction Per Sec', 'User Calls Per Sec', 'Logical Reads Per Sec', 'Physical Reads Per Sec',
'Physical Writes Per Sec', 'Temp Space Used', 'Database Time Per Sec', 'Average Active Sessions', 'Total PGA Allocated')
AND group_id = 3
GROUP BY inst_id),
(SELECT id2, SUM(asct) asct, SUM(isct) isct, SUM(cpas) cpas, SUM(ioas) ioas, SUM(waas) waas
FROM (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
inst_id id2, SUM(DECODE(status, 'ACTIVE', 1, 0)) asct, COUNT(*) isct, SUM(DECODE(status, 'ACTIVE', decode(WAIT_TIME, 0, 0, 1), 0)) cpas,
SUM(DECODE(status, 'ACTIVE', decode(wait_class, 'User I/O', 1, 0), 0)) ioas,
SUM(DECODE(status, 'ACTIVE', decode(WAIT_TIME, 0, decode(wait_class, 'User I/O', 0, 1), 0), 0)) waas
FROM gv$session
WHERE TYPE <> 'BACKGROUND'
AND username IS NOT NULL
AND SCHEMA# != 0
GROUP BY inst_id
UNION ALL
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
inst_id id2, 0 asct, 0 isct, 0 cpas, 0 ioas, 0 waas
FROM gv$instance)
GROUP BY id2),
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
inst_id id3, TO_NUMBER(VALUE) ncpu
FROM gv$osstat
WHERE stat_name = 'NUM_CPUS')
WHERE id1 = inid
AND id2 = inid
AND id3 = inid
AND ROWNUM <= 5
ORDER BY dbtm DESC;
-- event commulative
/* oratop s3a */
PROMPT EVENT COMMULATIVE:
PROMPT ==================
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */
event, totwa, twsec, avgms, ROUND(RATIO_TO_REPORT(twsec) OVER() * 100) pctwa, wclas, evtid
FROM (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
EVENT, SUM(TOTAL_WAITS) totwa, SUM(TIME_WAITED) / 100 twsec, AVG(AVERAGE_WAIT) * 10 avgms, WAIT_CLASS wclas, EVENT_ID evtid
FROM GV$SYSTEM_EVENT
WHERE WAIT_CLASS <> 'Idle'
GROUP BY EVENT, WAIT_CLASS, EVENT_ID
HAVING SUM(TOTAL_WAITS) > 0
UNION
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
'DB CPU' event, 0 totwa, SUM(VALUE) / 100 twsec, 0 avgms, NULL wclas, 19 evtid
FROM GV$SYSSTAT
WHERE NAME LIKE '%CPU used by this session%'
ORDER BY twsec DESC)
WHERE ROWNUM < 6;
-- event in realtime
/* oratop s3b */
PROMPT EVENT REAL-TIME:
PROMPT ================
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */
event, totwa, twsec, avgms, ROUND(RATIO_TO_REPORT(twsec) OVER() * 100) pctwa, wclas, evtid
FROM (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
SW.EVENT, SUM(SE.TOTAL_WAITS) totwa, SUM(SE.TIME_WAITED) / 100 twsec, SUM(SE.TIME_WAITED) / (GREATEST(SUM(SE.TOTAL_WAITS), 1) * 10) avgms,
SW.WAIT_CLASS wclas, SW.EVENT# evtid
FROM GV$SESSION_WAIT_CLASS SE
JOIN GV$SESSION SW
ON SE.INST_ID = SW.INST_ID
AND SE.SID = SW.SID
WHERE SE.wait_class != 'Idle'
AND SW.wait_class != 'Idle'
GROUP BY SW.EVENT, SW.WAIT_CLASS, SW.EVENT#
HAVING SUM(SE.TOTAL_WAITS) > 0
UNION
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
'DB CPU' event, 0 totwa, SUM(VALUE) / 100 twsec, 0 avgms, NULL wclas, 19 evtid
FROM GV$SESSTAT se
JOIN GV$SESSION s2
ON se.INST_ID = s2.INST_ID
AND se.SID = s2.SID
WHERE se.STATISTIC# = 19
AND se.value > 0
AND s2.wait_class != 'Idle'
ORDER BY twsec DESC)
WHERE ROWNUM < 6;
-- session details (file block)
/* oratop s4a */
PROMPT SESSION DETAILS FILE/BLOCK:
PROMPT ===========================
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */
s.WAIT_TIME trm4, s.inst_id id4, s.sid sid4, p.spid pid4, decode(p.BACKGROUND, 1, 'B/G', decode(s.username, NULL, 'F/G', s.username)) usr4,
decode(p.PNAME, NULL, s.program, p.PNAME) prg4, s.module modl, s.action actn, p.PGA_USED_MEM pgau, p.PGA_ALLOC_MEM pgac, p.PGA_FREEABLE_MEM pgaf,
x.pgax pgax, c.COMMAND_NAME opn, DECODE(s.PLSQL_SUBPROGRAM_ID, NULL, s.SQL_ID, NULL) sqid,
DECODE(s.FINAL_BLOCKING_SESSION_STATUS, 'VALID', to_char(s.FINAL_BLOCKING_INSTANCE) || ':' || to_char(s.FINAL_BLOCKING_SESSION), NULL) bses,
s.status st4, decode(s.state, 'WAITING', decode(s.wait_class, 'User I/O', 'I/O', s.state), 'CPU') su4,
CASE
WHEN s.STATE <> 'WAITING' AND s.TIME_SINCE_LAST_WAIT_MICRO < 1000000 THEN
'cpu runqueue'
ELSE
event
END ev4, s.wait_class wc4, s.WAIT_TIME_MICRO siw, s.last_call_et lcet, s.server sded, s.SERVICE_NAME svcn,
DECODE(n.name, NULL, NULL, '*' || n.name) lp2n,
DECODE(s.ROW_WAIT_OBJ#, -1, NULL, substr(to_char(s.ROW_WAIT_FILE#) || ':' || to_char(s.ROW_WAIT_BLOCK#), 1, 24)) fbon
FROM GV$SESSION s
JOIN gv$process p
ON (p.inst_id = s.inst_id AND p.addr = s.paddr)
LEFT OUTER JOIN v$sqlcommand c
ON (s.command = c.COMMAND_TYPE)
LEFT OUTER JOIN v$LATCHNAME n
ON (s.p2 = n.latch#), (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
inst_id, MAX(PGA_MAX_MEM) pgax
FROM GV$PROCESS
GROUP BY inst_id) x
WHERE x.inst_id = s.inst_id
AND s.wait_class <> 'Idle'
ORDER BY siw DESC, lcet DESC;
-- session details (detail)
/* oratop s4b */
PROMPT SESSION DETAILS:
PROMPT ================
WITH SQA AS
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */
INST_ID, PARSING_SCHEMA_NAME, MODULE, ACTION, SQL_ID, substr(SQL_TEXT, 1, 64) sql_text, EXECUTIONS, BUFFER_GETS, DISK_READS, ELAPSED_TIME, CPU_TIME,
USER_IO_WAIT_TIME, (CONCURRENCY_WAIT_TIME + CLUSTER_WAIT_TIME + APPLICATION_WAIT_TIME + PLSQL_EXEC_TIME + JAVA_EXEC_TIME) wait, ROWS_PROCESSED,
PX_SERVERS_EXECUTIONS, USERS_EXECUTING, (s.buffer_gets / GREATEST(s.disk_reads + s.buffer_gets, 1)) * 100 bhr
FROM GV$SQLAREA s
WHERE EXECUTIONS > 0
AND USERS_EXECUTING > 0
AND PARSING_USER_ID != 0
AND COMMAND_TYPE NOT IN (47, 170)
AND SQL_TEXT NOT LIKE '%oratop%')
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
*
FROM (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
INST_ID, PARSING_SCHEMA_NAME, MODULE, ACTION, SQL_ID, SQL_TEXT, EXECUTIONS, BUFFER_GETS, DISK_READS, ELAPSED_TIME, CPU_TIME, USER_IO_WAIT_TIME,
wait, ROWS_PROCESSED, PX_SERVERS_EXECUTIONS, USERS_EXECUTING, bhr
FROM SQA
WHERE PX_SERVERS_EXECUTIONS = 0
UNION
SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
x.INST_ID, x.PARSING_SCHEMA_NAME, x.MODULE, x.ACTION, x.SQL_ID, x.SQL_TEXT, x.EXECUTIONS, x.BUFFER_GETS, x.DISK_READS, x.ELAPSED_TIME,
x.CPU_TIME, x.USER_IO_WAIT_TIME, x.wait, x.ROWS_PROCESSED, x.PX_SERVERS_EXECUTIONS, x.USERS_EXECUTING, x.bhr
FROM (SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
INST_ID, PARSING_SCHEMA_NAME, MODULE, ACTION, SQL_ID, SQL_TEXT, EXECUTIONS, BUFFER_GETS, DISK_READS, ELAPSED_TIME, CPU_TIME,
USER_IO_WAIT_TIME, wait, ROWS_PROCESSED, PX_SERVERS_EXECUTIONS, USERS_EXECUTING, bhr
FROM SQA
WHERE PX_SERVERS_EXECUTIONS > 0) x,
(SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */
SQL_ID, MAX(USERS_EXECUTING) USERS_EXECUTING
FROM SQA
WHERE PX_SERVERS_EXECUTIONS > 0
GROUP BY SQL_ID) y
WHERE x.USERS_EXECUTING = y.USERS_EXECUTING
AND x.sql_id = y.sql_id)
ORDER BY ELAPSED_TIME / greatest(decode(PX_SERVERS_EXECUTIONS, 0, EXECUTIONS, PX_SERVERS_EXECUTIONS), 1) DESC;
-- sql plan
/* oratop s05*/
--PROMPT SQL PLAN
--WITH VPLAN as ( SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */ s1.INST_ID, s1.SQL_ID, p1.PLAN_HASH_VALUE, upper(rtrim(s1.sql_text)) text, MAX(p1.child_number) child_number from GV$SQL s1 JOIN GV$SQL_PLAN p1 on s1.inst_id=p1.inst_id and s1.sql_id=p1.sql_id and s1.child_number=p1.child_number and s1.ADDRESS=p1.ADDRESS and s1.hash_value=p1.hash_value and s1.PLAN_HASH_VALUE=p1.PLAN_HASH_VALUE where p1.SQL_ID= :sqlid and rownum = 1 group by s1.INST_ID, s1.SQL_ID, p1.PLAN_HASH_VALUE, s1.sql_text order by child_number desc ) SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ to_char(p.PLAN_HASH_VALUE), p.ID, substr(lpad(' ',p.depth) || p.operation || decode(p.options,NULL,'',' '|| p.options),1,80), substr(p.object_name,1,14), p.child_number, vp.text, p.cardinality, p.cost, (CASE when p.object_type like 'TABLE%' then t.STALE_STATS when p.object_type like 'INDEX%' then i.STALE_STATS else NULL end) from GV$SQL_PLAN p JOIN VPLAN vp on vp.inst_id=p.inst_id and vp.PLAN_HASH_VALUE=p.PLAN_HASH_VALUE and vp.sql_id=p.sql_id LEFT OUTER JOIN dba_tab_statistics t on t.table_name = p.object_name and t.owner= p.object_owner and t.partition_name is null and UPPER(p.object_type) not like '%TEMP%' LEFT OUTER JOIN dba_ind_statistics i on i.index_name = p.object_name and i.owner= p.object_owner and i.partition_name is null WHERE p.child_number = vp.child_number AND p.sql_id = vp.sql_id AND p.inst_id = vp.inst_id AND p.child_number = vp.child_number AND p.PLAN_HASH_VALUE = vp.PLAN_HASH_VALUE ORDER BY p.ID;
-- tablespace details
--/* oratop s06*/
-- PROMPT TABLESPACE DETAILS
--SELECT /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ /*+ NO_MONITOR */ d.tablespace_name tbsn, DECODE(d.contents,'UNDO', NVL(u.bytes, 0), NVL(a.bytes - NVL(f.bytes, 0), 0)) tbsu, d.status tbss, d.contents tbsc, d.extent_management tbse, d.segment_space_management tbsm, d.bigfile tbsf, d.LOGGING tbsl, d.RETENTION tbsr, d.ENCRYPTED tbsy, d.BLOCK_SIZE tbsb, NVL(a.count, 1) tbsi, a.maxb tbsz FROM sys.dba_tablespaces d, ( SELECT tablespace_name, SUM(bytes) bytes, SUM(maxbytes) maxb, COUNT(file_id) count from dba_data_files GROUP BY tablespace_name) a, ( select tablespace_name, sum(bytes) bytes from dba_free_space group by tablespace_name) f, ( SELECT tablespace_name, SUM(bytes) bytes FROM dba_undo_extents WHERE status IN ('ACTIVE','UNEXPIRED') GROUP BY tablespace_name) u WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+) AND d.tablespace_name = u.tablespace_name(+) AND NOT (d.extent_management = 'LOCAL' and d.contents = 'TEMPORARY') UNION ALL SELECT d.tablespace_name tbsn, NVL(t.bytes, 0) tbsu, d.status tbss, d.contents tbsc, d.extent_management tbse, d.segment_space_management tbsm, d.bigfile tbsf, d.LOGGING tbsl, d.RETENTION tbsr, d.ENCRYPTED tbsy, d.BLOCK_SIZE tbsb, NVL(a.count, 1) tbsi, a.maxb tbsz FROM sys.dba_tablespaces d, ( select tablespace_name, sum(bytes) bytes, SUM(maxbytes) maxb, count(file_id) count from dba_temp_files group by tablespace_name) a, ( select /*+ OPT_PARAM('_optimizer_adaptive_plans','false') */ ss.tablespace_name , sum((ss.used_blocks*ts.blocksize)) bytes from gv$sort_segment ss, sys.ts$ ts where ss.tablespace_name = ts.name group by ss.tablespace_name) t WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = t.tablespace_name(+) AND d.extent_management ='LOCAL' AND d.contents = 'TEMPORARY' ORDER BY 1;
|
<gh_stars>10-100
CREATE TABLE Minions
(
Id int PRIMARY KEY,
[Name] nvarchar(50),
Age int
)
CREATE TABLE Towns
(
Id int PRIMARY KEY,
[Name] nvarchar(50),
)
|
-- file:subscription.sql ln:66 expect:true
ALTER SUBSCRIPTION testsub SET (slot_name = 'newname')
|
<filename>Tools/Collect-QueryInfo/SQL/02.バッチ実行数/Result.sql
SELECT
*
FROM
(
SELECT
server_name,
db_name,
DATEADD(HOUR, 9, collect_date) AS [time],
counter_name,
FORMAT(
COALESCE((cntr_value - LAG(cntr_value) OVER(PARTITION BY server_name, object_name, counter_name,instance_name ORDER BY collect_date ASC)) * 1.0 /
DATEDIFF(SECOND,
DATEADD(HOUR, 9, LAG(collect_date) OVER(PARTITION BY server_name, object_name, counter_name,instance_name ORDER BY collect_date ASC)),
DATEADD(HOUR, 9, collect_date)
), 0)
, '#,##0.#0') AS cntr_value_diff
FROM
[01_BatchResp]
WHERE
object_name LIKE '%Batch Resp Statistics%'
AND
instance_name = 'Elapsed Time:Requests'
UNION
SELECT
server_name,
db_name,
DATEADD(HOUR, 9, collect_date) AS [time],
counter_name,
FORMAT(
COALESCE((cntr_value - LAG(cntr_value) OVER(PARTITION BY server_name, object_name, counter_name,instance_name ORDER BY collect_date ASC)) * 1.0 /
DATEDIFF(SECOND,
DATEADD(HOUR, 9, LAG(collect_date) OVER(PARTITION BY server_name, object_name, counter_name,instance_name ORDER BY collect_date ASC)),
DATEADD(HOUR, 9, collect_date)
), 0)
, '#,##0.#0') AS cntr_value_diff
FROM
[01_BatchResp]
WHERE
counter_name = 'Batch Requests/sec'
) AS T
PIVOT
(MAX(cntr_value_diff) FOR counter_name IN(
[Batch Requests/sec],
[Batches >=000000ms & <000001ms],
[Batches >=000001ms & <000002ms],
[Batches >=000002ms & <000005ms],
[Batches >=000005ms & <000010ms],
[Batches >=000010ms & <000020ms],
[Batches >=000020ms & <000050ms],
[Batches >=000050ms & <000100ms],
[Batches >=000100ms & <000200ms],
[Batches >=000200ms & <000500ms],
[Batches >=000500ms & <001000ms],
[Batches >=001000ms & <002000ms],
[Batches >=002000ms & <005000ms],
[Batches >=005000ms & <010000ms],
[Batches >=010000ms & <020000ms],
[Batches >=020000ms & <050000ms],
[Batches >=050000ms & <100000ms],
[Batches >=100000ms])
)
AS P
ORDER BY [time] ASC
|
<reponame>Syscrystal007/library<gh_stars>0
CREATE DATABASE library;
USE library;
SET NAMES utf8;
START TRANSACTION;
CREATE TABLE `admin` ( `admin_id` BIGINT NOT NULL PRIMARY KEY, `password` VARCHAR ( 15 ) NOT NULL, `username` VARCHAR ( 15 ) DEFAULT NULL ) ENGINE = INNODB DEFAULT CHARSET = utf8;
INSERT INTO `admin`
VALUES
( 123456, '123456', 'admin' );
CREATE TABLE `book_info` (
`book_id` BIGINT NOT NULL PRIMARY KEY,
`name` VARCHAR ( 20 ) NOT NULL,
`author` VARCHAR ( 15 ) NOT NULL,
`publish` VARCHAR ( 20 ) NOT NULL,
`ISBN` VARCHAR ( 15 ) NOT NULL,
`introduction` text,
`language` VARCHAR ( 4 ) NOT NULL,
`price` DECIMAL ( 10, 2 ) NOT NULL,
`pub_date` date NOT NULL,
`class_id` INT DEFAULT NULL,
`number` INT DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = utf8;
ALTER TABLE `book_info` MODIFY `book_id` BIGINT NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT = 1;
INSERT INTO `book_info`
VALUES
( 1, '大雪中的山庄', '东野圭吾 ', '北京十月文艺出版社', '9787530216835', '东野圭吾长篇小说杰作,中文简体首次出版。 一出没有剧本的舞台剧,为什么能让七个演员赌上全部人生.东野圭吾就是有这样过人的本领,能从充满悬念的案子写出荡气回肠的情感,在极其周密曲折的同时写出人性的黑暗与美丽。 一家与外界隔绝的民宿里,七个演员被要求住满四天,接受导演的考验,但不断有人失踪。难道这并非正常排练,而是有人布下陷阱要杀他们。 那时候我开始喜欢上戏剧和音乐,《大雪中的山庄》一书的灵感就来源于此。我相信这次的诡计肯定会让人大吃一惊。——东野圭吾', '中文', '35.00', '2017-06-01', 9, 1 ),
( 2, '三生三世 十里桃花', '唐七公子 ', '沈阳出版社', '9787544138000', '三生三世,她和他,是否注定背负一段纠缠的姻缘?\r\n三生三世,她和他,是否终能互许一个生生世世的承诺?', '中文', '26.80', '2009-01-06', 7, 1 ),
( 3, '何以笙箫默', '顾漫 ', '朝华出版社', '9787505414709', '一段年少时的爱恋,牵出一生的纠缠。大学时代的赵默笙阳光灿烂,对法学系大才子何以琛一见倾心,开朗直率的她拔足倒追,终于使才气出众的他为她停留驻足。然而,不善表达的他终于使她在一次伤心之下远走他乡……', '中文', '15.00', '2007-04-03', 7, 1 ),
( 4, '11处特工皇妃', '潇湘冬儿', '江苏文艺出版社', '9787539943893', '《11处特工皇妃(套装上中下册)》内容简介:她是国安局军情十一处惊才绝艳的王牌军师——收集情报、策划部署、进不友好国家布置暗杀任务……她运筹帷幄之中,决胜于千里之外,堪称军情局大厦的定海神针。', '中文', '74.80', '2011-05-05', 7, 1 ),
( 5, '人类简史', '[以色列] 尤瓦尔·赫拉利 ', '中信出版社', '9787508647357', '十万年前,地球上至少有六种不同的人\r\n但今日,世界舞台为什么只剩下了我们自己?\r\n从只能啃食虎狼吃剩的残骨的猿人,到跃居食物链顶端的智人,\r\n从雪维洞穴壁上的原始人手印,到阿姆斯壮踩上月球的脚印,\r\n从认知革命、农业革命,到科学革命、生物科技革命,\r\n我们如何登上世界舞台成为万物之灵的?\r\n从公元前1776年的《汉摩拉比法典》,到1776年的美国独立宣言,\r\n从帝国主义、资本主义,到自由主义、消费主义,\r\n从兽欲,到物欲,从兽性、人性,到神性,\r\n我们了解自己吗?我们过得更快乐吗?\r\n我们究竟希望自己得到什么、变成什么?', '英文', '68.00', '2014-11-01', 11, 1 ),
( 6, '明朝那些事儿(1-9)', '当年明月 ', '中国海关出版社', '9787801656087', '《明朝那些事儿》讲述从1344年到1644年,明朝三百年间的历史。作品以史料为基础,以年代和具体人物为主线,运用小说的笔法,对明朝十七帝和其他王公权贵和小人物的命运进行全景展示,尤其对官场政治、战争、帝王心术着墨最多。作品也是一部明朝政治经济制度、人伦道德的演义。', '中文', '358.20', '2009-04-06', 11, 1 ),
( 7, '经济学原理(上下)', '[美] 曼昆 ', '机械工业出版社', '9787111126768', '此《经济学原理》的第3版把较多篇幅用于应用与政策,较少篇幅用于正规的经济理论。书中主要从供给与需求、企业行为与消费者选择理论、长期经济增长与短期经济波动以及宏观经济政策等角度深入浅出地剖析了经济学家们的世界观。', '英文', '88.00', '2003-08-05', 6, 1 ),
( 8, '方向', '马克-安托万·马修 ', '后浪丨北京联合出版公司', '9787020125265', '《方向》即便在马修的作品中也算得最独特的:不着一字,尽得风流。原作本无一字,标题只是一个→,出版时才加了个书名Sens——既可以指“方向”,也可以指“意义”。 《方向》没有“字”,但有自己的语言——请读者在尽情释放想象力和独立思考之余,破解作者的密码,听听作者对荒诞的看法。', '中文', '99.80', '2017-04-01', 9, 1 ),
( 9, '画的秘密', '马克-安托万·马修 ', '北京联合出版公司·后浪出版公司', '9787550265608', '一本关于友情的疗伤图像小说,直击人内心最为隐秘的情感。 一部追寻艺术的纸上悬疑电影,揭示命运宇宙中奇诡的真相。 ★ 《画的秘密》荣获欧洲第二大漫画节“瑞士谢尔漫画节最佳作品奖”。 作者曾两度夺得安古兰国际漫画节重要奖项。 ★ 《画的秘密》是一部罕见的、结合了拼贴、镜像、3D等叙事手法的实验型漫画作品。作者巧妙地调度光线、纬度、时间、记忆,在一个悬念重重又温情治愈的故事中,注入了一个有关命运的哲学议题。', '中文', '60.00', '2016-01-01', 9, 0 ),
( 10, '造彩虹的人', '东野圭吾 ', '北京十月文艺出版社', '9787530216859', '其实每个人身上都会发光,但只有纯粹渴求光芒的人才能看到。 从那一刻起,人生会发生奇妙的转折。功一高中退学后无所事事,加入暴走族消极度日;政史备战高考却无法集中精神,几近崩溃;辉美因家庭不和对生活失去勇气,决定自杀。面对糟糕的人生,他们无所适从,直到一天夜里,一道如同彩虹的光闯进视野。 凝视着那道光,原本几乎要耗尽的气力,源源不断地涌了出来。一切又开始充满希望。打起精神来,不能输。到这儿来呀,快来呀——那道光低声呼唤着。 他们追逐着呼唤,到达一座楼顶,看到一个人正用七彩绚烂的光束演奏出奇妙的旋律。 他们没想到,这一晚看到的彩虹,会让自己的人生彻底转...', '中文', '39.50', '2017-06-01', 9, 1 ),
( 11, '控方证人', '阿加莎·克里斯蒂 ', '新星出版社', '9787513325745', '经典同名话剧六十年常演不衰; 比利•怀尔德执导同名电影,获奥斯卡金像奖六项提名! 阿加莎对神秘事物的向往大约来自于一种女性祖先的遗传,在足不出户的生活里,生出对世界又好奇又恐惧的幻想。 ——王安忆 伦纳德•沃尔被控谋杀富婆艾米丽以图染指其巨额遗产,他却一再表明自己的无辜。伦纳德的妻子是唯一能够证明他无罪的证人,却以控方证人的身份出庭指证其确实犯有谋杀罪。伦纳德几乎陷入绝境,直到一个神秘女人的出现…… 墙上的犬形图案;召唤死亡的收音机;蓝色瓷罐的秘密;一只疯狂的灰猫……十一篇神秘的怪谈,最可怕的不是“幽灵”,而是你心中的魔鬼。', '中文', '35.00', '2017-05-01', 9, 1 ),
( 12, '少有人走的路', 'M·斯科特·派克 ', '吉林文史出版社', '9787807023777', '这本书处处透露出沟通与理解的意味,它跨越时代限制,帮助我们探索爱的本质,引导我们过上崭新,宁静而丰富的生活;它帮助我们学习爱,也学习独立;它教诲我们成为更称职的、更有理解心的父母。归根到底,它告诉我们怎样找到真正的自我。 正如开篇所言:人生苦难重重。M·斯科特·派克让我们更加清楚:人生是一场艰辛之旅,心智成熟的旅程相当漫长。但是,他没有让我们感到恐惧,相反,他带领我们去经历一系列艰难乃至痛苦的转变,最终达到自我认知的更高境界。', '中文', '26.00', '2007-01-01', 9, 1 ),
( 13, '追寻生命的意义', '[奥] 维克多·弗兰克 ', '新华出版社', '9787501162734', '《追寻生命的意义》是一个人面对巨大的苦难时,用来拯救自己的内在世界,同时也是一个关于每个人存在的价值和能者多劳们生存的社会所应担负职责的思考。本书对于每一个想要了解我们这个时代的人来说,都是一部必不可少的读物。这是一部令人鼓舞的杰作……他是一个不可思议的人,任何人都可以从他无比痛苦的经历中,获得拯救自己的经验……高度推荐。', '中文', '12.00', '2003-01-01', 9, 0 ),
( 14, '秘密花园', '乔汉娜·贝斯福 ', '北京联合出版公司', '9787550252585', '欢迎来到秘密花园! 在这个笔墨编织出的美丽世界中漫步吧 涂上你喜爱的颜色,为花园带来生机和活力 发现隐藏其中的各类小生物,与它们共舞 激活创造力,描绘那些未完成的仙踪秘境 各个年龄段的艺术家和“园丁”都可以来尝试喔!', '中文', '42.00', '2015-06-01', 9, 1 );
CREATE TABLE `class_info` ( `class_id` INT NOT NULL PRIMARY KEY, `class_name` VARCHAR ( 15 ) NOT NULL ) ENGINE = INNODB DEFAULT CHARSET = utf8;
INSERT INTO `class_info`
VALUES
( 1, '马克思主义' ),
( 2, '哲学' ),
( 3, '社会科学总论' ),
( 4, '政治法律' ),
( 5, '军事' ),
( 6, '经济' ),
( 7, '文化' ),
( 8, '语言' ),
( 9, '文学' ),
( 10, '艺术' ),
( 11, '历史地理' ),
( 12, '自然科学总论' ),
( 13, ' 数理科学和化学' ),
( 14, '天文学、地球科学' ),
( 15, '生物科学' ),
( 16, '医药、卫生' ),
( 17, '农业科学' ),
( 18, '工业技术' ),
( 19, '交通运输' ),
( 20, '航空、航天' ),
( 21, '环境科学' ),
( 22, '综合' );
CREATE TABLE `lend_list` (
`ser_num` BIGINT NOT NULL PRIMARY KEY,
`book_id` BIGINT NOT NULL,
`reader_id` BIGINT NOT NULL,
`lend_date` date DEFAULT NULL,
`back_date` date DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = utf8;
ALTER TABLE `lend_list` MODIFY `ser_num` BIGINT NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT = 1;
INSERT INTO `lend_list`
VALUES
( 1, 1, 10000, '2017-03-15', '2017-06-16' ),
( 2, 2, 10001, '2017-06-10', '2017-09-02' ),
( 3, 3, 10003, '2017-06-12', '2017-09-02' ),
( 4, 4, 10000, '2017-03-15', '2017-09-03' ),
( 5, 5, 10002, '2017-06-15', NULL ),
( 6, 6, 10000, '2017-06-15', NULL ),
( 7, 1, 10001, '2017-09-02', '2017-09-02' );
CREATE TABLE `reader_info` (
`reader_id` BIGINT NOT NULL PRIMARY KEY,
`name` VARCHAR ( 10 ) NOT NULL,
`sex` VARCHAR ( 2 ) NOT NULL,
`birth` date NOT NULL,
`address` VARCHAR ( 50 ) NOT NULL,
`phone` VARCHAR ( 15 ) NOT NULL
) ENGINE = INNODB DEFAULT CHARSET = utf8;
ALTER TABLE `reader_info` MODIFY `reader_id` BIGINT NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT = 10000;
INSERT INTO `reader_info` ( NAME, sex, birth, address, phone )
VALUES
( '张华', '男', '1995-06-10', '天津市', '12345678900' ),
( '王小伟', '男', '1996-02-01', '北京市', '12345678909' ),
( '王莞尔', '女', '1995-04-15', '浙江省杭州市', '12345678908' ),
( '张明华', '男', '1996-08-29', '陕西省西安市', '12345678907' ),
( '李一琛', '男', '1996-01-01', '陕西省西安市', '15123659875' ),
( '李二飞', '男', '1996-05-03', '山东省青岛市', '15369874123' );
CREATE TABLE `reader_card` ( `reader_id` BIGINT NOT NULL PRIMARY KEY, `username` VARCHAR ( 15 ) NOT NULL, `password` VARCHAR ( 15 ) NOT NULL ) ENGINE = INNODB DEFAULT CHARSET = utf8;
INSERT INTO `reader_card`
VALUES
( 10000, '张华', '123456' ),
( 10001, '王小伟', '123456' ),
( 10002, '王莞尔', '123456' ),
( 10003, '张明华', '123456' ),
( 10004, '李一琛', '123456' ),
( 10005, '李二飞', '123456' );
COMMIT;
|
<reponame>bitapihub/api-optimization-engine
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
INSERT INTO `sjrv_accounts` (`id`, `consumer_key`, `consumer_secret`, `access_level`, `max_calls`, `reset_usage`, `free_account_on`, `can_run_inactive`, `acl_type`, `link_back`, `js_calls_allowed`, `store_credentials`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, '<KEY>', '<KEY>', 3, 0, 0, 0, 0, 1, 0, 0, 1, 1427132473, 1428799343, NULL);
INSERT INTO `sjrv_apis` (`id`, `account_id`, `name`, `min_access_level`, `active_level`, `private`, `secret`, `force_validation`, `allow_custom_dynamic`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 0, 'custom', 3, 1, 0, '<KEY>', 0, 1, 0, 0, NULL),
(2, 0, 'dummy', 1, 1, 0, 'Qc_-s-HEgAnSG-URkkuCsqYA9o9nqNBkfy22HxWrnX0x2ySm_KeqJUE9HVSUEeOecGtiNnYxbVEyZ2hDbjRiaUtFbXJjSkR2Y2EtbXRaS0dXUkNtV1MwZ0x1NA', 0, 1, 0, 0, NULL),
(3, 0, 'blockchain', 1, 1, 0, 'GRnwiIR2mZ57o7DUZ_GDtT16iRJiY9VV6ty5T8myF31nFShfn5ufCvrqJYu-FFKMNDhwLWZEN0EwOGtUblZxVDMwMlRzVGlqYTRKWERJWjJhRXJWMXZPOTdBcw', 0, 1, 0, 1436552130, NULL),
(4, 0, 'weather', 2, 1, 0, '<KEY>', 0, 1, 0, 1436552130, NULL);
INSERT INTO `sjrv_apis_metadata` (`id`, `apis_id`, `key`, `value`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 2, 'raml', '#%RAML 0.8\r\ntitle: Amazon simple storage API\r\nversion: 1\r\nbaseUri: https://api.twitter.com/1.1\r\nprotocols: [HTTP, HTTPS]\r\nbaseUriParameters:\r\n destinationBucket:\r\n description: ''My big "e;ol description.''\r\n enum: [''test'']\r\nlimits:\r\n level1:\r\n day: 50\r\n month: 1000\r\n level2:\r\n minute: 5\r\n month: 250000\r\nresourceTypes:\r\n - searchableCollection:\r\n get:\r\n queryParameters:\r\n <<queryParamName>>:\r\n description: Return <<resourcePathName>> that have their <<queryParamName>> matching the given value\r\n <<fallbackParamName>>:\r\n description: If no values match the value given for <<queryParamName>>, use <<fallbackParamName>> instead\r\nsecuritySchemes:\r\n basic:\r\n description: Use HTTP Basic Access Authentication for authentication.\r\n type: Basic Authorization\r\n describedBy:\r\n headers:\r\n Authorization:\r\n description: The Authorization header as described in rfc1945 section 11.1\r\n type: string\r\n digest:\r\n description: Use HTTP Digest Access Authentication for authentication.\r\n type: Digest Authentication\r\n describedBy:\r\n headers:\r\n Authorization:\r\n description: The Authorization header as described in rfc2069 or rfc2617\r\n type: string\r\n settings:\r\n realm: ''<EMAIL>''\r\n qop: ''auth''\r\n opaque: ''5ccc069c403ebaf9f0171e9517f40e41''\r\n custom:\r\n description: Test merging with all methods\r\n type: x-custom\r\n describedBy:\r\n headers:\r\n Authorization:\r\n description: Used to send a valid OAuth 2 access token. Do not use with the "access_token" query string parameter.\r\n type: string\r\n default: ''test''\r\n Authorization2:\r\n description: Used to send a valid OAuth 2 access token. Do not use with the "access_token" query string parameter.\r\n type: string\r\n default: ''test''\r\n queryParameters:\r\n access_token-cust:\r\n description: Used to send a valid OAuth 2 access token. Do not use together with the "Authorization" header\r\n type: string\r\n default: ''test''\r\n body:\r\n application/json:\r\n example: |\r\n {"test":"here"}\r\n settings:\r\n method: post\r\n url: https://api.twitter.com/oauth/request_token\r\n oauth_2_0:\r\n description: Dropbox supports OAuth 2.0 for authenticating all API requests.\r\n type: OAuth 2.0\r\n describedBy:\r\n headers:\r\n Authorization:\r\n description: Used to send a valid OAuth 2 access token. Do not use with the "access_token" query string parameter.\r\n type: string\r\n queryParameters:\r\n access_token:\r\n description: Used to send a valid OAuth 2 access token. Do not use together with the "Authorization" header\r\n type: string\r\n body:\r\n multipart/form-data:\r\n formParameters:\r\n key1:\r\n description: Your API key\r\n type: string\r\n responses:\r\n 401:\r\n description: Bad or expired token. This can happen if the user or Dropbox revoked or expired an access token. To fix, you should re-authenticate the user.\r\n 403:\r\n description: Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). Unfortunately, re-authenticating the user won''t help here.\r\n settings:\r\n scopeType: space\r\n scopes: [''https://www.googleapis.com/auth/plus.login'', ''https://www.googleapis.com/auth/plus.me'']\r\n expiresType: none\r\n tokenType: bearer\r\n authorizeLocation: header\r\n authorizationUri: https://accounts.google.com/o/oauth2/auth\r\n accessTokenUri: https://accounts.google.com/o/oauth2/token\r\n authorizationGrants: [ code ]\r\n oauth_1_0a:\r\n description: OAuth 1.0a continues to be supported for all API requests, but OAuth 2.0 is now preferred.\r\n type: OAuth 1.0\r\n settings:\r\n legs: 3\r\n callback: oob\r\n signatureMethod: HMAC-SHA1\r\n authorizeLocation: header\r\n requestTokenMethod: POST\r\n requestTokenUri: https://api.twitter.com/oauth/request_token\r\n authorizationUri: https://api.twitter.com/oauth/authorize\r\n tokenCredentialsMethod: POST\r\n tokenCredentialsUri: https://api.twitter.com/oauth/access_token\r\n/{{static-calls}}:\r\n /fakecall:\r\n stability: 1\r\n description: ''Define your static call here.''\r\n /statuses/mentions_timeline.json:\r\n get:\r\n securedBy: [oauth_1_0a]\r\n/oauth/example/echo_api.php:\r\n displayName: retrieve all users\r\n baseUriParameters:\r\n destinationBucket:\r\n enum: [ "static" ]\r\n get:\r\n securedBy: [oauth_1_0a]\r\n displayName: retrieve a user''s picture\r\n queryParameters:\r\n file:\r\n description: ''My qdesk''\r\n default: ''vacation.jpg''\r\n size:\r\n description: ''My qdesk2''\r\n default: ''original''\r\n/:\r\n post:\r\n description: The POST operation adds an object to a specified bucket using HTML forms.\r\n body:\r\n application/x-www-form-urlencoded:\r\n formParameters:\r\n AWSAccessKeyId:\r\n description: The AWS Access Key ID of the owner of the bucket who grants an Anonymous user access for a request that satisfies the set of constraints in the Policy.\r\n type: string\r\n acl:\r\n description: Specifies an Amazon S3 access control list. If an invalid access control list is specified, an error is generated.\r\n type: string\r\n file:\r\n - type: string\r\n description: Text content. The text content must be the last field in the form.\r\n - type: file\r\n description: File to upload. The file must be the last field in the form.', 0, 0, NULL),
(2, 3, 'raml', '#%RAML 0.8\r\ntitle: Blockchain.info Simple Query API\r\nversion: 1\r\nbaseUri: https://blockchain.info/q\r\nprotocols: [HTTPS]\r\ntraits:\r\n - secured:\r\n queryParameters:\r\n api_code:\r\n description: Used to avoid API limits imposed by Blockchain.info\r\n type: string\r\n default: ''my-key''\r\n/{{static-calls}}:\r\n /getdifficulty:\r\n stability: 1\r\n description: ''Get the Bitcoin blockchain difficulty.''\r\n /getdifficulty:\r\n get:\r\n is: [secured]', 0, 0, NULL),
(3, 4, 'raml', '#%RAML 0.8\r\ntitle: Weather.com API\r\nversion: 2\r\nbaseUri: http://wxdata.weather.com\r\nprotocols: [HTTP]\r\nlimits:\r\n level1:\r\n day: 50\r\n month: 1000\r\n level2:\r\n minute: 5\r\n month: 250000\r\n/wxdata/weather/local/{zip}:\r\n description: ''Pull local weather data''\r\n get:\r\n queryParameters:\r\n cc:\r\n description: ''Pull the current conditions information''\r\n type: string\r\n default: ''*''\r\n unit:\r\n description: ''The unit of temperature measurement''\r\n type: string\r\n maxLength: 1\r\n minLength: 1\r\n default: ''F''\r\n dayf:\r\n description: ''The number of days to forecast''\r\n type: integer\r\n maximum: 10\r\n minimum: 1\r\n default: 1', 0, 0, NULL),
(4, 1, 'raml', '#%RAML 0.8\r\ntitle: Custom API Calls\r\nversion: 1\r\nprotocols: [HTTP,HTTPS]', 0, 0, NULL);
INSERT INTO `sjrv_data_calls` (`id`, `account_id`, `name`, `call_script`, `active_level`, `min_access_level`, `created_at`, `updated_at`, `deleted_at`) VALUES
(2, 0, 'testing', '{"0":{"api":"blockchain","static-call":"getdifficulty"},"1":{"api":"weather","configure":{"uri":"\\/wxdata\\/weather\\/local\\/44136","method":"get","query":{"cc":"*","unit":"F","dayf":5}}},"template":{"variables":{"<<GET_DIFFICULTY>>":"blockchain.0.response.body","<<HIGH_TEMP>>":"weather.0.response.body.dayf.day.0.hi"},"css":"","body":"<p>I''m part of the Data Call <b>template data<\\/b>. You can dynamicallygenerate content for your site with templates and variables. Let''s take a gander.<\\/p><p>You see, thegander''s goose loves the small town life, but the gander wishes to fly to Silicone Valley to be a hugesuccess with his new high tech wing booster invention. He already has investors on board who wish to seehis invention boost the flight speed of every goose and gander in the world. If the gander concedes tostay with his goose in their small town, he may find it a bit more difficult to find customers. However,if we take the gander to Silicone Vally, the goose will be very upset. So, what''s good for the goosemight not be good for the gander. Wahh, Wahh... :)<\\/p><p>In other news, below is the output of the Data Call request to BlockChain''s \\"getdifficulty\\" staticcall. It''s shown using a variable, for instance <code><<Variable>><\\/code> or<code>{{Variable}}<\\/code> can signify the place in your template where a variable''s value should go.<\\/p><p>getdifficulty: <<GET_DIFFICULTY>><\\/p><p>Here''s the output for the high temperature for today in Strongsville, OH, our CEO''s home town.<\\/p>High temperature today in fahrenheit: <<HIGH_TEMP>><\\/p>","js":""}}', 1, 3, 0, 0, NULL),
(1, 0, 'custom', '', 1, 3, 0, 0, NULL);
|
<gh_stars>0
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
-- =============================================
-- Responsable: <NAME>
-- Ultima Modificación: 2018-07-18
-- Descripción: Obtener Seguridad por Usuario y Modulo
-- =============================================
CREATE FUNCTION [CNF].[fnSeguridadUsuarioModuloObtener]
(
@Usuario AS VARCHAR(15),
@CveModulo AS VARCHAR(15)
)
RETURNS VARCHAR(20)
AS
BEGIN
DECLARE @Resultado AS VARCHAR(20);
SELECT @Resultado = (CASE
WHEN s.IsConfiguracion = 1 THEN
'Configurar'
WHEN s.IsEdicion = 1 THEN
'Editar'
WHEN s.IsLectura = 1 THEN
'Lectura'
ELSE
'SinAcceso'
END
)
FROM CNF.Seguridad AS s
INNER JOIN CNF.Modulos AS m
ON m.IdModulo = s.IdModulo
INNER JOIN CNF.Perfiles AS p
ON p.IdPerfil = s.IdPerfil
AND p.IsActivo = 1
WHERE p.Perfil = CNF.fnPerfilUsuarioObtener(@Usuario)
AND m.CveModulo = @CveModulo;
IF @Resultado IS NULL
BEGIN
SELECT @Resultado = 'SinAcceso';
END;
RETURN @Resultado;
END;
GO
|
<gh_stars>0
CREATE TABLE ?SCHEMA?.XMLCUSTOMER
(
CID INT NOT NULL PRIMARY KEY,
INFO XML
);
INSERT
INTO ?SCHEMA?.XMLCUSTOMER VALUES
(
1000,
XMLPARSE (DOCUMENT '<?xml version="1.0" encoding="UTF-8" ?><customerinfo>
<name><NAME></name>
<addr country="United States">
<street>555 Bailey Ave</street>
<city>San Jose</city>
<prov-state>California</prov-state>
<pcode-zip>95141</pcode-zip>
</addr>
<phone type="work">408-555-1358</phone>
</customerinfo>' PRESERVE WHITESPACE)
)
,
(
1001,
XMLPARSE (DOCUMENT '<?xml version="1.0" encoding="UTF-8" ?><customerinfo>
<name><NAME></name>
<addr country="Canada">
<street>25 EastCreek</street>
<city>Toronto</city>
<prov-state>Ontario</prov-state>
<pcode-zip>M8X-3T6</pcode-zip>
</addr>
<phone type="work">416-555-1358</phone>
</customerinfo> ' PRESERVE WHITESPACE)
)
,
(
1002,
XMLPARSE (DOCUMENT '<?xml version="1.0" encoding="UTF-8" ?><customerinfo>
<name><NAME></name>
<addr country="Canada">
<street>25 EastCreek</street>
<city>Markham</city>
<prov-state>Ontario</prov-state>
<pcode-zip>N9C-3T6</pcode-zip>
</addr>
<phone type="work">905-555-7258</phone>
</customerinfo>' PRESERVE WHITESPACE)
)
,
(
1003,
XMLPARSE (DOCUMENT '<?xml version="1.0" encoding="UTF-8" ?><customerinfo>
<name><NAME></name>
<addr country="United States">
<street>555 Bailey Ave</street>
<city>San Jose</city>
<prov-state>California</prov-state>
<pcode-zip>95141</pcode-zip>
</addr>
<phone type="work">408-555-7258</phone>
<phone type="home">416-555-2937</phone>
<phone type="cell">905-555-8743</phone>
<phone type="cottage">613-555-3278</phone>
</customerinfo>' PRESERVE WHITESPACE)
)
,
(
1004,
XMLPARSE (DOCUMENT '<?xml version="1.0" encoding="UTF-8" ?><customerinfo>
<name><NAME> Inc.</name>
<addr country="Canada">
<street>1 Young Strett</street>
<city>Toronto</city>
<prov-state>Ontario</prov-state>
<pcode-zip>M5W-IE6</pcode-zip>
</addr>
<phone type="work">416-555-7845</phone>
</customerinfo>' PRESERVE WHITESPACE)
);
CREATE TABLE ?SCHEMA?.XMLPRODUCT
(
PID INT NOT NULL PRIMARY KEY,
DESCRIPTION XML
);
INSERT
INTO ?SCHEMA?.XMLPRODUCT VALUES
(
1000,
XMLPARSE (DOCUMENT '<product pid="100-101-01">
<description>
<name>Sterling Silver Sugar & Creamer by Poole</name>
<details>
Spectacular sugar and creamer set made of heavy, hand chased sterling
silver by Poole "Old English" with superb details; very ornate; body and
handles have a repousse and scroll pattern; sugar bowl with a lid
</details>
<price currency="us">350.00</price>
<weight units="lb">1.3</weight>
<size units="inches">
creamer height 4.5, spout to handle width 5; sugar
height 6, width handle to handle 6 inches
</size>
<brand>Poole</brand>
<category catx="sterling" caty="">Sugar & Creamer</category>
<images>
<image type="thumbnail" alias="">1a</image>
<image type="full" alias="">1a</image>
<image type="full" alias="">1b</image>
<image type="full" alias="">1c</image>
<image type="full" alias="">1d</image>
</images>
</description>
</product>' PRESERVE WHITESPACE)
)
,
(
1001,
XMLPARSE (DOCUMENT '<product pid="180-131-01">
<description>
<name>Red Lamp</name>
<details>
Lovely Red Lamp.
</details>
<price currency="us">1350.00</price>
<weight units="lb">4.3</weight>
<size units="inches">
12 inches tall
</size>
<brand>Lamparama</brand>
<category catx="lamps" caty="">Lamps</category>
<images>
<image type="thumbnail" alias="">1a</image>
<image type="full" alias="">1a</image>
<image type="full" alias="">1b</image>
<image type="full" alias="">1c</image>
<image type="full" alias="">1d</image>
</images>
</description>
</product>' PRESERVE WHITESPACE)
)
,
(
1002,
XMLPARSE (DOCUMENT '<product pid="100-121-99">
<description>
<name>Baseball Bat</name>
<details>
Heavy baseball bat.
</details>
<price currency="us">10.00</price>
<weight units="lb">9.3</weight>
<size units="inches">
15 inches long
</size>
<brand>Batter</brand>
<category catx="bats" caty="">Bats</category>
<images>
<image type="thumbnail" alias="">1a</image>
<image type="full" alias="">1a</image>
<image type="full" alias="">1b</image>
<image type="full" alias="">1c</image>
<image type="full" alias="">1d</image>
</images>
</description>
</product>' PRESERVE WHITESPACE)
);
|
<gh_stars>0
-- Databricks notebook source
-- MAGIC %md
-- MAGIC # Numbers for manuscript
-- MAGIC
-- MAGIC **Description**
-- MAGIC
-- MAGIC This notebook runs a list of `SQL` queries to extract the numbers (%) of each text entry in the `CCU013: COVID-19 Event Phenotypes` manuscript *"Understanding COVID-19 trajectories from a nationwide linked electronic health record cohort of 56 million people: phenotypes, severity, waves & vaccination"*.
-- MAGIC <br>
-- MAGIC The layout will follow that of the paper.
-- MAGIC
-- MAGIC
-- MAGIC **Project(s)** CCU013
-- MAGIC
-- MAGIC **Author(s)** <NAME>
-- MAGIC
-- MAGIC **Reviewer(s)**
-- MAGIC
-- MAGIC **Date last updated** 2022-01-24
-- MAGIC
-- MAGIC **Date last reviewed** *NA*
-- MAGIC
-- MAGIC **Date last run** `1/23/2022, 7:41:23 PM`
-- MAGIC
-- MAGIC ** Last export requested ** `1/23/2022`
-- MAGIC
-- MAGIC **Data input**
-- MAGIC * `ccu013_covid_trajectory_paper_cohort`
-- MAGIC * `ccu013_covid_events_paper_cohort`
-- MAGIC * `ccu013_paper_table_one_56million_denominator`
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ## Abstract
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > We identified X infected individuals (%)
-- COMMAND ----------
-- MAGIC %sql
-- MAGIC SELECT
-- MAGIC COUNT(distinct person_id_deid) as population,
-- MAGIC SUM(CASE WHEN severity != 'no_covid' then 1 else 0 end) as covid,
-- MAGIC round(SUM(CASE WHEN severity != 'no_covid' then 1 else 0 end) / COUNT(distinct person_id_deid) * 100, 2) as percent_covid
-- MAGIC FROM
-- MAGIC dars_nic_391419_j3w9t_collab.ccu013_paper_table_one_56million_denominator
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > with X recorded COVID-19 phenotypes
-- COMMAND ----------
SELECT COUNT(*) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_trajectory_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > Of these, X (%) were hospitalised and Y (%) died.
-- COMMAND ----------
SELECT
SUM(02_Covid_admission) as hospitalised,
round(SUM(02_Covid_admission)/COUNT(*)*100,2) as hospitalised_percent,
SUM(death) as died,
round(SUM(death)/COUNT(*)*100,2) as died_percent
FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > Of those hospitalised, X (%) were admitted to intensive care (ICU), Y (%) received non-invasive ventilation and Z (%) invasive ventilation.
-- COMMAND ----------
SELECT
SUM(03_ICU_admission) as ICU,
round(SUM(03_ICU_admission)/(SELECT COUNT(*) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_paper_cohort WHERE 02_Covid_admission = 1)*100,2) as ICU_percent,
SUM(03_NIV_treatment) as NIV,
round(SUM(03_NIV_treatment)/(SELECT COUNT(*) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_paper_cohort WHERE 02_Covid_admission = 1)*100,2) as NIV_percent,
SUM(03_IMV_treatment) as IMV,
round(SUM(03_IMV_treatment)/(SELECT COUNT(*) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_paper_cohort WHERE 02_Covid_admission = 1)*100,2) as IMV_percent
FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > X (%) COVID-19 related deaths occurred without diagnoses on the death certificate, but within 30 days of a positive test while Y (%) of cases were identified from mortality data alone with no prior phenotypes recorded.
-- COMMAND ----------
SELECT
COUNT(*) as deaths,
SUM(04_Fatal_without_covid_diagnosis) as fatal_noDX,
round(SUM(04_Fatal_without_covid_diagnosis)/COUNT(*)*100,2) as fatal_noDX_percent
FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_paper_cohort
WHERE death = 1
-- COMMAND ----------
SELECT
SUM(CASE WHEN severity != 'no_covid' then 1 else 0 end) as covid,
SUM(death_covid) as death_covid,
SUM(CASE WHEN severity = '4_death_only' then 1 else 0 end) as death_only,
round(SUM(CASE WHEN severity = '4_death_only' then 1 else 0 end) /SUM(death_covid)*100,2) as death_only_percent_deaths,
round(SUM(CASE WHEN severity = '4_death_only' then 1 else 0 end) /SUM(CASE WHEN severity != 'no_covid' then 1 else 0 end)*100,2) as death_only_percent_cases
FROM
dars_nic_391419_j3w9t_collab.ccu013_paper_table_one_56million_denominator
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ## Methods
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > Data cleaning, exploratory analysis, phenotype creation and cohort assembly was performed using Python (3.7) and Spark SQL (X) on Databricks Runtime 6.4 for Machine Learning.
-- COMMAND ----------
-- MAGIC %py
-- MAGIC from pyspark import version
-- MAGIC # Spark SQL version
-- MAGIC spark.version
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > We assessed X previously described comorbidities, across 16 clinical specialities / organ systems, using validated CALIBER phenotypes
-- COMMAND ----------
SELECT
COUNT(distinct phenotype)
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort as base
FULL JOIN
(SELECT
person_id_deid,
date,
phenotype,
1 as value
FROM
dars_nic_391419_j3w9t_collab.ccu013_caliber_skinny)
as phenos
ON
base.person_id_deid = phenos.person_id_deid
WHERE
phenos.date < '2020-01-01'
-- COMMAND ----------
SELECT
*
FROM
(SELECT
distinct phenotype
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort as base
FULL JOIN
(SELECT
person_id_deid,
date,
phenotype,
1 as value
FROM
dars_nic_391419_j3w9t_collab.ccu013_caliber_skinny)
as phenos
ON
base.person_id_deid = phenos.person_id_deid
WHERE
phenos.date < '2020-01-01'
) as phenos
INNER JOIN
(SELECT phenotype, category FROM dars_nic_391419_j3w9t_collab.ccu013_caliber_category_mapping) as mapping
ON phenos.phenotype = mapping.phenotype
-- COMMAND ----------
SELECT
category,
COUNT(distinct mapping.phenotype)
FROM
(SELECT
distinct phenotype
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort as base
FULL JOIN
(SELECT
person_id_deid,
date,
phenotype,
1 as value
FROM
dars_nic_391419_j3w9t_collab.ccu013_caliber_skinny)
as phenos
ON
base.person_id_deid = phenos.person_id_deid
WHERE
phenos.date < '2020-01-01'
) as phenos
INNER JOIN
(SELECT phenotype, category FROM dars_nic_391419_j3w9t_collab.ccu013_caliber_category_mapping) as mapping
ON
phenos.phenotype = mapping.phenotype
GROUP BY
category
-- COMMAND ----------
-- MAGIC %md
-- MAGIC # Results
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### Denominator
-- MAGIC > Among X individuals registered with a general practitioner in England and alive on 23rd January 2020,
-- COMMAND ----------
SELECT
count(DISTINCT NHS_NUMBER_DEID) as total_population
FROM
dars_nic_391419_j3w9t_collab.ccu013_dp_skinny_patient_23_01_2020
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### Individuals & Events + IR
-- MAGIC > we identified X events in Y individuals, representing an infection rate of Z%,
-- COMMAND ----------
SELECT
COUNT(*) as n_events,
COUNT(distinct person_id_deid) as n_individuals,
ROUND(COUNT(distinct person_id_deid) / (SELECT count(DISTINCT NHS_NUMBER_DEID) FROM dars_nic_391419_j3w9t_collab.ccu013_dp_skinny_patient_23_01_2020) * 100, 2) as infection_rate
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_trajectory_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### N. per Event
-- COMMAND ----------
SELECT
"01_Covid_positive_test" as phenotype,
SUM(01_Covid_positive_test) as n,
round(SUM(01_Covid_positive_test)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"01_GP_covid_diagnosis" as phenotype,
SUM(01_GP_covid_diagnosis) as n,
round(SUM(01_GP_covid_diagnosis)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"02_Covid_admission" as phenotype,
SUM(02_Covid_admission) as n,
round(SUM(02_Covid_admission)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"03_NIV_treatment" as phenotype,
SUM(03_NIV_treatment) as n,
round(SUM(03_NIV_treatment)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"03_IMV_treatment" as phenotype,
SUM(03_IMV_treatment) as n,
round(SUM(03_IMV_treatment)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"03_ICU_admission" as phenotype,
SUM(03_ICU_admission) as n,
round(SUM(03_ICU_admission)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"03_ECMO_treatment" as phenotype,
SUM(03_ECMO_treatment) as n,
round(SUM(03_ECMO_treatment)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"04_Covid_inpatient_death" as phenotype,
SUM(04_Covid_inpatient_death) as n,
round(SUM(04_Covid_inpatient_death)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"04_Fatal_with_covid_diagnosis" as phenotype,
SUM(04_Fatal_with_covid_diagnosis) as n,
round(SUM(04_Fatal_with_covid_diagnosis)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
UNION ALL
SELECT
"04_Fatal_without_covid_diagnosis" as phenotype,
SUM(04_Fatal_without_covid_diagnosis) as n,
round(SUM(04_Fatal_without_covid_diagnosis)/COUNT(*)*100,2) as percentage
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC #### Aggregated Events
-- COMMAND ----------
SELECT
SUM(CASE WHEN (03_NIV_treatment = 1 OR 03_IMV_treatment = 1 OR 03_ICU_admission = 1 OR 03_ECMO_treatment = 1) then 1 else 0 end) as n_ventilatory_support,
SUM(CASE WHEN (04_Covid_inpatient_death = 1 OR 04_Fatal_with_covid_diagnosis = 1 OR 04_Fatal_without_covid_diagnosis = 1) then 1 else 0 end) as n_deaths,
SUM(death)
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### Mutex Severities
-- MAGIC These are mutually exclusive phenotypes representing the **worst/most severe** COVID-19 events experienced by each individual patient
-- MAGIC
-- MAGIC > Most individuals with COVID-19 event(s), (n=X, %) avoided hospitalisation or death related to COVID-19.
-- COMMAND ----------
WITH t1 AS
(SELECT severity, COUNT(*) AS n
FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
GROUP BY severity)
SELECT severity, n,
n/(SELECT COUNT(*) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort) * 100 as percentage
FROM t1
ORDER BY
severity
-- COMMAND ----------
WITH t1 AS
(SELECT 'not_hospitalised' as severity, COUNT(*) AS n
FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
WHERE severity = '0_positive' OR severity = '1_gp'
)
SELECT severity, n,
ROUND(n/(SELECT COUNT(*) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort) * 100,2) as percentage
FROM t1
ORDER BY
severity
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### Ventilation
-- MAGIC > Of those admitted to hospital, X (%) received NIV, Y (%) were admitted to an ICU, Z (%) received IMV, A (%) patients received both NIV and IMV and B received ECMO.
-- COMMAND ----------
SELECT
SUM(02_Covid_admission) as n_hospitalised,
SUM(03_NIV_treatment) as niv_n,
ROUND(SUM(03_NIV_treatment) / SUM(02_Covid_admission) * 100, 2) as niv_percent,
SUM(03_ICU_admission) as icu_n,
ROUND(SUM(03_ICU_admission) / SUM(02_Covid_admission) * 100, 2) as icu_percent,
SUM(03_IMV_treatment) as imv_n,
ROUND(SUM(03_IMV_treatment) / SUM(02_Covid_admission) * 100, 2) as imv_percent,
SUM(03_ECMO_treatment) as ecmo_n,
ROUND(SUM(03_ECMO_treatment) / SUM(02_Covid_admission) * 100, 2) as ecmo_percent,
SUM(CASE WHEN 03_NIV_treatment = 1 AND 03_IMV_treatment = 1 then 1 else 0 end) as both_n,
ROUND(SUM(CASE WHEN 03_NIV_treatment = 1 AND 03_IMV_treatment = 1 then 1 else 0 end) / SUM(02_Covid_admission) * 100, 2) as both_percent
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
SELECT
SUM(03_NIV_treatment) as NIV_n,
SUM(03_IMV_treatment) as IMV_n,
SUM(CASE WHEN 03_NIV_treatment = 1 AND 03_IMV_treatment = 1 then 1 else 0 end) as both_n
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC #### Ventilation OUTSIDE ICU
-- COMMAND ----------
-- Outside ICU
SELECT
SUM(03_NIV_treatment) as NIV_n,
ROUND(SUM(03_NIV_treatment) /
(SELECT SUM(03_NIV_treatment) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort) * 100, 2) as NIV_percent_outICU,
SUM(CASE WHEN 03_IMV_treatment = 1 then 1 else 0 end) as IMV_n,
ROUND(SUM(03_IMV_treatment) /
(SELECT SUM(03_IMV_treatment) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort) * 100, 2) as IMV_percent_outICU
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
WHERE
03_ICU_admission = 0
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ## Mortality
-- MAGIC > X individuals died, representing a mortality rate of Y%
-- COMMAND ----------
SELECT
SUM(death) as deaths_total,
round(SUM(death)/COUNT(*)*100,2) as mortality
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > Of these deaths, the majority occurred in patients who were hospitalised (%, n), however n (%) died without having ever been admitted to hospital.
-- COMMAND ----------
SELECT
COUNT(*) as deaths_total,
SUM(02_Covid_admission) as deaths_hospital,
ROUND( SUM(02_Covid_admission)/COUNT(*)*100,2) as deaths_hospital_percent,
SUM(CASE WHEN 02_Covid_admission = 0 then 1 else 0 end) as deaths_NO_hospital_contact,
ROUND(SUM(CASE WHEN 02_Covid_admission = 0 then 1 else 0 end)/COUNT(*)*100,2) as deaths_NO_hospital_contact_percent
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
WHERE
death = 1
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### Unheralded deaths
-- MAGIC > Notably we identified X unheralded COVID-19 deaths - individuals who died with COVID-19 as a recorded cause, but for whom no other COVID-19 phenotypes, such as positive tests or primary care diagnosis, were identified.
-- COMMAND ----------
-- See Table 1 main manusript
SELECT
COUNT(*),
round(SUM(CASE WHEN age > 70 then 1 else 0 end)/COUNT(*)*100,2) as over70,
round(SUM(CASE WHEN ethnic_group == "White" then 1 else 0 end)/COUNT(*)*100,2) as white,
mean(multimorbidity)
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
WHERE
04_Fatal_with_covid_diagnosis = 1
AND
01_Covid_positive_test = 0
AND
01_GP_covid_diagnosis = 0
AND
02_Covid_admission = 0
AND
ventilatory_support = 0
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > X individuals died within 28-days of a COVID-19 event without a confirmed or suspected COVID-19 diagnosis listed on the death certificate.
-- COMMAND ----------
SELECT
COUNT(*)
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
WHERE
04_Fatal_without_covid_diagnosis = 1
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > Of the X individuals with a COVID-19 related death, Y (%) died without having ever been admitted to hospital and Z (%) died within 28-days of a COVID-19 event without a confirmed or suspected COVID-19 diagnosis listed on the death certificate.
-- COMMAND ----------
SELECT
SUM(death) as deaths_total,
SUM(CASE WHEN 02_Covid_admission = 1 AND death = 1 then 1 else 0 end) as deaths_hospital_contact,
ROUND(SUM(CASE WHEN 02_Covid_admission = 1 AND death = 1 then 1 else 0 end)/SUM(death)*100,2) as deaths_hospital_contact_percent,
SUM(CASE WHEN 02_Covid_admission = 0 AND death = 1 then 1 else 0 end) as deaths_NO_hospital_contact,
ROUND(SUM(CASE WHEN 02_Covid_admission = 0 AND death = 1 then 1 else 0 end)/SUM(death)*100,2) as deaths_NO_hospital_contact_percent
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
SELECT
SUM(death) as deaths_total,
SUM(04_Covid_inpatient_death) as inpatient_n,
ROUND(SUM(04_Covid_inpatient_death)/SUM(death)*100,2) as inpatient_percent,
SUM(04_Fatal_with_covid_diagnosis) as with_dx_n,
ROUND(SUM(04_Fatal_with_covid_diagnosis)/SUM(death)*100,2) as with_dx_percent,
SUM(04_Fatal_without_covid_diagnosis) as without_dx_n,
ROUND(SUM(04_Fatal_without_covid_diagnosis)/SUM(death)*100,2) as without_dx_percent
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
SELECT
SUM(CASE WHEN (03_NIV_treatment = 1 OR 03_IMV_treatment = 1 OR 03_ICU_admission = 1 OR 03_ECMO_treatment = 1) AND death = 1 then 1 else 0 end) as deaths_ventilatory_support,
SUM(CASE WHEN 03_ICU_admission = 1 AND death = 1 then 1 else 0 end) as deaths_ICU
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### High Risk patients
-- MAGIC > Amongst the X individuals classified as ?high risk?, X (%) experienced COVID-19 and Y died, a mortality rate of Y%.
-- MAGIC
-- MAGIC * Note significant change in results since preprint (ending May) due to vaccination/transmission
-- COMMAND ----------
SELECT
SUM(CASE WHEN high_risk = 1 then 1 else 0 end) as infected,
SUM(CASE WHEN high_risk = 1 AND death = 1 then 1 else 0 end) as died
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
SELECT
COUNT(*) as total_high_risk,
SUM(CASE WHEN severity != 'no_covid' then 1 else 0 end) as infected,
round(SUM(CASE WHEN severity != 'no_covid' then 1 else 0 end) / COUNT(*) *100, 2) as infection_rate,
SUM(CASE WHEN severity != 'no_covid' AND death_covid = 1 then 1 else 0 end) as died,
round(SUM(CASE WHEN severity != 'no_covid' AND death_covid = 1 then 1 else 0 end) / SUM(CASE WHEN severity != 'no_covid' then 1 else 0 end) *100, 2) as mortality
FROM
dars_nic_391419_j3w9t_collab.ccu013_paper_table_one_56million_denominator
WHERE
high_risk = 1
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ## Mortality in hospitalised patients
-- MAGIC >
-- MAGIC The composite of COVID-19 mortality (including deaths with a recorded diagnosis of COVID-19, deaths within 28 days of a positive test and deaths during a COVID-19 hospital admission) occurred in X% (n deaths) of hospitalised patients and Y% (n) deaths) for those admitted to intensive care.
-- COMMAND ----------
SELECT
SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1) then 1 else 0 end) as hosp_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1) then 1 else 0 end)/SUM(02_Covid_admission)*100,2) as hosp_mortality,
SUM(CASE WHEN (death = 1 and 03_ICU_admission = 1) then 1 else 0 end) as icu_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 03_ICU_admission = 1) then 1 else 0 end)/SUM(03_ICU_admission)*100,2) as icu_mortality
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ## CC-outside-ICU mortality
-- MAGIC > Kaplan-Meier survival analysis (Figure 3) corroborates these results whilst providing additional insight into the temporality of survival. Stratifying critical care treatment by admission to ICU reveals that **mortality is highest for those patients receiving critical care outside of ICU**.
-- COMMAND ----------
SELECT
SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1) then 1 else 0 end) as hosp_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1) then 1 else 0 end)/SUM(02_Covid_admission)*100,2) as hosp_mortality,
SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end) as hosp_noCC_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end)/SUM(CASE WHEN (02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end) *100,2) as hosp_noCC_mortality,
SUM(CASE WHEN (death = 1 and ventilatory_support = 1) then 1 else 0 end) as cc_deaths,
ROUND(SUM(CASE WHEN (death = 1 and ventilatory_support = 1) then 1 else 0 end)/SUM(ventilatory_support)*100,2) as cc_mortality,
SUM(CASE WHEN (death = 1 and 03_ICU_admission = 1) then 1 else 0 end) as icu_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 03_ICU_admission = 1) then 1 else 0 end)/SUM(03_ICU_admission)*100,2) as icu_mortality,
SUM(CASE WHEN (death = 1 and ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end) as cc_outofICU_deaths,
ROUND(SUM(CASE WHEN (death = 1 and ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end)/SUM(CASE WHEN (ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end) *100,2) as cc_outofICU_mortality
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### CC-outside-ICU mortality: Wave 1
-- COMMAND ----------
SELECT
SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1) then 1 else 0 end) as hosp_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1) then 1 else 0 end)/SUM(02_Covid_admission)*100,2) as hosp_mortality,
SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end) as hosp_noCC_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end)/SUM(CASE WHEN (02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end) *100,2) as hosp_noCC_mortality,
SUM(CASE WHEN (death = 1 and ventilatory_support = 1) then 1 else 0 end) as cc_deaths,
ROUND(SUM(CASE WHEN (death = 1 and ventilatory_support = 1) then 1 else 0 end)/SUM(ventilatory_support)*100,2) as cc_mortality,
SUM(CASE WHEN (death = 1 and 03_ICU_admission = 1) then 1 else 0 end) as icu_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 03_ICU_admission = 1) then 1 else 0 end)/SUM(03_ICU_admission)*100,2) as icu_mortality,
SUM(CASE WHEN (death = 1 and ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end) as cc_outofICU_deaths,
ROUND(SUM(CASE WHEN (death = 1 and ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end)/SUM(CASE WHEN (ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end) *100,2) as cc_outofICU_mortality
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
WHERE
date_first >= "2020-03-20" AND date_first <= "2020-05-29"
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### CC-outside-ICU mortality: Wave 2
-- COMMAND ----------
SELECT
SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1) then 1 else 0 end) as hosp_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1) then 1 else 0 end)/SUM(02_Covid_admission)*100,2) as hosp_mortality,
SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end) as hosp_noCC_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end)/SUM(CASE WHEN (02_Covid_admission = 1 and ventilatory_support = 0) then 1 else 0 end) *100,2) as hosp_noCC_mortality,
SUM(CASE WHEN (death = 1 and ventilatory_support = 1) then 1 else 0 end) as cc_deaths,
ROUND(SUM(CASE WHEN (death = 1 and ventilatory_support = 1) then 1 else 0 end)/SUM(ventilatory_support)*100,2) as cc_mortality,
SUM(CASE WHEN (death = 1 and 03_ICU_admission = 1) then 1 else 0 end) as icu_deaths,
ROUND(SUM(CASE WHEN (death = 1 and 03_ICU_admission = 1) then 1 else 0 end)/SUM(03_ICU_admission)*100,2) as icu_mortality,
SUM(CASE WHEN (death = 1 and ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end) as cc_outofICU_deaths,
ROUND(SUM(CASE WHEN (death = 1 and ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end)/SUM(CASE WHEN (ventilatory_support = 1 and 03_ICU_admission = 0) then 1 else 0 end) *100,2) as cc_outofICU_mortality
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
WHERE
date_first >= "2020-09-30" AND date_first <= "2021-02-12"
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ## Recording patterns across sources
-- MAGIC > Approximately X% of individuals with a positive test also received a primary care diagnosis, while N (%) had a positive test but no other record.
-- COMMAND ----------
SELECT
SUM(01_Covid_positive_test) as positive_tests,
SUM(CASE WHEN 01_Covid_positive_test = 1 and 01_GP_covid_diagnosis = 1 then 1 else 0 end) as positive_and_GP_Dx_n,
round(SUM(CASE WHEN 01_Covid_positive_test = 1 and 01_GP_covid_diagnosis = 1 then 1 else 0 end) / SUM(01_Covid_positive_test)*100,2) as positive_and_GP_Dx_percent,
SUM(CASE WHEN 01_Covid_positive_test = 1 and
01_GP_covid_diagnosis = 0 and
02_Covid_admission = 0 and
03_ICU_admission = 0 and
03_NIV_treatment = 0 and
03_IMV_treatment = 0 and
03_ECMO_treatment = 0 and
04_Fatal_with_covid_diagnosis = 0 and
04_Fatal_without_covid_diagnosis = 0 and
04_Covid_inpatient_death = 0 then 1 else 0 end) as positive_only_n,
round(SUM(CASE WHEN 01_Covid_positive_test = 1 and
01_GP_covid_diagnosis = 0 and
02_Covid_admission = 0 and
ventilatory_support = 0 and
death = 0 then 1 else 0 end) / SUM(01_Covid_positive_test)*100,2) as positive_only_percent
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > X% with a primary care record had no other evidence of COVID-19, as did X% with a secondary care record, and X COVID-19 cases were identified exclusively from mortality data with no prior COVID-19 events (Figure 2). A small number of individuals were identified only from PHE hospital surveillance data (CHESS, X individuals, X% of all hospitalisations). See Supplementary Figure 2, for further details on data source overlap.
-- COMMAND ----------
SELECT
SUM(01_GP_covid_diagnosis) as GP_Dx_n,
SUM(CASE WHEN 01_GP_covid_diagnosis = 1 and
01_Covid_positive_test = 0 and
02_Covid_admission = 0 and
ventilatory_support = 0 and
death = 0 then 1 else 0 end) as GP_only_n,
round(SUM(CASE WHEN 01_GP_covid_diagnosis = 1 and
01_Covid_positive_test = 0 and
02_Covid_admission = 0 and
ventilatory_support = 0 and
death = 0 then 1 else 0 end) / SUM(01_Covid_positive_test)*100,2) as GP_only_percent,
SUM(02_Covid_admission) as Hosp_n,
SUM(CASE WHEN 02_Covid_admission = 1 and
01_Covid_positive_test = 0 and
01_GP_covid_diagnosis = 0 and
-- Remove ventilatory support as that's a secondary care record
death = 0 then 1 else 0 end) as Hosp_only_n,
round(SUM(CASE WHEN 02_Covid_admission = 1 and
01_Covid_positive_test = 0 and
01_GP_covid_diagnosis = 0 and
death = 0 then 1 else 0 end) / SUM(01_Covid_positive_test)*100,2) as Hosp_only_percent
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC Alternative approach ** NB requires running notebook `upset_datagen` to update table `ccu013_01_paper_upset` first **
-- MAGIC
-- MAGIC **this takes a while!
-- COMMAND ----------
-- MAGIC %run /Workspaces/dars_nic_391419_j3w9t_collab/CCU013/COVID-19-SEVERITY-PHENOTYPING/03_analysis_databricks/upset_datagen
-- COMMAND ----------
-- Alternative approach using upset table (run that first)
SELECT
COUNT(distinct person_id_deid)
FROM
dars_nic_391419_j3w9t_collab.ccu013_01_paper_upset
WHERE
SGSS = 1
AND CHESS = 0 AND HES_APC = 0 AND HES_CC = 0 and GDPPR = 0 and SUS = 0 and deaths = 0
-- COMMAND ----------
-- Alternative approach using upset table (run that first)
SELECT
COUNT(distinct person_id_deid)
FROM
dars_nic_391419_j3w9t_collab.ccu013_01_paper_upset
WHERE
GDPPR = 1
AND CHESS = 0 AND HES_APC = 0 AND HES_CC = 0 and SGSS = 0 and SUS = 0 and deaths = 0
-- COMMAND ----------
-- MAGIC %md
-- MAGIC > A small number of individuals were identified only from PHE hospital surveillance data (CHESS, X individuals, X% of all hospitalisations)
-- COMMAND ----------
SELECT
COUNT(distinct person_id_deid) as individuals,
round(COUNT(*) /
(SELECT COUNT(*) FROM dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort WHERE 02_Covid_admission = 1)*100,2) as percentage_hospitalisations
FROM
dars_nic_391419_j3w9t_collab.ccu013_01_paper_upset
WHERE
CHESS = 1
AND GDPPR = 0 AND HES_APC = 0 AND HES_CC = 0 and SGSS = 0 and SUS = 0 and deaths = 0
-- COMMAND ----------
-- MAGIC %md
-- MAGIC # Discussion
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ### Insights from linkage
-- MAGIC > we identified X individuals who received NIV outside of ICU, X% of all patients treated with NIV,
-- COMMAND ----------
SELECT
SUM(CASE WHEN 03_NIV_treatment = 1 then 1 else 0 end) as NIV_total,
SUM(CASE WHEN 03_NIV_treatment = 1 AND 03_ICU_admission = 0 then 1 else 0 end) as NIV_outside_ICU,
ROUND(SUM(CASE WHEN 03_NIV_treatment = 1 AND 03_ICU_admission = 0 then 1 else 0 end)/SUM(CASE WHEN 03_NIV_treatment = 1 then 1 else 0 end)*100,2) as NIV_percent_outside_ICU
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
-- MAGIC %md
-- MAGIC # FINISHED
-- COMMAND ----------
-- MAGIC %md
-- MAGIC ## Wave numbers
-- COMMAND ----------
-- wave_1_start = "2020-03-20"
-- wave_1_end = "2020-05-29"
-- wave_2_start = "2020-09-30"
-- wave_2_end = "2021-02-12"
-- cohort %<>%
-- mutate(wave = if_else(date_first >= wave_1_start &
-- date_first <= wave_1_end,
-- 1, 1.5) # name inter-wave period as 1.5
-- ) %>%
-- mutate(wave = if_else(date_first >= wave_2_start &
-- date_first <= wave_2_end,
-- 2, wave)
-- ) %>%
-- select(-date_first)
-- COMMAND ----------
-- wave_1_start = "2020-03-20"
-- wave_1_end = "2020-05-29"
-- wave_2_start = "2020-09-30"
-- wave_2_end =
SELECT
SUM(CASE WHEN date_first >= "2020-03-20" AND date_first <= "2020-05-29" then 1 else 0 end) as wave1_all,
SUM(CASE WHEN date_first >= "2020-03-20" AND date_first <= "2020-05-29" AND 02_Covid_admission = 1 then 1 else 0 end) as wave1_hosp,
SUM(CASE WHEN date_first >= "2020-09-30" AND date_first <= "2021-02-12" then 1 else 0 end) as wave2_all,
SUM(CASE WHEN date_first >= "2020-09-30" AND date_first <= "2021-02-12" AND 02_Covid_admission = 1 then 1 else 0 end) as wave2_hosp
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
SELECT
SUM(CASE WHEN date_first >= "2020-03-20" AND date_first <= "2020-05-29" AND 01_Covid_positive_test = 1 then 1 else 0 end) as wave1_test
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
-- COMMAND ----------
SELECT
SUM(CASE WHEN date_first >= "2020-09-30" AND date_first <= "2021-02-12" then 1 else 0 end) as wave2_all,
SUM(CASE WHEN date_first >= "2020-09-30" AND date_first <= "2021-02-12" AND 01_Covid_positive_test = 1 then 1 else 0 end) as wave2_test,
(SELECT COUNT(distinct NHS_NUMBER_DEID) FROM dars_nic_391419_j3w9t_collab.ccu013_dp_skinny_patient_23_01_2020) as population,
ROUND(SUM(CASE WHEN date_first >= "2020-09-30" AND date_first <= "2021-02-12" AND 01_Covid_positive_test = 1 then 1 else 0 end)
/
(SELECT COUNT(distinct NHS_NUMBER_DEID) FROM dars_nic_391419_j3w9t_collab.ccu013_dp_skinny_patient_23_01_2020)
*100,2) as unaffected_to_test
FROM
dars_nic_391419_j3w9t_collab.ccu013_covid_events_demographics_paper_cohort
|
alter table subgraphs.subgraph_manifest
add column new_id int
references subgraphs.subgraph_deployment(id) on delete cascade;
update subgraphs.subgraph_manifest m
set new_id = d.id
from subgraphs.subgraph_deployment d
where d.manifest = m.id;
alter table subgraphs.subgraph_manifest
drop column id,
drop column vid,
drop column block_range;
alter table subgraphs.subgraph_manifest
rename column new_id to id;
alter table subgraphs.subgraph_manifest
add primary key(id);
alter table subgraphs.subgraph_deployment
drop column manifest;
drop index subgraphs.attr_4_1_subgraph_manifest_spec_version;
drop index subgraphs.attr_4_2_subgraph_manifest_description;
drop index subgraphs.attr_4_3_subgraph_manifest_repository;
drop index subgraphs.attr_4_4_subgraph_manifest_schema;
|
<gh_stars>1000+
/* contrib/seg/seg--1.1.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION seg" to load this file. \quit
-- Create the user-defined type for 1-D floating point intervals (seg)
CREATE FUNCTION seg_in(cstring)
RETURNS seg
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
CREATE FUNCTION seg_out(seg)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
CREATE TYPE seg (
INTERNALLENGTH = 12,
INPUT = seg_in,
OUTPUT = seg_out
);
COMMENT ON TYPE seg IS
'floating point interval ''FLOAT .. FLOAT'', ''.. FLOAT'', ''FLOAT ..'' or ''FLOAT''';
--
-- External C-functions for R-tree methods
--
-- Left/Right methods
CREATE FUNCTION seg_over_left(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_over_left(seg, seg) IS
'overlaps or is left of';
CREATE FUNCTION seg_over_right(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_over_right(seg, seg) IS
'overlaps or is right of';
CREATE FUNCTION seg_left(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_left(seg, seg) IS
'is left of';
CREATE FUNCTION seg_right(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_right(seg, seg) IS
'is right of';
-- Scalar comparison methods
CREATE FUNCTION seg_lt(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_lt(seg, seg) IS
'less than';
CREATE FUNCTION seg_le(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_le(seg, seg) IS
'less than or equal';
CREATE FUNCTION seg_gt(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_gt(seg, seg) IS
'greater than';
CREATE FUNCTION seg_ge(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_ge(seg, seg) IS
'greater than or equal';
CREATE FUNCTION seg_contains(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_contains(seg, seg) IS
'contains';
CREATE FUNCTION seg_contained(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_contained(seg, seg) IS
'contained in';
CREATE FUNCTION seg_overlap(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_overlap(seg, seg) IS
'overlaps';
CREATE FUNCTION seg_same(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_same(seg, seg) IS
'same as';
CREATE FUNCTION seg_different(seg, seg)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_different(seg, seg) IS
'different';
-- support routines for indexing
CREATE FUNCTION seg_cmp(seg, seg)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
COMMENT ON FUNCTION seg_cmp(seg, seg) IS 'btree comparison function';
CREATE FUNCTION seg_union(seg, seg)
RETURNS seg
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
CREATE FUNCTION seg_inter(seg, seg)
RETURNS seg
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
CREATE FUNCTION seg_size(seg)
RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
-- miscellaneous
CREATE FUNCTION seg_center(seg)
RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
CREATE FUNCTION seg_upper(seg)
RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
CREATE FUNCTION seg_lower(seg)
RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
--
-- OPERATORS
--
CREATE OPERATOR < (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_lt,
COMMUTATOR = '>',
NEGATOR = '>=',
RESTRICT = scalarltsel,
JOIN = scalarltjoinsel
);
CREATE OPERATOR <= (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_le,
COMMUTATOR = '>=',
NEGATOR = '>',
RESTRICT = scalarltsel,
JOIN = scalarltjoinsel
);
CREATE OPERATOR > (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_gt,
COMMUTATOR = '<',
NEGATOR = '<=',
RESTRICT = scalargtsel,
JOIN = scalargtjoinsel
);
CREATE OPERATOR >= (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_ge,
COMMUTATOR = '<=',
NEGATOR = '<',
RESTRICT = scalargtsel,
JOIN = scalargtjoinsel
);
CREATE OPERATOR << (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_left,
COMMUTATOR = '>>',
RESTRICT = positionsel,
JOIN = positionjoinsel
);
CREATE OPERATOR &< (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_over_left,
RESTRICT = positionsel,
JOIN = positionjoinsel
);
CREATE OPERATOR && (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_overlap,
COMMUTATOR = '&&',
RESTRICT = areasel,
JOIN = areajoinsel
);
CREATE OPERATOR &> (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_over_right,
RESTRICT = positionsel,
JOIN = positionjoinsel
);
CREATE OPERATOR >> (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_right,
COMMUTATOR = '<<',
RESTRICT = positionsel,
JOIN = positionjoinsel
);
CREATE OPERATOR = (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_same,
COMMUTATOR = '=',
NEGATOR = '<>',
RESTRICT = eqsel,
JOIN = eqjoinsel,
MERGES
);
CREATE OPERATOR <> (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_different,
COMMUTATOR = '<>',
NEGATOR = '=',
RESTRICT = neqsel,
JOIN = neqjoinsel
);
CREATE OPERATOR @> (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_contains,
COMMUTATOR = '<@',
RESTRICT = contsel,
JOIN = contjoinsel
);
CREATE OPERATOR <@ (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_contained,
COMMUTATOR = '@>',
RESTRICT = contsel,
JOIN = contjoinsel
);
-- obsolete:
CREATE OPERATOR @ (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_contains,
COMMUTATOR = '~',
RESTRICT = contsel,
JOIN = contjoinsel
);
CREATE OPERATOR ~ (
LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_contained,
COMMUTATOR = '@',
RESTRICT = contsel,
JOIN = contjoinsel
);
-- define the GiST support methods
CREATE FUNCTION gseg_consistent(internal,seg,smallint,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION gseg_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION gseg_decompress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION gseg_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION gseg_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION gseg_union(internal, internal)
RETURNS seg
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE FUNCTION gseg_same(seg, seg, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
-- Create the operator classes for indexing
CREATE OPERATOR CLASS seg_ops
DEFAULT FOR TYPE seg USING btree AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 seg_cmp(seg, seg);
CREATE OPERATOR CLASS gist_seg_ops
DEFAULT FOR TYPE seg USING gist
AS
OPERATOR 1 << ,
OPERATOR 2 &< ,
OPERATOR 3 && ,
OPERATOR 4 &> ,
OPERATOR 5 >> ,
OPERATOR 6 = ,
OPERATOR 7 @> ,
OPERATOR 8 <@ ,
OPERATOR 13 @ ,
OPERATOR 14 ~ ,
FUNCTION 1 gseg_consistent (internal, seg, smallint, oid, internal),
FUNCTION 2 gseg_union (internal, internal),
FUNCTION 3 gseg_compress (internal),
FUNCTION 4 gseg_decompress (internal),
FUNCTION 5 gseg_penalty (internal, internal, internal),
FUNCTION 6 gseg_picksplit (internal, internal),
FUNCTION 7 gseg_same (seg, seg, internal);
|
<reponame>geophile/sql-layer
SELECT name, state, order_date, sku, ship_date, referral
FROM customers
INNER JOIN addresses ON customers.cid = addresses.cid
INNER JOIN orders ON customers.cid = orders.cid
INNER JOIN items ON orders.oid = items.oid
INNER JOIN shipments ON orders.oid = shipments.oid
INNER JOIN referrals ON customers.cid = referrals.cid
|
<filename>scripts/schema.sql
-- "name" is stored as varchar to support variable length string with
-- no upper limit. "password" is stored as bytea to support the bcrypt implementation.
-- The Go implementation outputs the hash in base64 format which makes varchar an alternative
-- to bytea in our case. I still choose to go with bytea to be verbose about the fact that we
-- are dealing with binary data here. "email" is stored in accordance with RFC 5321 and Errata
-- 1690.
create table if not exists users(
id uuid primary key,
name varchar not null,
email varchar(319) not null,
password bytea not null
);
-- "startTime" and "endTime" are supposed to be 64-bit epoch time values.
-- Choices for other data types are self explanatory.
create table if not exists logs(
id uuid primary key,
userId uuid references users(id),
latitude double precision,
longitude double precision,
activity varchar not null,
startTime bigint not null,
endTime bigint not null,
notes varchar
);
|
-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Oct 23, 2018 at 09:56 AM
-- Server version: 10.1.28-MariaDB
-- PHP Version: 7.1.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `carhire_911`
--
-- --------------------------------------------------------
--
-- Table structure for table `cars`
--
CREATE TABLE `cars` (
`car_id` int(11) NOT NULL,
`category` varchar(255) NOT NULL,
`brand` varchar(255) NOT NULL,
`model` varchar(255) NOT NULL,
`colour` varchar(255) NOT NULL,
`plate_no` varchar(255) NOT NULL,
`base_price` int(11) NOT NULL,
`image` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`features` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `cars`
--
INSERT INTO `cars` (`car_id`, `category`, `brand`, `model`, `colour`, `plate_no`, `base_price`, `image`, `status`, `features`) VALUES
(1, 'Sedan', '<NAME>', 'S 550', 'black', 'KCF 990J', 9000, 'mercedes-s550.jpg\r\n', 'available', 'Air conditioning\r\nGreat control\r\nGreat Chassis\r\n');
-- --------------------------------------------------------
--
-- Table structure for table `department`
--
CREATE TABLE `department` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `department`
--
INSERT INTO `department` (`id`, `name`) VALUES
(0, 'unset'),
(2, 'Accounts'),
(3, 'Inventory'),
(4, 'Marketing'),
(23, 'Sales');
-- --------------------------------------------------------
--
-- Table structure for table `employee`
--
CREATE TABLE `employee` (
`employee_id` int(11) NOT NULL,
`department_id` int(11) NOT NULL DEFAULT 0,
`logged_once` int(1) NOT NULL DEFAULT 0,
`termination_date` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee`
--
INSERT INTO `employee` (`employee_id`, `department_id`, `logged_once`, `termination_date`) VALUES
(41, 3, 0, NULL),
(46, 3, 0, NULL),
(47, 4, 1, NULL),
(48, 4, 1, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `locations`
--
CREATE TABLE `locations` (
`location_id` int(11) NOT NULL,
`location_name` varchar(255) NOT NULL,
`location_fee` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Table structure for table `password_reset`
--
CREATE TABLE `password_reset` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`reset_code` varchar(255) NOT NULL,
`sent_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`valid` int(11) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `password_reset`
--
INSERT INTO `password_reset` (`id`, `user_id`, `reset_code`, `sent_at`, `valid`) VALUES
(4, 40, '<PASSWORD>', '2018-10-21 16:15:13', 1),
(5, 40, '<PASSWORD>', '2018-10-21 16:40:39', 0);
-- --------------------------------------------------------
--
-- Table structure for table `rental_history`
--
INSERT INTO `locations` (`location_id`, `location_name`, `location_fee`) VALUES
(1, 'Nairobi office', 0),
(2, 'JKIA', 1500),
(3, 'Wilson Airport', 1000),
(4, 'Madaraka Express - Nairobi Terminus', 500),
(5, 'Mombasa Main Office', 0),
(6, 'Moi International Airport', 1500),
(7, 'Bamburi Airport', 1000),
(8, 'Madaraka Express - Mombasa Terminus', 500);
-- --------------------------------------------------------
--
-- Table structure for table `reservations`
--
CREATE TABLE `reservations` (
`res_no` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`car_id` int(11) NOT NULL,
`pickup_location_id` int(11) NOT NULL,
`return_location_id` int(11) NOT NULL,
`pickup_date` date NOT NULL,
`return_date` date NOT NULL,
`mileage_onpick` int(11) DEFAULT NULL,
`mileage_onreturn` int(11) DEFAULT NULL,
`extra_mileage_fee` int(11) DEFAULT NULL,
`extra_feat_fee` int(11) DEFAULT NULL,
`amount_due` int(11) NOT NULL,
`amount_paid` int(11) DEFAULT NULL,
`car_condition` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `reviews`
--
CREATE TABLE `reviews` (
`review_no` int(11) NOT NULL,
`car_id` int(11) NOT NULL,
`rating` int(11) NOT NULL,
`comment` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`user_id` int(11) NOT NULL,
`fname` varchar(255) DEFAULT NULL,
`lname` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`date_reg` timestamp NOT NULL DEFAULT current_timestamp(),
`status` int(11) NOT NULL DEFAULT 1,
`user_type` int(11) DEFAULT NULL,
`is_logged` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`user_id`, `fname`, `lname`, `email`, `password`, `date_reg`, `status`, `user_type`, `is_logged`) VALUES
(40, 'Stephen', '<PASSWORD>', '<EMAIL>', '$2y$10$Gf.AplyUrd1Y0gZFFoAR6Ob4fx9RxnBV69.8m4Gf0wG5MUi1l3CaC', '2018-10-21 13:47:14', 1, 3, 0),
(41, 'Vance', 'Joy', '<EMAIL>', '$2y$10$i5aKiNdsX83sgZ469ZMyyeeCSTiiq1tnOHxkWJleEOJAyBlq89dF.', '2018-10-21 13:55:17', 1, 2, 0),
(43, 'Ray', 'Charles', '<EMAIL>', <PASSWORD>y$10$wCpxF.3mNrUF14que6tgve4FWwXHlLKdv607hGVuBbR8MM8ZnCneK', '2018-10-21 14:52:25', 1, 1, 0),
(44, 'Amy', 'Winehouse', '<EMAIL>', <PASSWORD>', '2018-10-21 14:54:33', 1, 1, 0),
(45, 'James', 'Arthur', '<EMAIL>', '$2y$10$vaOCjB06RQ8KrAaAZLAb8Otvl2vZx7LONnuiCzybtgdOyeEBsIIAi', '2018-10-21 14:55:01', 1, 1, 0),
(46, 'James', 'Jaymo', '<EMAIL>', '$2y$10$YJtAINl4oe6bOrZBjFrbpODoTcyd7ofACPYMsn19Pehr0KMkXmCji', '2018-10-21 14:57:05', 1, 2, 0),
(47, 'Healthy', 'Living', '<EMAIL>', <PASSWORD>', '2018-10-21 14:59:06', 1, 2, 0),
(48, 'New ', 'Girl', '<EMAIL>', <PASSWORD>', '2018-10-21 16:41:58', 1, 2, 0);
-- --------------------------------------------------------
--
-- Table structure for table `user_reservation_bridge`
--
CREATE TABLE `user_reservation_bridge` (
`user_id` int(11) NOT NULL,
`res_no` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `user_type`
--
CREATE TABLE `user_type` (
`id` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user_type`
--
INSERT INTO `user_type` (`id`, `name`) VALUES
(1, 'customer'),
(2, 'employee'),
(3, 'admin');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `cars`
--
ALTER TABLE `cars`
ADD PRIMARY KEY (`car_id`);
--
-- Indexes for table `department`
--
ALTER TABLE `department`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `employee`
--
ALTER TABLE `employee`
ADD UNIQUE KEY `employee_id` (`employee_id`),
ADD KEY `department_id` (`department_id`) USING BTREE;
--
-- Indexes for table `locations`
--
ALTER TABLE `department`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `password_reset`
--
ALTER TABLE `password_reset`
ADD PRIMARY KEY (`id`),
ADD KEY `user_id` (`user_id`);
--
-- Indexes for table `rental_history`
--
ALTER TABLE `employee`
ADD UNIQUE KEY `employee_id` (`employee_id`),
ADD KEY `department_id` (`department_id`);
--
-- Indexes for table `locations`
--
ALTER TABLE `locations`
ADD PRIMARY KEY (`location_id`);
--
-- Indexes for table `reservations`
--
ALTER TABLE `reservations`
ADD PRIMARY KEY (`res_no`),
ADD KEY `user_id` (`user_id`),
ADD KEY `pickup_location_id` (`pickup_location_id`),
ADD KEY `return_location_id` (`return_location_id`),
ADD KEY `car_id` (`car_id`);
--
-- Indexes for table `reviews`
--
ALTER TABLE `reviews`
ADD PRIMARY KEY (`review_no`),
ADD KEY `car_id` (`car_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`user_id`),
ADD KEY `user_type` (`user_type`);
--
-- Indexes for table `user_reservation_bridge`
--
ALTER TABLE `user_reservation_bridge`
ADD KEY `user` (`user_id`),
ADD KEY `car_id` (`res_no`);
--
-- Indexes for table `user_type`
--
ALTER TABLE `user_type`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `cars`
--
ALTER TABLE `cars`
MODIFY `car_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `department`
--
ALTER TABLE `department`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `locations`
--
ALTER TABLE `locations`
MODIFY `location_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `reservations`
--
ALTER TABLE `reservations`
MODIFY `res_no` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT for table `password_reset`
--
ALTER TABLE `password_reset`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `reviews`
--
ALTER TABLE `reviews`
MODIFY `review_no` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=38;
--
-- AUTO_INCREMENT for table `user_type`
--
ALTER TABLE `user_type`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=49;
--
-- AUTO_INCREMENT for table `user_type`
--
ALTER TABLE `user_type`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `employee`
--
ALTER TABLE `employee`
ADD CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `employee_ibfk_2` FOREIGN KEY (`department_id`) REFERENCES `department` (`id`) ON UPDATE CASCADE;
--
-- Constraints for table `password_reset`
--
ALTER TABLE `password_reset`
ADD CONSTRAINT `password_reset_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`);
--
-- Constraints for table `rental_history`
--
ALTER TABLE `rental_history`
ADD CONSTRAINT `rental_history_ibfk_2` FOREIGN KEY (`res_no`) REFERENCES `reservations` (`res_no`),
ADD CONSTRAINT `rental_history_ibfk_3` FOREIGN KEY (`car_id`) REFERENCES `cars` (`car_id`),
ADD CONSTRAINT `rental_history_ibfk_4` FOREIGN KEY (`car_id`) REFERENCES `cars` (`car_id`);
--
-- Constraints for table `reservations`
--#feedback-result{
/* margin-bottom: 10px; */
}
ALTER TABLE `reservations`
ADD CONSTRAINT `reservations_ibfk_3` FOREIGN KEY (`car_id`) REFERENCES `cars` (`car_id`),
ADD CONSTRAINT `reservations_ibfk_4` FOREIGN KEY (`pickup_location_id`) REFERENCES `locations` (`location_id`),
ADD CONSTRAINT `reservations_ibfk_5` FOREIGN KEY (`return_location_id`) REFERENCES `locations` (`location_id`);
--
-- Constraints for table `reviews`
--
ALTER TABLE `reviews`
ADD CONSTRAINT `reviews_ibfk_1` FOREIGN KEY (`car_id`) REFERENCES `cars` (`car_id`);
--
-- Constraints for table `users`
--
ALTER TABLE `users`
ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`user_type`) REFERENCES `user_type` (`id`);
--
-- Constraints for table `user_reservation_bridge`
--
ALTER TABLE `user_reservation_bridge`
ADD CONSTRAINT `user_reservation_bridge_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `user_reservation_bridge_ibfk_2` FOREIGN KEY (`res_no`) REFERENCES `reservations` (`res_no`);
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 */;
|
-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Waktu pembuatan: 19 Jun 2021 pada 08.32
-- Versi server: 10.4.13-MariaDB
-- Versi PHP: 7.4.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `dika-arenda`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `customer`
--
CREATE TABLE `customer` (
`code` varchar(10) NOT NULL,
`nama_customer` varchar(255) NOT NULL,
`alamat` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `customer`
--
INSERT INTO `customer` (`code`, `nama_customer`, `alamat`, `status`) VALUES
('C1', 'Budi', 'Gaten', 'customer'),
('C2', 'Siti', 'Puluhdadi', 'customer'),
('C3', 'Gondrong', 'Giwangan', 'customer'),
('C4', 'Sate', 'Mundu', 'customer'),
('U1', 'Umum', 'btn', 'umum'),
('U2', 'Marsih', 'Saren', 'umum');
-- --------------------------------------------------------
--
-- Struktur dari tabel `detail_penyusutan`
--
CREATE TABLE `detail_penyusutan` (
`id_produk` int(11) NOT NULL,
`id_penyusutan` int(11) NOT NULL,
`ayam_masuk_ekor` int(11) NOT NULL,
`ayam_masuk_kg` float NOT NULL,
`mati_kandang_ekor` int(11) NOT NULL,
`mati_kandang_kg` float NOT NULL,
`mati_armada_ekor` int(11) NOT NULL,
`mati_armada_kg` float NOT NULL,
`mati_rpa_ekor` int(11) NOT NULL,
`mati_rpa_kg` float NOT NULL,
`admin_ekor` int(11) NOT NULL,
`admin_kg` float NOT NULL,
`riil_ekor` int(11) NOT NULL,
`riil_kg` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `detail_penyusutan`
--
INSERT INTO `detail_penyusutan` (`id_produk`, `id_penyusutan`, `ayam_masuk_ekor`, `ayam_masuk_kg`, `mati_kandang_ekor`, `mati_kandang_kg`, `mati_armada_ekor`, `mati_armada_kg`, `mati_rpa_ekor`, `mati_rpa_kg`, `admin_ekor`, `admin_kg`, `riil_ekor`, `riil_kg`) VALUES
(1, 1, 0, 0, 7, 7, 5, 5.5, 3, 4.5, 2000, 2106.7, 1957, 2087.5),
(2, 1, 0, 0, 7, 7, 5, 5.5, 3, 4.5, 2000, 2106.7, 0, 0),
(4, 3, 1111, 1111, 1, 1.1, 1, 1.1, 1, 1.1, 1110, 1110.1, 1101, 1101.1),
(6, 4, 1111, 1112, 2, 2, 2, 2, 2, 2, 1105, 1106, 1100, 1100);
-- --------------------------------------------------------
--
-- Struktur dari tabel `detail_rekening`
--
CREATE TABLE `detail_rekening` (
`code` varchar(10) NOT NULL,
`id_rekening` int(11) NOT NULL,
`tanggal` date NOT NULL,
`saldo_awal` int(11) NOT NULL,
`saldo_akhir` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `detail_rekening`
--
INSERT INTO `detail_rekening` (`code`, `id_rekening`, `tanggal`, `saldo_awal`, `saldo_akhir`) VALUES
('C1', 1, '2021-04-01', 1500000, 360300),
('C2', 2, '2021-04-01', 0, 0),
('C3', 3, '2021-04-01', 0, -2160000),
('C4', 6, '2021-04-01', 0, 4200),
('C1', 1, '2021-05-01', 360300, 360300),
('C2', 2, '2021-05-01', 0, -36000),
('C3', 3, '2021-05-01', -2160000, 1205440),
('C4', 6, '2021-05-01', 4200, 4200),
('C1', 1, '2021-06-01', 360300, 217500),
('C2', 2, '2021-06-01', -36000, -42200),
('C3', 3, '2021-06-01', 1205440, 37840),
('C4', 6, '2021-06-01', 4200, 4200);
-- --------------------------------------------------------
--
-- Struktur dari tabel `detail_transaksi`
--
CREATE TABLE `detail_transaksi` (
`id_transaksi` int(11) NOT NULL,
`id_produk` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Struktur dari tabel `pegawai`
--
CREATE TABLE `pegawai` (
`id_pegawai` int(11) NOT NULL,
`nama_pegawai` varchar(255) NOT NULL,
`telp` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `pegawai`
--
INSERT INTO `pegawai` (`id_pegawai`, `nama_pegawai`, `telp`) VALUES
(1, 'Ronald', '082123321123'),
(2, 'Haryanti', '089765432123');
-- --------------------------------------------------------
--
-- Struktur dari tabel `penjualan`
--
CREATE TABLE `penjualan` (
`id_penjualan` int(11) NOT NULL,
`id_produk` int(11) NOT NULL,
`code` varchar(10) NOT NULL,
`tanggal` date NOT NULL,
`ekor` int(11) NOT NULL,
`kg` float NOT NULL,
`harga` int(11) NOT NULL,
`a_kompensasi` int(11) NOT NULL,
`total` int(11) NOT NULL,
`pembayaran` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `penjualan`
--
INSERT INTO `penjualan` (`id_penjualan`, `id_produk`, `code`, `tanggal`, `ekor`, `kg`, `harga`, `a_kompensasi`, `total`, `pembayaran`) VALUES
(2, 6, 'C1', '2021-06-18', 12, 12, 24000, 0, 288000, 250000),
(3, 7, 'C1', '2021-06-04', 11, 12, 19000, 0, 228000, 200000);
-- --------------------------------------------------------
--
-- Struktur dari tabel `penyusutan`
--
CREATE TABLE `penyusutan` (
`id_penyusutan` int(11) NOT NULL,
`jumlah_ekor` int(11) NOT NULL,
`jumlah_kg` int(11) NOT NULL,
`persentase` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `penyusutan`
--
INSERT INTO `penyusutan` (`id_penyusutan`, `jumlah_ekor`, `jumlah_kg`, `persentase`) VALUES
(1, 15, 17, 0.04),
(3, 3, 3, 99.919),
(4, 6, 6, 99.4604);
-- --------------------------------------------------------
--
-- Struktur dari tabel `produk`
--
CREATE TABLE `produk` (
`id_produk` int(11) NOT NULL,
`tanggal` date NOT NULL,
`stok_ekor` int(100) NOT NULL,
`stok_kg` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `produk`
--
INSERT INTO `produk` (`id_produk`, `tanggal`, `stok_ekor`, `stok_kg`) VALUES
(1, '2021-06-02', 2000, 2106.7),
(2, '2021-06-03', 1500, 1639.8),
(3, '2021-06-15', 1200, 1230.8),
(4, '2021-06-16', 1200, 1230.8),
(5, '2021-06-17', 1200, 1210),
(6, '2021-06-18', 1240, 1250.6),
(7, '2021-06-04', 1489, 1627.8);
-- --------------------------------------------------------
--
-- Struktur dari tabel `rekening`
--
CREATE TABLE `rekening` (
`id_rekening` int(11) NOT NULL,
`saldo_akhir` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `rekening`
--
INSERT INTO `rekening` (`id_rekening`, `saldo_akhir`) VALUES
(1, -70300),
(2, -42200),
(3, 37840),
(6, 4200);
-- --------------------------------------------------------
--
-- Struktur dari tabel `transaksi`
--
CREATE TABLE `transaksi` (
`id_transaksi` int(11) NOT NULL,
`id_vendor` int(11) NOT NULL,
`id_pegawai` int(11) NOT NULL,
`no_surat` varchar(255) NOT NULL,
`jenis_transaksi` varchar(255) NOT NULL,
`tanggal` date NOT NULL,
`ekor` int(11) NOT NULL,
`kg` float NOT NULL,
`harga` int(11) NOT NULL,
`total` int(11) NOT NULL,
`pembayaran` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `transaksi`
--
INSERT INTO `transaksi` (`id_transaksi`, `id_vendor`, `id_pegawai`, `no_surat`, `jenis_transaksi`, `tanggal`, `ekor`, `kg`, `harga`, `total`, `pembayaran`) VALUES
(1, 1, 1, '00213', 'pembelian', '2021-06-18', 100, 135.8, 16200, 2199960, 0),
(2, 2, 1, '', 'pembelian', '2021-06-18', 300, 521.8, 16200, 8453160, 0);
-- --------------------------------------------------------
--
-- Struktur dari tabel `user`
--
CREATE TABLE `user` (
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`role` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `user`
--
INSERT INTO `user` (`username`, `password`, `role`) VALUES
('marketing', '<PASSWORD>', 1),
('pimpinan', '<PASSWORD>', 0);
-- --------------------------------------------------------
--
-- Struktur dari tabel `vendor`
--
CREATE TABLE `vendor` (
`id_vendor` int(11) NOT NULL,
`nama_vendor` varchar(255) NOT NULL,
`alamat` varchar(255) NOT NULL,
`telp` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `vendor`
--
INSERT INTO `vendor` (`id_vendor`, `nama_vendor`, `alamat`, `telp`) VALUES
(1, 'Mustika SLE', 'Sleman', '081321123321'),
(2, 'Mustika KP/GK', 'Kulon Progo', '083456098765');
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `customer`
--
ALTER TABLE `customer`
ADD PRIMARY KEY (`code`);
--
-- Indeks untuk tabel `detail_penyusutan`
--
ALTER TABLE `detail_penyusutan`
ADD KEY `fk_penyusutan_produk` (`id_produk`),
ADD KEY `fk_penyusutan` (`id_penyusutan`);
--
-- Indeks untuk tabel `detail_rekening`
--
ALTER TABLE `detail_rekening`
ADD KEY `fk_code` (`code`),
ADD KEY `fk_rekening` (`id_rekening`);
--
-- Indeks untuk tabel `detail_transaksi`
--
ALTER TABLE `detail_transaksi`
ADD KEY `fk_detail_transaksi` (`id_transaksi`),
ADD KEY `fk_detail_transaksi_produk` (`id_produk`);
--
-- Indeks untuk tabel `pegawai`
--
ALTER TABLE `pegawai`
ADD PRIMARY KEY (`id_pegawai`);
--
-- Indeks untuk tabel `penjualan`
--
ALTER TABLE `penjualan`
ADD PRIMARY KEY (`id_penjualan`),
ADD KEY `fk_code_penjualan` (`code`),
ADD KEY `fk_produk_penjualan` (`id_produk`);
--
-- Indeks untuk tabel `penyusutan`
--
ALTER TABLE `penyusutan`
ADD PRIMARY KEY (`id_penyusutan`);
--
-- Indeks untuk tabel `produk`
--
ALTER TABLE `produk`
ADD PRIMARY KEY (`id_produk`);
--
-- Indeks untuk tabel `rekening`
--
ALTER TABLE `rekening`
ADD PRIMARY KEY (`id_rekening`);
--
-- Indeks untuk tabel `transaksi`
--
ALTER TABLE `transaksi`
ADD PRIMARY KEY (`id_transaksi`),
ADD KEY `fk_vendor` (`id_vendor`),
ADD KEY `fk_pegawai` (`id_pegawai`);
--
-- Indeks untuk tabel `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`username`);
--
-- Indeks untuk tabel `vendor`
--
ALTER TABLE `vendor`
ADD PRIMARY KEY (`id_vendor`);
--
-- AUTO_INCREMENT untuk tabel yang dibuang
--
--
-- AUTO_INCREMENT untuk tabel `pegawai`
--
ALTER TABLE `pegawai`
MODIFY `id_pegawai` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT untuk tabel `penjualan`
--
ALTER TABLE `penjualan`
MODIFY `id_penjualan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT untuk tabel `penyusutan`
--
ALTER TABLE `penyusutan`
MODIFY `id_penyusutan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT untuk tabel `produk`
--
ALTER TABLE `produk`
MODIFY `id_produk` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT untuk tabel `rekening`
--
ALTER TABLE `rekening`
MODIFY `id_rekening` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT untuk tabel `transaksi`
--
ALTER TABLE `transaksi`
MODIFY `id_transaksi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT untuk tabel `vendor`
--
ALTER TABLE `vendor`
MODIFY `id_vendor` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
--
--
-- Ketidakleluasaan untuk tabel `detail_penyusutan`
--
ALTER TABLE `detail_penyusutan`
ADD CONSTRAINT `fk_penyusutan` FOREIGN KEY (`id_penyusutan`) REFERENCES `penyusutan` (`id_penyusutan`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `fk_penyusutan_produk` FOREIGN KEY (`id_produk`) REFERENCES `produk` (`id_produk`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Ketidakleluasaan untuk tabel `detail_rekening`
--
ALTER TABLE `detail_rekening`
ADD CONSTRAINT `fk_code` FOREIGN KEY (`code`) REFERENCES `customer` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `fk_rekening` FOREIGN KEY (`id_rekening`) REFERENCES `rekening` (`id_rekening`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Ketidakleluasaan untuk tabel `detail_transaksi`
--
ALTER TABLE `detail_transaksi`
ADD CONSTRAINT `fk_detail_transaksi` FOREIGN KEY (`id_transaksi`) REFERENCES `transaksi` (`id_transaksi`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `fk_detail_transaksi_produk` FOREIGN KEY (`id_produk`) REFERENCES `produk` (`id_produk`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Ketidakleluasaan untuk tabel `penjualan`
--
ALTER TABLE `penjualan`
ADD CONSTRAINT `fk_code_penjualan` FOREIGN KEY (`code`) REFERENCES `customer` (`code`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `fk_produk_penjualan` FOREIGN KEY (`id_produk`) REFERENCES `produk` (`id_produk`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Ketidakleluasaan untuk tabel `transaksi`
--
ALTER TABLE `transaksi`
ADD CONSTRAINT `fk_pegawai` FOREIGN KEY (`id_pegawai`) REFERENCES `pegawai` (`id_pegawai`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `fk_vendor` FOREIGN KEY (`id_vendor`) REFERENCES `vendor` (`id_vendor`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<reponame>pradeepkumarcm-egov/DIGIT-Dev
alter table eg_applicationindex add column sla integer;
alter table eg_applicationindex add column slagap integer;
--alter table eg_applicationindex drop column sla;
--alter table eg_applicationindex drop column slagap;
|
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: May 26, 2019 at 02:50 PM
-- Server version: 5.7.26-0ubuntu0.16.04.1
-- PHP Version: 7.0.33-0ubuntu0.16.04.4
CREATE DATABASE IF NOT EXISTS smart_home;
USE smart_home;
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: `smart_home`
--
-- --------------------------------------------------------
--
-- Table structure for table `Devices`
--
CREATE TABLE `Devices` (
`id` int(11) NOT NULL,
`name` varchar(64) NOT NULL,
`description` varchar(128) NOT NULL,
`state` int(11) NOT NULL,
`type` int(11) NOT NULL
`x` int(5) NOT NULL
`y` int(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Devices`
--
INSERT INTO `Devices` (`id`, `name`, `description`, `state`, `type`, `posx`, `posy`) VALUES
(1, 'Lampara Living 1', 'Luz living A', 1, 0, 165, 58),
(2, 'Valador 2', 'Velador 2 - Habitación 1', 0, 0, 60, 50),
(3, 'Luz Cocina', 'Luz led cocina', 0, 0, 75, 25),
(5, 'Cortina Habitación 2', 'Cortina Automática Habitación 2', 61, 1, 155, 112),
(6, '<NAME>', 'Luz mesa comedor dimerizable', 0, 1, 113, 50),
(15, 'Velador 1', 'Velador 1 - Habitación 1', 1, 0, 37, 65),
(17, 'Aire Acondicionado 1', 'Aire Acondicionado Living - Control de Temperatura', 0, 1, 92, 22);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `Devices`
--
ALTER TABLE `Devices`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `Devices`
--
ALTER TABLE `Devices`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
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 */;
|
-- analyze2.test
--
-- execsql {
-- DROP TABLE IF EXISTS t4;
-- CREATE TABLE t5(a, b); CREATE INDEX t5i ON t5(a, b);
-- CREATE TABLE t6(a, b); CREATE INDEX t6i ON t6(a, b);
-- }
DROP TABLE IF EXISTS t4;
CREATE TABLE t5(a, b); CREATE INDEX t5i ON t5(a, b);
CREATE TABLE t6(a, b); CREATE INDEX t6i ON t6(a, b);
|
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1
Source Server Version : 80012
Source Host : 127.0.0.1:3306
Source Database : tp_layim
Target Server Type : MYSQL
Target Server Version : 80012
File Encoding : 65001
Date: 2020-11-21 09:46:02
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for yz_chat_recoed
-- ----------------------------
DROP TABLE IF EXISTS `yz_chat_recoed`;
CREATE TABLE `yz_chat_recoed` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键',
`fromname` varchar(65) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发送人昵称',
`fromavatar` varchar(120) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发送人头像',
`send` int(10) NOT NULL COMMENT '发送者',
`receive` int(10) NOT NULL COMMENT '接收者',
`content` varchar(1024) COLLATE utf8mb4_general_ci NOT NULL COMMENT '发送内容',
`send_time` int(11) NOT NULL COMMENT '发送时间',
`type` enum('group','friend') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'friend' COMMENT '聊天类型',
`is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0 未读 1 以读',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=203 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='聊天记录表';
-- ----------------------------
-- Table structure for yz_group
-- ----------------------------
DROP TABLE IF EXISTS `yz_group`;
CREATE TABLE `yz_group` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`accunt` varchar(20) COLLATE utf8mb4_general_ci NOT NULL COMMENT '群号',
`groupname` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '群名称',
`des` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群描述',
`number` smallint(3) DEFAULT '0' COMMENT '人数',
`approval` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 无需验证 1 需要验证',
`group_status` tinyint(1) DEFAULT '1' COMMENT '1 正常 2全员禁言',
`avatar` varchar(128) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '/static/images/defult_image.png' COMMENT '群头像',
`owner_name` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT '群主名称',
`owner_id` int(10) NOT NULL COMMENT '群主id',
`owner_avatar` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群主头像',
`owner_sign` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群主签名',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='群聊天表';
-- ----------------------------
-- Table structure for yz_group_member
-- ----------------------------
DROP TABLE IF EXISTS `yz_group_member`;
CREATE TABLE `yz_group_member` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL COMMENT '群id',
`member_id` int(11) NOT NULL COMMENT '用户id',
`status` tinyint(1) DEFAULT '1' COMMENT '1 正常 2 为该群黑名单',
`add_time` int(11) DEFAULT NULL COMMENT '加群时间',
`type` tinyint(1) DEFAULT '3' COMMENT '1群主 2管理员 3会员',
`forbidden_speech_time` int(11) DEFAULT '0' COMMENT '禁言到某个时间',
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群员昵称',
`useravatar` varchar(120) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群主头像',
`usersign` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户签名',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='群员表';
-- ----------------------------
-- Table structure for yz_member
-- ----------------------------
DROP TABLE IF EXISTS `yz_member`;
CREATE TABLE `yz_member` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`account` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账号',
`password` char(32) NOT NULL COMMENT '密码',
`salt` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '秘钥',
`birthday` int(11) DEFAULT NULL COMMENT '生日',
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '匿名' COMMENT '昵称',
`sex` tinyint(4) DEFAULT '3' COMMENT '性别1男2女3保密',
`status` tinyint(4) DEFAULT '0' COMMENT '在线状态0不在线1在线',
`sign` varchar(65) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '签名',
`email` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '邮箱',
`phone` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '电话',
`blood_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '其他血型' COMMENT 'A型 B型 AB型 0型 其他血型',
`job` tinyint(4) DEFAULT '0' COMMENT '1计算机/互联网/通信 2生产/工艺/制造 3医疗/护理/制药 4金融/银行/投资/保险 5商业/服务业/个体经营 6文化/广告/传媒 7娱乐/艺术/表演 8律师/法务 9教育/培训 10共五月/行政/事业单位 11 模特 12空姐 13 学生 14 其他',
`avatar` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '/static/ images/default_ image.png' COMMENT '头像',
`qq` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT 'qq号',
`create_time` int(11) unsigned DEFAULT NULL COMMENT '创建时间',
`update_time` int(11) unsigned DEFAULT NULL COMMENT '更新时间',
`login_time` int(11) unsigned DEFAULT NULL COMMENT '上一次登录时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='会员表';
-- ----------------------------
-- Table structure for yz_message
-- ----------------------------
DROP TABLE IF EXISTS `yz_message`;
CREATE TABLE `yz_message` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`msg_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1 请求添加用户 2系统(加好友) 3 请求加群 4 系统(加群) 5全体会员消息',
`send` int(11) NOT NULL COMMENT '消息发送者',
`receive` int(11) NOT NULL COMMENT '消息接收者',
`msg_status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1未读 2同意 3拒绝 4 同意且返回消息以读 5拒绝且返回消息以读 6 全体消息以读',
`remark` varchar(128) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附加消息',
`send_time` int(11) DEFAULT NULL COMMENT '发送消息时间',
`read_time` int(11) DEFAULT NULL COMMENT '接收消息时间',
`receive_group` int(11) DEFAULT NULL COMMENT '接收消息的群主',
`andle_group` int(11) DEFAULT NULL COMMENT '处理该请求的群主',
`my_group` int(11) DEFAULT NULL COMMENT '好友分组',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='通知表';
-- ----------------------------
-- Table structure for yz_my_friend
-- ----------------------------
DROP TABLE IF EXISTS `yz_my_friend`;
CREATE TABLE `yz_my_friend` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL COMMENT '分组id',
`member_id` int(11) NOT NULL COMMENT '好友id',
`username` varchar(65) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '好友昵称',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='会员分组下好友列表';
-- ----------------------------
-- Table structure for yz_my_group
-- ----------------------------
DROP TABLE IF EXISTS `yz_my_group`;
CREATE TABLE `yz_my_group` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主健ID',
`member_id` int(11) NOT NULL COMMENT '会员ID',
`group_name` varchar(128) NOT NULL COMMENT '分组名称',
`sort` tinyint(4) DEFAULT '1' COMMENT '好友分组的排列顺序越小越靠前',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COMMENT='会员好友分组表';
-- ----------------------------
-- Table structure for yz_skin
-- ----------------------------
DROP TABLE IF EXISTS `yz_skin`;
CREATE TABLE `yz_skin` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`member_id` int(10) unsigned NOT NULL COMMENT '会员ID',
`url` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '皮肤地址',
`is_user_upload` tinyint(1) DEFAULT '0' COMMENT '1用户自定义 0默认',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='皮肤表';
|
<reponame>tbolis/spring-oauth2-gateway
-- Initial Data
-- @formatter:off
-- Authorities
INSERT INTO auth_authority (NAME, DESCRIPTION) VALUES ('ROLE_ADMIN', 'System Administrator');
INSERT INTO auth_authority (NAME, DESCRIPTION) VALUES ('ROLE_USER', 'Authorized User');
-- Users
INSERT INTO auth_user (id, login, password, first_name, last_name, email, activated, lang_key, created_by, created_date) VALUES (1, 'admin', <PASSWORD>', 'Administrator', 'Administrator','admin@localhost', TRUE, 'en', 'system', current_timestamp);
INSERT INTO auth_user_authority (user_id, authority_name) VALUES (1, 'ROLE_ADMIN');
-- OAuth2 Clients
INSERT INTO oauth_client_details (client_id, resource_ids, client_secret, scope, authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information, autoapprove) VALUES ('backend', 'OAuth2Server', '$2a$10$K98cVwJOlwUOIAYrHVICveUZh.jj9N0D3XSVHiAmevCNsJ9ulwLrq', 'read,write', 'password,refresh_token', null, 'ROLE_ADMIN', 900, 172800, null, null);
INSERT INTO oauth_client_details (client_id, resource_ids, client_secret, scope, authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, refresh_token_validity, additional_information, autoapprove) VALUES ('client', 'OAuth2Server', 'bSZRuJkLDgCWupmH', 'read,write', 'authorization_code', 'http://localhost:8082/home', 'ROLE_USER', 900, 172800, null, 'true');
-- @formatter:on
|
<filename>source/exercises.sql<gh_stars>0
@exercises/exercise_1.sql
@exercises/exercise_2.sql
|
<reponame>zzsoszz/MyPaper<filename>database/oracle/plsql-utils-v170/ora/rss_util_pkg.pkb
create or replace package body rss_util_pkg
as
/*
Purpose: Package handles web feeds (RSS/Atom)
Remarks:
Who Date Description
------ ---------- -------------------------------------
MBR 22.01.2011 Created
*/
g_date_format_rss constant varchar2(50) := 'Dy, DD Mon YYYY HH24:MI:SS "+0000"';
g_date_format_rdf constant varchar2(50) := 'YYYY-MM-DD"T"HH24:MI:SS".000Z"';
g_date_format_atom constant varchar2(50) := 'YYYY-MM-DD"T"HH24:MI:SS".000Z"';
g_namespace_rdf constant varchar2(255) := 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/"';
g_namespace_atom constant varchar2(255) := 'xmlns="http://www.w3.org/2005/Atom"';
function fmt_date (p_date in date,
p_format in varchar2 := null) return varchar2
as
l_returnvalue varchar2(100);
begin
/*
Purpose: format date for feed
Remarks:
Who Date Description
------ ---------- -------------------------------------
MBR 22.01.2011 Created
*/
if p_format = g_format_rss then
l_returnvalue := to_char(p_date, g_date_format_rss);
elsif p_format = g_format_rdf then
l_returnvalue := to_char(p_date, g_date_format_rdf);
elsif p_format = g_format_atom then
l_returnvalue := to_char(p_date, g_date_format_atom);
end if;
return l_returnvalue;
end fmt_date;
function get_date (p_date_str in varchar2,
p_format in varchar2 := null) return date
as
l_returnvalue date;
begin
/*
Purpose: get date for specific feed format
Remarks: for RSS, we ignore the timezone part
for RDF/Atom, the fractional seconds part is optional, we ignore it always
Who Date Description
------ ---------- -------------------------------------
MBR 22.01.2011 Created
MBR 21.04.2012 Fixed: l_returnvalue was defined as varchar2 instead of date
*/
begin
if p_format = g_format_rss then
--l_returnvalue := to_date(p_date_str, g_date_format_rss);
l_returnvalue := to_date(substr(p_date_str,1,26), 'Dy, DD Mon YYYY HH24:MI:SS');
elsif p_format = g_format_rdf then
--l_returnvalue := to_date(p_date_str, g_date_format_rdf);
l_returnvalue := to_date(substr(p_date_str,1,19), 'YYYY-MM-DD"T"HH24:MI:SS');
elsif p_format = g_format_atom then
--l_returnvalue := to_date(p_date_str, g_date_format_atom);
l_returnvalue := to_date(substr(p_date_str,1,19), 'YYYY-MM-DD"T"HH24:MI:SS');
end if;
exception
when others then
l_returnvalue := null;
end;
return l_returnvalue;
end get_date;
function ref_cursor_to_feed (p_ref_cursor in sys_refcursor,
p_feed_title in varchar2,
p_feed_description in varchar2 := null,
p_feed_link in varchar2 := null,
p_feed_date in date := null,
p_format in varchar2 := null) return clob
as
l_format varchar2(10) := nvl(p_format, g_format_rss);
l_items t_feed_item_list;
l_returnvalue clob;
begin
/*
Purpose: ref cursor to rss
Remarks: the ref cursor (query) used must match the definition of the t_feed_item type (column order and data types),
although the actual column names are irrelevant
Who Date Description
------ ---------- -------------------------------------
MBR 22.01.2011 Created
MBR 10.10.2011 Added escaping of special characters in title/description
*/
fetch p_ref_cursor
bulk collect
into l_items;
close p_ref_cursor;
if l_format = g_format_rss then
l_returnvalue := '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>' || htf.escape_sc(p_feed_title) || '</title>
<description>' || htf.escape_sc(p_feed_description) || '</description>
<link>' || p_feed_link || '</link>
<lastBuildDate>' || fmt_date(nvl(p_feed_date, sysdate), l_format) || '</lastBuildDate>
<pubDate>' || fmt_date(sysdate, p_format) || '</pubDate>';
for i in 1 .. l_items.count loop
l_returnvalue := l_returnvalue || '
<item>
<title>' || htf.escape_sc(l_items(i).item_title) || '</title>
<description>' || htf.escape_sc(l_items(i).item_description) || '</description>
<link>' || l_items(i).item_link || '</link>
<guid>' || l_items(i).item_guid || '</guid>
<pubDate>' || fmt_date (l_items(i).item_date, l_format) || '</pubDate>
</item>';
end loop;
l_returnvalue := l_returnvalue || '</channel></rss>';
elsif l_format = g_format_rdf then
l_returnvalue := '<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF ' || g_namespace_rdf || '>
<channel>
<title>' || htf.escape_sc(p_feed_title) || '</title>
<description>' || htf.escape_sc(p_feed_description) || '</description>
<link>' || p_feed_link || '</link>
<dc:date>' || fmt_date(nvl(p_feed_date, sysdate), l_format) || '</dc:date>
<items>
<rdf:Seq>';
for i in 1 .. l_items.count loop
l_returnvalue := l_returnvalue || '
<rdf:li resource="' || l_items(i).item_guid || '" />';
end loop;
l_returnvalue := l_returnvalue || '</rdf:Seq></items></channel>';
for i in 1 .. l_items.count loop
l_returnvalue := l_returnvalue || '
<item rdf:about="' || l_items(i).item_guid || '">
<title>' || htf.escape_sc(l_items(i).item_title) || '</title>
<description>' || htf.escape_sc(l_items(i).item_description) || '</description>
<link>' || l_items(i).item_link || '</link>
<dc:date>' || fmt_date (l_items(i).item_date, l_format) || '</dc:date>
</item>';
end loop;
l_returnvalue := l_returnvalue || '</rdf:RDF>';
elsif l_format = g_format_atom then
l_returnvalue := '<?xml version="1.0" encoding="UTF-8" ?>
<feed ' || g_namespace_atom || '>
<title>' || htf.escape_sc(p_feed_title) || '</title>
<subtitle>' || htf.escape_sc(p_feed_description) || '</subtitle>
<link href="' || p_feed_link || '" rel="self" />
<link href="' || p_feed_link || '" />
<id>' || to_char(sysdate, 'yyyymmddhh24miss') || '</id>
<updated>' || fmt_date(nvl(p_feed_date, sysdate), l_format) || '</updated>';
for i in 1 .. l_items.count loop
l_returnvalue := l_returnvalue || '
<entry>
<title>' || htf.escape_sc(l_items(i).item_title) || '</title>
<link href="' || l_items(i).item_link || '" />
<link rel="alternate" type="text/html" href="' || l_items(i).item_link || '"/>
<link rel="edit" href="' || l_items(i).item_link || '"/>
<id>' || l_items(i).item_guid || '</id>
<updated>' || fmt_date (l_items(i).item_date, l_format) || '</updated>
<summary>' || htf.escape_sc(l_items(i).item_description) || '</summary>
</entry>';
end loop;
l_returnvalue := l_returnvalue || '</feed>';
end if;
return l_returnvalue;
end ref_cursor_to_feed;
function get_format (p_xml in xmltype) return varchar2
as
l_returnvalue varchar2(10);
begin
/*
Purpose: attempt to autodetect format based on XML
Remarks:
Who Date Description
------ ---------- -------------------------------------
MBR 22.01.2011 Created
*/
begin
if p_xml.existsnode ('/rdf:RDF', g_namespace_rdf) = 1 then
l_returnvalue := g_format_rdf;
elsif p_xml.existsnode ('/feed', g_namespace_atom) = 1 then
l_returnvalue := g_format_atom;
else
l_returnvalue := g_format_rss;
end if;
exception
when others then
l_returnvalue := g_format_rss;
end;
return l_returnvalue;
end get_format;
function rss_to_list (p_feed in clob,
p_format in varchar2 := null) return t_feed_item_list
as
l_returnvalue t_feed_item_list;
l_xml xmltype;
l_count pls_integer := 0;
l_format varchar2(10);
begin
/*
Purpose: rss feed to list
Remarks: problem with 10g, extractValue and node text over 4k (typically in description field), see http://forums.oracle.com/forums/thread.jspa?threadID=353436
Who Date Description
------ ---------- -------------------------------------
MBR 22.01.2011 Created
*/
l_xml := xmltype (p_feed);
l_format := coalesce (p_format, get_format (l_xml));
if l_format = g_format_rss then
for l_rec in (
select extractValue(value(t), '*/guid') as item_guid,
extractValue(value(t), '*/title') as item_title,
extractValue(value(t), '*/description') as item_description,
extractValue(value(t), '*/link') as item_link,
extractValue(value(t), '*/pubDate') as item_date
from table(xmlsequence(l_xml.extract('//rss/channel/item'))) t
) loop
l_count := l_count + 1;
l_returnvalue(l_count).item_guid := l_rec.item_guid;
l_returnvalue(l_count).item_title := l_rec.item_title;
l_returnvalue(l_count).item_description := l_rec.item_description;
l_returnvalue(l_count).item_link := l_rec.item_link;
l_returnvalue(l_count).item_date := get_date (l_rec.item_date, l_format);
end loop;
elsif l_format = g_format_rdf then
for l_rec in (
select extractValue(value(t), '*/@rdf:about', g_namespace_rdf) as item_guid,
extractValue(value(t), '*/title', g_namespace_rdf) as item_title,
extractValue(value(t), '*/description', g_namespace_rdf) as item_description,
extractValue(value(t), '*/link', g_namespace_rdf) as item_link,
extractValue(value(t), '*/dc:date', g_namespace_rdf) as item_date
from table(xmlsequence(l_xml.extract('//rdf:RDF/item', g_namespace_rdf))) t
) loop
l_count := l_count + 1;
l_returnvalue(l_count).item_guid := l_rec.item_guid;
l_returnvalue(l_count).item_title := l_rec.item_title;
l_returnvalue(l_count).item_description := l_rec.item_description;
l_returnvalue(l_count).item_link := l_rec.item_link;
l_returnvalue(l_count).item_date := get_date (l_rec.item_date, l_format);
end loop;
elsif l_format = g_format_atom then
for l_rec in (
select extractValue(value(t), '*/id', g_namespace_atom) as item_guid,
extractValue(value(t), '*/title', g_namespace_atom) as item_title,
extractValue(value(t), '*/summary', g_namespace_atom) as item_description,
extractValue(value(t), '*/link[1]/@href', g_namespace_atom) as item_link,
extractValue(value(t), '*/updated', g_namespace_atom) as item_date
from table(xmlsequence(l_xml.extract('//feed/entry', g_namespace_atom))) t
) loop
l_count := l_count + 1;
l_returnvalue(l_count).item_guid := l_rec.item_guid;
l_returnvalue(l_count).item_title := l_rec.item_title;
l_returnvalue(l_count).item_description := l_rec.item_description;
l_returnvalue(l_count).item_link := l_rec.item_link;
l_returnvalue(l_count).item_date := get_date (l_rec.item_date, l_format);
end loop;
end if;
return l_returnvalue;
end rss_to_list;
function rss_to_table (p_feed in clob,
p_format in varchar2 := null) return t_feed_item_tab pipelined
as
l_items t_feed_item_list;
begin
/*
Purpose: rss feed to table rows
Remarks:
Who Date Description
------ ---------- -------------------------------------
MBR 22.01.2011 Created
*/
l_items := rss_to_list (p_feed, p_format);
for i in 1 .. l_items.count loop
pipe row (l_items(i));
end loop;
return;
end rss_to_table;
end rss_util_pkg;
/
|
<filename>migrations/2018-04-08-160446_audit_log/down.sql
DROP TABLE audit_log;
|
/*
Table that creates a debit record to Discounts Refunds Given and a credit record to the specified income account.
*/
--To disable this model, set the using_credit_memo variable within your dbt_project.yml file to False.
{{ config(enabled=var('using_credit_memo', True)) }}
with credit_memos as (
select *
from {{ref('stg_quickbooks__credit_memo')}}
),
credit_memo_lines as (
select *
from {{ref('stg_quickbooks__credit_memo_line')}}
),
items as (
select *
from {{ref('stg_quickbooks__item')}}
),
accounts as (
select *
from {{ ref('stg_quickbooks__account') }}
),
df_accounts as (
select
account_id as account_id
from accounts
where account_type = 'Accounts Receivable'
and is_active
),
credit_memo_join as (
select
credit_memos.credit_memo_id as transaction_id,
credit_memos.transaction_date,
credit_memo_lines.amount,
coalesce(credit_memo_lines.sales_item_account_id, items.income_account_id, items.expense_account_id) as account_id,
credit_memos.customer_id
from credit_memos
inner join credit_memo_lines
on credit_memos.credit_memo_id = credit_memo_lines.credit_memo_id
left join items
on credit_memo_lines.sales_item_item_id = items.item_id
where coalesce(credit_memo_lines.discount_account_id, credit_memo_lines.sales_item_account_id, credit_memo_lines.sales_item_item_id) is not null
),
final as (
select
transaction_id,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_int() }}) as vendor_id,
amount * -1 as amount,
account_id,
'credit' as transaction_type,
'credit_memo' as transaction_source
from credit_memo_join
union all
select
transaction_id,
transaction_date,
customer_id,
cast(null as {{ dbt_utils.type_int() }}) as vendor_id,
amount * -1 as amount,
df_accounts.account_id,
'debit' as transaction_type,
'credit_memo' as transaction_source
from credit_memo_join
cross join df_accounts
)
select *
from final
|
<gh_stars>1000+
select if(number>1, true, false) from numbers(3) order by number;
select if(number>1, number, 1) from numbers(3) order by number;
select if(number<1, 2, number) from numbers(3) order by number;
select if(number>0, 'Z+', 'zero') from numbers(3) order by number;
select if(number<1, true, null) from numbers(3) order by number;
select typeof(if(number % 3 = 0, to_uint32(1), to_int64(3))) from numbers(10) limit 1;
select typeof(if(number % 3 = 0, to_uint32(1), to_float32(3))) from numbers(10) limit 1;
SELECT if (number % 3 = 1, null, number) as a FROM numbers(7) order by number;
|
<reponame>germanohaus/crud-api-pets
/***************************** owner ****************************/
INSERT INTO [dbo].owner (name) values ('<NAME>')
go
INSERT INTO [dbo].owner (name) values ('<NAME>')
go
INSERT INTO [dbo].owner (name) values ('<NAME>')
go
/***************************** cats ****************************/
insert into [dbo].cats (name,age,ownerid) values ('Lily',5,1)
go
insert into [dbo].cats (name,age,ownerid) values ('Chloe',2,3)
go
insert into [dbo].cats (name,age,ownerid) values ('Charlie',3,2)
go
/***************************** dogs ****************************/
insert into [dbo].dogs (name,age,ownerid) values ('Maggie',1,2)
go
insert into [dbo].dogs (name,age,ownerid) values ('Duke',7,1)
go
insert into [dbo].dogs (name,age,ownerid) values ('Buddy',4,2)
go
|
<reponame>Pacotreflip/salonesupiicsa.com.mx
-- MySQL Script generated by MySQL Workbench
-- 03/31/16 12:03:24
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema crf
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema crf
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `crf` DEFAULT CHARACTER SET utf8 ;
USE `crf` ;
-- -----------------------------------------------------
-- Table `crf`.`secuencias`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crf`.`secuencias` (
`id_secuencia` INT NOT NULL,
`clave` VARCHAR(5) NULL,
`carrera` VARCHAR(45) NULL,
PRIMARY KEY (`id_secuencia`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crf`.`edificios`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crf`.`edificios` (
`id_edificio` INT NOT NULL,
`clave` VARCHAR(2) NULL,
PRIMARY KEY (`id_edificio`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crf`.`academias`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crf`.`academias` (
`id_academia` INT NOT NULL,
`nombre` VARCHAR(45) NULL,
`id_edificio` INT NOT NULL,
PRIMARY KEY (`id_academia`, `id_edificio`),
INDEX `fk_id_edificio_idx` (`id_edificio` ASC),
CONSTRAINT `fk_id_edificio`
FOREIGN KEY (`id_edificio`)
REFERENCES `crf`.`edificios` (`id_edificio`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crf`.`materias`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crf`.`materias` (
`id_materia` INT NOT NULL,
`clave` VARCHAR(10) NULL,
`nombre` VARCHAR(100) NULL,
`id_secuencia` INT NOT NULL,
`id_academia` INT NOT NULL,
PRIMARY KEY (`id_materia`, `id_secuencia`, `id_academia`),
INDEX `fk_materias_secuencias1_idx` (`id_secuencia` ASC),
INDEX `fk_materias_academias1_idx` (`id_academia` ASC),
CONSTRAINT `fk_materias_secuencias1`
FOREIGN KEY (`id_secuencia`)
REFERENCES `crf`.`secuencias` (`id_secuencia`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_materias_academias1`
FOREIGN KEY (`id_academia`)
REFERENCES `crf`.`academias` (`id_academia`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crf`.`salones`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crf`.`salones` (
`id_salon` INT NOT NULL,
`clave` VARCHAR(10) NULL,
`id_edificio` INT NULL,
PRIMARY KEY (`id_salon`, `id_edificio`),
INDEX `fk_id_edificio1_idx` (`id_edificio` ASC),
CONSTRAINT `fk_id_edificio1`
FOREIGN KEY (`id_edificio`)
REFERENCES `crf`.`edificios` (`id_edificio`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crf`.`dias`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crf`.`dias` (
`id_dia` INT NOT NULL,
`clave` VARCHAR(1) NULL,
`nombre` VARCHAR(9) NULL,
PRIMARY KEY (`id_dia`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `crf`.`materias_salones`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `crf`.`materias_salones` (
`id_materias_salones` INT NOT NULL,
`id_materia` INT NOT NULL,
`id_salon` INT NOT NULL,
`id_dia` INT NOT NULL,
PRIMARY KEY (`id_materias_salones`, `id_materia`, `id_salon`, `id_dia`),
INDEX `fk_materias_salones_materias1_idx` (`id_materia` ASC),
INDEX `fk_materias_salones_salones1_idx` (`id_salon` ASC),
INDEX `fk_materias_salones_dias1_idx` (`id_dia` ASC),
CONSTRAINT `fk_materias_salones_materias1`
FOREIGN KEY (`id_materia`)
REFERENCES `crf`.`materias` (`id_materia`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_materias_salones_salones1`
FOREIGN KEY (`id_salon`)
REFERENCES `crf`.`salones` (`id_salon`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_materias_salones_dias1`
FOREIGN KEY (`id_dia`)
REFERENCES `crf`.`dias` (`id_dia`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
<reponame>nitikornearthcm/create_qrcode_url<gh_stars>0
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 100422
Source Host : localhost:3306
Source Schema : url_db
Target Server Type : MySQL
Target Server Version : 100422
File Encoding : 65001
Date: 25/03/2022 04:57:25
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for url_generate
-- ----------------------------
DROP TABLE IF EXISTS `url_generate`;
CREATE TABLE `url_generate` (
`url_id` int NOT NULL AUTO_INCREMENT COMMENT 'รหัสรายการสราง url',
`full_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'full url',
`short_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'short url',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT 'เวลาในการสร้างรายการ short url',
PRIMARY KEY (`url_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of url_generate
-- ----------------------------
INSERT INTO `url_generate` VALUES (1, 'https://ocsc9.thaijobjob.com/search/paystatus/', 'http://localhost/create_qrcode_url/Short?url=d52a0', '2022-03-24 15:38:22');
INSERT INTO `url_generate` VALUES (2, 'https://www.w3schools.com/tags/att_a_target.asp', 'http://localhost/create_qrcode_url/Short?url=68df5', '2022-03-24 15:39:21');
INSERT INTO `url_generate` VALUES (3, 'https://ocsc9.thaijobjob.com/search/paystatus/', 'http://localhost/create_qrcode_url/Short?url=14acb', '2022-03-24 15:41:11');
SET FOREIGN_KEY_CHECKS = 1;
|
CREATE TABLE [dbo].[InvoiceLinks]
(
[Id] INT IDENTITY (1, 1) NOT NULL,
[LinkId] NVARCHAR(50) NOT NULL,
[InvoiceId] INT NOT NULL,
[Expired] BIT NOT NULL,
CONSTRAINT [PK_InvoiceLinkss] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_InvoiceLinks_Invoices] FOREIGN KEY ([InvoiceId]) REFERENCES [dbo].[Invoices]([Id])
)
|
-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 16, 2020 at 01:52 AM
-- Server version: 10.4.17-MariaDB
-- PHP Version: 8.0.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `covid19_korsel`
--
-- --------------------------------------------------------
--
-- Table structure for table `city`
--
CREATE TABLE `city` (
`idCity` int(10) NOT NULL AUTO_INCREMENT,
`city` varchar(20) NOT NULL,
`idProvince` int(10) NOT NULL,
PRIMARY KEY (`idCity`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `city`
--
INSERT INTO `city` (`idCity`, `city`, `idProvince`) VALUES
(0, 'Tidak Diketahui', 0),
(1, 'Gangnam-gu', 1),
(2, 'Gangdong-gu', 1),
(3, 'Gangbuk-gu', 1),
(4, 'Gangseo-gu', 1),
(5, 'Gwanak-gu', 1),
(6, 'Gwangjin-gu', 1),
(7, 'Guro-gu', 1),
(8, 'Geumcheon-gu', 1),
(9, 'Nowon-gu', 1),
(10, 'Dobong-gu', 1),
(11, 'Dongdaemun-gu', 1),
(12, 'Dongjak-gu', 1),
(13, 'Mapo-gu', 1),
(14, 'Seodaemun-gu', 1),
(15, 'Seocho-gu', 1),
(16, 'Seongdong-gu', 1),
(17, 'Seongbuk-gu', 1),
(18, 'Songpa-gu', 1),
(19, 'Yangcheon-gu', 1),
(20, 'Yeongdeungpo-gu', 1),
(21, 'Yongsan-gu', 1),
(22, 'Eunpyeong-gu', 1),
(23, 'Jongno-gu', 1),
(24, 'Jung-gu', 1),
(25, 'Jungnang-gu', 1),
(26, 'Gangseo-gu', 2),
(27, 'Geumjeong-gu', 2),
(28, 'Gijang-gun', 2),
(29, 'Nam-gu', 2),
(30, 'Dong-gu', 2),
(31, 'Dongnae-gu', 2),
(32, 'Busanjin-gu', 2),
(33, 'Buk-gu', 2),
(34, 'Sasang-gu', 2),
(35, 'Saha-gu', 2),
(36, 'Seo-gu', 2),
(37, 'Suyeong-gu', 2),
(38, 'Yeonje-gu', 2),
(39, 'Yeongdo-gu', 2),
(40, 'Jung-gu', 2),
(41, 'Haeundae-gu', 2),
(42, 'Nam-gu', 3),
(43, 'Dalseo-gu', 3),
(44, 'Dalseong-gun', 3),
(45, 'Dong-gu', 3),
(46, 'Buk-gu', 3),
(47, 'Seo-gu', 3),
(48, 'Suseong-gu', 3),
(49, 'Jung-gu', 3),
(50, 'Gwangsan-gu', 4),
(51, 'Nam-gu', 4),
(52, 'Dong-gu', 4),
(53, 'Buk-gu', 4),
(54, 'Seo-gu', 4),
(55, 'Ganghwa-gun', 5),
(56, 'Gyeyang-gu', 5),
(57, 'Michuhol-gu', 5),
(58, 'Namdong-gu', 5),
(59, 'Dong-gu', 5),
(60, 'Bupyeong-gu', 5),
(61, 'Seo-gu', 5),
(62, 'Yeonsu-gu', 5),
(63, 'Ongjin-gun', 5),
(64, 'Jung-gu', 5),
(65, 'Daedeok-gu', 6),
(66, 'Dong-gu', 6),
(67, 'Seo-gu', 6),
(68, 'Yuseong-gu', 6),
(69, 'Jung-gu', 6),
(70, 'Nam-gu', 7),
(71, 'Dong-gu', 7),
(72, 'Buk-gu', 7),
(73, 'Ulju-gun', 7),
(74, 'Jung-gu', 7),
(75, 'Sejong', 8),
(76, 'Gapyeong-gun', 9),
(77, 'Goyang-si', 9),
(78, 'Gwacheon-si', 9),
(79, 'Gwangmyeong-si', 9),
(80, 'Gwangju-si', 9),
(81, 'Guri-si', 9),
(82, 'Gunpo-si', 9),
(83, 'Gimpo-si', 9),
(84, 'Namyangju-si', 9),
(85, 'Dongducheon-si', 9),
(86, 'Bucheon-si', 9),
(87, 'Seongnam-si', 9),
(88, 'Suwon-si', 9),
(89, 'Siheung-si', 9),
(90, 'Ansan-si', 9),
(91, 'Anseong-si', 9),
(92, 'Anyang-si', 9),
(93, 'Yangju-si', 9),
(94, 'Yangpyeong-gun', 9),
(95, 'Yeoju-si', 9),
(96, 'Yeoncheon-gun', 9),
(97, 'Osan-si', 9),
(98, 'Yongin-si', 9),
(99, 'Uiwang-si', 9),
(100, 'Uijeongbu-si', 9),
(101, 'Icheon-si', 9),
(102, 'Paju-si', 9),
(103, 'Pyeongtaek-si', 9),
(104, 'Pocheon-si', 9),
(105, 'Hanam-si', 9),
(106, 'Hwaseong-si', 9),
(107, 'Gangneung-si', 10),
(108, 'Goseong-gun', 10),
(109, 'Donghae-si', 10),
(110, 'Samcheok-si', 10),
(111, 'Sokcho-si', 10),
(112, 'Yanggu-gun', 10),
(113, 'Yangyang-gun', 10),
(114, 'Yeongwol-gun', 10),
(115, 'Wonju-si', 10),
(116, 'Inje-gun', 10),
(117, 'Jeongseon-gun', 10),
(118, 'Cheorwon-gun', 10),
(119, 'Chuncheon-si', 10),
(120, 'Taebaek-si', 10),
(121, 'Pyeongchang-gun', 10),
(122, 'Hongcheon-gun', 10),
(123, 'Hwacheon-gun', 10),
(124, 'Hoengseong-gun', 10),
(125, 'Goesan-gun', 11),
(126, 'Danyang-gun', 11),
(127, 'Boeun-gun', 11),
(128, 'Yeongdong-gun', 11),
(129, 'Okcheon-gun', 11),
(130, 'Eumseong-gun', 11),
(131, 'Jecheon-si', 11),
(132, 'Jeungpyeong-gun', 11),
(133, 'Jincheon-gun', 11),
(134, 'Cheongju-si', 11),
(135, 'Chungju-si', 11),
(136, 'Gyeryong-si', 12),
(137, 'Gongju-si', 12),
(138, 'Geumsan-gun', 12),
(139, 'Nonsan-si', 12),
(140, 'Dangjin-si', 12),
(141, 'Boryeong-si', 12),
(142, 'Buyeo-gun', 12),
(143, 'Seosan-si', 12),
(144, 'Seocheon-gun', 12),
(145, 'Asan-si', 12),
(146, 'Yesan-gun', 12),
(147, 'Cheonan-si', 12),
(148, 'Cheongyang-gun', 12),
(149, 'Taean-gun', 12),
(150, 'Hongseong-gun', 12),
(151, 'Gochang-gun', 13),
(152, 'Gunsan-si', 13),
(153, 'Gimje-si', 13),
(154, 'Namwon-si', 13),
(155, 'Muju-gun', 13),
(156, 'Buan-gun', 13),
(157, 'Sunchang-gun', 13),
(158, 'Wanju-gun', 13),
(159, 'Iksan-si', 13),
(160, 'Imsil-gun', 13),
(161, 'Jangsu-gun', 13),
(162, 'Jeonju-si', 13),
(163, 'Jeongeup-si', 13),
(164, 'Jinan-gun', 13),
(165, 'Gangjin-gun', 14),
(166, 'Goheung-gun', 14),
(167, 'Gokseong-gun', 14),
(168, 'Gwangyang-si', 14),
(169, 'Gurye-gun', 14),
(170, 'Naju-si', 14),
(171, 'Damyang-gun', 14),
(172, 'Mokpo-si', 14),
(173, 'Muan-gun', 14),
(174, 'Boseong-gun', 14),
(175, 'Suncheon-si', 14),
(176, 'Sinan-gun', 14),
(177, 'Yeosu-si', 14),
(178, 'Yeonggwang-gun', 14),
(179, 'Yeongam-gun', 14),
(180, 'Wando-gun', 14),
(181, 'Jangseong-gun', 14),
(182, 'Jangheung-gun', 14),
(183, 'Jindo-gun', 14),
(184, 'Hampyeong-gun', 14),
(185, 'Haenam-gun', 14),
(186, 'Hwasun-gun', 14),
(187, 'Gyeongsan-si', 15),
(188, 'Gyeongju-si', 15),
(189, 'Goryeong-gun', 15),
(190, 'Gumi-si', 15),
(191, 'Gunwi-gun', 15),
(192, 'Gimcheon-si', 15),
(193, 'Mungyeong-si', 15),
(194, 'Bonghwa-gun', 15),
(195, 'Sangju-si', 15),
(196, 'Seongju-gun', 15),
(197, 'Andong-si', 15),
(198, 'Yeongdeok-gun', 15),
(199, 'Yeongyang-gun', 15),
(200, 'Yeongju-si', 15),
(201, 'Yeongcheon-si', 15),
(202, 'Yecheon-gun', 15),
(203, 'Ulleung-gun', 15),
(204, 'Uljin-gun', 15),
(205, 'Uiseong-gun', 15),
(206, 'Cheongdo-gun', 15),
(207, 'Cheongsong-gun', 15),
(208, 'Chilgok-gun', 15),
(209, 'Pohang-si', 15),
(210, 'Geoje-si', 16),
(211, 'Geochang-gun', 16),
(212, 'Goseong-gun', 16),
(213, 'Gimhae-si', 16),
(214, 'Namhae-gun', 16),
(215, 'Miryang-si', 16),
(216, 'Sacheon-si', 16),
(217, 'Sancheong-gun', 16),
(218, 'Yangsan-si', 16),
(219, 'Uiryeong-gun', 16),
(220, 'Jinju-si', 16),
(221, 'Changnyeong-gun', 16),
(222, 'Changwon-si', 16),
(223, 'Tongyeong-si', 16),
(224, 'Hadong-gun', 16),
(225, 'Haman-gun', 16),
(226, 'Hamyang-gun', 16),
(227, 'Hapcheon-gun', 16),
(228, 'Jeju-do', 17),
(229, 'Yangpyeong-si', 0),
(230, 'Dalsung-gun', 0),
(231, 'Kyeongsan-si', 0),
(232, 'Icheon-dong', 0),
(233, 'Sankyeock-dong', 0),
(234, 'etc', 0);
|
CREATE TABLE [dbo].[Keys] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Active] BIT NOT NULL,
[Code] NVARCHAR (64) NOT NULL,
[Group] NVARCHAR (32) NULL,
[Name] NVARCHAR (64) NOT NULL,
[Tags] NVARCHAR (MAX) NULL,
[TeamId] INT NOT NULL,
[Notes] NVARCHAR(MAX) NULL,
CONSTRAINT [PK_Keys] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_Keys_Teams_TeamId] FOREIGN KEY ([TeamId]) REFERENCES [dbo].[Teams] ([Id]) ON DELETE CASCADE
);
GO
CREATE NONCLUSTERED INDEX [IX_Keys_TeamId]
ON [dbo].[Keys]([TeamId] ASC);
GO
CREATE NONCLUSTERED INDEX [IX_Keys_Active]
ON [dbo].[Keys]([Active] DESC);
|
use employee_db;
INSERT INTO department(department_name) VALUES
INSERT INTO roles(title, salary, department_id) VALUES ('IT Director', 120000, 1), ('App Manager', 80000, 1), ('App Admin', 65000, 2), ('App Developer', 75000, 2), ('App Analyst', 55000, 3), ('Senior Software Developer', 90000, 3), ('Office Assistant', 63000, 4), ('Junior Software Developer', 75000, 4);
INSERT INTO employee(first_name, last_name, roles_id, manager_id) VALUES ('Kobe', 'Bryant', 1, null), ('Micahel', 'Jordan', 2, 1), ('Pete', 'Marovich', 3, 4), ('Phil', 'Jackson', 4, null);
|
<filename>databanjarsurabya.sql
/*
SQLyog Enterprise - MySQL GUI v7.02
MySQL - 5.5.5-10.1.9-MariaDB : Database - databanjarsurabaya
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`databanjarsurabaya` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `databanjarsurabaya`;
/*Table structure for table `datawarga` */
DROP TABLE IF EXISTS `datawarga`;
CREATE TABLE `datawarga` (
`id_warga` varchar(6) NOT NULL,
`nama_lengkap` varchar(50) DEFAULT NULL,
`alamat` text,
`jenis_kelamin` char(1) DEFAULT NULL,
`tanggal_lahir` date DEFAULT NULL,
`pekerjaan` varchar(30) DEFAULT NULL,
`no_telpon` varchar(15) DEFAULT NULL,
PRIMARY KEY (`id_warga`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Data for the table `datawarga` */
/*Table structure for table `login_mahasiswa` */
DROP TABLE IF EXISTS `login_mahasiswa`;
CREATE TABLE `login_mahasiswa` (
`id_login` int(11) NOT NULL AUTO_INCREMENT,
`id_mahasiswa` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(100) NOT NULL,
`cookie_set` varchar(50) NOT NULL,
`last_time_login` time DEFAULT NULL,
`log_status` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_login`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Data for the table `login_mahasiswa` */
/*Table structure for table `mahasiswa` */
DROP TABLE IF EXISTS `mahasiswa`;
CREATE TABLE `mahasiswa` (
`id_mahasiswa` int(11) NOT NULL AUTO_INCREMENT,
`id_perguruan_tinggi` int(11) DEFAULT NULL,
`Nama` varchar(30) NOT NULL,
`Email` varchar(100) NOT NULL,
`Fakultas` varchar(50) NOT NULL,
`Jurusan` varchar(50) NOT NULL,
`Tahun_angkatan` year(4) NOT NULL,
`Facebook` varchar(50) NOT NULL,
`Twitter` varchar(50) NOT NULL,
PRIMARY KEY (`id_mahasiswa`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
/*Data for the table `mahasiswa` */
insert into `mahasiswa`(`id_mahasiswa`,`id_perguruan_tinggi`,`Nama`,`Email`,`Fakultas`,`Jurusan`,`Tahun_angkatan`,`Facebook`,`Twitter`) values (1,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(2,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(3,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(4,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(5,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(6,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(7,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(8,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(9,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby'),(10,1,'nobby','<EMAIL>','ftif','tc',2014,'nobby','nobby');
/*Table structure for table `perguruan_tinggi` */
DROP TABLE IF EXISTS `perguruan_tinggi`;
CREATE TABLE `perguruan_tinggi` (
`id_perguruan_tinggi` int(11) NOT NULL AUTO_INCREMENT,
`Nama_perguruan` varchar(50) NOT NULL,
`Alias` varchar(50) NOT NULL,
`Jumlah_anggota` int(11) NOT NULL,
PRIMARY KEY (`id_perguruan_tinggi`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
/*Data for the table `perguruan_tinggi` */
insert into `perguruan_tinggi`(`id_perguruan_tinggi`,`Nama_perguruan`,`Alias`,`Jumlah_anggota`) values (1,'Institut Teknologi Sepuluh Nopember','ITS',10),(2,'Universitas Airlangga','UNAIr',10);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
<filename>db/DMS_INSERT_ROLES_MIGRATION.sql
INSERT INTO `roles` (`name`)
VALUES ('admin');
INSERT INTO `roles` (`name`)
VALUES ('user');
|
#设置客户端连接的编码
SET NAMES UTF8;
#丢弃数据库
DROP DATABASE IF EXISTS yijia;
#创建数据库
CREATE DATABASE yijia CHARSET=UTF8;
#进入数据库
USE yijia;
#创建保存用户数据的表
CREATE TABLE yijia_user(
uid INT PRIMARY KEY AUTO_INCREMENT,
uname VARCHAR(50),
upwd VARCHAR(32),
gender BOOL,
birthday DATE,
user_name VARCHAR(32),
email VARCHAR(32),
phone VARCHAR(20)
);
INSERT INTO yijia_user VALUES(null,'jerry',md5('123'),1,'19951005','李四','<EMAIL>',15454612341);
#创建首页轮播图
CREATE TABLE yijia_index_carousel(
cid INT PRIMARY KEY AUTO_INCREMENT,
img VARCHAR(128)
);
INSERT INTO yijia_index_carousel VALUES(NULL,'public/img/1.jpg');
INSERT INTO yijia_index_carousel VALUES(NULL,'public/img/2.jpg');
INSERT INTO yijia_index_carousel VALUES(NULL,'public/img/3.jpg');
INSERT INTO yijia_index_carousel VALUES(NULL,'public/img/4.jpg');
#创建保存地区房源信息的表
CREATE TABLE yijia_house(
hid INT PRIMARY KEY AUTO_INCREMENT,
hname VARCHAR(64), #房屋名
title VARCHAR(128), #标题
detail VARCHAR(256), #详情
price DECIMAL(6,2), #价格
addr VARCHAR(128), #地区
h_grade VARCHAR(32), #房屋级别
h_layout VARCHAR(32), #户型
h_Layout VARCHAR(64), #房型
#配套
WIFI BOOL, #无线网络
hot_water BOOL, #全天热水
elevator BOOL, #电梯
washing_machine BOOL, #洗衣机
TV BOOL, #电视
air-conditioning BOOL, #空调
refrigerator BOOL, #冰箱
microwave_oven BOOL, #微波炉
#特色
);
|
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.4
-- Dumped by pg_dump version 12.3
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: partitioned; Type: SCHEMA; Schema: -; Owner: dba_test_db_admin
--
CREATE SCHEMA partitioned;
ALTER SCHEMA partitioned OWNER TO dba_test_db_admin;
--
-- Name: hstore; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
--
-- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
--
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed';
--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
--
-- Name: create_timeseries_rolling_insert(); Type: FUNCTION; Schema: partitioned; Owner: dba_test_db_admin
--
CREATE FUNCTION partitioned.create_timeseries_rolling_insert() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
INSERT into partitioned.time_series_rolling (id, captured_at, series, ccy_pair, style, bid, ask, mid, ref_mid)
values (new.id, new.captured_at, new.series, new.ccy_pair, new.style, new.bid, new.ask, new.mid, new.ref_mid);
RETURN new;
END;
$$;
ALTER FUNCTION partitioned.create_timeseries_rolling_insert() OWNER TO dba_test_db_admin;
--
-- Name: add_three_values(anyelement, anyelement, anyelement); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.add_three_values(v1 anyelement, v2 anyelement, v3 anyelement) RETURNS anyelement
LANGUAGE plpgsql
AS $_$
DECLARE
result ALIAS FOR $0;
BEGIN
result := v1 + v2 + v3;
RETURN result;
END;
$_$;
ALTER FUNCTION public.add_three_values(v1 anyelement, v2 anyelement, v3 anyelement) OWNER TO dba_test_db_admin;
--
-- Name: create_historic_price_partition(); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.create_historic_price_partition() RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
parent_table TEXT;
partition_key TEXT;
partition TEXT;
partition_next TEXT;
partition_date_month TEXT;
partition_date_month_next TEXT;
BEGIN
parent_table := 'historic_price';
partition_key := 'created_at';
partition_date_month := to_char((now() AT TIME ZONE 'UTC')::date,'YYYY_MM');
partition_date_month_next := to_char((now() AT TIME ZONE 'UTC' + interval '1 month')::date,'YYYY_MM');
partition := parent_table || '_' || partition_date_month;
partition_next := parent_table || '_' || partition_date_month_next;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
EXECUTE '
CREATE TABLE IF NOT EXISTS public.' || partition
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('
|| (extract(epoch from ((date_trunc('month',now() AT TIME ZONE 'UTC'))::timestamp) ) * 1000)::bigint
|| ') TO ('
|| (extract(epoch from ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp) ) * 1000)::bigint
|| ');
';
END IF;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition_next) THEN
EXECUTE '
CREATE TABLE IF NOT EXISTS public.' || partition_next
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('
|| (extract(epoch from ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp) ) * 1000)::bigint
|| ') TO ('
|| (extract(epoch from ((date_trunc('month',now() AT TIME ZONE 'UTC' + '2 months' ))::timestamp) ) * 1000)::bigint
|| ');
';
END IF;
RETURN NULL;
END;
$$;
ALTER FUNCTION public.create_historic_price_partition() OWNER TO dba_test_db_admin;
--
-- Name: create_historic_price_partition_02(); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.create_historic_price_partition_02() RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
parent_table TEXT;
partition_key TEXT;
partition TEXT;
partition_next TEXT;
partition_date_month TEXT;
partition_date_month_next TEXT;
BEGIN
parent_table := 'historic_price_timestamp';
partition_key := 'created_at';
partition_date_month := to_char((now() AT TIME ZONE 'UTC')::date,'YYYY_MM');
partition_date_month_next := to_char((now() AT TIME ZONE 'UTC' + interval '1 month')::date,'YYYY_MM');
partition := parent_table || '_' || partition_date_month;
partition_next := parent_table || '_' || partition_date_month_next;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
EXECUTE '
CREATE TABLE IF NOT EXISTS public.' || partition
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC'))::timestamp)
|| ''') TO ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp)
|| ''');
';
END IF;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition_next) THEN
EXECUTE '
CREATE TABLE IF NOT EXISTS public.' || partition_next
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp)
|| ''') TO ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + '2 months' ))::timestamp)
|| ''');
';
END IF;
RETURN NULL;
END;
$$;
ALTER FUNCTION public.create_historic_price_partition_02() OWNER TO dba_test_db_admin;
--
-- Name: create_historic_price_partition_03(); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.create_historic_price_partition_03() RETURNS integer
LANGUAGE plpgsql
AS $$
DECLARE
parent_table TEXT;
partition_key TEXT;
partition TEXT;
partition_next TEXT;
partition_date_month TEXT;
partition_date_month_next TEXT;
BEGIN
-- this is the parent partition table name
parent_table := 'historic_price_timestamp';
-- this is the partition column name, the type is "timestamp without time zone", such as '2021-02-26 05:26:42'::timestamp without time zone
partition_key := 'created_at';
partition_date_month := to_char((now() AT TIME ZONE 'UTC')::date,'YYYY_MM');
partition_date_month_next := to_char((now() AT TIME ZONE 'UTC' + interval '1 month')::date,'YYYY_MM');
partition := parent_table || '_' || partition_date_month;
partition_next := parent_table || '_' || partition_date_month_next;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
EXECUTE '
CREATE TABLE IF NOT EXISTS public.' || partition
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC'))::timestamp)
|| ''') TO ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp)
|| ''');
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month
|| ' ON public.' || partition || ' (value_date, valid_from);
';
END IF;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition_next) THEN
EXECUTE '
CREATE TABLE IF NOT EXISTS public.' || partition_next
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp)
|| ''') TO ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + '2 months' ))::timestamp)
|| ''');
';
END IF;
RETURN NULL;
END;
$$;
ALTER FUNCTION public.create_historic_price_partition_03() OWNER TO dba_test_db_admin;
--
-- Name: create_historic_price_partition_04(integer); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.create_historic_price_partition_04(next_month_number integer DEFAULT 1) RETURNS integer
LANGUAGE plpgsql
AS $_$
DECLARE
parent_table TEXT;
partition_key TEXT;
partition TEXT;
partition_next TEXT;
partition_date_month TEXT;
partition_date_month_next TEXT;
number ALIAS FOR $1;
number_02 int;
BEGIN
-- this is the parent partition table name
parent_table := 'historic_price_timestamp';
-- this is the partition column name, the type is "timestamp without time zone", such as '2021-02-26 05:26:42'::timestamp without time zone
partition_key := 'created_at';
number := 12;
number_02 := number + 1;
partition_date_month := to_char((now() AT TIME ZONE 'UTC')::date,'YYYY_MM');
partition_date_month_next := to_char((now() AT TIME ZONE 'UTC' + interval ' || 12 || month')::date,'YYYY_MM');
partition := parent_table || '_' || partition_date_month;
partition_next := parent_table || '_' || partition_date_month_next;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
EXECUTE '
CREATE TABLE IF NOT EXISTS public.' || partition
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC'))::timestamp)
|| ''') TO ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp)
|| ''');
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month
|| ' ON public.' || partition || ' (value_date, valid_from);
';
END IF;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition_next) THEN
EXECUTE '
CREATE TABLE IF NOT EXISTS public.' || partition_next
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + ' || 12 || months' ))::timestamp)
|| ''') TO ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + ' || 13 || months' ))::timestamp)
|| ''');
';
END IF;
RETURN NULL;
END;
$_$;
ALTER FUNCTION public.create_historic_price_partition_04(next_month_number integer) OWNER TO dba_test_db_admin;
--
-- Name: create_historic_price_partition_05(); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.create_historic_price_partition_05() RETURNS integer
LANGUAGE plpgsql
AS $_$
DECLARE
parent_table TEXT;
partition_key TEXT;
partition TEXT;
partition_next TEXT;
partition_date_month TEXT;
partition_date_month_next TEXT;
BEGIN
-- this is the parent partition table name
parent_table := 'historic_price_timestamp';
-- this is the partition column name, the type is "timestamp without time zone", such as '2021-02-26 05:26:42'::timestamp without time zone
partition_key := 'created_at';
partition_date_month := to_char((now() AT TIME ZONE 'UTC')::date,'YYYY_MM');
partition_date_month_next := to_char((now() AT TIME ZONE 'UTC' + interval ' 12 month')::date,'YYYY_MM');
partition := parent_table || '_' || partition_date_month;
partition_next := parent_table || '_' || partition_date_month_next;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
EXECUTE '
DO $$
BEGIN
-- create new partition table
IF NOT EXISTS (SELECT * from INFORMATION_SCHEMA.Tables WHERE Table_name = ''' || partition || ''') THEN
CREATE TABLE IF NOT EXISTS public.' || partition
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC'))::timestamp)
|| ''') TO ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp)
|| ''');
END IF;
-- check and create other db objects of the new partition table
IF to_regclass(''public.idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month || ''') IS NULL THEN
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month
|| ' ON public.' || partition || ' (value_date, valid_from);
END IF;
END
$$;
';
END IF;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition_next) THEN
EXECUTE '
DO $$
BEGIN
-- create new partition table
IF NOT EXISTS (SELECT * from INFORMATION_SCHEMA.Tables WHERE Table_name = ''' || partition_next || ''') THEN
CREATE TABLE IF NOT EXISTS public.' || partition_next
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + ' 12 months' ))::timestamp)
|| ''') TO ('''
|| ((date_trunc('month',now() AT TIME ZONE 'UTC' + ' 13 months' ))::timestamp)
|| ''');
END IF;
-- check and create other db objects of the new partition table
IF to_regclass(''public.idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month_next || ''') IS NULL THEN
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month_next
|| ' ON public.' || partition_next || ' (value_date, valid_from);
END IF;
END
$$;
';
END IF;
RETURN NULL;
END;
$_$;
ALTER FUNCTION public.create_historic_price_partition_05() OWNER TO dba_test_db_admin;
--
-- Name: create_historic_price_partition_06(); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.create_historic_price_partition_06() RETURNS integer
LANGUAGE plpgsql
AS $_$
DECLARE
parent_table TEXT;
partition_key TEXT;
partition TEXT;
partition_next TEXT;
partition_date_month TEXT;
partition_date_month_next TEXT;
BEGIN
-- this is the parent partition table name
parent_table := 'historic_price';
-- this is the partition column name, the type is "bigint", such as 1614556800000::bigint
partition_key := 'created_at';
partition_date_month := to_char((now() AT TIME ZONE 'UTC')::date,'YYYY_MM');
partition_date_month_next := to_char((now() AT TIME ZONE 'UTC' + interval ' 1 month')::date,'YYYY_MM');
partition := parent_table || '_' || partition_date_month;
partition_next := parent_table || '_' || partition_date_month_next;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
EXECUTE '
DO $$
BEGIN
-- create new partition table
IF NOT EXISTS (SELECT * from INFORMATION_SCHEMA.Tables WHERE Table_name = ''' || partition || ''') THEN
CREATE TABLE IF NOT EXISTS public.' || partition
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('
|| (extract(epoch from ((date_trunc('month',now() AT TIME ZONE 'UTC'))::timestamp) ) * 1000)::bigint
|| ') TO ('
|| (extract(epoch from ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp) ) * 1000)::bigint
|| ');
END IF;
-- check and create other db objects of the new partition table
IF to_regclass(''public.idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month || ''') IS NULL THEN
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month
|| ' ON public.' || partition || ' (value_date, valid_from);
END IF;
IF to_regclass(''time_series_rolling_insert_trigger_' || partition_date_month || ''') IS NULL THEN
CREATE TRIGGER time_series_rolling_insert_trigger' || partition_date_month
|| ' BEFORE INSERT ON public.' || partition || ' FOR EACH ROW EXECUTE PROCEDURE partitioned.create_timeseries_rolling_insert();
END IF;
END
$$;
';
END IF;
IF NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition_next) THEN
EXECUTE '
DO $$
BEGIN
-- create new partition table
IF NOT EXISTS (SELECT * from INFORMATION_SCHEMA.Tables WHERE Table_name = ''' || partition_next || ''') THEN
CREATE TABLE IF NOT EXISTS public.' || partition_next
|| ' PARTITION OF public.' || parent_table || ' FOR VALUES FROM ('
|| (extract(epoch from ((date_trunc('month',now() AT TIME ZONE 'UTC' + '1 months' ))::timestamp) ) * 1000)::bigint
|| ') TO ('
|| (extract(epoch from ((date_trunc('month',now() AT TIME ZONE 'UTC' + '2 months' ))::timestamp) ) * 1000)::bigint
|| ');
END IF;
-- check and create other db objects of the new partition table
IF to_regclass(''public.idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month_next || ''') IS NULL THEN
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_' || partition_date_month_next
|| ' ON public.' || partition_next || ' (value_date, valid_from);
END IF;
IF to_regclass(''time_series_rolling_insert_trigger_' || partition_date_month_next || ''') IS NULL THEN
CREATE TRIGGER time_series_rolling_insert_trigger' || partition_date_month_next
|| ' BEFORE INSERT ON public.' || partition_next || ' FOR EACH ROW EXECUTE PROCEDURE partitioned.create_timeseries_rolling_insert();
END IF;
END
$$;
';
END IF;
RETURN NULL;
END;
$_$;
ALTER FUNCTION public.create_historic_price_partition_06() OWNER TO dba_test_db_admin;
--
-- Name: sales_tax(real); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.sales_tax(real) RETURNS real
LANGUAGE plpgsql
AS $_$
DECLARE
subtotal ALIAS FOR $1;
BEGIN
RETURN subtotal + 1;
END;
$_$;
ALTER FUNCTION public.sales_tax(real) OWNER TO dba_test_db_admin;
--
-- Name: sales_tax_02(real); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.sales_tax_02(real) RETURNS real
LANGUAGE plpgsql
AS $_$
DECLARE
subtotal ALIAS FOR $1;
month_name TEXT;
BEGIN
subtotal := subtotal + 1;
month_name = to_char((now() AT TIME ZONE 'UTC')::date,'YYYY_MM');
-- RETURN subtotal;
RETURN month_name;
END;
$_$;
ALTER FUNCTION public.sales_tax_02(real) OWNER TO dba_test_db_admin;
--
-- Name: sum_n_product(integer, integer); Type: FUNCTION; Schema: public; Owner: dba_test_db_admin
--
CREATE FUNCTION public.sum_n_product(x integer, y integer, OUT sum integer, OUT prod integer) RETURNS record
LANGUAGE plpgsql
AS $$
BEGIN
sum := x + y;
prod := x * y;
END;
$$;
ALTER FUNCTION public.sum_n_product(x integer, y integer, OUT sum integer, OUT prod integer) OWNER TO dba_test_db_admin;
SET default_tablespace = '';
--
-- Name: historic_price; Type: TABLE; Schema: public; Owner: dba_test_db_admin
--
CREATE TABLE public.historic_price (
id character varying(64) NOT NULL,
created_at bigint NOT NULL,
ccy_pair character varying(6) NOT NULL,
style character varying(16) NOT NULL,
product character varying(16) NOT NULL,
type character varying(16) NOT NULL,
value_date date,
tenor character varying(16),
bid jsonb NOT NULL,
ask jsonb NOT NULL,
mid numeric(16,8),
source jsonb NOT NULL,
cross_source jsonb,
valid_from bigint NOT NULL,
valid_to bigint NOT NULL,
carded_price_data jsonb,
volume_band numeric(16,0)
)
PARTITION BY RANGE (created_at);
ALTER TABLE public.historic_price OWNER TO dba_test_db_admin;
SET default_table_access_method = heap;
--
-- Name: historic_price_2021_03; Type: TABLE; Schema: public; Owner: dba_test_db_admin
--
CREATE TABLE public.historic_price_2021_03 (
id character varying(64) NOT NULL,
created_at bigint NOT NULL,
ccy_pair character varying(6) NOT NULL,
style character varying(16) NOT NULL,
product character varying(16) NOT NULL,
type character varying(16) NOT NULL,
value_date date,
tenor character varying(16),
bid jsonb NOT NULL,
ask jsonb NOT NULL,
mid numeric(16,8),
source jsonb NOT NULL,
cross_source jsonb,
valid_from bigint NOT NULL,
valid_to bigint NOT NULL,
carded_price_data jsonb,
volume_band numeric(16,0)
);
ALTER TABLE ONLY public.historic_price ATTACH PARTITION public.historic_price_2021_03 FOR VALUES FROM ('1614556800000') TO ('1617235200000');
ALTER TABLE public.historic_price_2021_03 OWNER TO dba_test_db_admin;
--
-- Name: historic_price_2021_04; Type: TABLE; Schema: public; Owner: dba_test_db_admin
--
CREATE TABLE public.historic_price_2021_04 (
id character varying(64) NOT NULL,
created_at bigint NOT NULL,
ccy_pair character varying(6) NOT NULL,
style character varying(16) NOT NULL,
product character varying(16) NOT NULL,
type character varying(16) NOT NULL,
value_date date,
tenor character varying(16),
bid jsonb NOT NULL,
ask jsonb NOT NULL,
mid numeric(16,8),
source jsonb NOT NULL,
cross_source jsonb,
valid_from bigint NOT NULL,
valid_to bigint NOT NULL,
carded_price_data jsonb,
volume_band numeric(16,0)
);
ALTER TABLE ONLY public.historic_price ATTACH PARTITION public.historic_price_2021_04 FOR VALUES FROM ('1617235200000') TO ('1619827200000');
ALTER TABLE public.historic_price_2021_04 OWNER TO dba_test_db_admin;
--
-- Name: historic_price_timestamp; Type: TABLE; Schema: public; Owner: dba_test_db_admin
--
CREATE TABLE public.historic_price_timestamp (
id character varying(64) NOT NULL,
created_at timestamp without time zone NOT NULL,
ccy_pair character varying(6) NOT NULL,
style character varying(16) NOT NULL,
product character varying(16) NOT NULL,
type character varying(16) NOT NULL,
value_date date,
tenor character varying(16),
bid jsonb NOT NULL,
ask jsonb NOT NULL,
mid numeric(16,8),
source jsonb NOT NULL,
cross_source jsonb,
valid_from bigint NOT NULL,
valid_to bigint NOT NULL,
carded_price_data jsonb,
volume_band numeric(16,0)
)
PARTITION BY RANGE (created_at);
ALTER TABLE public.historic_price_timestamp OWNER TO dba_test_db_admin;
--
-- Name: historic_price_timestamp_2021_03; Type: TABLE; Schema: public; Owner: dba_test_db_admin
--
CREATE TABLE public.historic_price_timestamp_2021_03 (
id character varying(64) NOT NULL,
created_at timestamp without time zone NOT NULL,
ccy_pair character varying(6) NOT NULL,
style character varying(16) NOT NULL,
product character varying(16) NOT NULL,
type character varying(16) NOT NULL,
value_date date,
tenor character varying(16),
bid jsonb NOT NULL,
ask jsonb NOT NULL,
mid numeric(16,8),
source jsonb NOT NULL,
cross_source jsonb,
valid_from bigint NOT NULL,
valid_to bigint NOT NULL,
carded_price_data jsonb,
volume_band numeric(16,0)
);
ALTER TABLE ONLY public.historic_price_timestamp ATTACH PARTITION public.historic_price_timestamp_2021_03 FOR VALUES FROM ('2021-03-01 00:00:00') TO ('2021-04-01 00:00:00');
ALTER TABLE public.historic_price_timestamp_2021_03 OWNER TO dba_test_db_admin;
--
-- Name: historic_price_timestamp_2022_03; Type: TABLE; Schema: public; Owner: dba_test_db_admin
--
CREATE TABLE public.historic_price_timestamp_2022_03 (
id character varying(64) NOT NULL,
created_at timestamp without time zone NOT NULL,
ccy_pair character varying(6) NOT NULL,
style character varying(16) NOT NULL,
product character varying(16) NOT NULL,
type character varying(16) NOT NULL,
value_date date,
tenor character varying(16),
bid jsonb NOT NULL,
ask jsonb NOT NULL,
mid numeric(16,8),
source jsonb NOT NULL,
cross_source jsonb,
valid_from bigint NOT NULL,
valid_to bigint NOT NULL,
carded_price_data jsonb,
volume_band numeric(16,0)
);
ALTER TABLE ONLY public.historic_price_timestamp ATTACH PARTITION public.historic_price_timestamp_2022_03 FOR VALUES FROM ('2022-03-01 00:00:00') TO ('2022-04-01 00:00:00');
ALTER TABLE public.historic_price_timestamp_2022_03 OWNER TO dba_test_db_admin;
--
-- Data for Name: historic_price_2021_03; Type: TABLE DATA; Schema: public; Owner: dba_test_db_admin
--
COPY public.historic_price_2021_03 (id, created_at, ccy_pair, style, product, type, value_date, tenor, bid, ask, mid, source, cross_source, valid_from, valid_to, carded_price_data, volume_band) FROM stdin;
\.
--
-- Data for Name: historic_price_2021_04; Type: TABLE DATA; Schema: public; Owner: dba_test_db_admin
--
COPY public.historic_price_2021_04 (id, created_at, ccy_pair, style, product, type, value_date, tenor, bid, ask, mid, source, cross_source, valid_from, valid_to, carded_price_data, volume_band) FROM stdin;
\.
--
-- Data for Name: historic_price_timestamp_2021_03; Type: TABLE DATA; Schema: public; Owner: dba_test_db_admin
--
COPY public.historic_price_timestamp_2021_03 (id, created_at, ccy_pair, style, product, type, value_date, tenor, bid, ask, mid, source, cross_source, valid_from, valid_to, carded_price_data, volume_band) FROM stdin;
\.
--
-- Data for Name: historic_price_timestamp_2022_03; Type: TABLE DATA; Schema: public; Owner: dba_test_db_admin
--
COPY public.historic_price_timestamp_2022_03 (id, created_at, ccy_pair, style, product, type, value_date, tenor, bid, ask, mid, source, cross_source, valid_from, valid_to, carded_price_data, volume_band) FROM stdin;
\.
--
-- Name: idx_historic_price_timestamp_value_date_valid_from_2021_03; Type: INDEX; Schema: public; Owner: dba_test_db_admin
--
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_2021_03 ON public.historic_price_timestamp_2021_03 USING btree (value_date, valid_from);
--
-- Name: idx_historic_price_timestamp_value_date_valid_from_2021_04; Type: INDEX; Schema: public; Owner: dba_test_db_admin
--
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_2021_04 ON public.historic_price_2021_04 USING btree (value_date, valid_from);
--
-- Name: idx_historic_price_timestamp_value_date_valid_from_2022_03; Type: INDEX; Schema: public; Owner: dba_test_db_admin
--
CREATE INDEX idx_historic_price_timestamp_value_date_valid_from_2022_03 ON public.historic_price_timestamp_2022_03 USING btree (value_date, valid_from);
--
-- Name: historic_price_2021_03 time_series_rolling_insert_trigger2021_03; Type: TRIGGER; Schema: public; Owner: dba_test_db_admin
--
CREATE TRIGGER time_series_rolling_insert_trigger2021_03 BEFORE INSERT ON public.historic_price_2021_03 FOR EACH ROW EXECUTE FUNCTION partitioned.create_timeseries_rolling_insert();
--
-- Name: historic_price_2021_04 time_series_rolling_insert_trigger2021_04; Type: TRIGGER; Schema: public; Owner: dba_test_db_admin
--
CREATE TRIGGER time_series_rolling_insert_trigger2021_04 BEFORE INSERT ON public.historic_price_2021_04 FOR EACH ROW EXECUTE FUNCTION partitioned.create_timeseries_rolling_insert();
--
-- Name: TABLE historic_price; Type: ACL; Schema: public; Owner: dba_test_db_admin
--
GRANT ALL ON TABLE public.historic_price TO airwallex;
GRANT SELECT ON TABLE public.historic_price TO airwallex_r;
GRANT ALL ON TABLE public.historic_price TO dba_test_db_rw;
GRANT SELECT ON TABLE public.historic_price TO dba_test_db_r;
--
-- Name: TABLE historic_price_2021_03; Type: ACL; Schema: public; Owner: dba_test_db_admin
--
GRANT ALL ON TABLE public.historic_price_2021_03 TO airwallex;
GRANT SELECT ON TABLE public.historic_price_2021_03 TO airwallex_r;
GRANT ALL ON TABLE public.historic_price_2021_03 TO dba_test_db_rw;
GRANT SELECT ON TABLE public.historic_price_2021_03 TO dba_test_db_r;
--
-- Name: TABLE historic_price_2021_04; Type: ACL; Schema: public; Owner: dba_test_db_admin
--
GRANT ALL ON TABLE public.historic_price_2021_04 TO airwallex;
GRANT SELECT ON TABLE public.historic_price_2021_04 TO airwallex_r;
GRANT ALL ON TABLE public.historic_price_2021_04 TO dba_test_db_rw;
GRANT SELECT ON TABLE public.historic_price_2021_04 TO dba_test_db_r;
--
-- Name: TABLE historic_price_timestamp; Type: ACL; Schema: public; Owner: dba_test_db_admin
--
GRANT ALL ON TABLE public.historic_price_timestamp TO airwallex;
GRANT SELECT ON TABLE public.historic_price_timestamp TO airwallex_r;
GRANT ALL ON TABLE public.historic_price_timestamp TO dba_test_db_rw;
GRANT SELECT ON TABLE public.historic_price_timestamp TO dba_test_db_r;
--
-- Name: TABLE historic_price_timestamp_2021_03; Type: ACL; Schema: public; Owner: dba_test_db_admin
--
GRANT ALL ON TABLE public.historic_price_timestamp_2021_03 TO airwallex;
GRANT SELECT ON TABLE public.historic_price_timestamp_2021_03 TO airwallex_r;
GRANT ALL ON TABLE public.historic_price_timestamp_2021_03 TO dba_test_db_rw;
GRANT SELECT ON TABLE public.historic_price_timestamp_2021_03 TO dba_test_db_r;
--
-- Name: TABLE historic_price_timestamp_2022_03; Type: ACL; Schema: public; Owner: dba_test_db_admin
--
GRANT ALL ON TABLE public.historic_price_timestamp_2022_03 TO airwallex;
GRANT SELECT ON TABLE public.historic_price_timestamp_2022_03 TO airwallex_r;
GRANT ALL ON TABLE public.historic_price_timestamp_2022_03 TO dba_test_db_rw;
GRANT SELECT ON TABLE public.historic_price_timestamp_2022_03 TO dba_test_db_r;
--
-- Name: TABLE pg_stat_statements; Type: ACL; Schema: public; Owner: airwallex
--
GRANT ALL ON TABLE public.pg_stat_statements TO dba_test_db_admin;
GRANT ALL ON TABLE public.pg_stat_statements TO dba_test_db_rw;
GRANT SELECT ON TABLE public.pg_stat_statements TO dba_test_db_r;
--
-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: dba_test_db_admin
--
ALTER DEFAULT PRIVILEGES FOR ROLE dba_test_db_admin IN SCHEMA public REVOKE ALL ON SEQUENCES FROM dba_test_db_admin;
ALTER DEFAULT PRIVILEGES FOR ROLE dba_test_db_admin IN SCHEMA public GRANT SELECT,USAGE ON SEQUENCES TO dba_test_db_rw;
--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: airwallex
--
ALTER DEFAULT PRIVILEGES FOR ROLE airwallex IN SCHEMA public REVOKE ALL ON TABLES FROM airwallex;
ALTER DEFAULT PRIVILEGES FOR ROLE airwallex IN SCHEMA public GRANT ALL ON TABLES TO dba_test_db_admin;
ALTER DEFAULT PRIVILEGES FOR ROLE airwallex IN SCHEMA public GRANT ALL ON TABLES TO dba_test_db_rw;
ALTER DEFAULT PRIVILEGES FOR ROLE airwallex IN SCHEMA public GRANT SELECT ON TABLES TO dba_test_db_r;
--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: dba_test_db_admin
--
ALTER DEFAULT PRIVILEGES FOR ROLE dba_test_db_admin IN SCHEMA public GRANT ALL ON TABLES TO airwallex;
ALTER DEFAULT PRIVILEGES FOR ROLE dba_test_db_admin IN SCHEMA public GRANT SELECT ON TABLES TO airwallex_r;
ALTER DEFAULT PRIVILEGES FOR ROLE dba_test_db_admin IN SCHEMA public GRANT ALL ON TABLES TO dba_test_db_rw;
ALTER DEFAULT PRIVILEGES FOR ROLE dba_test_db_admin IN SCHEMA public GRANT SELECT ON TABLES TO dba_test_db_r;
--
-- PostgreSQL database dump complete
--
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_getActiveCronJobCommand`(IN `p_CompanyID` INT, IN `p_CronJobID` INT)
BEGIN
SELECT
tblCronJobCommand.Command,
tblCronJob.CronJobID
FROM tblCronJob
INNER JOIN tblCronJobCommand
ON tblCronJobCommand.CronJobCommandID = tblCronJob.CronJobCommandID
WHERE tblCronJob.CronJobID = p_CronJobID and tblCronJob.CompanyID = p_CompanyID
AND tblCronJob.Status = 1;
END
|
<filename>samples/features/sql-big-data-cluster/data-virtualization/hadoop/product-reviews-hdfs-orc.sql<gh_stars>1-10
USE sales
GO
-- Create data source for HDFS inside SQL big data cluster using the HADOOP type.
-- The HADOOP data source type was introduced in SQL Server 2016 to query data in
-- Hadoop clusters and relies on Java Hadoop client libraries and Map/Reduce for query
-- execution.
--
IF NOT EXISTS(SELECT * FROM sys.external_data_sources WHERE name = 'HadoopData')
IF SERVERPROPERTY('ProductLevel') = 'CTP2.4'
CREATE EXTERNAL DATA SOURCE HadoopData
WITH(
TYPE=HADOOP,
LOCATION='hdfs://mssql-master-pool-0.service-master-pool:9000/',
RESOURCE_MANAGER_LOCATION='mssql-master-pool-0.service-master-pool:8032'
);
ELSE IF SERVERPROPERTY('ProductLevel') = 'CTP2.5'
CREATE EXTERNAL DATA SOURCE HadoopData
WITH(
TYPE=HADOOP,
LOCATION='hdfs://nmnode-0-0.nmnode-0-svc:9000/',
RESOURCE_MANAGER_LOCATION='master-0.master-svc:8032'
);
-- Create file format for orc file with appropriate properties.
--
IF NOT EXISTS(SELECT * FROM sys.external_file_formats WHERE name = 'orc_file')
CREATE EXTERNAL FILE FORMAT orc_file
WITH (
FORMAT_TYPE = ORC,
DATA_COMPRESSION = 'org.apache.hadoop.io.compress.SnappyCodec'
);
-- Create external table over HDFS data source using HADOOP type in
-- SQL Server 2019 big data cluster. The HADOOP data source is existing
-- PolyBase v1 syntax available by specifying location to HDFS namenode in
-- SQL Server big data cluster.
--
IF NOT EXISTS(SELECT * FROM sys.external_tables WHERE name = 'product_reviews_hdfs_orc')
CREATE EXTERNAL TABLE [product_reviews_hdfs_orc]
("pr_review_sk" BIGINT , "pr_review_content" varchar(8000))
WITH
(
DATA_SOURCE = HadoopData,
LOCATION = '/user/hive/warehouse/product_reviews_orc',
FILE_FORMAT = orc_file
);
GO
-- Join external table with local tables
--
SELECT
p.pr_review_sk, pc.pr_review_content
FROM product_reviews as p
JOIN (SELECT TOP(10) * FROM product_reviews_hdfs_orc) AS pc
ON pc.pr_review_sk = p.pr_review_sk;
GO
-- Cleanup
/*
DROP EXTERNAL TABLE [dbo].[product_reviews_hdfs_orc];
GO
*/
|
<gh_stars>1-10
/*
titulo: costo_segmento.sql
descripción: calcula el costo de un segmento
como la distancia absoluta de la cantidad de viviendas
al valor deseado
autor: -h
fecha: 2019-05-01 Mi
*/
drop function costo_segmento;
create or replace function costo_segmento (
segmento bigint,
deseado integer)
returns float as $$
select abs($1::integer - $2::integer)::float
$$
language sql
;
/*
solución inicial lazy de la segmentación
-- asignar segmento a manzanas completas
-- 1 segmento = 1 manzana
with s as (
select frac, radio, mza, rank()
over (
partition by frac, radio
order by mza) as sgm_id
from listados.caba
group by frac, radio, mza)
select frac, radio, sgm_id, count(*) as vivs, costo_segmento(count(*), 40)
from s
natural join listados.caba
group by frac, radio, sgm_id
limit 10
;
frac | radio | sgm_id | vivs | costo_segmento
------+-------+--------+------+----------------
1 | 1 | 1 | 249 | 209
1 | 1 | 2 | 154 | 114
1 | 1 | 3 | 164 | 124
1 | 1 | 4 | 103 | 63
1 | 1 | 5 | 73 | 33
1 | 1 | 6 | 77 | 37
1 | 1 | 7 | 30 | 10
1 | 1 | 8 | 15 | 25
1 | 2 | 1 | 20 | 20
1 | 2 | 2 | 28 | 12
*/
|
INSERT INTO tweb_apbd(`lembaga_id`, `lembaga_kode`, `wilayah_kode`,`tahun`, `rekening_kode`, `uraian`, `nominal`,`nominal_sebelum`, `nominal_sesudah`, `nominal_perubahan`, `nominal_persen`, `keterangan`, `created_by`, `updated_by`) VALUES
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.4.','Pendapatan','321000000','0','321000000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.4.1.','Pendapatan Asli Daerah','321000000','0','321000000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.4.1.2.','Hasil Retribusi Daerah','321000000','0','321000000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.4.1.2.01.','Retribusi Jasa Umum','181000000','0','181000000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.4.1.2.02.','Retribusi Jasa Usaha','140000000','0','140000000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.5.','Belanja','32035274884','0','32035274884','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.5.1.','Belanja Tidak Langsung','11819274884','0','11819274884','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.5.1.1.','Belanja Pegawai','11819274884','0','11819274884','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.5.1.1.01.','Gaji Dan Tunjangan','11819274884','0','11819274884','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.00.00.5.2.','BELANJA LANGSUNG','20216076430','0','20216076430','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.01.','PROGRAM PELAYANAN ADMINISTRASI PERKANTORAN','2200581322','0','2200581322','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.02.','PROGRAM, PENINGKATAN SARANA DAN PRASARANA APARATUR','3645692000','0','3645692000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.05.','PROGRAM PENINGKATAN KAPASITAS SUMBERDAYA APARATUR','28600000','0','28600000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.06.','PROGRAM PENINGKATAN PENGEMBANGAN SISTEM PELAPORAN CAPAIAN KINERJA DAN KEUANGAN','201491950','0','201491950','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.15.','PROGRAM PENCIPTAAN IKLIM USAHA KECIL MENENGAH YANG KONDUSIF','266158400','0','266158400','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.15.033.','Fasilitasi Pengembangan Koperasi','149370400','0','149370400','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.15.040.','Fasilitasi Dekopin','48655500','0','48655500','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.15.041.','Optimalisasi Akses Pemodalan bagi UMKM (KUR dan PKBL BUMN)','24838500','0','24838500','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.15.042.','Diklat Peningkatan Kapasitas SDM dan Kelembagaan UMKM','43294000','0','43294000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.16.','PROGRAM PENGEMBANGAN KEWIRAUSAHAAN DAN KEUNGGULAN KOMPETITIF USAHA KECIL MENENGAH','123896900','0','123896900','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.16.017.','Fasilitasi Kemitraan Usaha bagi UKM','58726800','0','58726800','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.16.018.','Pelatihan Kewirausahaan UMKM','65170100','0','65170100','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.18.','PROGRAM PENINGKATAN KUALITAS KELEMBAGAAN KOPERASI','195110750','0','195110750','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.18.029.','Pengembangan Kopsis dan Kopma','13991750','0','13991750','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.18.032.','Pengawasan dan Pembinaan KSP/USP dan KJK/UJKS Koperasi','25125000','0','25125000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.18.033.','Diklat Pengembangan Perkoperasian','120994000','0','120994000','0','0','','0','0'),
('37','1.15.01.','34','2014','1.15.1.15.01.18.037.','Penilaian, Pemeringkatan dan Pembinaan Koperasi','35000000','0','35000000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.','PROGRAM PERLINDUNGAN KONSUMEN DAN PENGAMANAN PERDAGANGAN','723566600','0','723566600','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.004.','Pengembangan U P T Kemetrologian Daerah ( Pelayanan Sidang Tera Ulang )','723566600','0','723566600','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.005.','Koordinasi Peningkatan Kinerja Distributor ( Pengadaan, Penyaluran, Pemantauan Stok Dan Harga ) Komoditi Pokok Penting Dan Strategis','36346960','0','36346960','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.007.','Pembinaan Dan Pengawasan Barang Dan Jasa Yang Beredar','105641930','0','105641930','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.014.','Oprasi Pasar Murni Bebas','42003460','0','42003460','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.019.','Peningkatan Perlindungan Konsumen','60594400','0','60594400','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.021.','Pengawasan dan Penyuluhan Kemetrologian','100000000','0','100000000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.022.','Pemantauan Pengadaan Panyaluran, Stock, dan Harga Kebutuhan Pokok','26330100','0','26330100','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.15.025.','Penyusunan Prognosa Kebutuhan Barang Penting dan Strategis','36645500','0','36645500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.17.','PROGRAM PENINGKATAN PENGEMBANGAN EKSPOR','2744946260','0','2744946260','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.17.027.','Pameran Dalam Negeri Berskala Ekspor','771955500','0','771955500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.17.032.','Pengelolaan Surat Keterangan Asal Bagi Eksportir','30370500','0','30370500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.17.033.','Fasilitasi KADIN DIY','49987500','0','49987500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.17.034.','Promosi Perdagangan Luar Negeri dan Temu Bisnis','1806143960','0','1806143960','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.17.035.','Penyebarluasan Informasi Kerjasama Perdagangan Internasional','39061500','0','39061500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.17.036.','Sosialisasi Perdagangan Bebas Bidang Jasa','17721100','0','17721100','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.17.037.','Bimbingan Teknis Prosedur dan Dokumen Ekspor Impor','29706200','0','29706200','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.','PROGRAM PENINGKATAN EFISIENSI PERDAGANGAN DALAM NEGERI','2181021760','0','2181021760','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.017.','Pelayanan Bimbingan Bisnis','78620000','0','78620000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.021.','Pengelolaam J B S C','64154500','0','64154500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.023.','Pengembangan Promosi Perdagangan','73946500','0','73946500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.039.','Fasilitasi Pembangunan Pasar Tradisional','16207900','0','16207900','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.040.','Promosi Perdagangan Produk UKM DIY di Dalam Negeri','1231167500','0','1231167500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.044.','Fasilitasi Pembinaan dan Pengembangan UKM','163948300','0','163948300','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.046.','Fasilitasi Dekranasda','100000000','0','100000000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.047.','Pengembangan Data dan Informasi HaKI','50835960','0','50835960','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.048.','Pemetaan Potensi Bisnis Unggulan','56044500','0','56044500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.049.','Fasilitasi Pengelolaan dan Pelayanan HaKI','304386100','0','304386100','0','0','','0','0'),
('37','1.15.01.','34','2014','2.06.1.15.01.18.052.','Optimalisasi Layanan Pasar Online Jogjaplaza','41710500','0','41710500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.','PROGRAM, PENGEMBANGAN INDUSTRI MENENGAH','1366961360,0','0','1366961360,0','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.078.','Temu Usaha Industri Kecil Menengah ( I K M ) Pangan D I Y Dengan Pelaku Pariwisata','46189960','0','46189960','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.083.','Peningkatan Sertifikasi Produk IKM Pangan','92930000','0','92930000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.085.','Penerapan SNI IKM Logam','99628000','0','99628000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.092.','Pesona Pangan Nusantara','122477500','0','122477500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.099.','Fasilitasi Pengembangan Industri (IKM) Pewarnaan Alam Batik','46558460','0','46558460','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.101.','Fasilitasi Pengembangan Desain Kerajinan Perhiasan Logam dan Perak','68929500','0','68929500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.107.','Promosi Gelar Sepatu dan Kulit','117887000','0','117887000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.110.','Sosialisasi SVLK bagi IKM Kayu dan Eksportir Kayu','21995460','0','21995460','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.111.','Sosialisasi Ketentuan di Bidang Cukai Tembakau (Cukai)','79998560','0','79998560','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.112.','Penumbuhan WUB ILSA','175260000','0','175260000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.113.','Fasilitasi Pengembangan Desain dan Diversifikasi Produk Kerajinan Anyaman','49051000','0','49051000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.114.','Fasilitasi Pengembangan Desain Kerajinan Batu Mulia','50000000','0','50000000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.115.','Pengembangan Produksi IKM Kimia','197820500','0','197820500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.116.','Pengembangan Sentra IKM Batik','51408460','0','51408460','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.125.','Temu Usaha IKM Kerajinan dengan Pelaku Pariwisata','39218800','0','39218800','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.127.','Pengembangan IKM Kayu','77157460','0','77157460','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.16.128.','Pameran Kerajinan Kayu dan Bambu','30450700','0','30450700','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.','PROGRAM PENINGKATAN KEMAMPUAN TEKNOLOGI INDUSTRI','1274507128','0','1274507128','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.013.','Pengembangan Dan Pelayanan Teknologi Tepat Guna','300126960','0','300126960','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.079.','Pengelolaan Rekayasa Dan Produksi','81034000','0','81034000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.081.','Pengembangan Teknologi Pengelolaan Produk Herbal','75000000','0','75000000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.086.','Pengembangan IKM Sandang dan Kulit','124504000','0','124504000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.087.','Pengembangan dan Pelayanan Teknologi Kemasan','169580784','0','169580784','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.088.','Pengembangan dan Pelayanan CFSMI','100007500','0','100007500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.089.','Promosi Teknologi Tepat Guna','200161500','0','200161500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.090.','Pengembangan Teknologi Produksi IKM Bambu','74662460','0','74662460','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.092.','Bimbingan Teknologi Peningkatan Kemampuan Teknologi IKM Logam Kuningan','60314960','0','60314960','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.17.093.','Fasilitasi Peningkatan Kualitas dan Diversifikasi Produk IKM Logam Ferro','89115000','0','89115000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.20.','PROGRAM PEMBINAAN DAN PENGEMBANGAN INDUSTRI KREATIF','851756000','0','851756000','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.20.018.','Jogja Fashion Week','430473500','0','430473500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.20.021.','Pengembangan Industri Kreatif','330761500','0','330761500','0','0','','0','0'),
('37','1.15.01.','34','2014','2.07.1.15.01.20.023.','Pelatihan Pengelolaan UKM berbasis IT','90521000','0','90521000','0','0','','0','0'),
('37','1.15.01.','34','2014','3.33.1.15.01.16.','PROGRAM PENGEMBANGAN INDUSTRI KECIL DAN MENENGAH','2996586000','0','2996586000','0','0','','0','0'),
('37','1.15.01.','34','2014','3.33.1.15.01.16.130.','Pembinaan dan Pengembangan Produk Khas Jogja','2996586000','0','2996586000','0','0','','0','0'),
('37','1.15.01.','34','2014','3.33.1.15.01.20.','PROGRAM PEMBINAAN DAN PENGEMBANGAN INDUSTRI KREATIF','1415200000','0','1415200000','0','0','','0','0'),
('37','1.15.01.','34','2014','3.33.1.15.01.20.028.','PengembanganIndustri Kreatif Tradisional','1415200000','0','1415200000','0','0','','0','0'),
|
--
-- Copyright (c) Microsoft Corporation. All rights reserved.
-- Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
--
--run this manually on Commerce DB in INT environment
use master
go
-- login should be created in master db
--sys.server_principals does not work in Azure SQL
--IF NOT EXISTS (SELECT name FROM master.sys.server_principals WHERE name = 'dotmExec')
IF NOT EXISTS (select * from sys.sql_logins WHERE name = 'dotmExec')
BEGIN
CREATE LOGIN dotmExec WITH PASSWORD = '<PASSWORD>';
END
-- following statements should be executed in commerce int db
use commerce
go
IF NOT EXISTS (SELECT name FROM sys.database_principals WHERE name = 'dotmExec' and Type = 'S')
BEGIN
CREATE USER dotmExec FOR LOGIN dotmExec;
END
if not exists (select * from sys.database_principals where name='db_execproc' and Type = 'R')
begin
CREATE ROLE db_execproc AUTHORIZATION dotmExec;
GRANT EXECUTE TO db_execproc;
GRANT EXECUTE ON SCHEMA::dbo TO db_execproc;
end
execute sp_addrolemember @rolename = 'db_execproc', @membername = 'dotmExec';
|
INSERT INTO "Estudiante_U_Representante" ("id", "estudianteID", "representanteID") VALUES (1, 1, 1);
INSERT INTO "Estudiante_U_Representante" ("id", "estudianteID", "representanteID") VALUES (2, 2, 1);
INSERT INTO "Estudiante_U_Representante" ("id", "estudianteID", "representanteID") VALUES (3, 3, 1);
|
<filename>prisma/migrations/20220127030343_correction_field_company_id_is_required/migration.sql
/*
Warnings:
- Made the column `company_id` on table `accounts` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "accounts" ALTER COLUMN "company_id" SET NOT NULL;
|
CREATE TABLE `pri_price` (
`price_id` int(11) NOT NULL AUTO_INCREMENT,
`route_id` varchar(50) DEFAULT NULL,
`vehicle_type_id` varchar(50) DEFAULT NULL,
`price` float(13) DEFAULT NULL,
`group_price_per_person` float(15) DEFAULT NULL,
`group_size` int(15) DEFAULT NULL,
PRIMARY KEY (`price_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
-- job history
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
DECLARE @StartDate datetime;
SET @StartDate = CONVERT(datetime, '{0}', 120);
--SET @StartDate = CONVERT(datetime, '2016-11-02 05:28:00', 120);
WITH cteJobHistory AS (
SELECT
CONVERT(nvarchar(128), SERVERPROPERTY('ServerName')) AS ServerName,
j.[job_id] AS [JobID], j.[name] AS [JobName], h.step_id AS [StepID], h.step_name AS [StepName],
[msdb].dbo.agent_datetime(h.run_date, h.run_time) AS [LastRunTime],
h.run_status AS [RunStatus], -- 0 = Failed; 1 = Succeeded; 2 = Retry; 3 = Cancelled
h.[message] AS [Message]
FROM [msdb].dbo.sysjobs j
INNER JOIN [msdb].dbo.sysjobhistory h ON j.job_id = h.job_id
WHERE j.enabled = 1 AND h.step_id > 0
)
SELECT * FROM cteJobHistory
WHERE [LastRunTime] > @StartDate
ORDER BY [LastRunTime] DESC, [JobName] ASC, [StepID] ASC;
|
CREATE TABLE IF NOT EXISTS `pre_setting` (
`name` VARCHAR(50) PRIMARY KEY,
`value` LONGTEXT NOT NULL
) ENGINE=InnoDB CHARSET=utf8mb4;
INSERT INTO `pre_setting` (`name`, `value`) VALUES
('appid', ''),
('appsecret', ''),
('promotion', '[{"k":50,"v":10}]'),
('img_swiper', '["\\/static\\/uploads\\/default\\/banner_1.png","\\/static\\/uploads\\/default\\/banner_2.png","\\/static\\/uploads\\/default\\/banner_3.png"]'),
('img_ad', '/static/uploads/default/image_ad.png'),
('img_category', '["\\/static\\/uploads\\/default\\/bottom_1.png","\\/static\\/uploads\\/default\\/bottom_2.png","\\/static\\/uploads\\/default\\/bottom_3.png","\\/static\\/uploads\\/default\\/bottom_1.png"]');
CREATE TABLE IF NOT EXISTS `pre_admin` (
`id` INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
`username` VARCHAR(32) UNIQUE NOT NULL DEFAULT '',
`password` VARCHAR(32) NOT NULL DEFAULT '',
`salt` VARCHAR(32) NOT NULL DEFAULT ''
) ENGINE=InnoDB CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `pre_user` (
`id` INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
`openid` VARCHAR(255) DEFAULT '' NOT NULL,
`price` DECIMAL(10, 2) UNSIGNED NOT NULL DEFAULT 0,
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `pre_category` (
`id` INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL DEFAULT '',
`sort` INT NOT NULL DEFAULT 0
) ENGINE=InnoDB CHARSET=utf8mb4;
INSERT INTO `pre_category` (`id`, `name`,`sort`) VALUES
(1, '热销推荐', 1),
(2, '特色小吃', 2),
(3, '甜粥', 3),
(4, '凉菜', 4),
(5, '醇香奶茶', 5),
(6, '主食', 6),
(7, '小炒菜', 7),
(8, '现磨咖啡', 8),
(9, '鲜果奶茶', 9);
CREATE TABLE IF NOT EXISTS `pre_food` (
`id` INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
`category_id` INT UNSIGNED NOT NULL DEFAULT 0,
`name` VARCHAR(255) NOT NULL DEFAULT '',
`price` DECIMAL(10, 2) UNSIGNED NOT NULL DEFAULT 0,
`image_url` VARCHAR(255) NOT NULL DEFAULT '',
`status` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` DATETIME DEFAULT NULL,
`delete_time` DATETIME DEFAULT NULL
) ENGINE=InnoDB CHARSET=utf8mb4;
INSERT INTO `pre_food` (`id`, `category_id`, `name`, `price`, `image_url`, `status`) VALUES
(1, 1, '奶香糯玉米松饼', 14, 'images/1.jpg', 1),
(2, 1, '鲜枣馍', 13, 'images/2.jpg', 1),
(3, 1, '华夫饼', 12, 'images/3.jpg', 1),
(4, 1, '琥珀珍珠奶茶(中杯)', 10, 'images/4.webp', 1),
(5, 1, '香柠咖啡(大杯)', 14, 'images/5.webp', 1),
(6, 1, '柠檬椰果养乐多/大杯', 17, 'images/6.webp', 1),
(7, 1, '芒果养乐多/大杯', 16, 'images/7.webp', 1),
(8, 1, '葡萄柚养乐多/大杯', 18, 'images/8.webp', 1),
(9, 1, '绿茶养乐多/大杯', 14, 'images/9.webp', 1),
(10, 1, '加10元得冷饮杯', 10, 'images/10.webp', 1),
(11, 1, '红茶拿铁/大杯', 14, 'images/11.webp', 1),
(12, 1, '珍珠红茶拿铁/大杯', 14, 'images/12.webp', 1),
(13, 1, '鲜醇牛奶三兄弟/中杯', 14, 'images/13.webp', 1),
(14, 1, '鲜醇草莓欧蕾/中杯', 14, 'images/14.webp', 1),
(15, 1, '鲜醇芒果欧蕾/中杯', 12, 'images/15.webp', 1),
(16, 1, '铁观音茶拿铁珍珠/大杯', 15, 'images/16.webp', 1),
(17, 2, '南瓜荷叶饼', 13, 'images/17.jpg', 1),
(18, 2, '鲜枣馍', 12, 'images/18.jpg', 1),
(19, 2, '芝士火腿包', 10, 'images/19.jpg', 1),
(20, 2, '华夫饼', 10, 'images/20.jpg', 1),
(21, 3, '红豆薏米紫米粥', 15, 'images/21.jpg', 1),
(22, 3, '枸杞酒酿玉米羹', 14, 'images/22.jpg', 1),
(23, 3, '红豆桂圆银耳羹/大份', 14, 'images/23.jpg', 1),
(24, 3, '红豆桂圆银耳羹/小份', 11, 'images/24.jpg', 1),
(25, 3, '冬瓜酥肉汤/大份', 14, 'images/25.jpg', 1),
(26, 3, '冬瓜酥肉汤/小份', 11, 'images/26.jpg', 1),
(27, 3, '土豆炖豆腐/大份', 14, 'images/27.jpg', 1),
(28, 3, '土豆炖豆腐/小份', 11, 'images/28.jpg', 1),
(29, 4, '口水鸡', 12, 'images/29.jpg', 1),
(30, 5, '鲜芋奶茶/中杯', 11, 'images/30.webp', 1),
(31, 5, '珍珠奶茶/大杯', 11, 'images/31.webp', 1),
(32, 5, '珍珠奶茶/中杯', 9, 'images/32.webp', 1),
(33, 5, '布丁奶茶/大杯', 11, 'images/33.webp', 1),
(34, 5, '布丁奶茶/中杯', 9, 'images/34.webp', 1),
(35, 5, '奶茶三兄弟/大杯', 13, 'images/35.webp', 1),
(36, 5, '奶茶三兄弟/中杯', 11, 'images/36.webp', 1),
(37, 5, '双拼奶茶/大杯', 12, 'images/37.webp', 1),
(38, 5, '双拼奶茶/中杯', 10, 'images/38.webp', 1),
(39, 5, '红豆奶茶/大杯', 12, 'images/39.webp', 1),
(40, 5, '红豆奶茶/中杯', 10, 'images/40.webp', 1),
(41, 5, 'QQ奶茶/大杯', 12, 'images/41.webp', 1),
(42, 5, 'QQ奶茶/中杯', 10, 'images/42.webp', 1),
(43, 5, '椰果奶茶/大杯', 11, 'images/43.webp', 1),
(44, 5, '椰果奶茶/中杯', 9, 'images/44.webp', 1),
(45, 5, '仙草冻奶茶/大杯', 11, 'images/45.webp', 1),
(46, 5, '仙草冻奶茶/中杯', 9, 'images/46.webp', 1),
(47, 5, '铁观音珍珠奶茶/大杯', 12, 'images/47.webp', 1),
(48, 5, '琥珀珍珠奶茶大杯 ', 12, 'images/48.webp', 1),
(49, 6, '奶香糯玉米松饼', 10, 'images/49.jpg', 1),
(50, 6, '红糖酥饼', 10, 'images/50.jpg', 1),
(51, 7, '耗油青菜小炒/大份', 12, 'images/51.jpg', 1),
(52, 7, '耗油青菜小炒/小份', 10, 'images/52.jpg', 1),
(53, 7, '鸡蛋木耳小炒/大份', 12, 'images/53.jpg', 1),
(54, 7, '鸡蛋木耳小炒/小份', 10, 'images/54.jpg', 1),
(55, 7, '可乐鸡翅', 11, 'images/55.jpg', 1),
(56, 7, '油菜沙拉/大份', 11, 'images/56.jpg', 1),
(57, 7, '油菜沙拉/小份', 9, 'images/57.jpg', 1),
(58, 8, '美式咖啡/中杯', 8, 'images/58.webp', 1),
(59, 8, '香柠咖啡/大杯', 14, 'images/59.webp', 1),
(60, 8, '拿铁咖啡/大杯', 16, 'images/60.webp', 1),
(61, 8, '拿铁咖啡/中杯', 13, 'images/61.webp', 1),
(62, 8, '卡布奇诺/大杯', 16, 'images/62.webp', 1),
(63, 8, '卡布奇诺/中杯', 13, 'images/63.webp', 1),
(64, 8, '摩卡咖啡/大杯', 19, 'images/64.webp', 1),
(65, 8, '摩卡咖啡/中杯', 16, 'images/65.webp', 1),
(66, 8, '珍珠拿铁/大杯', 16, 'images/66.webp', 1),
(67, 8, '香草拿铁/大杯', 19, 'images/67.webp', 1),
(68, 8, '香草拿铁/中杯', 16, 'images/68.webp', 1),
(69, 8, '法式奶霜咖啡/大杯', 15, 'images/69.webp', 1),
(70, 8, '海盐焦糖拿铁/大杯', 18, 'images/70.webp', 1),
(71, 8, '海盐焦糖拿铁/中杯', 15, 'images/71.webp', 1),
(72, 8, '香柠咖啡', 14, 'images/72.webp', 1),
(73, 9, '法式奶霜草莓果茶(大杯)', 15, 'images/73.webp', 1),
(74, 9, '鲜百香双响炮/大杯', 13, 'images/74.webp', 1),
(75, 9, '柠檬霸/大杯', 13, 'images/75.webp', 1),
(76, 9, '金桔柠檬汁/中杯', 11, 'images/76.webp', 1),
(77, 9, '葡萄柚绿茶/中杯', 11, 'images/77.webp', 1),
(78, 9, '草莓果茶/中杯', 10, 'images/78.webp', 1),
(79, 9, '鲜柠檬红茶/中杯', 10, 'images/79.webp', 1),
(80, 9, '鲜柠檬绿茶/中杯', 10, 'images/80.webp', 1),
(81, 9, '鲜百香绿茶/中杯', 10, 'images/81.webp', 1);
CREATE TABLE IF NOT EXISTS `pre_order` (
`id` INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
`user_id` INT UNSIGNED NOT NULL DEFAULT 0,
`price` DECIMAL(10, 2) UNSIGNED NOT NULL DEFAULT 0,
`promotion` DECIMAL(10, 2) UNSIGNED NOT NULL DEFAULT 0,
`number` INT UNSIGNED NOT NULL DEFAULT 0,
`is_pay` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`is_taken` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`comment` TEXT NOT NULL,
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`pay_time` DATETIME DEFAULT NULL,
`taken_time` DATETIME DEFAULT NULL
) ENGINE=InnoDB CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `pre_order_food` (
`id` INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
`order_id` INT UNSIGNED NOT NULL DEFAULT 0,
`food_id` INT UNSIGNED NOT NULL DEFAULT 0,
`number` INT UNSIGNED NOT NULL DEFAULT 0,
`price` DECIMAL(10, 2) NOT NULL DEFAULT 0
) ENGINE=InnoDB CHARSET=utf8mb4;
|
DELETE FROM partner_proof WHERE proof_template_id IN (SELECT id FROM bpa_proof_template);
DELETE FROM bpa_proof_template;
|
DROP TABLE IF EXISTS `shuyang_book_reply`;
|
Use hospital;
Create Table WardDetails(
Ward_no int primary key auto_increment,
Ward_Type varchar(50) not null,
Ward_Contact varchar(20) not null
) ;
Insert into warddetails(Ward_Type,Ward_Contact) values ('General', '0731-6789023');
Insert into warddetails(Ward_Type,Ward_Contact) values ('Private', '0731-6789045');
Insert into warddetails(Ward_Type,Ward_Contact) values ('Special', '0731-6783285');
select * from warddetails;
select count(*) from warddetails where Ward_room_type='AC';
select * from warddetails where Ward_room_type='AC';
-- DELETE FROM `hospital`.`patientdetails` WHERE (`Patient_id` = '5');
-- Update Query
-- Update [Table-Name] Set [Col1=value.....] Where [Condition]
-- update Department set Capcity=10 where DeptNo=50;
-- Change the COlumn NAme from 'capcity' to 'capacity'
-- Alter [Table-Name] Change [OldNAme][NewNAme] Datatype size;
-- Alter Table Department Change Capcity Capacity int;
|
ALTER TABLE `team_accounts`
DROP FOREIGN KEY `FK_account_id`;
ALTER TABLE `team_accounts`
ADD CONSTRAINT `FK_account_id`
FOREIGN KEY (`account_id`)
REFERENCES `account` (`id`)
ON DELETE CASCADE;
|
<reponame>raster-foundry/raster-foundry
ALTER TABLE public.annotation_label_classes
ADD COLUMN "is_active" BOOLEAN NOT NULL DEFAULT TRUE;
ALTER TABLE public.annotation_label_class_groups
ADD COLUMN "is_active" BOOLEAN NOT NULL DEFAULT TRUE;
|
delete from user_permissions;
delete from users;
delete from apps;
delete from permissions;
-- Default apps
-- TODO: This could be broken up into a file for each app, and live
-- in the app's directory.
insert into apps (app_name) values ('UserAdmin');
insert into apps (app_name) values ('PosdaCuration');
insert into apps (app_name) values ('PhiFixer');
insert into apps (app_name) values ('ReviewPhi');
insert into apps (app_name) values ('SubmissionSender');
insert into apps (app_name) values ('CountGetter');
insert into apps (app_name) values ('FileDist');
insert into apps (app_name) values ('DicomProxy');
insert into apps (app_name) values ('DicomProxyAnalysis');
insert into apps (app_name) values ('DbIf');
-- Default users
insert into users (user_name, full_name, password) values (
'admin', 'Default Admin Account', 'aJE5lY8D,2wUueoiymAn8HsfbdAp0kPfTiODV7kpeNUttYTgQGbE');
-- Default permissions
insert into permissions (app_id, permission_name)
select app_id, column1 from apps, (values ('launch'), ('debug')) a;
insert into permissions (app_id, permission_name) values (
(select app_id from apps where app_name = 'DbIf'),
'update'
);
-- Default user/app/permission associations
insert into user_permissions values (
(select user_id from users where user_name = 'admin'),
(select permission_id from permissions where permission_name = 'launch'
and app_id = (select app_id from apps where app_name = 'UserAdmin'))
);
insert into user_permissions values (
(select user_id from users where user_name = 'admin'),
(select permission_id from permissions where permission_name = 'debug'
and app_id = (select app_id from apps where app_name = 'UserAdmin'))
);
-- PURE TESTING DATA DO NOT PUT IN PRODUCTION
insert into users (user_name, full_name) values ('quasar',
'<NAME>');
insert into user_permissions values (
(select user_id from users where user_name = 'quasar'),
(select permission_id from permissions where permission_name = 'launch'
and app_id = (select app_id from apps where app_name = 'UserAdmin'))
);
insert into user_permissions values (
(select user_id from users where user_name = 'quasar'),
(select permission_id from permissions where permission_name = 'launch'
and app_id = (select app_id from apps where app_name = 'PosdaCuration'))
);
|
ALTER TABLE `processes` DROP `resource_type`;
|
<reponame>WeilerWebServices/PostgreSQL<filename>pgAdmin/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/tests/pg/default/msql_create_domain_numeric.sql
CREATE DOMAIN public."Dom1_$%{}[]()&*^!@""'`\/#"
AS numeric(5,2)
DEFAULT 3
NOT NULL;
ALTER DOMAIN public."Dom1_$%{}[]()&*^!@""'`\/#" OWNER TO postgres;
COMMENT ON DOMAIN public."Dom1_$%{}[]()&*^!@""'`\/#"
IS 'test_comment';
|
<filename>contrib/babelfishpg_tsql/sql/sys_procedures.sql
CREATE PROCEDURE sys.sp_unprepare(IN prep_handle INTEGER)
AS 'babelfishpg_tsql', 'sp_unprepare'
LANGUAGE C;
GRANT EXECUTE ON PROCEDURE sys.sp_unprepare(IN INTEGER) TO PUBLIC;
CREATE PROCEDURE sys.sp_prepare(INOUT prep_handle INTEGER, IN params varchar(8000),
IN stmt varchar(8000), IN options int default 1)
AS 'babelfishpg_tsql', 'sp_prepare'
LANGUAGE C;
GRANT EXECUTE ON PROCEDURE sys.sp_prepare(
INOUT INTEGER, IN varchar(8000), IN varchar(8000), IN int
) TO PUBLIC;
CREATE OR REPLACE FUNCTION sys.sp_getapplock_function (IN "@resource" varchar(255),
IN "@lockmode" varchar(32),
IN "@lockowner" varchar(32) DEFAULT 'TRANSACTION',
IN "@locktimeout" INTEGER DEFAULT -99,
IN "@dbprincipal" varchar(32) DEFAULT 'dbo')
RETURNS INTEGER
AS 'babelfishpg_tsql', 'sp_getapplock_function' LANGUAGE C;
GRANT EXECUTE ON FUNCTION sys.sp_getapplock_function(
IN varchar(255), IN varchar(32), IN varchar(32), IN INTEGER, IN varchar(32)
) TO PUBLIC;
CREATE OR REPLACE FUNCTION sys.sp_releaseapplock_function(IN "@resource" varchar(255),
IN "@lockowner" varchar(32) DEFAULT 'TRANSACTION',
IN "@dbprincipal" varchar(32) DEFAULT 'dbo')
RETURNS INTEGER
AS 'babelfishpg_tsql', 'sp_releaseapplock_function' LANGUAGE C;
GRANT EXECUTE ON FUNCTION sys.sp_releaseapplock_function(
IN varchar(255), IN varchar(32), IN varchar(32)
) TO PUBLIC;
CREATE OR REPLACE PROCEDURE sys.sp_cursor_list (INOUT "@cursor_return" refcursor,
IN "@cursor_scope" INTEGER)
AS $$
DECLARE
cur refcursor;
BEGIN
IF "@cursor_scope" >= 1 AND "@cursor_scope" <= 3 THEN
OPEN cur FOR EXECUTE 'SELECT reference_name::name, cursor_name::name, cursor_scope::smallint, status::smallint, model::smallint, concurrency::smallint, scrollable::smallint, open_status::smallint, cursor_rows::numeric(10,0), fetch_status::smallint, column_count::smallint, row_count::numeric(10,0), last_operation::smallint, cursor_handle::int FROM sys.babelfish_cursor_list($1)' USING "@cursor_scope";
ELSE
RAISE 'invalid @cursor_scope: %', "@cursor_scope";
END IF;
-- PG cursor evaluates the query at first fetch. We need to evaluate table function now because cursor_list() depeneds on "current" tsql_estate().
-- Running MOVE fowrard and backward to force evaluating sys.babelfish_cursor_list() now.
MOVE NEXT FROM cur;
MOVE PRIOR FROM cur;
SELECT cur INTO "@cursor_return";
END;
$$ LANGUAGE plpgsql;
GRANT EXECUTE ON PROCEDURE sys.sp_cursor_list(INOUT refcursor, IN INTEGER) TO PUBLIC;
CREATE OR REPLACE PROCEDURE sys.sp_describe_cursor (INOUT "@cursor_return" refcursor,
IN "@cursor_source" nvarchar(30),
IN "@cursor_identity" nvarchar(30))
AS $$
DECLARE
cur refcursor;
cursor_source int;
BEGIN
IF lower("@cursor_source") = 'local' THEN
cursor_source := 1;
ELSIF lower("@cursor_source") = 'global' THEN
cursor_source := 2;
ELSIF lower("@cursor_source") = 'variable' THEN
cursor_source := 3;
ELSE
RAISE 'invalid @cursor_source: %', "@cursor_source";
END IF;
OPEN cur FOR EXECUTE 'SELECT reference_name::name, cursor_name::name, cursor_scope::smallint, status::smallint, model::smallint, concurrency::smallint, scrollable::smallint, open_status::smallint, cursor_rows::numeric(10,0), fetch_status::smallint, column_count::smallint, row_count::numeric(10,0), last_operation::smallint, cursor_handle::int FROM sys.babelfish_cursor_list($1) WHERE cursor_source = $1 and reference_name = $2' USING cursor_source, "@cursor_identity";
-- PG cursor evaluates the query at first fetch. We need to evaluate table function now because cursor_list() depeneds on "current" tsql_estate().
-- Running MOVE fowrard and backward to force evaluating sys.babelfish_cursor_list() now.
MOVE NEXT FROM cur;
MOVE PRIOR FROM cur;
SELECT cur INTO "@cursor_return";
END;
$$ LANGUAGE plpgsql;
GRANT EXECUTE ON PROCEDURE sys.sp_describe_cursor(
INOUT refcursor, IN nvarchar(30), IN nvarchar(30)
) TO PUBLIC;
CREATE OR REPLACE PROCEDURE sys.sp_babelfish_configure()
AS 'babelfishpg_tsql', 'sp_babelfish_configure'
LANGUAGE C;
GRANT EXECUTE ON PROCEDURE sys.sp_babelfish_configure() TO PUBLIC;
CREATE OR REPLACE PROCEDURE sys.sp_babelfish_configure(IN "@option_name" varchar(128))
AS 'babelfishpg_tsql', 'sp_babelfish_configure'
LANGUAGE C;
GRANT EXECUTE ON PROCEDURE sys.sp_babelfish_configure(IN varchar(128)) TO PUBLIC;
CREATE OR REPLACE PROCEDURE sys.sp_babelfish_configure(IN "@option_name" varchar(128), IN "@option_value" varchar(128))
AS $$
BEGIN
CALL sys.sp_babelfish_configure("@option_name", "@option_value", '');
END;
$$ LANGUAGE plpgsql;
GRANT EXECUTE ON PROCEDURE sys.sp_babelfish_configure(IN varchar(128), IN varchar(128)) TO PUBLIC;
CREATE OR REPLACE PROCEDURE sys.sp_babelfish_configure(IN "@option_name" varchar(128), IN "@option_value" varchar(128), IN "@option_scope" varchar(128))
AS $$
DECLARE
normalized_name varchar(256);
default_value text;
cnt int;
cur refcursor;
eh_name varchar(256);
server boolean := false;
prev_user text;
BEGIN
IF lower("@option_name") like 'babelfishpg_tsql.%' THEN
SELECT "@option_name" INTO normalized_name;
ELSE
SELECT concat('babelfishpg_tsql.',"@option_name") INTO normalized_name;
END IF;
IF lower("@option_scope") = 'server' THEN
server := true;
ELSIF btrim("@option_scope") != '' THEN
RAISE EXCEPTION 'invalid option: %', "@option_scope";
END IF;
SELECT COUNT(*) INTO cnt FROM pg_catalog.pg_settings WHERE name like normalized_name and name like '%escape_hatch%';
IF cnt = 0 THEN
RAISE EXCEPTION 'unknown configuration: %', normalized_name;
END IF;
OPEN cur FOR SELECT name FROM pg_catalog.pg_settings WHERE name like normalized_name and name like '%escape_hatch%';
LOOP
FETCH NEXT FROM cur into eh_name;
exit when not found;
-- Each setting has a boot_val which is the wired-in default value
-- Assuming that escape hatches cannot be modified using ALTER SYTEM/config file
-- we are setting the boot_val as the default value for the escape hatches
SELECT boot_val INTO default_value FROM pg_catalog.pg_settings WHERE name = eh_name;
IF lower("@option_value") = 'default' THEN
PERFORM pg_catalog.set_config(eh_name, default_value, 'false');
ELSE
PERFORM pg_catalog.set_config(eh_name, "@option_value", 'false');
END IF;
IF server THEN
SELECT current_user INTO prev_user;
PERFORM sys.babelfish_set_role(session_user);
IF lower("@option_value") = 'default' THEN
EXECUTE format('ALTER DATABASE %s SET %s = %s', CURRENT_DATABASE(), eh_name, default_value);
ELSE
-- store the setting in PG master database so that it can be applied to all bbf databases
EXECUTE format('ALTER DATABASE %s SET %s = %s', CURRENT_DATABASE(), eh_name, "@option_value");
END IF;
PERFORM sys.babelfish_set_role(prev_user);
END IF;
END LOOP;
CLOSE cur;
END;
$$ LANGUAGE plpgsql;
GRANT EXECUTE ON PROCEDURE sys.sp_babelfish_configure(
IN varchar(128), IN varchar(128), IN varchar(128)
) TO PUBLIC;
|
/*
First derived from View "mgd.mgi_note_allele_view"
~ 2 ninutes
*/
SELECT
nav._note_key,
nav._object_key as mgi_internal,
--n._mgitype_key,
--n._notetype_key,
--n._createdby_key,
--n._modifiedby_key,
--n.creation_date,
--n.modification_date,
nav.notetype,
nav.note,
--c.sequencenum,
nav.mgitype
--u1.login AS createdby,
--u2.login AS modifiedby
FROM mgi_note_allele_view nav
;
|
<gh_stars>1-10
-- create class using Constraints null,Unique and DEFAULT
create table t1 (
c1 int DEFAULT 9 null Unique
);
drop t1;
|
<reponame>ervinne13/wof_erp_reports<filename>dump/20160408 JO - Table Script.sql<gh_stars>0
/*
Created: 4/5/2016
Modified: 4/7/2016
Model: JO
Database: PostgreSQL 9.2
*/
-- Create tables section -------------------------------------------------
-- Table tblCOM_JO
CREATE TABLE "tblCOM_JO"(
"JO_DocNo" Character varying(30) NOT NULL,
"JO_DocDate" Timestamp NOT NULL,
"JO_RefNo" Character varying(30),
"JO_Remarks" Text,
"JO_Location" Character varying(30) NOT NULL,
"JO_Company" Character varying(30) NOT NULL,
"JO_Status" Character varying(30) NOT NULL,
"JO_AssetID" Character varying(20) NOT NULL,
"JO_ItemNo" Character varying(30) NOT NULL,
"JO_ItemDescription" Character varying(200) NOT NULL,
"JO_NatureOfDefect" Character varying(100) NOT NULL,
"JO_JobNeeded" Character varying(100) NOT NULL,
"JO_Technician" Character varying(100) NOT NULL,
"JO_DateDown" Timestamp,
"JO_DateOperational" Timestamp,
"JO_DowntimeDays" Numeric(12,4),
"CreatedBy" Character varying(20),
"DateCreated" Timestamp,
"ModifiedBy" Character varying(20),
"DateModified" Timestamp
)
WITH (OIDS=FALSE)
;
-- Add keys for table tblCOM_JO
ALTER TABLE "tblCOM_JO" ADD CONSTRAINT "JO_DocNo" PRIMARY KEY ("JO_DocNo")
;
-- Table tblCOM_JODetail
CREATE TABLE "tblCOM_JODetail"(
"JOD_JO_DocNo" Character varying(30) NOT NULL,
"JOD_LineNo" BigSerial NOT NULL,
"JOD_Date" Timestamp NOT NULL,
"JOD_ActionTaken" Text NOT NULL,
"JOD_UserID" Character varying(20) NOT NULL,
"CreatedBy" Character varying(20),
"DateCreated" Timestamp,
"ModifiedBy" Character varying(20),
"DateModified" Timestamp
)
WITH (OIDS=FALSE)
;
-- Add keys for table tblCOM_JODetail
ALTER TABLE "tblCOM_JODetail" ADD CONSTRAINT "JOD_JO_DocNo" PRIMARY KEY
("JOD_JO_DocNo","JOD_LineNo")
;
-- Create relationships section -------------------------------------------------
ALTER TABLE "tblCOM_JODetail" ADD CONSTRAINT "PFK_JO_Detail" FOREIGN KEY ("JOD_JO_DocNo")
REFERENCES "tblCOM_JO" ("JO_DocNo") ON DELETE RESTRICT ON UPDATE CASCADE
;
|
<gh_stars>0
CREATE USER jtb_user;
CREATE DATABASE cities;
CREATE DATABASE university;
GRANT ALL PRIVILEGES ON DATABASE cities TO jtb_user;
GRANT ALL PRIVILEGES ON DATABASE university TO jtb_user;
|
--adds a column with the frequency of each post across multiple reddits
drop table if exists scored_posts;
create table scored_posts as
select *,
count(id)over(partition by url) as Frequency
from posts;
--filters down to only the posts on more than one subreddit
drop table if exists duplicate_posts;
create table duplicate_posts as
select *
from scored_posts
where frequency > 1;
--send this back to python to get the comments from the post
|
-- --------------------------------------------------
-- Generated by Enterprise Architect Version 9.3.931
-- Created On : Wednesday, 07 October, 2015
-- DBMS : MySql
-- --------------------------------------------------
SET FOREIGN_KEY_CHECKS=0;
-- Drop Tables, Stored Procedures and Views
DROP TABLE IF EXISTS api_client CASCADE;
DROP TABLE IF EXISTS auth_operation CASCADE;
DROP TABLE IF EXISTS auth_permission CASCADE;
DROP TABLE IF EXISTS auth_resource CASCADE;
DROP TABLE IF EXISTS auth_role CASCADE;
DROP TABLE IF EXISTS auth_user_role CASCADE;
DROP TABLE IF EXISTS beam CASCADE;
DROP TABLE IF EXISTS beam_event CASCADE;
DROP TABLE IF EXISTS beam_system CASCADE;
DROP TABLE IF EXISTS breakdown_category CASCADE;
DROP TABLE IF EXISTS breakdown_event CASCADE;
DROP TABLE IF EXISTS control_signal CASCADE;
DROP TABLE IF EXISTS element CASCADE;
DROP TABLE IF EXISTS event CASCADE;
DROP TABLE IF EXISTS experiment CASCADE;
DROP TABLE IF EXISTS expr_event CASCADE;
DROP TABLE IF EXISTS external_service CASCADE;
DROP TABLE IF EXISTS facility CASCADE;
DROP TABLE IF EXISTS logbook CASCADE;
DROP TABLE IF EXISTS mode CASCADE;
DROP TABLE IF EXISTS mode_event CASCADE;
DROP TABLE IF EXISTS operations_role CASCADE;
DROP TABLE IF EXISTS shift CASCADE;
DROP TABLE IF EXISTS shift_staff_member CASCADE;
DROP TABLE IF EXISTS shift_status CASCADE;
DROP TABLE IF EXISTS source CASCADE;
DROP TABLE IF EXISTS source_event CASCADE;
DROP TABLE IF EXISTS staff_role CASCADE;
DROP TABLE IF EXISTS summary CASCADE;
DROP TABLE IF EXISTS summary_event CASCADE;
DROP TABLE IF EXISTS system_property CASCADE;
DROP TABLE IF EXISTS sysuser CASCADE;
DROP TABLE IF EXISTS training_record CASCADE;
DROP TABLE IF EXISTS trouble_report CASCADE;
DROP TABLE IF EXISTS user_preference CASCADE;
DROP TABLE IF EXISTS vault CASCADE;
DROP TABLE IF EXISTS vault_event CASCADE;
-- Create Tables
CREATE TABLE api_client
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NOT NULL,
api_key VARCHAR(255) NOT NULL,
api_password VARCHAR(255),
description VARCHAR(255) NOT NULL,
contact_name VARCHAR(128) NOT NULL,
contact_email VARCHAR(128),
comments VARCHAR(255),
PRIMARY KEY (id)
) ENGINE=InnoDB COMMENT='a client that uses hour log API';
CREATE TABLE auth_operation
(
operation_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NOT NULL,
description VARCHAR(255) NOT NULL,
PRIMARY KEY (operation_id),
UNIQUE UQ_auth_operation_name(name)
) ENGINE=InnoDB;
CREATE TABLE auth_permission
(
privilege_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
role INTEGER UNSIGNED NOT NULL,
operation INTEGER UNSIGNED NOT NULL,
resource INTEGER UNSIGNED NOT NULL,
version INTEGER UNSIGNED NOT NULL DEFAULT 0 COMMENT 'for concurrency control',
PRIMARY KEY (privilege_id),
KEY (operation),
KEY (resource),
KEY (role)
) ENGINE=InnoDB COMMENT='a role''s allowed operation on a resource';
CREATE TABLE auth_resource
(
resource_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
description VARCHAR(255) NOT NULL,
version INTEGER UNSIGNED NOT NULL DEFAULT 0 COMMENT 'for optimistic concurrency control',
PRIMARY KEY (resource_id),
UNIQUE UQ_resource_name(name)
) ENGINE=InnoDB;
CREATE TABLE auth_role
(
role_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
role_name VARCHAR(64) NOT NULL,
description VARCHAR(255) NOT NULL,
version INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (role_id),
UNIQUE UQ_role_role_name(role_name)
) ENGINE=InnoDB COMMENT='each row is a role that defines authorization';
CREATE TABLE auth_user_role
(
user_role_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
user INTEGER UNSIGNED NOT NULL,
role INTEGER UNSIGNED NOT NULL,
can_delegate BOOL NOT NULL DEFAULT false,
is_role_manager BOOL NOT NULL DEFAULT false,
start_time TIMESTAMP,
end_time TIMESTAMP,
comment VARCHAR(255),
version INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (user_role_id),
KEY (user),
KEY (role)
) ENGINE=InnoDB;
CREATE TABLE beam
(
beam_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
beam_system TINYINT UNSIGNED NOT NULL,
element SMALLINT UNSIGNED NOT NULL,
charge INTEGER NOT NULL,
mass_number INTEGER NOT NULL,
energy FLOAT(0) NOT NULL,
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (beam_id),
KEY (beam_system),
KEY (element)
) ENGINE=InnoDB COMMENT='each row is a beam';
CREATE TABLE beam_event
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
beam_system TINYINT UNSIGNED NOT NULL,
beam SMALLINT UNSIGNED,
element SMALLINT UNSIGNED,
mass_number INTEGER,
charge INTEGER,
energy FLOAT(0),
event INTEGER UNSIGNED NOT NULL,
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY (beam),
KEY (beam_system),
KEY (element),
KEY (event)
) ENGINE=InnoDB COMMENT='beam event in a log entry';
CREATE TABLE beam_system
(
beam_system_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(16) NOT NULL,
facility TINYINT UNSIGNED NOT NULL,
description VARCHAR(255),
active BOOL NOT NULL DEFAULT TRUE,
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
accelerator BOOL NOT NULL DEFAULT TRUE COMMENT 'it is an accelerator ',
PRIMARY KEY (beam_system_id),
UNIQUE UQ_beam_system_name(name),
KEY (facility)
) ENGINE=InnoDB COMMENT='a beam-related system in a facility';
CREATE TABLE breakdown_category
(
brkcat_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Each row represents a system such as RF, Vaccuum, Cryo, Detector etc',
name VARCHAR(64) NOT NULL,
description VARCHAR(255) NOT NULL,
parent INTEGER UNSIGNED,
active BOOL NOT NULL DEFAULT TRUE,
version INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (brkcat_id),
UNIQUE UQ_component_name(name)
) ENGINE=InnoDB;
CREATE TABLE breakdown_event
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
category TINYINT UNSIGNED NOT NULL,
failed BOOL NOT NULL DEFAULT false,
event INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (id),
KEY (category),
KEY (event)
) ENGINE=InnoDB COMMENT='a breakdown event in a log entry';
CREATE TABLE control_signal
(
signal_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
description VARCHAR(255) NOT NULL,
facility TINYINT UNSIGNED NOT NULL,
PRIMARY KEY (signal_id),
KEY (facility)
) ENGINE=InnoDB COMMENT='a control system signal of interest';
CREATE TABLE element
(
element_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
symbol VARCHAR(8) NOT NULL,
name VARCHAR(128) NOT NULL,
version INTEGER UNSIGNED NOT NULL DEFAULT 0 COMMENT 'for concurrency control',
PRIMARY KEY (element_id),
UNIQUE UQ_element_symbol(symbol)
) ENGINE=InnoDB;
CREATE TABLE event
(
event_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
facility TINYINT UNSIGNED NOT NULL,
occurred_at DATETIME NOT NULL COMMENT 'Event started at this time. Can be in the past.',
event_entered_at DATETIME NOT NULL COMMENT 'Event was reported at this time',
reported_by INTEGER UNSIGNED NOT NULL COMMENT 'user who reported it',
obsoleted_by INTEGER UNSIGNED COMMENT 'Obsoleted by this event',
note INTEGER UNSIGNED COMMENT 'Reference to log entry',
log_entered_at DATETIME NOT NULL COMMENT 'Used for matching edited log entries with edited events.',
version INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (event_id),
KEY (facility),
KEY (reported_by),
KEY (obsoleted_by),
INDEX IX_occurred_at (occurred_at ASC),
INDEX IX_log_entered_at (log_entered_at ASC)
) ENGINE=InnoDB COMMENT='Each row is an event occurring in a facility';
CREATE TABLE experiment
(
number INTEGER UNSIGNED NOT NULL,
spokesperson VARCHAR(128),
title VARCHAR(128),
hours_approved INTEGER,
hours_requested INTEGER,
experiment_completed VARCHAR(3),
description TEXT,
a1900_contact VARCHAR(64),
approval_date DATE,
PAC SMALLINT,
completion_date DATE,
on_target_hours INTEGER,
in_charge VARCHAR(128),
updated_at DATETIME COMMENT 'time last updated at',
PRIMARY KEY (number)
) ENGINE=InnoDB;
CREATE TABLE expr_event
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
experiment INTEGER UNSIGNED NOT NULL,
event INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (id),
KEY (event),
KEY (experiment)
) ENGINE=InnoDB;
CREATE TABLE external_service
(
service_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NOT NULL,
description VARCHAR(255) NOT NULL,
base_url TEXT,
status VARCHAR(32) NOT NULL,
status_message VARCHAR(255) NOT NULL,
status_updated_at DATETIME,
last_serviced_at DATETIME COMMENT 'Time of last successful service',
PRIMARY KEY (service_id),
UNIQUE UQ_external_service_name(name)
) ENGINE=InnoDB COMMENT='an external service like Trouble Reports';
CREATE TABLE facility
(
facility_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
facility_name VARCHAR(32) NOT NULL,
description VARCHAR(255) NOT NULL,
ops_logbook SMALLINT UNSIGNED COMMENT 'operations logbook',
in_operation BOOL NOT NULL DEFAULT true COMMENT 'is in operation',
version INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (facility_id),
UNIQUE UQ_facility_facility_name(facility_name),
KEY (ops_logbook)
) ENGINE=InnoDB;
CREATE TABLE logbook
(
logbook_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
logbook_name VARCHAR(32) NOT NULL,
description VARCHAR(255) NOT NULL,
version INTEGER NOT NULL DEFAULT 0 COMMENT 'for concurrency control',
PRIMARY KEY (logbook_id),
UNIQUE UQ_logbook_logbook_name(logbook_name)
) ENGINE=InnoDB COMMENT='each row represents a facility''s logbook';
CREATE TABLE mode
(
mode_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(16) NOT NULL,
description VARCHAR(255) NOT NULL,
active BOOL NOT NULL DEFAULT TRUE,
PRIMARY KEY (mode_id),
UNIQUE UQ_mode_name(name)
) ENGINE=InnoDB;
CREATE TABLE mode_event
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
mode TINYINT UNSIGNED NOT NULL,
event INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (id),
KEY (event),
KEY (mode)
) ENGINE=InnoDB;
CREATE TABLE operations_role
(
op_role_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NOT NULL,
description VARCHAR(255),
active BOOL NOT NULL DEFAULT TRUE,
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (op_role_id),
UNIQUE UQ_job_name(name)
) ENGINE=InnoDB COMMENT='role of an operations staff member';
CREATE TABLE shift
(
shift_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
facility TINYINT UNSIGNED NOT NULL,
updated_at DATETIME NOT NULL,
updated_by INTEGER UNSIGNED COMMENT 'shift started by. can be null due to legacy data.',
op_in_charge INTEGER UNSIGNED COMMENT 'operator in charge. can be null due to legacy data.',
exp_in_charge VARCHAR(128) COMMENT 'experimenter in charge. can be null due to legacy data.',
note INTEGER UNSIGNED NOT NULL COMMENT 'id of log text ',
PRIMARY KEY (shift_id),
KEY (facility),
KEY (op_in_charge),
KEY (updated_by)
) ENGINE=InnoDB COMMENT='each row is a shift of a facility';
CREATE TABLE shift_staff_member
(
ssm_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
shift INTEGER UNSIGNED NOT NULL,
staff_member INTEGER UNSIGNED NOT NULL,
role SMALLINT UNSIGNED NOT NULL,
status TINYINT UNSIGNED NOT NULL,
send_sms BOOL NOT NULL DEFAULT false COMMENT 'send sms in case of UOF',
PRIMARY KEY (ssm_id),
KEY (staff_member),
KEY (role),
KEY (shift),
KEY (status)
) ENGINE=InnoDB COMMENT='a staff member on a shift';
CREATE TABLE shift_status
(
status_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(32) NOT NULL,
description VARCHAR(255) NOT NULL,
version INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (status_id),
UNIQUE UQ_shift_ostatus_name(name)
) ENGINE=InnoDB COMMENT='on shift status - on call, in house etc';
CREATE TABLE source
(
source_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
facility TINYINT UNSIGNED NOT NULL,
name VARCHAR(32) NOT NULL,
description VARCHAR(255) NOT NULL,
active BOOL NOT NULL DEFAULT TRUE,
PRIMARY KEY (source_id),
UNIQUE UQ_source_name(name),
KEY (facility)
) ENGINE=InnoDB COMMENT='beam source';
CREATE TABLE source_event
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
source TINYINT UNSIGNED NOT NULL,
event INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (id),
KEY (event),
KEY (source)
) ENGINE=InnoDB;
CREATE TABLE staff_role
(
staff_role_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
staff_member INTEGER UNSIGNED NOT NULL,
role SMALLINT UNSIGNED NOT NULL,
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (staff_role_id),
KEY (staff_member),
KEY (role)
) ENGINE=InnoDB COMMENT='role an operations staff member performs';
CREATE TABLE summary
(
summary_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(32) NOT NULL,
description VARCHAR(255) NOT NULL,
parent TINYINT UNSIGNED COMMENT 'statuses have hierarchy. id of parent.',
active BOOL NOT NULL DEFAULT TRUE,
version INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (summary_id),
UNIQUE UQ_summary_name(name),
KEY (parent)
) ENGINE=InnoDB COMMENT='summary status of a facility';
CREATE TABLE summary_event
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
summary TINYINT UNSIGNED NOT NULL,
event INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (id),
KEY (event),
KEY (summary)
) ENGINE=InnoDB;
CREATE TABLE system_property
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NOT NULL,
prop_value VARCHAR(255),
PRIMARY KEY (id),
UNIQUE UQ_system_property_name(name)
) ENGINE=InnoDB COMMENT='each row is a property of Hour Log System';
CREATE TABLE sysuser
(
user_id INTEGER UNSIGNED NOT NULL,
first_name VARCHAR(128) NOT NULL,
last_name VARCHAR(128) NOT NULL,
login_id VARCHAR(32) COMMENT 'login name',
nick_name VARCHAR(16) COMMENT 'shorter name',
department VARCHAR(64),
email VARCHAR(128),
job INTEGER UNSIGNED,
current_employee BOOL NOT NULL DEFAULT FALSE COMMENT 'current employee?',
operations_staff BOOL NOT NULL DEFAULT FALSE COMMENT 'operations staff member?',
sms_address VARCHAR(64) COMMENT 'email address to contact via sms etc',
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (user_id)
) ENGINE=InnoDB COMMENT='person who is or has been a user of the application';
CREATE TABLE training_record
(
employee_number INTEGER UNSIGNED NOT NULL,
employee_id VARCHAR(64),
last_name VARCHAR(128),
first_name VARCHAR(128),
work_email VARCHAR(255),
oic BOOL COMMENT 'valid training as operator-in-charge?',
updated_at DATETIME COMMENT 'time last updated at ',
PRIMARY KEY (employee_number)
) ENGINE=InnoDB COMMENT='each row is a (cached) training record';
CREATE TABLE trouble_report
(
id INTEGER UNSIGNED NOT NULL,
report_date DATE NOT NULL,
problem TEXT,
system VARCHAR(255),
employee_uniq_name VARCHAR(64),
employee_id INTEGER UNSIGNED,
employee_name VARCHAR(255),
updated_at DATETIME COMMENT 'time last updated at',
PRIMARY KEY (id)
) ENGINE=InnoDB COMMENT='each row is a (cached) trouble report';
CREATE TABLE user_preference
(
user_preference_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
user INTEGER UNSIGNED NOT NULL,
name VARCHAR(64) NOT NULL,
pref_value VARCHAR(64),
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (user_preference_id),
KEY (user)
) ENGINE=InnoDB COMMENT='a user preference';
CREATE TABLE vault
(
vault_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(8) NOT NULL,
description VARCHAR(255) NOT NULL,
active BOOL NOT NULL DEFAULT TRUE,
facility TINYINT UNSIGNED NOT NULL,
version INTEGER UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (vault_id),
UNIQUE UQ_vault_name(name),
KEY (facility)
) ENGINE=InnoDB COMMENT='experiment vault';
CREATE TABLE vault_event
(
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
vault TINYINT UNSIGNED NOT NULL,
event INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (id),
KEY (event),
KEY (vault)
) ENGINE=InnoDB;
SET FOREIGN_KEY_CHECKS=1;
-- Create Foreign Key Constraints
ALTER TABLE auth_permission ADD CONSTRAINT FK_permission_auth_operation
FOREIGN KEY (operation) REFERENCES auth_operation (operation_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE auth_permission ADD CONSTRAINT FK_permission_resource
FOREIGN KEY (resource) REFERENCES auth_resource (resource_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE auth_permission ADD CONSTRAINT FK_priv_role
FOREIGN KEY (role) REFERENCES auth_role (role_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE auth_user_role ADD CONSTRAINT FK_user_role_employee
FOREIGN KEY (user) REFERENCES sysuser (user_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE auth_user_role ADD CONSTRAINT FK_user_role_role
FOREIGN KEY (role) REFERENCES auth_role (role_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE beam ADD CONSTRAINT FK_beam_beam_system
FOREIGN KEY (beam_system) REFERENCES beam_system (beam_system_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE beam ADD CONSTRAINT FK_beam_element
FOREIGN KEY (element) REFERENCES element (element_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE beam_event ADD CONSTRAINT FK_beam_log_beam
FOREIGN KEY (beam) REFERENCES beam (beam_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE beam_event ADD CONSTRAINT FK_beam_log_beam_system
FOREIGN KEY (beam_system) REFERENCES beam_system (beam_system_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE beam_event ADD CONSTRAINT FK_beam_log_element
FOREIGN KEY (element) REFERENCES element (element_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE beam_event ADD CONSTRAINT FK_beam_event_event
FOREIGN KEY (event) REFERENCES event (event_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE beam_system ADD CONSTRAINT FK_beam_system_facility
FOREIGN KEY (facility) REFERENCES facility (facility_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE breakdown_event ADD CONSTRAINT FK_breakdown_event_breakdown_category
FOREIGN KEY (category) REFERENCES breakdown_category (brkcat_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE breakdown_event ADD CONSTRAINT FK_breakdownt_status_log_entry
FOREIGN KEY (event) REFERENCES event (event_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE control_signal ADD CONSTRAINT FK_control_signal_facility
FOREIGN KEY (facility) REFERENCES facility (facility_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE event ADD CONSTRAINT FK_event_facility
FOREIGN KEY (facility) REFERENCES facility (facility_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE event ADD CONSTRAINT FK_event_sysuser
FOREIGN KEY (reported_by) REFERENCES sysuser (user_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE event ADD CONSTRAINT FK_event_event
FOREIGN KEY (obsoleted_by) REFERENCES event (event_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE expr_event ADD CONSTRAINT FK_expr_event_event
FOREIGN KEY (event) REFERENCES event (event_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE expr_event ADD CONSTRAINT FK_expr_event_experiment
FOREIGN KEY (experiment) REFERENCES experiment (number)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE facility ADD CONSTRAINT FK_facility_logbook
FOREIGN KEY (ops_logbook) REFERENCES logbook (logbook_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE mode_event ADD CONSTRAINT FK_mode_event_event
FOREIGN KEY (event) REFERENCES event (event_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE mode_event ADD CONSTRAINT FK_mode_event_mode
FOREIGN KEY (mode) REFERENCES mode (mode_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE shift ADD CONSTRAINT FK_shift_facility
FOREIGN KEY (facility) REFERENCES facility (facility_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE shift ADD CONSTRAINT FK_shift_OIC
FOREIGN KEY (op_in_charge) REFERENCES sysuser (user_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE shift ADD CONSTRAINT FK_shift_started_by
FOREIGN KEY (updated_by) REFERENCES sysuser (user_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE shift_staff_member ADD CONSTRAINT FK_shift_staff_member_employee
FOREIGN KEY (staff_member) REFERENCES sysuser (user_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE shift_staff_member ADD CONSTRAINT FK_shift_staff_member_operations_role
FOREIGN KEY (role) REFERENCES operations_role (op_role_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE shift_staff_member ADD CONSTRAINT FK_shift_staff_member_shift
FOREIGN KEY (shift) REFERENCES shift (shift_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE shift_staff_member ADD CONSTRAINT FK_shift_staff_member_shift_ostatus
FOREIGN KEY (status) REFERENCES shift_status (status_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE source ADD CONSTRAINT FK_source_facility
FOREIGN KEY (facility) REFERENCES facility (facility_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE source_event ADD CONSTRAINT FK_source_event_event
FOREIGN KEY (event) REFERENCES event (event_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE source_event ADD CONSTRAINT FK_source_event_source
FOREIGN KEY (source) REFERENCES source (source_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE staff_role ADD CONSTRAINT FK_staff_role_employee
FOREIGN KEY (staff_member) REFERENCES sysuser (user_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE staff_role ADD CONSTRAINT FK_staff_role_operations_role
FOREIGN KEY (role) REFERENCES operations_role (op_role_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE summary ADD CONSTRAINT FK_summary_summary
FOREIGN KEY (parent) REFERENCES summary (summary_id);
ALTER TABLE summary_event ADD CONSTRAINT FK_summary_event_event
FOREIGN KEY (event) REFERENCES event (event_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE summary_event ADD CONSTRAINT FK_summary_event_summary
FOREIGN KEY (summary) REFERENCES summary (summary_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE user_preference ADD CONSTRAINT FK_user_preference_employee
FOREIGN KEY (user) REFERENCES sysuser (user_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vault ADD CONSTRAINT FK_vault_facility
FOREIGN KEY (facility) REFERENCES facility (facility_id)
ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vault_event ADD CONSTRAINT FK_vault_event_event
FOREIGN KEY (event) REFERENCES event (event_id)
ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE vault_event ADD CONSTRAINT FK_vault_event_vault
FOREIGN KEY (vault) REFERENCES vault (vault_id)
ON DELETE RESTRICT ON UPDATE RESTRICT;
|
<reponame>quantum13/mlbootcamp7<gh_stars>1-10
CREATE TABLE `qml_models` (
`model_id` int(11) NOT NULL AUTO_INCREMENT,
`cls` varchar(100) NOT NULL DEFAULT '',
`params` varchar(4000) NOT NULL DEFAULT '',
`descr` varchar(1000) NOT NULL DEFAULT '',
`predict_fn` varchar(200) NOT NULL DEFAULT 'predict',
`level` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`model_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8;
CREATE TABLE `qml_results` (
`data_id` int(11) NOT NULL,
`model_id` int(11) NOT NULL,
`cv_score` decimal(18,10) DEFAULT NULL,
`cv_time` decimal(18,1) DEFAULT NULL,
`public_board_score` decimal(18,10) DEFAULT NULL,
PRIMARY KEY (`data_id`,`model_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `qml_results_statistic` (
`data_id` int(11) NOT NULL,
`model_id` int(11) NOT NULL,
`fold` int(11) NOT NULL,
`seed` int(11) NOT NULL,
`cv_score` decimal(18,10) NOT NULL,
PRIMARY KEY (`data_id`,`model_id`,`fold`,`seed`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
<filename>cinefx.sql
-- phpMyAdmin SQL Dump
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1:3306
-- Généré le : jeu. 13 juin 2019 à 22:31
-- Version du serveur : 5.7.21
-- Version de PHP : 7.2.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `cinefx`
--
-- --------------------------------------------------------
--
-- Structure de la table `administrateurs`
--
DROP TABLE IF EXISTS `administrateurs`;
CREATE TABLE IF NOT EXISTS `administrateurs` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`NomAdmin` varchar(255) DEFAULT NULL,
`PrenomAdmin` varchar(255) DEFAULT NULL,
`EmailAdmin` varchar(255) DEFAULT NULL,
`PasswordAdmin` varchar(255) DEFAULT NULL,
`PhoneAdmin` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `administrateurs`
--
INSERT INTO `administrateurs` (`ID`, `NomAdmin`, `PrenomAdmin`, `EmailAdmin`, `PasswordAdmin`, `PhoneAdmin`) VALUES
(1, 'Whoever', 'Yourname', '<EMAIL>', '1234', '0600000000'),
(2, 'Whoever', 'Yourname', 'admin2<EMAIL>', '1234', '0606060606');
-- --------------------------------------------------------
--
-- Structure de la table `cartesbancaires`
--
DROP TABLE IF EXISTS `cartesbancaires`;
CREATE TABLE IF NOT EXISTS `cartesbancaires` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`NumeroCarte` varchar(255) DEFAULT NULL,
`DECarte` varchar(255) DEFAULT NULL,
`CryptoCarte` int(10) NOT NULL,
`SoldeCarte` double NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `cartesbancaires`
--
INSERT INTO `cartesbancaires` (`ID`, `NumeroCarte`, `DECarte`, `CryptoCarte`, `SoldeCarte`) VALUES
(1, '1111 2222 3333 4444', '01/21', 123, 7402707),
(2, '1234 1234 1234 1234', '01/21', 123, 20),
(3, '5555 6666 7777 8888', '01/21', 123, 1156),
(4, '5678 5678 5678 5678', '01/21', 123, 267.54);
-- --------------------------------------------------------
--
-- Structure de la table `clients`
--
DROP TABLE IF EXISTS `clients`;
CREATE TABLE IF NOT EXISTS `clients` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`ForfaitAbonne` int(10) DEFAULT NULL,
`fraisabonnements` double NOT NULL DEFAULT '0',
`EmailClient` varchar(255) DEFAULT NULL,
`FinAbonnement` date DEFAULT NULL,
`NomClient` varchar(255) DEFAULT NULL,
`PrenomClient` varchar(255) DEFAULT NULL,
`AdresseAbonne` varchar(255) DEFAULT NULL,
`PhoneAbonne` varchar(255) DEFAULT NULL,
`NAchats` int(10) NOT NULL DEFAULT '0',
`FlagAbonne` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structure de la table `dates`
--
DROP TABLE IF EXISTS `dates`;
CREATE TABLE IF NOT EXISTS `dates` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`Dates` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `dates`
--
INSERT INTO `dates` (`ID`, `Dates`) VALUES
(1, '10/06/2020'),
(2, '11/06/2020'),
(3, '12/06/2018'),
(4, '13/06/2019'),
(5, '14/06/2020'),
(6, '15/06/2020'),
(7, '16/06/2020'),
(8, '17/06/2020'),
(9, '18/06/2020'),
(10, '19/06/2020');
-- --------------------------------------------------------
--
-- Structure de la table `films`
--
DROP TABLE IF EXISTS `films`;
CREATE TABLE IF NOT EXISTS `films` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`AdministrateursID` int(10) NOT NULL,
`LanguesID` int(10) NOT NULL,
`PaysID` int(10) NOT NULL,
`NomFilm` varchar(255) DEFAULT NULL,
`SynopsisFilm` text,
`TrailerFilm` varchar(255) DEFAULT NULL,
`ImageFilm` varchar(255) DEFAULT NULL,
`ActeursFilm` varchar(255) DEFAULT NULL,
`RealisateurFilm` varchar(255) DEFAULT NULL,
`DureeFilm` int(10) NOT NULL,
`GenresFilm` varchar(255) DEFAULT NULL,
`ImdbFilm` double NOT NULL,
`ReleaseFilm` int(10) NOT NULL,
`Projectable` tinyint(1) DEFAULT '1',
PRIMARY KEY (`ID`),
KEY `FKFilms973461` (`PaysID`),
KEY `FKFilms945466` (`LanguesID`),
KEY `FKFilms489655` (`AdministrateursID`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `films`
--
INSERT INTO `films` (`ID`, `AdministrateursID`, `LanguesID`, `PaysID`, `NomFilm`, `SynopsisFilm`, `TrailerFilm`, `ImageFilm`, `ActeursFilm`, `RealisateurFilm`, `DureeFilm`, `GenresFilm`, `ImdbFilm`, `ReleaseFilm`, `Projectable`) VALUES
(1, 2, 1, 231, 'Captain Marvel', 'After crashing an experimental aircraft, Air Force pilot Carol Danvers is discovered by the Kree and trained as a member of the elite Starforce Military under the command of her mentor Yon-Rogg. Six years later, after escaping to Earth while under attack by the Skrulls, Danvers begins to discover there\'s more to her past. With help from S.H.I.E.L.D. agent <NAME>, they set out to unravel the truth.\r\n', 'https://www.youtube.com/embed/Z1BCujX3pw8', 'https://img.yts.am/assets/images/movies/captain_marvel_2019/medium-cover.jpg', '<NAME>, <NAME>, <NAME> ', '<NAME>, <NAME>', 120, 'Adventure', 7, 2019, 1),
(2, 1, 1, 231, 'Logan', 'In 2029 the mutant population has shrunken significantly due to genetically modified plants designed to reduce mutant powers and the X-Men have disbanded. Logan, whose power to self-heal is dwindling, has surrendered himself to alcohol and now earns a living as a chauffeur. He takes care of the ailing old Professor X whom he keeps hidden away. One day, a female stranger asks Logan to drive a girl named Laura to the Canadian border. At first he refuses, but the Professor has been waiting for a long time for her to appear. Laura possesses an extraordinary fighting prowess and is in many ways like Wolverine. She is pursued by sinister figures working for a powerful corporation; this is because they made her, with Logan\'s DNA. A decrepit Logan is forced to ask himself if he can or even wants to put his remaining powers to good use. It would appear that in the near-future, the times in which they were able put the world to rights with razor sharp claws and telepathic powers are now over.', 'https://www.youtube.com/embed/Div0iP65aZo', 'https://img.yts.am/assets/images/movies/logan_2017/medium-cover.jpg', '<NAME>, <NAME>, <NAME>, <NAME>', '<NAME>', 132, 'Action/Drama', 8.1, 2017, 1),
(3, 1, 1, 231, 'The Imitation Game', 'Based on the real life story of legendary cryptanalyst Alan Turing, the film portrays the nail-biting race against time by Turing and his brilliant team of code-breakers at Britain\'s top-secret Government Code and Cypher School at Bletchley Park, during the darkest days of World War II.', 'https://www.youtube.com/embed/nuPZUUED5uk', 'https://img.yts.am/assets/images/movies/the_imitation_game_2014/medium-cover.jpg', '<NAME>, <NAME>, <NAME>, <NAME>', '<NAME>', 112, 'Biography', 8, 2014, 1),
(4, 2, 2, 72, 'The Intouchables', 'In Paris, the aristocratic and intellectual Philippe is a quadriplegic millionaire who is interviewing candidates for the position of his carer, with his red-haired secretary Magalie. Out of the blue, Driss cuts the line of candidates and brings a document from the Social Security and asks Phillipe to sign it to prove that he is seeking a job position so he can receive his unemployment benefit. Philippe challenges Driss, offering him a trial period of one month to gain experience helping him. Then Driss can decide whether he would like to stay with him or not. Driss accepts the challenge and moves to the mansion, changing the boring life of Phillipe and his employees.\r\n', 'https://www.youtube.com/embed/34WIbmXkewU', 'https://img.yts.am/assets/images/movies/the_intouchables_2011/medium-cover.jpg', '<NAME>, <NAME>, <NAME>', '<NAME>', 109, 'Comedy', 8.5, 2011, 1),
(5, 1, 1, 231, 'Tomb Raider', '<NAME> is the fiercely independent daughter of an eccentric adventurer who vanished when she was scarcely a teen. Now a young woman of twenty-one without any real focus or purpose, Lara navigates the chaotic streets of trendy East London as a bike courier, barely making the rent, and takes college courses, rarely making it to class. Determined to forge her own path, she refuses to take the reins of her father\'s global empire just as staunchly as she rejects the idea that he\'s truly gone. Advised to face the facts and move forward after seven years without him, even Lara can\'t understand what drives her to finally solve the puzzle of his mysterious death. Going explicitly against his final wishes, she leaves everything she knows behind in search of her dad\'s last-known destination: a fabled tomb on a mythical island that might be somewhere off the coast of Japan. But her mission will not be an easy one; just reaching the island will be extremely treacherous. Suddenly, the stakes ...', 'https://www.youtube.com/embed/rOEHpkZCc1Y', 'https://img.yts.am/assets/images/movies/tomb_raider_2018/medium-cover.jpg', '<NAME>, <NAME>, <NAME>, <NAME>', '<NAME>', 119, 'Fantasy', 7, 2018, 1),
(6, 2, 1, 231, 'Arrival', 'Linguistics professor <NAME> leads an elite team of investigators when gigantic spaceships touchdown in 12 locations around the world. As nations teeter on the verge of global war, Banks and her crew must race against time to find a way to communicate with the extraterrestrial visitors. Hoping to unravel the mystery, she takes a chance that could threaten her life and quite possibly all of mankind.', 'https://www.youtube.com/embed/AMgyWT075KY', 'https://img.yts.am/assets/images/movies/arrival_2016/medium-cover.jpg', '<NAME>, <NAME>, <NAME>', '<NAME>', 116, 'Drama', 8, 2016, 1),
(7, 2, 1, 231, 'Game Night', 'Six close friends meet each week for a game night involving board games, charades and pop culture trivia quizzes. Being the most competitive of the bunch, Max and his wife Annie, who seem to be a perfect match in every way, usually win every time. However, their marriage is on rocky ground as Annie fears that Max doesn\'t want to have children. When Max\'s shady brother Brooks reappears after a long mysterious absence and suggests that they have their next gathering at his place, no one expects that their weekly game night is about to go to the next level as Brooks organizes a full blown murder mystery party complete with actors as criminals and cops for them. However, when Brooks is violently kidnapped in front of everyone, it turns out that the game is all too real. Now, Max, Annie, their womanizing dimwitted friend Ryan, his domineering Irish date Sarah, and their childhood friends Michelle and her husband Kevin, who\'s obsessed with finding out with which mysterious celebrity ...\r\n', 'https://www.youtube.com/embed/fNtLIcyjsnI', 'https://img.yts.am/assets/images/movies/game_night_2018/medium-cover.jpg', '<NAME>, <NAME>, <NAME>', '<NAME>', 100, 'Crime/Mystery', 7.5, 2018, 1),
(8, 1, 1, 231, 'The Queen\'s Corgi', 'This is about the adventure of Rex (Jack Whitehall), the British monarch\'s (Dame Julie Walters\') most beloved dog, who loses track of his mistress and stumbles across a clan with dogs of all kinds confronting and fighting each other. During his epic journey to return to the Queen, Rex falls in love and discovers his true self.', 'https://www.youtube.com/embed/sbrEmlTJd7E', 'https://img.yts.am/assets/images/movies/the_queens_corgi_2019/medium-cover.jpg', '<NAME>, <NAME>, <NAME>, <NAME>', '<NAME>', 85, 'Animation', 6, 2019, 1),
(9, 1, 2, 72, 'Ratatouille', 'A rat named Remy dreams of becoming a great French chef despite his family\'s wishes and the obvious problem of being a rat in a decidedly rodent-phobic profession. When fate places Remy in the sewers of Paris, he finds himself ideally situated beneath a restaurant made famous by his culinary hero, <NAME>. Despite the apparent dangers of being an unlikely, and certainly unwanted, visitor in the kitchen of a fine French restaurant, Remy\'s passion for cooking soon sets into motion a hilarious and exciting rat race that turns the culinary world of Paris upside down.', 'https://www.youtube.com/embed/nTTxc1Vf2pQ', 'https://img.yts.am/assets/images/movies/Ratatouille_2007/medium-cover.jpg', '<NAME>, <NAME>, <NAME>, <NAME>', '<NAME>', 111, 'Family/Fantasy', 8.5, 2007, 1),
(10, 2, 2, 72, 'Amelie', 'Amélie is a story about a girl named Amélie whose childhood was suppressed by her Father\'s mistaken concerns of a heart defect. With these concerns Amélie gets hardly any real life contact with other people. This leads Amélie to resort to her own fantastical world and dreams of love and beauty. She later on becomes a young woman and moves to the central part of Paris as a waitress. After finding a lost treasure belonging to the former occupant of her apartment, she decides to return it to him. After seeing his reaction and his new found perspective - she decides to devote her life to the people around her. Such as, her father who is obsessed with his garden-gnome, a failed writer, a hypochondriac, a man who stalks his ex girlfriends, the \"ghost\", a suppressed young soul, the love of her life and a man whose bones are as brittle as glass. But after consuming herself with these escapades - she finds out that she is disregarding her own life and damaging her quest for love. Amélie then ...', 'https://www.youtube.com/embed/-ONWqL_BvtM', 'https://img.yts.am/assets/images/movies/amelie_2001/medium-cover.jpg', '<NAME>, <NAME>, <NAME>', '<NAME>', 122, 'Romance', 9, 2001, 1);
-- --------------------------------------------------------
--
-- Structure de la table `horaires`
--
DROP TABLE IF EXISTS `horaires`;
CREATE TABLE IF NOT EXISTS `horaires` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`Horaire` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `horaires`
--
INSERT INTO `horaires` (`ID`, `Horaire`) VALUES
(1, '14h15'),
(2, '17h15'),
(3, '20h15'),
(4, '23h15');
-- --------------------------------------------------------
--
-- Structure de la table `langues`
--
DROP TABLE IF EXISTS `langues`;
CREATE TABLE IF NOT EXISTS `langues` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`Langue` varchar(255) DEFAULT NULL,
`Iso6391` varchar(8) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=136 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `langues`
--
INSERT INTO `langues` (`ID`, `Langue`, `Iso6391`) VALUES
(1, 'English', 'en'),
(2, 'French', 'fr'),
(3, 'Arabic', 'ar'),
(4, 'Spanish', 'es'),
(5, 'German', 'de'),
(6, 'Turkish', 'tr'),
(7, 'Hindi', 'hi'),
(8, 'Afar', 'aa'),
(9, 'Abkhazian', 'ab'),
(10, 'Afrikaans', 'af'),
(11, 'Amharic', 'am'),
(12, 'Assamese', 'as'),
(13, 'Aymara', 'ay'),
(14, 'Azerbaijani', 'az'),
(15, 'Bashkir', 'ba'),
(16, 'Belarusian', 'be'),
(17, 'Bulgarian', 'bg'),
(18, 'Bihari', 'bh'),
(19, 'Bislama', 'bi'),
(20, 'Bengali/Bangla', 'bn'),
(21, 'Tibetan', 'bo'),
(22, 'Breton', 'br'),
(23, 'Catalan', 'ca'),
(24, 'Corsican', 'co'),
(25, 'Czech', 'cs'),
(26, 'Welsh', 'cy'),
(27, 'Danish', 'da'),
(28, 'Bhutani', 'dz'),
(29, 'Greek', 'el'),
(30, 'Esperanto', 'eo'),
(31, 'Estonian', 'et'),
(32, 'Basque', 'eu'),
(33, 'Persian', 'fa'),
(34, 'Finnish', 'fi'),
(35, 'Fiji', 'fj'),
(36, 'Faeroese', 'fo'),
(37, 'Frisian', 'fy'),
(38, 'Irish', 'ga'),
(39, 'Scots/Gaelic', 'gd'),
(40, 'Galician', 'gl'),
(41, 'Guarani', 'gn'),
(42, 'Gujarati', 'gu'),
(43, 'Hausa', 'ha'),
(44, 'Croatian', 'hr'),
(45, 'Hungarian', 'hu'),
(46, 'Armenian', 'hy'),
(47, 'Interlingua', 'ia'),
(48, 'Interlingue', 'ie'),
(49, 'Inupiak', 'ik'),
(50, 'Indonesian', 'in'),
(51, 'Icelandic', 'is'),
(52, 'Italian', 'it'),
(53, 'Hebrew', 'iw'),
(54, 'Japanese', 'ja'),
(55, 'Yiddish', 'ji'),
(56, 'Javanese', 'jw'),
(57, 'Georgian', 'ka'),
(58, 'Kazakh', 'kk'),
(59, 'Greenlandic', 'kl'),
(60, 'Cambodian', 'km'),
(61, 'Kannada', 'kn'),
(62, 'Korean', 'ko'),
(63, 'Kashmiri', 'ks'),
(64, 'Kurdish', 'ku'),
(65, 'Kirghiz', 'ky'),
(66, 'Latin', 'la'),
(67, 'Lingala', 'ln'),
(68, 'Laothian', 'lo'),
(69, 'Lithuanian', 'lt'),
(70, 'Latvian/Lettish', 'lv'),
(71, 'Malagasy', 'mg'),
(72, 'Maori', 'mi'),
(73, 'Macedonian', 'mk'),
(74, 'Malayalam', 'ml'),
(75, 'Mongolian', 'mn'),
(76, 'Moldavian', 'mo'),
(77, 'Marathi', 'mr'),
(78, 'Malay', 'ms'),
(79, 'Maltese', 'mt'),
(80, 'Burmese', 'my'),
(81, 'Nauru', 'na'),
(82, 'Nepali', 'ne'),
(83, 'Dutch', 'nl'),
(84, 'Norwegian', 'no'),
(85, 'Occitan', 'oc'),
(86, '(Afan)/Oromoor/Oriya', 'om'),
(87, 'Punjabi', 'pa'),
(88, 'Polish', 'pl'),
(89, 'Pashto/Pushto', 'ps'),
(90, 'Portuguese', 'pt'),
(91, 'Quechua', 'qu'),
(92, 'Rhaeto-Romance', 'rm'),
(93, 'Kirundi', 'rn'),
(94, 'Romanian', 'ro'),
(95, 'Russian', 'ru'),
(96, 'Kinyarwanda', 'rw'),
(97, 'Sanskrit', 'sa'),
(98, 'Sindhi', 'sd'),
(99, 'Sangro', 'sg'),
(100, 'Serbo-Croatian', 'sh'),
(101, 'Singhalese', 'si'),
(102, 'Slovak', 'sk'),
(103, 'Slovenian', 'sl'),
(104, 'Samoan', 'sm'),
(105, 'Shona', 'sn'),
(106, 'Somali', 'so'),
(107, 'Albanian', 'sq'),
(108, 'Serbian', 'sr'),
(109, 'Siswati', 'ss'),
(110, 'Sesotho', 'st'),
(111, 'Sundanese', 'su'),
(112, 'Swedish', 'sv'),
(113, 'Swahili', 'sw'),
(114, 'Tamil', 'ta'),
(115, 'Telugu', 'te'),
(116, 'Tajik', 'tg'),
(117, 'Thai', 'th'),
(118, 'Tigrinya', 'ti'),
(119, 'Turkmen', 'tk'),
(120, 'Tagalog', 'tl'),
(121, 'Setswana', 'tn'),
(122, 'Tonga', 'to'),
(123, 'Tsonga', 'ts'),
(124, 'Tatar', 'tt'),
(125, 'Twi', 'tw'),
(126, 'Ukrainian', 'uk'),
(127, 'Urdu', 'ur'),
(128, 'Uzbek', 'uz'),
(129, 'Vietnamese', 'vi'),
(130, 'Volapuk', 'vo'),
(131, 'Wolof', 'wo'),
(132, 'Xhosa', 'xh'),
(133, 'Yoruba', 'yo'),
(134, 'Chinese', 'zh'),
(135, 'Zulu', 'zu');
-- --------------------------------------------------------
--
-- Structure de la table `pays`
--
DROP TABLE IF EXISTS `pays`;
CREATE TABLE IF NOT EXISTS `pays` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`CodePays` varchar(2) NOT NULL,
`Pays` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=247 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `pays`
--
INSERT INTO `pays` (`ID`, `CodePays`, `Pays`) VALUES
(1, 'AF', 'Afghanistan'),
(2, 'AL', 'Albania'),
(3, 'DZ', 'Algeria'),
(4, 'DS', 'American Samoa'),
(5, 'AD', 'Andorra'),
(6, 'AO', 'Angola'),
(7, 'AI', 'Anguilla'),
(8, 'AQ', 'Antarctica'),
(9, 'AG', 'Antigua and Barbuda'),
(10, 'AR', 'Argentina'),
(11, 'AM', 'Armenia'),
(12, 'AW', 'Aruba'),
(13, 'AU', 'Australia'),
(14, 'AT', 'Austria'),
(15, 'AZ', 'Azerbaijan'),
(16, 'BS', 'Bahamas'),
(17, 'BH', 'Bahrain'),
(18, 'BD', 'Bangladesh'),
(19, 'BB', 'Barbados'),
(20, 'BY', 'Belarus'),
(21, 'BE', 'Belgium'),
(22, 'BZ', 'Belize'),
(23, 'BJ', 'Benin'),
(24, 'BM', 'Bermuda'),
(25, 'BT', 'Bhutan'),
(26, 'BO', 'Bolivia'),
(27, 'BA', 'Bosnia and Herzegovina'),
(28, 'BW', 'Botswana'),
(29, 'BV', 'Bouvet Island'),
(30, 'BR', 'Brazil'),
(31, 'IO', 'British Indian Ocean Territory'),
(32, 'BN', 'Brunei Darussalam'),
(33, 'BG', 'Bulgaria'),
(34, 'BF', 'Burkina Faso'),
(35, 'BI', 'Burundi'),
(36, 'KH', 'Cambodia'),
(37, 'CM', 'Cameroon'),
(38, 'CA', 'Canada'),
(39, 'CV', 'Cape Verde'),
(40, 'KY', 'Cayman Islands'),
(41, 'CF', 'Central African Republic'),
(42, 'TD', 'Chad'),
(43, 'CL', 'Chile'),
(44, 'CN', 'China'),
(45, 'CX', 'Christmas Island'),
(46, 'CC', 'Cocos (Keeling) Islands'),
(47, 'CO', 'Colombia'),
(48, 'KM', 'Comoros'),
(49, 'CG', 'Congo'),
(50, 'CK', 'Cook Islands'),
(51, 'CR', 'Costa Rica'),
(52, 'HR', 'Croatia (Hrvatska)'),
(53, 'CU', 'Cuba'),
(54, 'CY', 'Cyprus'),
(55, 'CZ', 'Czech Republic'),
(56, 'DK', 'Denmark'),
(57, 'DJ', 'Djibouti'),
(58, 'DM', 'Dominica'),
(59, 'DO', 'Dominican Republic'),
(60, 'TP', 'East Timor'),
(61, 'EC', 'Ecuador'),
(62, 'EG', 'Egypt'),
(63, 'SV', 'El Salvador'),
(64, 'GQ', 'Equatorial Guinea'),
(65, 'ER', 'Eritrea'),
(66, 'EE', 'Estonia'),
(67, 'ET', 'Ethiopia'),
(68, 'FK', 'Falkland Islands (Malvinas)'),
(69, 'FO', 'Faroe Islands'),
(70, 'FJ', 'Fiji'),
(71, 'FI', 'Finland'),
(72, 'FR', 'France'),
(73, 'FX', 'France, Metropolitan'),
(74, 'GF', 'French Guiana'),
(75, 'PF', 'French Polynesia'),
(76, 'TF', 'French Southern Territories'),
(77, 'GA', 'Gabon'),
(78, 'GM', 'Gambia'),
(79, 'GE', 'Georgia'),
(80, 'DE', 'Germany'),
(81, 'GH', 'Ghana'),
(82, 'GI', 'Gibraltar'),
(83, 'GK', 'Guernsey'),
(84, 'GR', 'Greece'),
(85, 'GL', 'Greenland'),
(86, 'GD', 'Grenada'),
(87, 'GP', 'Guadeloupe'),
(88, 'GU', 'Guam'),
(89, 'GT', 'Guatemala'),
(90, 'GN', 'Guinea'),
(91, 'GW', 'Guinea-Bissau'),
(92, 'GY', 'Guyana'),
(93, 'HT', 'Haiti'),
(94, 'HM', 'Heard and Mc Donald Islands'),
(95, 'HN', 'Honduras'),
(96, 'HK', 'Hong Kong'),
(97, 'HU', 'Hungary'),
(98, 'IS', 'Iceland'),
(99, 'IN', 'India'),
(100, 'IM', 'Isle of Man'),
(101, 'ID', 'Indonesia'),
(102, 'IR', 'Iran (Islamic Republic of)'),
(103, 'IQ', 'Iraq'),
(104, 'IE', 'Ireland'),
(105, 'IL', 'Israel'),
(106, 'IT', 'Italy'),
(107, 'CI', 'Ivory Coast'),
(108, 'JE', 'Jersey'),
(109, 'JM', 'Jamaica'),
(110, 'JP', 'Japan'),
(111, 'JO', 'Jordan'),
(112, 'KZ', 'Kazakhstan'),
(113, 'KE', 'Kenya'),
(114, 'KI', 'Kiribati'),
(115, 'KP', 'Korea, Democratic People\'s Republic of'),
(116, 'KR', 'Korea, Republic of'),
(117, 'XK', 'Kosovo'),
(118, 'KW', 'Kuwait'),
(119, 'KG', 'Kyrgyzstan'),
(120, 'LA', 'Lao People\'s Democratic Republic'),
(121, 'LV', 'Latvia'),
(122, 'LB', 'Lebanon'),
(123, 'LS', 'Lesotho'),
(124, 'LR', 'Liberia'),
(125, 'LY', 'Libyan Arab Jamahiriya'),
(126, 'LI', 'Liechtenstein'),
(127, 'LT', 'Lithuania'),
(128, 'LU', 'Luxembourg'),
(129, 'MO', 'Macau'),
(130, 'MK', 'Macedonia'),
(131, 'MG', 'Madagascar'),
(132, 'MW', 'Malawi'),
(133, 'MY', 'Malaysia'),
(134, 'MV', 'Maldives'),
(135, 'ML', 'Mali'),
(136, 'MT', 'Malta'),
(137, 'MH', 'Marshall Islands'),
(138, 'MQ', 'Martinique'),
(139, 'MR', 'Mauritania'),
(140, 'MU', 'Mauritius'),
(141, 'TY', 'Mayotte'),
(142, 'MX', 'Mexico'),
(143, 'FM', 'Micronesia, Federated States of'),
(144, 'MD', 'Moldova, Republic of'),
(145, 'MC', 'Monaco'),
(146, 'MN', 'Mongolia'),
(147, 'ME', 'Montenegro'),
(148, 'MS', 'Montserrat'),
(149, 'MA', 'Morocco'),
(150, 'MZ', 'Mozambique'),
(151, 'MM', 'Myanmar'),
(152, 'NA', 'Namibia'),
(153, 'NR', 'Nauru'),
(154, 'NP', 'Nepal'),
(155, 'NL', 'Netherlands'),
(156, 'AN', 'Netherlands Antilles'),
(157, 'NC', 'New Caledonia'),
(158, 'NZ', 'New Zealand'),
(159, 'NI', 'Nicaragua'),
(160, 'NE', 'Niger'),
(161, 'NG', 'Nigeria'),
(162, 'NU', 'Niue'),
(163, 'NF', 'Norfolk Island'),
(164, 'MP', 'Northern Mariana Islands'),
(165, 'NO', 'Norway'),
(166, 'OM', 'Oman'),
(167, 'PK', 'Pakistan'),
(168, 'PW', 'Palau'),
(169, 'PS', 'Palestine'),
(170, 'PA', 'Panama'),
(171, 'PG', 'Papua New Guinea'),
(172, 'PY', 'Paraguay'),
(173, 'PE', 'Peru'),
(174, 'PH', 'Philippines'),
(175, 'PN', 'Pitcairn'),
(176, 'PL', 'Poland'),
(177, 'PT', 'Portugal'),
(178, 'PR', 'Puerto Rico'),
(179, 'QA', 'Qatar'),
(180, 'RE', 'Reunion'),
(181, 'RO', 'Romania'),
(182, 'RU', 'Russian Federation'),
(183, 'RW', 'Rwanda'),
(184, 'KN', 'Saint Kitts and Nevis'),
(185, 'LC', 'Saint Lucia'),
(186, 'VC', 'Saint Vincent and the Grenadines'),
(187, 'WS', 'Samoa'),
(188, 'SM', 'San Marino'),
(189, 'ST', 'Sao Tome and Principe'),
(190, 'SA', 'Saudi Arabia'),
(191, 'SN', 'Senegal'),
(192, 'RS', 'Serbia'),
(193, 'SC', 'Seychelles'),
(194, 'SL', 'Sierra Leone'),
(195, 'SG', 'Singapore'),
(196, 'SK', 'Slovakia'),
(197, 'SI', 'Slovenia'),
(198, 'SB', 'Solomon Islands'),
(199, 'SO', 'Somalia'),
(200, 'ZA', 'South Africa'),
(201, 'GS', 'South Georgia South Sandwich Islands'),
(202, 'SS', 'South Sudan'),
(203, 'ES', 'Spain'),
(204, 'LK', 'Sri Lanka'),
(205, 'SH', 'St. Helena'),
(206, 'PM', 'St. Pierre and Miquelon'),
(207, 'SD', 'Sudan'),
(208, 'SR', 'Suriname'),
(209, 'SJ', 'Svalbard and Jan Mayen Islands'),
(210, 'SZ', 'Swaziland'),
(211, 'SE', 'Sweden'),
(212, 'CH', 'Switzerland'),
(213, 'SY', 'Syrian Arab Republic'),
(214, 'TW', 'Taiwan'),
(215, 'TJ', 'Tajikistan'),
(216, 'TZ', 'Tanzania, United Republic of'),
(217, 'TH', 'Thailand'),
(218, 'TG', 'Togo'),
(219, 'TK', 'Tokelau'),
(220, 'TO', 'Tonga'),
(221, 'TT', 'Trinidad and Tobago'),
(222, 'TN', 'Tunisia'),
(223, 'TR', 'Turkey'),
(224, 'TM', 'Turkmenistan'),
(225, 'TC', 'Turks and Caicos Islands'),
(226, 'TV', 'Tuvalu'),
(227, 'UG', 'Uganda'),
(228, 'UA', 'Ukraine'),
(229, 'AE', 'United Arab Emirates'),
(230, 'GB', 'United Kingdom'),
(231, 'US', 'United States'),
(232, 'UM', 'United States minor outlying islands'),
(233, 'UY', 'Uruguay'),
(234, 'UZ', 'Uzbekistan'),
(235, 'VU', 'Vanuatu'),
(236, 'VA', 'Vatican City State'),
(237, 'VE', 'Venezuela'),
(238, 'VN', 'Vietnam'),
(239, 'VG', 'Virgin Islands (British)'),
(240, 'VI', 'Virgin Islands (U.S.)'),
(241, 'WF', 'Wallis and Futuna Islands'),
(242, 'EH', 'Western Sahara'),
(243, 'YE', 'Yemen'),
(244, 'ZR', 'Zaire'),
(245, 'ZM', 'Zambia'),
(246, 'ZW', 'Zimbabwe');
-- --------------------------------------------------------
--
-- Structure de la table `salles`
--
DROP TABLE IF EXISTS `salles`;
CREATE TABLE IF NOT EXISTS `salles` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`Salle` varchar(255) DEFAULT NULL,
`Nplaces` int(10) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `salles`
--
INSERT INTO `salles` (`ID`, `Salle`, `Nplaces`) VALUES
(1, 'K01', 80),
(2, 'K02', 100),
(3, 'K03', 85),
(4, 'K04', 90),
(5, 'K05', 60),
(6, 'K06', 90),
(7, 'K07', 65),
(8, 'K08', 40),
(9, 'K09', 50),
(10, 'K10', 100);
-- --------------------------------------------------------
--
-- Structure de la table `seances`
--
DROP TABLE IF EXISTS `seances`;
CREATE TABLE IF NOT EXISTS `seances` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`SallesID` int(10) NOT NULL,
`HorairesID` int(10) NOT NULL,
`DatesID` int(10) NOT NULL,
`AdministrateursID` int(10) NOT NULL,
`FilmsID` int(10) NOT NULL,
`PrixSeance` double NOT NULL,
`NReservation` int(10) NOT NULL,
PRIMARY KEY (`ID`),
KEY `FKSeances689149` (`FilmsID`),
KEY `FKSeances494776` (`AdministrateursID`),
KEY `FKSeances281509` (`DatesID`),
KEY `FKSeances734065` (`HorairesID`),
KEY `FKSeances253344` (`SallesID`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `seances`
--
INSERT INTO `seances` (`ID`, `SallesID`, `HorairesID`, `DatesID`, `AdministrateursID`, `FilmsID`, `PrixSeance`, `NReservation`) VALUES
(1, 1, 1, 1, 1, 1, 55, 2),
(2, 2, 1, 1, 1, 2, 60, 0),
(3, 3, 1, 1, 2, 3, 55, 0),
(4, 4, 1, 1, 2, 4, 50, 0),
(5, 5, 1, 1, 1, 5, 70, 1),
(6, 6, 1, 1, 1, 6, 45, 0),
(7, 1, 2, 2, 2, 7, 65, 0),
(8, 2, 3, 2, 2, 8, 55, 1),
(9, 3, 4, 2, 1, 9, 55, 1),
(10, 4, 3, 3, 2, 5, 60, 0);
-- --------------------------------------------------------
--
-- Structure de la table `tickets`
--
DROP TABLE IF EXISTS `tickets`;
CREATE TABLE IF NOT EXISTS `tickets` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`ClientsID` int(10) NOT NULL,
`CartesbancairesID` int(10) NOT NULL,
`SeancesID` int(10) NOT NULL,
`tempsTicket` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`PrixTicket` double NOT NULL,
PRIMARY KEY (`ID`),
KEY `FKTickets807122` (`SeancesID`),
KEY `FKTickets612375` (`CartesbancairesID`),
KEY `FKTickets153187` (`ClientsID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
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 */;
|
<gh_stars>10-100
use master
GO
alter database [DatabaseName] set single_user with rollback immediate
GO
RESTORE DATABASE [DatabaseName] FROM DISK = N'd:\SQL-BACKUPS\DatabaseName.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
GO
alter database [DatabaseName] set multi_user
GO
|
-- Gets RRT Patients
SELECT DISTINCT stay_id FROM `physionet-data.mimic_derived.rrt` where dialysis_present = 1
|
/* Formatted on 12-20-2018 1:38:29 PM (QP5 v5.126.903.23003) */
/*
"C:\Program Files (x86)\pgAdmin 4\v3\runtime\pg_dump" --host localhost --port 5432 --username postgres --verbose --table=WKF.WKF_APPS --data-only --column-inserts psdc_live > WKF.WKF_APPS.sql
*/
set define off;
TRUNCATE TABLE WKF.WKF_APPS CASCADE;
INSERT INTO wkf.wkf_apps (app_id, app_name, source_module, app_desc, created_by, creation_date) VALUES (1, 'Login', 'System Administration', 'Login Welcome Messages', 1, '2013-11-25 07:55:01');
INSERT INTO wkf.wkf_apps (app_id, app_name, source_module, app_desc, created_by, creation_date) VALUES (5, 'Clinical Appointments', 'Clinic/Hospital', 'Messages related to Clinic/Hospital Appointments', 1, '2016-01-08 15:39:43');
INSERT INTO wkf.wkf_apps (app_id, app_name, source_module, app_desc, created_by, creation_date) VALUES (6, 'Personal Records Change', 'Basic Person Data', 'Messages related to Basic Person Data Change Requests', 1, '2016-01-08 15:39:44');
INSERT INTO wkf.wkf_apps (app_id, app_name, source_module, app_desc, created_by, creation_date) VALUES (7, 'PSB Forms Submission', 'Payment Systems Banking', 'Messages related to PSB Forms Submitted', 1, '2016-01-22 09:05:21');
COMMIT;
EXEC SYS.SEQUENCE_NEWVALUE( 'WKF', 'WKF_WORKFLOW_APPS_APP_ID_SEQ', 10 );
COMMIT;
|
<reponame>ponekbladh/d365fo.blog
DROP workload GROUP AX_BATCH_WORKGROUP ON DATABASE
GO
DROP workload GROUP AX_ONLINE_WORKGROUP ON DATABASE
GO
ALTER workload GROUP "default" ON DATABASE
WITH (MIN_CPU_PERCENT = 100
,MAX_CPU_PERCENT = 100
,MIN_LOG_RATE_PERCENT = 100
,MAX_LOG_RATE_PERCENT = 100
,MIN_IOPS_PERCENT = 100
,MAX_IOPS_PERCENT = 100)
GO
ALTER RESOURCE GOVERNOR ON DATABASE WITH
(CLASSIFIER_FUNCTION=NULL)
GO
ALTER RESOURCE GOVERNOR ON DATABASE reconfigure
GO
-- this is just to set the AX configuration to an initial state
UPDATE AXClassificationTable SET CONFIGUREDDATETIME = NULL
-- check the results
SELECT * FROM sys.resource_governor_configuration
SELECT * FROM axclassificationtable
SELECT * FROM SYS.DATABASE_RESOURCE_GOVERNOR_WORKLOAD_GROUPS
|
<filename>res/sysbench/bulk_insert.sql<gh_stars>10-100
CREATE TABLE sbtest1 (
id INTEGER NOT NULL,
/*{{ rownum }}*/
k INTEGER DEFAULT '0' NOT NULL,
/*{{ rownum }}*/
PRIMARY KEY (id)
);
|
<gh_stars>0
CREATE schema `movies3`;
use `movies3`;
CREATE TABLE `Actor`(
`id` int NOT NULL AUTO_INCREMENT,
`name` nvarchar(50) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB;
CREATE TABLE `Director`(
`id` int NOT NULL AUTO_INCREMENT,
`name` nvarchar(50) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB;
CREATE TABLE `Movies`(
`id` int NOT NULL AUTO_INCREMENT,
`language` nchar(5) NOT NULL,
`original_title` nvarchar(50) NOT NULL,
`release_date` date NOT NULL,
`runtime` int NOT NULL,
`actor_id` int NOT NULL,
`director_id` int NOT NULL,
CONSTRAINT `Actor_id_fk` FOREIGN KEY (`actor_id`) REFERENCES `Actor` (`id`) ON DELETE cascade ON UPDATE CASCADE,
CONSTRAINT `Director_id_fk` FOREIGN KEY (`director_id`) REFERENCES `Director` (`id`) ON DELETE cascade ON UPDATE CASCADE,
KEY `Actor_id_fk_idx` (`actor_id`),
KEY `Director_id_fk_idx` (`director_id`),
PRIMARY KEY (`id`)
)ENGINE=InnoDB;
CREATE TABLE `Genre`(
`id` int NOT NULL AUTO_INCREMENT,
`genre` nvarchar(50) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB;
CREATE TABLE `Through`(
`id` int NOT NULL,
`movie_id` int NOT NULL,
`genre_id` int NOT NULL,
CONSTRAINT FOREIGN KEY (`movie_id`) REFERENCES `Movies` (`id`) ON DELETE cascade ON UPDATE CASCADE,
CONSTRAINT FOREIGN KEY (`genre_id`) REFERENCES `Genre` (`id`) ON DELETE cascade ON UPDATE CASCADE
-- KEY `movies_id_fk_idx` (`movie_id`),
-- KEY `genre_id_fk_idx` (`genre_id`)
)ENGINE=InnoDB;
INSERT into `Actor` (`name`) VALUES
('Armando'),
('Estela'),
('Rodrigo'),
('Michael'),
('Billie'),
('Rivers'),
('Dave'),
('David'),
('Tom'),
('Zendaya'),
('Riley');
INSERT into `Director` (`name`) VALUES
('José'),
('João'),
('Maria'),
('Ana'),
('Leonardo'),
('Rafael'),
('Mário'),
('Donatelo'),
('Thomas'),
('Manuel'),
('Mariana');
INSERT INTO `Movies` (`language`, `original_title`, `release_date`, `runtime`, `actor_id`, `director_id`) VALUES
('en', 'Spider-Man: No Way Home', CAST('2021-12-15' AS Date), 148, 1, 3),
('en', 'Dont Look Up', CAST('2021-12-07' AS Date), 138, 4, 6),
('en', 'The Matrix Resurrections', CAST('021-12-16' AS Date), 148, 1, 6),
('en','Encanto', CAST('2021-11-24' AS Date), 102, 7,11),
('en', 'Resident Evil: Welcome to Raccoon City', CAST('2021-11-24' AS Date), 107, 11, 7),
('en' , 'Venom: Let There Be Carnage', CAST('2021-09-30' AS Date), 97, 4, 8),
('en','Last Looks', CAST('2021-12-02' AS Date), 111, 4, 9),
('en','No Time to Die', CAST('2021-09-29' AS Date), 163, 11, 1),
('en', 'Dune', CAST('2021-09-15' AS Date), 155, 9, 6),
('en','Spider-Man: Far From Home', CAST('2019-06-28' AS Date), 129, 7, 10),
('en', 'Ghostbusters: Afterlife', CAST('2021-11-11' AS Date), 124, 4, 7),
('pt', 'Lulli', CAST('2021-12-26' AS Date), 90, 1, 1),
('en', 'The King´s Man', CAST('2021-12-21' AS Date), 131, 2, 2),
('en', 'Red Notice', CAST('2021-11-04' AS Date), 117, 3, 3),
('en', 'Shang-Chi and the Legend of the Ten Rings', CAST('2021-09-01' AS Date), 132, 4, 4),
('en', 'The Amazing Spider-Man', CAST('2012-06-23' AS Date), 136,5 ,5),
('en', 'Spider-Man: Homecoming', CAST('2017-07-05' AS Date), 133,6 ,6),
('en', 'Clifford the Big Red Dog', CAST('2021-11-10' AS Date), 97,7 ,7),
('en', 'Encounter', CAST('2021-12-03' AS Date), 108,8 ,8),
('en', 'The Amazing Spider-Man 2', CAST('2014-04-16' AS Date), 142, 9, 9),
('en','Sing 2', CAST('2021-12-01' AS Date), 110, 10, 10),
('en', 'Eternals', CAST('2021-11-03' AS Date), 157, 11, 11),
('en', 'Spider-Man', CAST('2002-05-01' AS Date), 121, 1,2),
('en', 'Ida Red', CAST('2021-11-05' AS Date), 111, 3, 4),
('en', 'The Last Duel', CAST('2021-10-13' AS Date), 152, 5, 6),
('en', 'The Greatest Game Ever Played', CAST('2005-09-30' AS Date), 120, 7, 8),
('en', 'Furnace', CAST('2007-12-11' AS Date), 90, 9, 10),
('en','Twelve OClock High', CAST('1949-12-21' AS Date), 132, 11, 1),
('pt', 'Quando as Mulheres Querem Provas', CAST('1975-03-04' AS Date), 110, 11, 2),
('en', 'The Second Arrival', CAST('1998-11-06' AS Date), 101, 2, 10);
INSERT into `Genre` (`genre`) VALUES
('Action'),
('Adventure'),
('Animation'),
('Comedy'),
('Crime'),
('Documentary'),
('Drama'),
('Family'),
('Fantasy'),
('History'),
('Horror'),
('Music'),
('Mystery'),
('Romance'),
('Science Fiction'),
('V movie'),
('Thriller'),
('War'),
('Western');
INSERT `Through` (`id`, `movie_id`, `genre_id`) VALUES
(1, 1, 1),
(2, 1, 2),
(3, 1, 15),
(4, 2, 4),
(5, 2, 7),
(6, 2, 15),
(7, 3, 1),
(8, 3, 15),
(9, 4, 3),
(10, 4, 4),
(11, 4, 8),
(12, 4, 9),
(13, 5, 11),
(14, 5, 1),
(15, 5, 15),
(16, 6, 15),
(17, 6, 1),
(18, 6, 2),
(19, 7, 1),
(20, 7, 5),
(21, 7, 17),
(22, 8, 2),
(23, 8, 1),
(24, 8, 17),
(25, 9, 15),
(26, 9, 2),
(27, 10, 1),
(28, 10, 2),
(29, 10, 15),
(30, 11, 4),
(31, 11, 9),
(32, 11, 2),
(33, 11, 15),
(34, 12, 4),
(35, 12, 14),
(36, 12, 9),
(37, 13, 1),
(38, 13, 2),
(39, 13, 17),
(40,14, 1),
(41,14, 4),
(42, 14, 5),
(43, 14, 17),
(44, 15, 1),
(45, 15, 2),
(46, 15, 9),
(47, 16, 1),
(48, 16, 2),
(49, 16, 9),
(50, 17, 1),
(51, 17, 2),
(52, 17, 15),
(53, 17, 7),
(54, 18, 3),
(55, 18, 4),
(56, 18, 8),
(57, 19, 15),
(58, 19, 17),
(59, 19, 2),
(60, 20, 1),
(61, 20, 2),
(62, 20, 9),
(63, 21, 3),
(64, 21, 4),
(65, 21, 8),
(66, 21, 12),
(67, 22, 1),
(68, 22, 2),
(69, 22, 9),
(70, 22, 15),
(71, 23, 9),
(72, 23, 1),
(73, 24, 5),
(74, 24, 17),
(75, 24, 7),
(76, 24, 1),
(77, 25, 1),
(78, 25, 7),
(79, 25, 10),
(80, 26, 7),
(81, 27, 5),
(82, 27, 11),
(83, 27, 13),
(84, 28, 18),
(85, 28, 1),
(86, 28, 7),
(87, 29, 4),
(88, 29, 14),
(89, 30, 15);
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678'
|
<reponame>franchb/ClickHouse
DROP TABLE IF EXISTS test.t;
create table test.t(d Date) engine MergeTree(d, d, 8192);
insert into test.t values ('2018-02-20');
select count() from test.t where toDayOfWeek(d) in (2);
DROP TABLE test.t;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.