Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
1
1.05M
# tz zone descriptions (deprecated version) # # This file is in the public domain, so clarified as of # 2009-05-17 by Arthur David Olson. # # From Paul Eggert (2014-07-31): # This file is intended as a backward-compatibility aid for older programs. # New programs should use zone1970.tab. This file is like zone1970.tab (see # zone1970.tab's comments), but with the following additional restrictions: # # 1. This file contains only ASCII characters. # 2. The first data column contains exactly one country code. # # Because of (2), each row stands for an area that is the intersection # of a region identified by a country code and of a zone where civil # clocks have agreed since 1970; this is a narrower definition than # that of zone1970.tab. # # This table is intended as an aid for users, to help them select time # zone data entries appropriate for their practical needs. It is not # intended to take or endorse any position on legal or territorial claims. # #country- #code coordinates TZ comments AD +4230+00131 Europe/Andorra AE +2518+05518 Asia/Dubai AF +3431+06912 Asia/Kabul AG +1703-06148 America/Antigua AI +1812-06304 America/Anguilla AL +4120+01950 Europe/Tirane AM +4011+04430 Asia/Yerevan AO -0848+01314 Africa/Luanda AQ -7750+16636 Antarctica/McMurdo New Zealand time - McMurdo, South Pole AQ -6617+11031 Antarctica/Casey Casey AQ -6835+07758 Antarctica/Davis Davis AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville AQ -6736+06253 Antarctica/Mawson Mawson AQ -6448-06406 Antarctica/Palmer Palmer AQ -6734-06808 Antarctica/Rothera Rothera AQ -690022+0393524 Antarctica/Syowa Syowa AQ -720041+0023206 Antarctica/Troll Troll AQ -7824+10654 Antarctica/Vostok Vostok AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF) AR -3124-06411 America/Argentina/Cordoba Argentina (most areas: CB, CC, CN, ER, FM, MN, SE, SF) AR -2447-06525 America/Argentina/Salta Salta (SA, LP, NQ, RN) AR -2411-06518 America/Argentina/Jujuy Jujuy (JY) AR -2649-06513 America/Argentina/Tucuman Tucuman (TM) AR -2828-06547 America/Argentina/Catamarca Catamarca (CT); Chubut (CH) AR -2926-06651 America/Argentina/La_Rioja La Rioja (LR) AR -3132-06831 America/Argentina/San_Juan San Juan (SJ) AR -3253-06849 America/Argentina/Mendoza Mendoza (MZ) AR -3319-06621 America/Argentina/San_Luis San Luis (SL) AR -5138-06913 America/Argentina/Rio_Gallegos Santa Cruz (SC) AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF) AS -1416-17042 Pacific/Pago_Pago AT +4813+01620 Europe/Vienna AU -3133+15905 Australia/Lord_Howe Lord Howe Island AU -5430+15857 Antarctica/Macquarie Macquarie Island AU -4253+14719 Australia/Hobart Tasmania (most areas) AU -3956+14352 Australia/Currie Tasmania (King Island) AU -3749+14458 Australia/Melbourne Victoria AU -3352+15113 Australia/Sydney New South Wales (most areas) AU -3157+14127 Australia/Broken_Hill New South Wales (Yancowinna) AU -2728+15302 Australia/Brisbane Queensland (most areas) AU -2016+14900 Australia/Lindeman Queensland (Whitsunday Islands) AU -3455+13835 Australia/Adelaide South Australia AU -1228+13050 Australia/Darwin Northern Territory AU -3157+11551 Australia/Perth Western Australia (most areas) AU -3143+12852 Australia/Eucla Western Australia (Eucla) AW +1230-06958 America/Aruba AX +6006+01957 Europe/Mariehamn AZ +4023+04951 Asia/Baku BA +4352+01825 Europe/Sarajevo BB +1306-05937 America/Barbados BD +2343+09025 Asia/Dhaka BE +5050+00420 Europe/Brussels BF +1222-00131 Africa/Ouagadougou BG +4241+02319 Europe/Sofia BH +2623+05035 Asia/Bahrain BI -0323+02922 Africa/Bujumbura BJ +0629+00237 Africa/Porto-Novo BL +1753-06251 America/St_Barthelemy BM +3217-06446 Atlantic/Bermuda BN +0456+11455 Asia/Brunei BO -1630-06809 America/La_Paz BQ +120903-0681636 America/Kralendijk BR -0351-03225 America/Noronha Atlantic islands BR -0127-04829 America/Belem Para (east); Amapa BR -0343-03830 America/Fortaleza Brazil (northeast: MA, PI, CE, RN, PB) BR -0803-03454 America/Recife Pernambuco BR -0712-04812 America/Araguaina Tocantins BR -0940-03543 America/Maceio Alagoas, Sergipe BR -1259-03831 America/Bahia Bahia BR -2332-04637 America/Sao_Paulo Brazil (southeast: GO, DF, MG, ES, RJ, SP, PR, SC, RS) BR -2027-05437 America/Campo_Grande Mato Grosso do Sul BR -1535-05605 America/Cuiaba Mato Grosso BR -0226-05452 America/Santarem Para (west) BR -0846-06354 America/Porto_Velho Rondonia BR +0249-06040 America/Boa_Vista Roraima BR -0308-06001 America/Manaus Amazonas (east) BR -0640-06952 America/Eirunepe Amazonas (west) BR -0958-06748 America/Rio_Branco Acre BS +2505-07721 America/Nassau BT +2728+08939 Asia/Thimphu BW -2439+02555 Africa/Gaborone BY +5354+02734 Europe/Minsk BZ +1730-08812 America/Belize CA +4734-05243 America/St_Johns Newfoundland; Labrador (southeast) CA +4439-06336 America/Halifax Atlantic - NS (most areas); PE CA +4612-05957 America/Glace_Bay Atlantic - NS (Cape Breton) CA +4606-06447 America/Moncton Atlantic - New Brunswick CA +5320-06025 America/Goose_Bay Atlantic - Labrador (most areas) CA +5125-05707 America/Blanc-Sablon AST - QC (Lower North Shore) CA +4339-07923 America/Toronto Eastern - ON, QC (most areas) CA +4901-08816 America/Nipigon Eastern - ON, QC (no DST 1967-73) CA +4823-08915 America/Thunder_Bay Eastern - ON (Thunder Bay) CA +6344-06828 America/Iqaluit Eastern - NU (most east areas) CA +6608-06544 America/Pangnirtung Eastern - NU (Pangnirtung) CA +484531-0913718 America/Atikokan EST - ON (Atikokan); NU (Coral H) CA +4953-09709 America/Winnipeg Central - ON (west); Manitoba CA +4843-09434 America/Rainy_River Central - ON (Rainy R, Ft Frances) CA +744144-0944945 America/Resolute Central - NU (Resolute) CA +624900-0920459 America/Rankin_Inlet Central - NU (central) CA +5024-10439 America/Regina CST - SK (most areas) CA +5017-10750 America/Swift_Current CST - SK (midwest) CA +5333-11328 America/Edmonton Mountain - AB; BC (E); SK (W) CA +690650-1050310 America/Cambridge_Bay Mountain - NU (west) CA +6227-11421 America/Yellowknife Mountain - NT (central) CA +682059-1334300 America/Inuvik Mountain - NT (west) CA +4906-11631 America/Creston MST - BC (Creston) CA +5946-12014 America/Dawson_Creek MST - BC (Dawson Cr, Ft St John) CA +5848-12242 America/Fort_Nelson MST - BC (Ft Nelson) CA +4916-12307 America/Vancouver Pacific - BC (most areas) CA +6043-13503 America/Whitehorse Pacific - Yukon (south) CA +6404-13925 America/Dawson Pacific - Yukon (north) CC -1210+09655 Indian/Cocos CD -0418+01518 Africa/Kinshasa Dem. Rep. of Congo (west) CD -1140+02728 Africa/Lubumbashi Dem. Rep. of Congo (east) CF +0422+01835 Africa/Bangui CG -0416+01517 Africa/Brazzaville CH +4723+00832 Europe/Zurich CI +0519-00402 Africa/Abidjan CK -2114-15946 Pacific/Rarotonga CL -3327-07040 America/Santiago Chile (most areas) CL -2709-10926 Pacific/Easter Easter Island CM +0403+00942 Africa/Douala CN +3114+12128 Asia/Shanghai Beijing Time CN +4348+08735 Asia/Urumqi Xinjiang Time CO +0436-07405 America/Bogota CR +0956-08405 America/Costa_Rica CU +2308-08222 America/Havana CV +1455-02331 Atlantic/Cape_Verde CW +1211-06900 America/Curacao CX -1025+10543 Indian/Christmas CY +3510+03322 Asia/Nicosia CZ +5005+01426 Europe/Prague DE +5230+01322 Europe/Berlin Germany (most areas) DE +4742+00841 Europe/Busingen Busingen DJ +1136+04309 Africa/Djibouti DK +5540+01235 Europe/Copenhagen DM +1518-06124 America/Dominica DO +1828-06954 America/Santo_Domingo DZ +3647+00303 Africa/Algiers EC -0210-07950 America/Guayaquil Ecuador (mainland) EC -0054-08936 Pacific/Galapagos Galapagos Islands EE +5925+02445 Europe/Tallinn EG +3003+03115 Africa/Cairo EH +2709-01312 Africa/El_Aaiun ER +1520+03853 Africa/Asmara ES +4024-00341 Europe/Madrid Spain (mainland) ES +3553-00519 Africa/Ceuta Ceuta, Melilla ES +2806-01524 Atlantic/Canary Canary Islands ET +0902+03842 Africa/Addis_Ababa FI +6010+02458 Europe/Helsinki FJ -1808+17825 Pacific/Fiji FK -5142-05751 Atlantic/Stanley FM +0725+15147 Pacific/Chuuk Chuuk/Truk, Yap FM +0658+15813 Pacific/Pohnpei Pohnpei/Ponape FM +0519+16259 Pacific/Kosrae Kosrae FO +6201-00646 Atlantic/Faroe FR +4852+00220 Europe/Paris GA +0023+00927 Africa/Libreville GB +513030-0000731 Europe/London GD +1203-06145 America/Grenada GE +4143+04449 Asia/Tbilisi GF +0456-05220 America/Cayenne GG +4927-00232 Europe/Guernsey GH +0533-00013 Africa/Accra GI +3608-00521 Europe/Gibraltar GL +6411-05144 America/Godthab Greenland (most areas) GL +7646-01840 America/Danmarkshavn National Park (east coast) GL +7029-02158 America/Scoresbysund Scoresbysund/Ittoqqortoormiit GL +7634-06847 America/Thule Thule/Pituffik GM +1328-01639 Africa/Banjul GN +0931-01343 Africa/Conakry GP +1614-06132 America/Guadeloupe GQ +0345+00847 Africa/Malabo GR +3758+02343 Europe/Athens GS -5416-03632 Atlantic/South_Georgia GT +1438-09031 America/Guatemala GU +1328+14445 Pacific/Guam GW +1151-01535 Africa/Bissau GY +0648-05810 America/Guyana HK +2217+11409 Asia/Hong_Kong HN +1406-08713 America/Tegucigalpa HR +4548+01558 Europe/Zagreb HT +1832-07220 America/Port-au-Prince HU +4730+01905 Europe/Budapest ID -0610+10648 Asia/Jakarta Java, Sumatra ID -0002+10920 Asia/Pontianak Borneo (west, central) ID -0507+11924 Asia/Makassar Borneo (east, south); Sulawesi/Celebes, Bali, Nusa Tengarra; Timor (west) ID -0232+14042 Asia/Jayapura New Guinea (West Papua / Irian Jaya); Malukus/Moluccas IE +5320-00615 Europe/Dublin IL +314650+0351326 Asia/Jerusalem IM +5409-00428 Europe/Isle_of_Man IN +2232+08822 Asia/Kolkata IO -0720+07225 Indian/Chagos IQ +3321+04425 Asia/Baghdad IR +3540+05126 Asia/Tehran IS +6409-02151 Atlantic/Reykjavik IT +4154+01229 Europe/Rome JE +4912-00207 Europe/Jersey JM +175805-0764736 America/Jamaica JO +3157+03556 Asia/Amman JP +353916+1394441 Asia/Tokyo KE -0117+03649 Africa/Nairobi KG +4254+07436 Asia/Bishkek KH +1133+10455 Asia/Phnom_Penh KI +0125+17300 Pacific/Tarawa Gilbert Islands KI -0308-17105 Pacific/Enderbury Phoenix Islands KI +0152-15720 Pacific/Kiritimati Line Islands KM -1141+04316 Indian/Comoro KN +1718-06243 America/St_Kitts KP +3901+12545 Asia/Pyongyang KR +3733+12658 Asia/Seoul KW +2920+04759 Asia/Kuwait KY +1918-08123 America/Cayman KZ +4315+07657 Asia/Almaty Kazakhstan (most areas) KZ +4448+06528 Asia/Qyzylorda Qyzylorda/Kyzylorda/Kzyl-Orda KZ +5017+05710 Asia/Aqtobe Aqtobe/Aktobe KZ +4431+05016 Asia/Aqtau Atyrau/Atirau/Gur'yev, Mangghystau/Mankistau KZ +5113+05121 Asia/Oral West Kazakhstan LA +1758+10236 Asia/Vientiane LB +3353+03530 Asia/Beirut LC +1401-06100 America/St_Lucia LI +4709+00931 Europe/Vaduz LK +0656+07951 Asia/Colombo LR +0618-01047 Africa/Monrovia LS -2928+02730 Africa/Maseru LT +5441+02519 Europe/Vilnius LU +4936+00609 Europe/Luxembourg LV +5657+02406 Europe/Riga LY +3254+01311 Africa/Tripoli MA +3339-00735 Africa/Casablanca MC +4342+00723 Europe/Monaco MD +4700+02850 Europe/Chisinau ME +4226+01916 Europe/Podgorica MF +1804-06305 America/Marigot MG -1855+04731 Indian/Antananarivo MH +0709+17112 Pacific/Majuro Marshall Islands (most areas) MH +0905+16720 Pacific/Kwajalein Kwajalein MK +4159+02126 Europe/Skopje ML +1239-00800 Africa/Bamako MM +1647+09610 Asia/Rangoon MN +4755+10653 Asia/Ulaanbaatar Mongolia (most areas) MN +4801+09139 Asia/Hovd Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan MN +4804+11430 Asia/Choibalsan Dornod, Sukhbaatar MO +2214+11335 Asia/Macau MP +1512+14545 Pacific/Saipan MQ +1436-06105 America/Martinique MR +1806-01557 Africa/Nouakchott MS +1643-06213 America/Montserrat MT +3554+01431 Europe/Malta MU -2010+05730 Indian/Mauritius MV +0410+07330 Indian/Maldives MW -1547+03500 Africa/Blantyre MX +1924-09909 America/Mexico_City Central Time MX +2105-08646 America/Cancun Eastern Standard Time - Quintana Roo MX +2058-08937 America/Merida Central Time - Campeche, Yucatan MX +2540-10019 America/Monterrey Central Time - Durango; Coahuila, Nuevo Leon, Tamaulipas (most areas) MX +2550-09730 America/Matamoros Central Time US - Coahuila, Nuevo Leon, Tamaulipas (US border) MX +2313-10625 America/Mazatlan Mountain Time - Baja California Sur, Nayarit, Sinaloa MX +2838-10605 America/Chihuahua Mountain Time - Chihuahua (most areas) MX +2934-10425 America/Ojinaga Mountain Time US - Chihuahua (US border) MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora MX +3232-11701 America/Tijuana Pacific Time US - Baja California MX +2048-10515 America/Bahia_Banderas Central Time - Bahia de Banderas MY +0310+10142 Asia/Kuala_Lumpur Malaysia (peninsula) MY +0133+11020 Asia/Kuching Sabah, Sarawak MZ -2558+03235 Africa/Maputo NA -2234+01706 Africa/Windhoek NC -2216+16627 Pacific/Noumea NE +1331+00207 Africa/Niamey NF -2903+16758 Pacific/Norfolk NG +0627+00324 Africa/Lagos NI +1209-08617 America/Managua NL +5222+00454 Europe/Amsterdam NO +5955+01045 Europe/Oslo NP +2743+08519 Asia/Kathmandu NR -0031+16655 Pacific/Nauru NU -1901-16955 Pacific/Niue NZ -3652+17446 Pacific/Auckland New Zealand (most areas) NZ -4357-17633 Pacific/Chatham Chatham Islands OM +2336+05835 Asia/Muscat PA +0858-07932 America/Panama PE -1203-07703 America/Lima PF -1732-14934 Pacific/Tahiti Society Islands PF -0900-13930 Pacific/Marquesas Marquesas Islands PF -2308-13457 Pacific/Gambier Gambier Islands PG -0930+14710 Pacific/Port_Moresby Papua New Guinea (most areas) PG -0613+15534 Pacific/Bougainville Bougainville PH +1435+12100 Asia/Manila PK +2452+06703 Asia/Karachi PL +5215+02100 Europe/Warsaw PM +4703-05620 America/Miquelon PN -2504-13005 Pacific/Pitcairn PR +182806-0660622 America/Puerto_Rico PS +3130+03428 Asia/Gaza Gaza Strip PS +313200+0350542 Asia/Hebron West Bank PT +3843-00908 Europe/Lisbon Portugal (mainland) PT +3238-01654 Atlantic/Madeira Madeira Islands PT +3744-02540 Atlantic/Azores Azores PW +0720+13429 Pacific/Palau PY -2516-05740 America/Asuncion QA +2517+05132 Asia/Qatar RE -2052+05528 Indian/Reunion RO +4426+02606 Europe/Bucharest RS +4450+02030 Europe/Belgrade RU +5443+02030 Europe/Kaliningrad MSK-01 - Kaliningrad RU +554521+0373704 Europe/Moscow MSK+00 - Moscow area RU +4457+03406 Europe/Simferopol MSK+00 - Crimea RU +4844+04425 Europe/Volgograd MSK+00 - Volgograd, Kirov, Saratov RU +4621+04803 Europe/Astrakhan MSK+01 - Astrakhan RU +5312+05009 Europe/Samara MSK+01 - Samara, Udmurtia RU +5420+04824 Europe/Ulyanovsk MSK+01 - Ulyanovsk RU +5651+06036 Asia/Yekaterinburg MSK+02 - Urals RU +5500+07324 Asia/Omsk MSK+03 - Omsk RU +5502+08255 Asia/Novosibirsk MSK+03 - Novosibirsk, Tomsk RU +5322+08345 Asia/Barnaul MSK+04 - Altai RU +5345+08707 Asia/Novokuznetsk MSK+04 - Kemerovo RU +5601+09250 Asia/Krasnoyarsk MSK+04 - Krasnoyarsk area RU +5216+10420 Asia/Irkutsk MSK+05 - Irkutsk, Buryatia RU +5203+11328 Asia/Chita MSK+05 - Zabaykalsky RU +6200+12940 Asia/Yakutsk MSK+06 - Lena River RU +623923+1353314 Asia/Khandyga MSK+06 - Tomponsky, Ust-Maysky RU +4310+13156 Asia/Vladivostok MSK+07 - Amur River RU +4658+14242 Asia/Sakhalin MSK+07 - Sakhalin Island RU +643337+1431336 Asia/Ust-Nera MSK+07 - Oymyakonsky RU +5934+15048 Asia/Magadan MSK+07 - Magadan RU +6728+15343 Asia/Srednekolymsk MSK+08 - Sakha (E); North Kuril Is RU +5301+15839 Asia/Kamchatka MSK+09 - Kamchatka RU +6445+17729 Asia/Anadyr MSK+09 - Bering Sea RW -0157+03004 Africa/Kigali SA +2438+04643 Asia/Riyadh SB -0932+16012 Pacific/Guadalcanal SC -0440+05528 Indian/Mahe SD +1536+03232 Africa/Khartoum SE +5920+01803 Europe/Stockholm SG +0117+10351 Asia/Singapore SH -1555-00542 Atlantic/St_Helena SI +4603+01431 Europe/Ljubljana SJ +7800+01600 Arctic/Longyearbyen SK +4809+01707 Europe/Bratislava SL +0830-01315 Africa/Freetown SM +4355+01228 Europe/San_Marino SN +1440-01726 Africa/Dakar SO +0204+04522 Africa/Mogadishu SR +0550-05510 America/Paramaribo SS +0451+03136 Africa/Juba ST +0020+00644 Africa/Sao_Tome SV +1342-08912 America/El_Salvador SX +180305-0630250 America/Lower_Princes SY +3330+03618 Asia/Damascus SZ -2618+03106 Africa/Mbabane TC +2128-07108 America/Grand_Turk TD +1207+01503 Africa/Ndjamena TF -492110+0701303 Indian/Kerguelen TG +0608+00113 Africa/Lome TH +1345+10031 Asia/Bangkok TJ +3835+06848 Asia/Dushanbe TK -0922-17114 Pacific/Fakaofo TL -0833+12535 Asia/Dili TM +3757+05823 Asia/Ashgabat TN +3648+01011 Africa/Tunis TO -2110-17510 Pacific/Tongatapu TR +4101+02858 Europe/Istanbul TT +1039-06131 America/Port_of_Spain TV -0831+17913 Pacific/Funafuti TW +2503+12130 Asia/Taipei TZ -0648+03917 Africa/Dar_es_Salaam UA +5026+03031 Europe/Kiev Ukraine (most areas) UA +4837+02218 Europe/Uzhgorod Ruthenia UA +4750+03510 Europe/Zaporozhye Zaporozh'ye/Zaporizhia; Lugansk/Luhansk (east) UG +0019+03225 Africa/Kampala UM +1645-16931 Pacific/Johnston Johnston Atoll UM +2813-17722 Pacific/Midway Midway Islands UM +1917+16637 Pacific/Wake Wake Island US +404251-0740023 America/New_York Eastern (most areas) US +421953-0830245 America/Detroit Eastern - MI (most areas) US +381515-0854534 America/Kentucky/Louisville Eastern - KY (Louisville area) US +364947-0845057 America/Kentucky/Monticello Eastern - KY (Wayne) US +394606-0860929 America/Indiana/Indianapolis Eastern - IN (most areas) US +384038-0873143 America/Indiana/Vincennes Eastern - IN (Da, Du, K, Mn) US +410305-0863611 America/Indiana/Winamac Eastern - IN (Pulaski) US +382232-0862041 America/Indiana/Marengo Eastern - IN (Crawford) US +382931-0871643 America/Indiana/Petersburg Eastern - IN (Pike) US +384452-0850402 America/Indiana/Vevay Eastern - IN (Switzerland) US +415100-0873900 America/Chicago Central (most areas) US +375711-0864541 America/Indiana/Tell_City Central - IN (Perry) US +411745-0863730 America/Indiana/Knox Central - IN (Starke) US +450628-0873651 America/Menominee Central - MI (Wisconsin border) US +470659-1011757 America/North_Dakota/Center Central - ND (Oliver) US +465042-1012439 America/North_Dakota/New_Salem Central - ND (Morton rural) US +471551-1014640 America/North_Dakota/Beulah Central - ND (Mercer) US +394421-1045903 America/Denver Mountain (most areas) US +433649-1161209 America/Boise Mountain - ID (south); OR (east) US +332654-1120424 America/Phoenix MST - Arizona (except Navajo) US +340308-1181434 America/Los_Angeles Pacific US +611305-1495401 America/Anchorage Alaska (most areas) US +581807-1342511 America/Juneau Alaska - Juneau area US +571035-1351807 America/Sitka Alaska - Sitka area US +550737-1313435 America/Metlakatla Alaska - Annette Island US +593249-1394338 America/Yakutat Alaska - Yakutat US +643004-1652423 America/Nome Alaska (west) US +515248-1763929 America/Adak Aleutian Islands US +211825-1575130 Pacific/Honolulu Hawaii UY -3453-05611 America/Montevideo UZ +3940+06648 Asia/Samarkand Uzbekistan (west) UZ +4120+06918 Asia/Tashkent Uzbekistan (east) VA +415408+0122711 Europe/Vatican VC +1309-06114 America/St_Vincent VE +1030-06656 America/Caracas VG +1827-06437 America/Tortola VI +1821-06456 America/St_Thomas VN +1045+10640 Asia/Ho_Chi_Minh VU -1740+16825 Pacific/Efate WF -1318-17610 Pacific/Wallis WS -1350-17144 Pacific/Apia YE +1245+04512 Asia/Aden YT -1247+04514 Indian/Mayotte ZA -2615+02800 Africa/Johannesburg ZM -1525+02817 Africa/Lusaka ZW -1750+03103 Africa/Harare
USE [WideWorldImportersDW] GO ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 140 GO EXEC sp_executesql N'SELECT  [fo].[Order Key], [si].[Lead Time Days], [fo].[Quantity] FROM    [Fact].[Order] AS [fo] INNER JOIN [Dimension].[Stock Item] AS [si]        ON [fo].[Stock Item Key] = [si].[Stock Item Key] WHERE   [fo].[Quantity] =@param1', N'@param1 int', @param1 = 360 GO EXEC sp_executesql N'SELECT  [fo].[Order Key], [si].[Lead Time Days], [fo].[Quantity] FROM    [Fact].[Order] AS [fo] INNER JOIN [Dimension].[Stock Item] AS [si]        ON [fo].[Stock Item Key] = [si].[Stock Item Key] WHERE   [fo].[Quantity] =@param1', N'@param1 int', @param1 = 361 GO
CREATE TABLE IF NOT EXISTS pluginkeyvaluestore ( pluginid VARCHAR(190) NOT NULL, pkey VARCHAR(50) NOT NULL, pvalue bytea, PRIMARY KEY (pluginid, pkey) ); ALTER TABLE pluginkeyvaluestore ADD COLUMN IF NOT EXISTS expireat bigint DEFAULT 0; DO $$BEGIN IF ( SELECT column_default::bigint FROM information_schema.columns WHERE table_schema='public' AND table_name='pluginkeyvaluestore' AND column_name='expireat' ) = 0 THEN ALTER TABLE pluginkeyvaluestore ALTER COLUMN expireat SET DEFAULT NULL; END IF; END$$;
-- phpMyAdmin SQL Dump -- version 4.6.5.2 -- https://www.phpmyadmin.net/ -- -- Servidor: 127.0.0.1 -- Tiempo de generación: 08-11-2017 a las 23:42:52 -- Versión del servidor: 10.1.21-MariaDB -- Versión de PHP: 5.6.30 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de datos: `cartilla_educacion` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `Datos personales` -- CREATE TABLE `datos personales` ( `pri_ape` varchar(24) NOT NULL, `seg_ape` varchar(24) NOT NULL, `nom` varchar(35) NOT NULL, `curp` varchar(18) NOT NULL, `grup` varchar(10) NOT NULL, `turno` varchar(15) NOT NULL, `nom_esc` varchar(60) NOT NULL, `cct` varchar(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
CREATE PROCEDURE [dbo].[spCustomers_GetAll] AS BEGIN SET NOCOUNT ON; SELECT [CustomerId], [FirstName], [LastName], [FullName], [Address], [Phone], [Email], [PayCentreId], [UploadReceipts] FROM [dbo].[Customers] END
-- menu admin UPDATE `sys_menu_admin` SET `name` = 'Custom RSS', `title` = '_crss_ami_custom_rss', `icon` = 'rss' WHERE `name` = 'Custom RSS Moderation'; -- page biulder DELETE FROM `sys_page_compose` WHERE `Page` = 'profile' AND `Desc` = 'Custom RSS block'; SET @PageKey1 = (SELECT MAX(`order`) FROM `sys_page_compose` WHERE `Page` = 'profile' AND `Column`=2); INSERT INTO `sys_page_compose` (`ID`, `Page`, `PageWidth`, `Desc`, `Caption`, `Column`, `Order`, `Func`, `Content`, `DesignBox`, `ColWidth`, `Visible`, `MinWidth`) VALUES (NULL, 'profile', '1140px', 'Custom RSS block', '_crss_Custom_Feeds', 2, @PageKey1+1, 'PHP', 'return BxDolService::call(''custom_rss'', ''gen_custom_rss_block'', array($this->oProfileGen->_iProfileID));', 0, 71.9, 'non,memb', 0); -- site stats DELETE FROM `sys_stat_site` WHERE `Name` = 'crss'; SET @iStatSiteOrder := (SELECT `StatOrder` + 1 FROM `sys_stat_site` WHERE 1 ORDER BY `StatOrder` DESC LIMIT 1); INSERT INTO `sys_stat_site` VALUES(NULL, 'crss', 'crss_ss', '', 'SELECT COUNT(`ID`) FROM `[db_prefix]_main` WHERE `Status`=''active''', 'modules/boonex/custom_rss/post_mod_crss.php', 'SELECT COUNT(`ID`) FROM `[db_prefix]_main` WHERE `Status`=''passive''', 'rss', @iStatSiteOrder); -- update module version UPDATE `sys_modules` SET `version` = '1.1.0' WHERE `uri` = 'custom_rss' AND `version` = '1.0.9';
-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64) -- -- Host: localhost Database: db_proyecto -- ------------------------------------------------------ -- Server version 5.7.33-log /*!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 */; /*!50503 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 `tipo_notificacions` -- DROP TABLE IF EXISTS `tipo_notificacions`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `tipo_notificacions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `nombre` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `tipo_notificacions` -- LOCK TABLES `tipo_notificacions` WRITE; /*!40000 ALTER TABLE `tipo_notificacions` DISABLE KEYS */; INSERT INTO `tipo_notificacions` VALUES (1,'EVENTO APROBADO',NULL,NULL),(2,'EVENTO DESCARTADO',NULL,NULL),(3,'PERDIDA DOCUMENTO',NULL,NULL),(4,'CAMBIO DOCUMENTO',NULL,NULL),(5,'ACTUALIZACION INFORMACION',NULL,NULL); /*!40000 ALTER TABLE `tipo_notificacions` 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 2021-04-14 22:55:32
ALTER TABLE "public"."users" ALTER COLUMN "username" DROP NOT NULL;
CREATE OR REPLACE VIEW OSP$BUDGET_JUSTIFICATION ( PROPOSAL_NUMBER, VERSION_NUMBER, BUDGET_JUSTIFICATION, UPDATE_TIMESTAMP, UPDATE_USER ) AS select null,null,null,null,null from dual;
WITH source AS ( SELECT * FROM {{ source('gitlab_dotcom', 'todos') }} QUALIFY ROW_NUMBER() OVER (PARTITION BY id ORDER BY _uploaded_at DESC) = 1 ), renamed AS ( SELECT id::NUMBER AS todo_id, user_id::NUMBER AS user_id, project_id::NUMBER AS project_id, target_id::NUMBER AS target_id, target_type::VARCHAR AS target_type, author_id::NUMBER AS author_id, action::NUMBER AS todo_action_id, state::VARCHAR AS todo_state, created_at::TIMESTAMP AS created_at, updated_at::TIMESTAMP AS updated_at, note_id::NUMBER AS note_id, commit_id::VARCHAR AS commit_id, group_id::NUMBER AS group_id FROM source ) SELECT * FROM renamed
CREATE DATABASE IF NOT EXISTS testdb ; USE testdb; DROP TABLE IF EXISTS sign_product; CREATE TABLE sign_product ( id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT, code VARCHAR(32) DEFAULT '' NOT NULL, full_name VARCHAR(128) DEFAULT '' NOT NULL, inventory INT DEFAULT 0 NOT NULL, gmt_create TIMESTAMP DEFAULT current_timestamp, gmt_update TIMESTAMP DEFAULT current_timestamp ON UPDATE current_timestamp ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; INSERT INTO sign_product (code, full_name, inventory) VALUES ('893341', '远见产品3号', 12); INSERT INTO sign_product (code, full_name, inventory) VALUES ('213324', '这是测试产品', 543); INSERT INTO sign_product (code, full_name, inventory) VALUES ('123873', '正式环境产品53', 76); INSERT INTO sign_product (code, full_name, inventory) VALUES ('678567', '招商银行限量', 9765);
CREATE TABLE REALESTATE ( ID VARCHAR(32) NOT NULL, POST_CODE VARCHAR(5), SURFACE DOUBLE PRECISION, PRICE DOUBLE PRECISION, PRICE_PER_M2 DOUBLE PRECISION, NUM_ROOMS SMALLINT, NUM_BED_ROOMS SMALLINT, PROPERTY_TYPE_AS_STRING VARCHAR(32), DETAIL_URL VARCHAR(2048), title VARCHAR(256), CONSTRAINT REALESTATE_PKEY PRIMARY KEY (ID) );
/* SQL script to initialize CZIDLO core database for CZIDLO versions 4.4 - 4.6 */ /* Drop Indexes */ DROP INDEX IF EXISTS DIGITALDOCUMENT_ENTITYID; DROP INDEX IF EXISTS DIGITALINSTANCE_DIGDOCID; DROP INDEX IF EXISTS LIBRARY_REGISTRARID; DROP INDEX IF EXISTS IEIDENTIFIER_VALUE; DROP INDEX IF EXISTS URNNBN_REGISTRARCODEDOCUMENTCODE; DROP INDEX IF EXISTS URNNBNRESERVED_REGISTRARCODEDOCUMENTCODE; DROP INDEX IF EXISTS URNNBN_PREDECESSOR; DROP INDEX IF EXISTS URNNBN_SUCCESSOR; DROP INDEX IF EXISTS URNNBN_PREDECESSOR_SUCCESSOR; /* Drop triggers */ /* Drop Tables */ DROP TABLE IF EXISTS DIGITALINSTANCE; DROP TABLE IF EXISTS REGISTRARSCOPEID; DROP TABLE IF EXISTS URNNBN; DROP TABLE IF EXISTS DIGITALDOCUMENT; DROP TABLE IF EXISTS CATALOGUE; DROP TABLE IF EXISTS DIGITALLIBRARY; DROP TABLE IF EXISTS URNNBNGENERATOR; DROP TABLE IF EXISTS URNNBNRESERVED; DROP TABLE IF EXISTS USER_REGISTRAR; DROP TABLE IF EXISTS REGISTRAR; DROP TABLE IF EXISTS ARCHIVER; DROP TABLE IF EXISTS IEIDENTIFIER; DROP TABLE IF EXISTS ORIGINATOR; DROP TABLE IF EXISTS PUBLICATION; DROP TABLE IF EXISTS SOURCEDOCUMENT; DROP TABLE IF EXISTS INTELECTUALENTITY; DROP TABLE IF EXISTS URNNBNSUCCESSORS; DROP TABLE IF EXISTS USERACCOUNT; DROP TABLE IF EXISTS CONTENT; DROP TABLE IF EXISTS URNNBN_RESOLVATION_LOG; /* Drop Sequences */ DROP SEQUENCE IF EXISTS SEQ_ARCHIVER; DROP SEQUENCE IF EXISTS SEQ_CATALOGUE; DROP SEQUENCE IF EXISTS SEQ_DIGITALDOCUMENT; DROP SEQUENCE IF EXISTS SEQ_DIGITALINSTANCE; DROP SEQUENCE IF EXISTS SEQ_DIGITALLIBRARY; DROP SEQUENCE IF EXISTS SEQ_INTELECTUALENTITY; DROP SEQUENCE IF EXISTS SEQ_USERACCOUNT; DROP SEQUENCE IF EXISTS SEQ_CONTENT; /* Create Sequences */ CREATE SEQUENCE SEQ_ARCHIVER; CREATE SEQUENCE SEQ_CATALOGUE; CREATE SEQUENCE SEQ_DIGITALDOCUMENT; CREATE SEQUENCE SEQ_DIGITALINSTANCE; CREATE SEQUENCE SEQ_DIGITALLIBRARY; CREATE SEQUENCE SEQ_INTELECTUALENTITY; CREATE SEQUENCE SEQ_USERACCOUNT; CREATE SEQUENCE SEQ_CONTENT; /* Create Tables */ CREATE TABLE ARCHIVER ( ID NUMERIC NOT NULL, CREATED TIMESTAMP NOT NULL, MODIFIED TIMESTAMP NOT NULL, NAME VARCHAR NOT NULL, DESCRIPTION VARCHAR, HIDDEN BOOLEAN DEFAULT false, PRIMARY KEY (ID) ) WITHOUT OIDS; CREATE TABLE CATALOGUE ( ID NUMERIC NOT NULL, REGISTRARID NUMERIC NOT NULL, CREATED TIMESTAMP NOT NULL, MODIFIED TIMESTAMP NOT NULL, NAME VARCHAR NOT NULL, DESCRIPTION VARCHAR, URLPREFIX VARCHAR NOT NULL, PRIMARY KEY (ID) ) WITHOUT OIDS; CREATE TABLE DIGITALDOCUMENT ( ID NUMERIC NOT NULL, INTELECTUALENTITYID NUMERIC NOT NULL, REGISTRARID NUMERIC NOT NULL, ARCHIVERID NUMERIC NOT NULL, CREATED TIMESTAMP NOT NULL, MODIFIED TIMESTAMP NOT NULL, FINANCEDFROM VARCHAR, CONTRACTNUMBER VARCHAR, FORMAT VARCHAR, FORMATVERSION VARCHAR, EXTENT VARCHAR, RESOLUTIONHORIZONTAL INT, RESOLUTIONVERTICAL INT, COMPRESSION VARCHAR, COMPRESSIONRATIO FLOAT, COLORMODEL VARCHAR, COLORDEPTH INT, ICCPROFILE VARCHAR, PICTUREWIDTH INT, PICTUREHEIGHT INT, PRIMARY KEY (ID) ) WITHOUT OIDS; CREATE TABLE DIGITALINSTANCE ( ID NUMERIC NOT NULL, DIGITALDOCUMENTID NUMERIC NOT NULL, DIGITALLIBRARYID NUMERIC NOT NULL, CREATED TIMESTAMP NOT NULL, DEACTIVATED TIMESTAMP, ACTIVE BOOLEAN NOT NULL, URL VARCHAR NOT NULL, FORMAT VARCHAR, ACCESSIBILITY VARCHAR, ACCESSRESTRICTION NUMERIC NOT NULL, PRIMARY KEY (ID) ) WITHOUT OIDS; CREATE TABLE DIGITALLIBRARY ( ID NUMERIC NOT NULL, REGISTRARID NUMERIC NOT NULL, CREATED TIMESTAMP NOT NULL, MODIFIED TIMESTAMP NOT NULL, NAME VARCHAR NOT NULL, DESCRIPTION VARCHAR, URL VARCHAR, PRIMARY KEY (ID) ) WITHOUT OIDS; CREATE TABLE IEIDENTIFIER ( INTELECTUALENTITYID NUMERIC NOT NULL, TYPE VARCHAR NOT NULL, IDVALUE VARCHAR NOT NULL, PRIMARY KEY (INTELECTUALENTITYID, TYPE) ) WITHOUT OIDS; CREATE TABLE INTELECTUALENTITY ( ID NUMERIC NOT NULL, CREATED TIMESTAMP NOT NULL, MODIFIED TIMESTAMP NOT NULL, ENTITYTYPE VARCHAR NOT NULL, DOCUMENTTYPE VARCHAR, DIGITALBORN BOOLEAN NOT NULL, OTHERORIGINATOR VARCHAR, DEGREEAWARDINGINSTITUTION VARCHAR, PRIMARY KEY (ID) ) WITHOUT OIDS; CREATE TABLE ORIGINATOR ( INTELECTUALENTITYID NUMERIC NOT NULL, ORIGINTYPE VARCHAR NOT NULL, ORIGINVALUE VARCHAR NOT NULL, PRIMARY KEY (INTELECTUALENTITYID) ) WITHOUT OIDS; CREATE TABLE PUBLICATION ( INTELECTUALENTITYID NUMERIC NOT NULL, PYEAR DECIMAL(4), PLACE VARCHAR, PUBLISHER VARCHAR, PRIMARY KEY (INTELECTUALENTITYID) ) WITHOUT OIDS; CREATE TABLE REGISTRAR ( ID NUMERIC NOT NULL, CODE VARCHAR NOT NULL UNIQUE, ALLOWEDREGISTRATIONMODEBYREGISTRAR BOOLEAN NOT NULL, ALLOWEDREGISTRATIONMODEBYRESOLVER BOOLEAN NOT NULL, ALLOWEDREGISTRATIONMODEBYRESERVATION BOOLEAN NOT NULL, PRIMARY KEY (ID) ) WITHOUT OIDS; CREATE TABLE REGISTRARSCOPEID ( REGISTRARID NUMERIC NOT NULL, DIGITALDOCUMENTID NUMERIC NOT NULL, TYPE VARCHAR NOT NULL, CREATED TIMESTAMP NOT NULL, MODIFIED TIMESTAMP NOT NULL, IDVALUE VARCHAR NOT NULL, PRIMARY KEY (REGISTRARID, DIGITALDOCUMENTID, TYPE), CONSTRAINT registrar_idType_idValue UNIQUE (REGISTRARID, TYPE, IDVALUE) ) WITHOUT OIDS; CREATE TABLE SOURCEDOCUMENT ( INTELECTUALENTITYID NUMERIC NOT NULL, TITLE VARCHAR, VOLUMETITLE VARCHAR, ISSUETITLE VARCHAR, CCNB VARCHAR, ISBN VARCHAR, ISSN VARCHAR, OTHERID VARCHAR, PUBLISHER VARCHAR, PUBLICATIONPLACE VARCHAR, PUBLICATIONYEAR NUMERIC(4), PRIMARY KEY (INTELECTUALENTITYID) ) WITHOUT OIDS; CREATE TABLE URNNBN ( DIGITALDOCUMENTID NUMERIC NOT NULL, RESERVED TIMESTAMP, REGISTERED TIMESTAMP NOT NULL, DEACTIVATED TIMESTAMP, REGISTRARCODE VARCHAR NOT NULL, DOCUMENTCODE VARCHAR NOT NULL, ACTIVE BOOLEAN NOT NULL, DEACTIVATIONNOTE VARCHAR, PRIMARY KEY (DIGITALDOCUMENTID), CONSTRAINT registrarCodeDocumentCode UNIQUE (REGISTRARCODE, DOCUMENTCODE) ) WITHOUT OIDS; CREATE TABLE URNNBNGENERATOR ( REGISTRARID NUMERIC NOT NULL, LASTDOCUMENTCODE VARCHAR DEFAULT '000000' NOT NULL, PRIMARY KEY (REGISTRARID) ) WITHOUT OIDS; CREATE TABLE URNNBNRESERVED ( REGISTRARID NUMERIC NOT NULL, DOCUMENTCODE VARCHAR NOT NULL, CREATED TIMESTAMP NOT NULL, REGISTRARCODE VARCHAR NOT NULL, PRIMARY KEY (REGISTRARID, DOCUMENTCODE) ) WITHOUT OIDS; CREATE TABLE URNNBNSUCCESSORS ( PREDECESSORREGCODE VARCHAR NOT NULL, PREDECESSORDOCCODE VARCHAR NOT NULL, SUCCESSORREGCODE VARCHAR NOT NULL, SUCCESSORDOCCODE VARCHAR NOT NULL, NOTE VARCHAR ) WITHOUT OIDS; CREATE TABLE USERACCOUNT ( ID NUMERIC NOT NULL, CREATED TIMESTAMP NOT NULL, MODIFIED TIMESTAMP NOT NULL, LOGIN VARCHAR NOT NULL UNIQUE, PASSHASH VARCHAR NOT NULL, PASSSALT VARCHAR NOT NULL, ISADMIN BOOLEAN DEFAULT 'false' NOT NULL, EMAIL VARCHAR NOT NULL, PRIMARY KEY (ID) ) WITHOUT OIDS; CREATE TABLE USER_REGISTRAR ( REGISTRARID NUMERIC NOT NULL, USERACCOUNTID NUMERIC NOT NULL, PRIMARY KEY (REGISTRARID, USERACCOUNTID) ) WITHOUT OIDS; CREATE TABLE CONTENT ( ID NUMERIC NOT NULL, LANGUAGE VARCHAR NOT NULL, NAME VARCHAR NOT NULL, CONTENT VARCHAR NOT NULL, PRIMARY KEY (ID), CONSTRAINT languageName UNIQUE (LANGUAGE, NAME) ) WITHOUT OIDS; /* Create Foreign Keys */ ALTER TABLE DIGITALDOCUMENT ADD FOREIGN KEY (ARCHIVERID) REFERENCES ARCHIVER (ID) ON UPDATE RESTRICT ON DELETE RESTRICT ; ALTER TABLE REGISTRAR ADD FOREIGN KEY (ID) REFERENCES ARCHIVER (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE DIGITALINSTANCE ADD FOREIGN KEY (DIGITALDOCUMENTID) REFERENCES DIGITALDOCUMENT (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE REGISTRARSCOPEID ADD FOREIGN KEY (DIGITALDOCUMENTID) REFERENCES DIGITALDOCUMENT (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE URNNBN ADD FOREIGN KEY (DIGITALDOCUMENTID) REFERENCES DIGITALDOCUMENT (ID) ON UPDATE RESTRICT ON DELETE SET NULL ; ALTER TABLE DIGITALINSTANCE ADD FOREIGN KEY (DIGITALLIBRARYID) REFERENCES DIGITALLIBRARY (ID) ON UPDATE RESTRICT ON DELETE RESTRICT ; ALTER TABLE DIGITALDOCUMENT ADD FOREIGN KEY (INTELECTUALENTITYID) REFERENCES INTELECTUALENTITY (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE IEIDENTIFIER ADD FOREIGN KEY (INTELECTUALENTITYID) REFERENCES INTELECTUALENTITY (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE ORIGINATOR ADD FOREIGN KEY (INTELECTUALENTITYID) REFERENCES INTELECTUALENTITY (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE PUBLICATION ADD FOREIGN KEY (INTELECTUALENTITYID) REFERENCES INTELECTUALENTITY (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE SOURCEDOCUMENT ADD FOREIGN KEY (INTELECTUALENTITYID) REFERENCES INTELECTUALENTITY (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE CATALOGUE ADD FOREIGN KEY (REGISTRARID) REFERENCES REGISTRAR (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE DIGITALDOCUMENT ADD FOREIGN KEY (REGISTRARID) REFERENCES REGISTRAR (ID) ON UPDATE RESTRICT ON DELETE RESTRICT ; ALTER TABLE DIGITALLIBRARY ADD FOREIGN KEY (REGISTRARID) REFERENCES REGISTRAR (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE REGISTRARSCOPEID ADD FOREIGN KEY (REGISTRARID) REFERENCES REGISTRAR (ID) ON UPDATE RESTRICT ON DELETE RESTRICT ; ALTER TABLE URNNBNGENERATOR ADD FOREIGN KEY (REGISTRARID) REFERENCES REGISTRAR (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE URNNBNRESERVED ADD FOREIGN KEY (REGISTRARID) REFERENCES REGISTRAR (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE USER_REGISTRAR ADD FOREIGN KEY (REGISTRARID) REFERENCES REGISTRAR (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; ALTER TABLE USER_REGISTRAR ADD FOREIGN KEY (USERACCOUNTID) REFERENCES USERACCOUNT (ID) ON UPDATE RESTRICT ON DELETE CASCADE ; /* Create Indexes */ CREATE INDEX DIGITALDOCUMENT_ENTITYID ON DIGITALDOCUMENT (INTELECTUALENTITYID); CREATE INDEX DIGITALINSTANCE_DIGDOCID ON DIGITALINSTANCE (DIGITALDOCUMENTID); CREATE INDEX DIGITALINSTANCE_URL ON DIGITALINSTANCE (URL); CREATE INDEX LIBRARY_REGISTRARID ON DIGITALLIBRARY (REGISTRARID); CREATE INDEX IEIDENTIFIER_VALUE ON IEIDENTIFIER (IDVALUE); CREATE INDEX REGISTRARSCOPEID_REGISTRARID_TYPE_VALUE ON REGISTRARSCOPEID (REGISTRARID, TYPE, IDVALUE); CREATE INDEX URNNBN_REGISTRARCODEDOCUMENTCODE ON URNNBN (REGISTRARCODE, DOCUMENTCODE); CREATE INDEX URNNBNRESERVED_REGISTRARCODEDOCUMENTCODE ON URNNBNRESERVED (REGISTRARCODE, DOCUMENTCODE); CREATE INDEX URNNBN_PREDECESSOR ON URNNBNSUCCESSORS (PREDECESSORREGCODE, PREDECESSORDOCCODE); CREATE INDEX URNNBN_SUCCESSOR ON URNNBNSUCCESSORS (SUCCESSORREGCODE, SUCCESSORDOCCODE); CREATE INDEX URNNBN_PREDECESSOR_SUCCESSOR ON URNNBNSUCCESSORS (PREDECESSORREGCODE, PREDECESSORDOCCODE, SUCCESSORREGCODE, SUCCESSORDOCCODE); /* Create initial administrator account admin:admin */ INSERT INTO USERACCOUNT(ID, CREATED, MODIFIED, LOGIN, PASSHASH, PASSSALT, ISADMIN, EMAIL) VALUES(nextval('SEQ_USERACCOUNT'), LOCALTIMESTAMP, LOCALTIMESTAMP, 'admin', '906c4a1d79fec34d4d7243ff9583fc823147a68ef4d5c9a315a122d060105f27', '[B@75b84c92', true, 'somone@somewhere.com'); /* Initialize content of panels "info" and "rules" for language version "cs", "en" */ INSERT INTO CONTENT(ID, LANGUAGE, NAME, CONTENT) VALUES (nextval('SEQ_CONTENT'), 'cs', 'info', ''); INSERT INTO CONTENT(ID, LANGUAGE, NAME, CONTENT) VALUES (nextval('SEQ_CONTENT'), 'en', 'info', ''); INSERT INTO CONTENT(ID, LANGUAGE, NAME, CONTENT) VALUES (nextval('SEQ_CONTENT'), 'cs', 'rules', ''); INSERT INTO CONTENT(ID, LANGUAGE, NAME, CONTENT) VALUES (nextval('SEQ_CONTENT'), 'en', 'rules', ''); /**************************************/ /* Statistics for URN:NBN assignments */ /**************************************/ /* cleanup */ DROP INDEX IF EXISTS urnnbn_registrar_code_year_month_active_idx; DROP TABLE IF EXISTS urnnbn_assignment_statistics_preprocessed; DROP VIEW IF EXISTS urnnbn_assignment_statistics_view; DROP FUNCTION IF EXISTS update_urnnbn_assignment_tg() CASCADE; DROP FUNCTION IF EXISTS update_urnnbn_assignment() CASCADE; DROP FUNCTION IF EXISTS update_urnnbn_assignment(VARCHAR, TIMESTAMP) CASCADE; DROP FUNCTION IF EXISTS update_urnnbn_assignment(VARCHAR, NUMERIC,NUMERIC, BOOLEAN) CASCADE; /* new functions (needed for immutable function for indecies) */ DROP FUNCTION IF EXISTS to_month(TIMESTAMP) CASCADE; DROP FUNCTION IF EXISTS to_year(TIMESTAMP) CASCADE; CREATE OR REPLACE FUNCTION to_month(TIMESTAMP) RETURNS NUMERIC AS $BODY$ SELECT to_number(to_char($1,'MM'),'99') $BODY$ LANGUAGE sql IMMUTABLE; CREATE OR REPLACE FUNCTION to_year(TIMESTAMP) RETURNS NUMERIC AS $BODY$ SELECT to_number(to_char($1,'YYYY'),'9999') $BODY$ LANGUAGE sql IMMUTABLE; /* create preprocessed table */ CREATE TABLE urnnbn_assignment_statistics_preprocessed ( registrarCode VARCHAR NOT NULL, year NUMERIC NOT NULL, month NUMERIC NOT NULL, active BOOLEAN NOT NULL, sum NUMERIC NOT NULL, PRIMARY KEY (registrarCode, year, month, active) ) WITHOUT OIDS; /* index for efficient view*/ CREATE INDEX urnnbn_registrar_code_year_month_active_idx ON urnnbn(registrarCode, to_year(registered), to_month(registered), active); /* view - source for data for preprocessd table */ CREATE OR REPLACE VIEW urnnbn_assignment_statistics_view AS SELECT registrarCode AS registrarCode, to_year(registered) AS year, to_month(registered) AS month, active AS active, count(*) AS sum FROM UrnNbn GROUP BY registrarCode, year, month, active; /* function to update preprocessed table record by registrarCode, year, month, activity */ CREATE OR REPLACE FUNCTION update_urnnbn_assignment(VARCHAR, NUMERIC, NUMERIC, BOOLEAN) RETURNS void AS $BODY$ BEGIN IF (EXISTS (SELECT sum FROM urnnbn_assignment_statistics_view WHERE registrarCode=$1 AND year=$2 AND month=$3 AND active=$4)) THEN IF (EXISTS (SELECT sum FROM urnnbn_assignment_statistics_preprocessed WHERE registrarCode=$1 AND year=$2 AND month=$3 AND active=$4)) THEN UPDATE urnnbn_assignment_statistics_preprocessed SET sum = (SELECT sum FROM urnnbn_assignment_statistics_view WHERE registrarCode=$1 AND year=$2 AND month=$3 AND active=$4) WHERE registrarCode=$1 AND year=$2 AND month=$3 AND active=$4; ELSE INSERT INTO urnnbn_assignment_statistics_preprocessed (SELECT * FROM urnnbn_assignment_statistics_view WHERE registrarCode=$1 AND year=$2 AND month=$3 AND active=$4); END IF; ELSE DELETE FROM urnnbn_assignment_statistics_preprocessed WHERE registrarCode=$1 AND year=$2 AND month=$3 AND active=$4; END IF; END; $BODY$ LANGUAGE plpgsql; /* function to update preprocessed table record by registrarCode, timestamp */ CREATE OR REPLACE FUNCTION update_urnnbn_assignment(VARCHAR, TIMESTAMP) RETURNS void AS $BODY$ BEGIN EXECUTE update_urnnbn_assignment($1, to_year($2), to_month($2),true); EXECUTE update_urnnbn_assignment($1, to_year($2), to_month($2),false); END; $BODY$ LANGUAGE plpgsql; /* function to update preprocessed table record after registrarScopeId change */ CREATE OR REPLACE FUNCTION update_urnnbn_assignment() RETURNS TRIGGER AS $BODY$ BEGIN IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN EXECUTE update_urnnbn_assignment(NEW.registrarCode, to_year(NEW.registered), to_year(NEW.registered),true); EXECUTE update_urnnbn_assignment(NEW.registrarCode, to_year(NEW.registered), to_year(NEW.registered),false); ELSIF (TG_OP = 'DELETE') THEN EXECUTE update_urnnbn_assignment(OLD.registrarCode, to_year(OLD.registered), to_year(OLD.registered),true); EXECUTE update_urnnbn_assignment(OLD.registrarCode, to_year(OLD.registered), to_year(OLD.registered),false); END IF; RETURN NULL; END; $BODY$ LANGUAGE plpgsql; /* triggers to update preprocessed table record after various changes */ CREATE TRIGGER update_urnnbn_assignment_tg AFTER INSERT OR UPDATE ON UrnNbn FOR EACH ROW EXECUTE PROCEDURE update_urnnbn_assignment(); /* initial filling table search_rsi_preprocessed */ INSERT INTO urnnbn_assignment_statistics_preprocessed (SELECT * FROM urnnbn_assignment_statistics_view); /**************************************/ /* Statistics for URN:NBN resolvations */ /**************************************/ /* cleanup */ DROP TABLE IF EXISTS urnnbn_resolvation_statistics; CREATE TABLE urnnbn_resolvation_statistics ( registrarCode VARCHAR NOT NULL, year NUMERIC NOT NULL, month NUMERIC NOT NULL, sum NUMERIC NOT NULL, PRIMARY KEY (registrarCode, year, month) ) WITHOUT OIDS;
DROP DATABASE IF EXISTS employee_DB; CREATE DATABASE employee_DB; USE employee_DB; DROP TABLE IF EXISTS department; DROP TABLE IF EXISTS role; DROP TABLE IF EXISTS employee; CREATE TABLE department ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) NOT NULL ); CREATE TABLE role ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(30) NOT NULL, salary DECIMAL(10,2) NOT NULL, department_id INT NOT NULL, foreign key(department_id) REFERENCES department(id) ); CREATE TABLE employee ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(30) NOT NULL, role_id INT NOT NULL, foreign key(role_id) REFERENCES role(id), manager_id INT, foreign key(manager_id) REFERENCES employee(id) );
-- We are declaring the return type to be queue_classic_jobs. -- This is ok since I am assuming that all of the users added queues will -- have identical columns to queue_classic_jobs. -- When QC supports queues with columns other than the default, we will have to change this. CREATE OR REPLACE FUNCTION lock_head(q_name varchar, top_boundary integer) RETURNS SETOF queue_classic_jobs AS $$ DECLARE unlocked bigint; relative_top integer; job_count integer; BEGIN -- The purpose is to release contention for the first spot in the table. -- The select count(*) is going to slow down dequeue performance but allow -- for more workers. Would love to see some optimization here... EXECUTE 'SELECT count(*) FROM ' || '(SELECT * FROM queue_classic_jobs ' || ' WHERE locked_at IS NULL' || ' AND q_name = ' || quote_literal(q_name) || ' LIMIT ' || quote_literal(top_boundary) || ') limited' INTO job_count; SELECT TRUNC(random() * (top_boundary - 1)) INTO relative_top; IF job_count < top_boundary THEN relative_top = 0; END IF; LOOP BEGIN EXECUTE 'SELECT id FROM queue_classic_jobs ' || ' WHERE locked_at IS NULL' || ' AND q_name = ' || quote_literal(q_name) || ' ORDER BY id ASC' || ' LIMIT 1' || ' OFFSET ' || quote_literal(relative_top) || ' FOR UPDATE NOWAIT' INTO unlocked; EXIT; EXCEPTION WHEN lock_not_available THEN -- do nothing. loop again and hope we get a lock END; END LOOP; RETURN QUERY EXECUTE 'UPDATE queue_classic_jobs ' || ' SET locked_at = (CURRENT_TIMESTAMP)' || ' WHERE id = $1' || ' AND locked_at is NULL' || ' RETURNING *' USING unlocked; RETURN; END; $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION lock_head(tname varchar) RETURNS SETOF queue_classic_jobs AS $$ BEGIN RETURN QUERY EXECUTE 'SELECT * FROM lock_head($1,10)' USING tname; END; $$ LANGUAGE plpgsql;
TRUNCATE TABLE public.recommendation_template_translation; -- -- Load public.recommendation_template_translation -- INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('LESS_SHOWER_TIME'), 'en', 'Spend 1 less minute in the shower and save <h1>{integer1}</h1> liters', 'You are spending 50% more time in the shower than others. You could spend just 2 less minutes per shower and save up to <h1>{integer2}</h1> liters a year. Why not use our shower timer?' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('LESS_SHOWER_TIME'), 'es', 'Reduce en un minut tu ducha y ahorra <h1>{integer1}</h1> litros', 'Estás gastando un 50% más de agua en la ducha que otrοs. Reduciendo tu ducha en dos minutos puedes ahorrar <h1>{integer2}</h1> litros en un año. ¿Por qué no usar un contador en la ducha?' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('LOWER_TEMPERATURE'), 'en', 'You could save <h1>{currency1}</h1> if you used a bit less hot water in the shower', 'You are using a bit more hot water in the shower than others. If you reduced your shower temperature by 2 degrees you would save up to <h1>{currency2}</h1> in a year! Do you want us to remind you next time you take a shower?' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('LOWER_TEMPERATURE'), 'es', 'Puedes ahorrar <h1>{currency1}</h1> si usas agua menos caliente en la ducha', 'Estás utilizando agua más caliente que otros. ¡Reduciendo la temperatura de tu ducha en 2 grados ahorrarás <h1>{currency2}</h1> en un año! ¿Quiéres que te lo recordemos la próxima vez que te duches?' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('LOWER_FLOW'), 'en', 'Reduce the water flow in the shower and save <h1>{integer1}</h1> liters', 'You can slightly reduce the flow of water when you take a shower, and save up to <h1>{integer2}</h1> liters in a year!' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('LOWER_FLOW'), 'es', 'Reduce el caudal de agua de tu ducha y ahorra <h1>{integer1}</h1> litros', '¡Puedes reducir un poco el caudal de tu ducha y ahorrar hasta <h1>{integer2}</h1> litros en un año!' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('CHANGE_SHOWERHEAD'), 'en', 'Change your showerhead and save <h1>{integer1}</h1> liters', 'Why not change your shower-head with a more efficient one? It could save you up to <h1>{integer2}</h1> liters a year. The new shower head will provide you with an equally enjoyable shower. Do you want to find out more?' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('CHANGE_SHOWERHEAD'), 'es', 'Renueva el teléfono de la ducha y ahorra <h1>{integer1}</h1> litros', '¿Por qué no renovar el teléfono de la ducha con una más eficiente? Puedes ahorrar hasta <h1>{integer2}</h1> litros al año. Los nuevos modelos proporcionan una sensación de ducha similar pero con un menor consumo.' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('CHANGE_SHAMPOO'), 'en', 'Have you considered changing your shampoo?', 'You are using <h1>{integer1}</h1>% more water than others. You may be using a shampoo or wash that foams excessively and is difficult to rinse. This does not mean it works better than others, but just that it leads to more water use. Perhaps try and use another product, easier to rinse, and more water friendly.' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('CHANGE_SHAMPOO'), 'es', '¿Has considerado cambiar de champú?', 'Estás consumiendo un <h1>{integer1}</h1>% más de agua que. Puede que estés utilizando demasiado champú o gel alargando así tu ducha. Puedes probar a usar otro que sea más sencillo de aclarar.' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('REDUCE_FLOW_WHEN_NOT_NEEDED'), 'en', 'When showering, reduce the water flow when you do not need it', 'Try turning the water off in the shower when you do not actually need it. You could save up to <h1>{integer1}</h1> liters per year this way! You might be surprised to find this quite comfortable, as the bathroom will already be quite warm. Try it once and see how easy it is!' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('REDUCE_FLOW_WHEN_NOT_NEEDED'), 'es', 'Cuando te duches, cierra el grifo si no necesitas agua', 'Intenta cerrar el grifo de la ducha cuando no lo necesitas. Puedes ahorrar <h1>{integer1}</h1> litros cada año! Te sorprenderás al comprobar que aún apagando el grifo, el baño se mantiene caliente y ahorras agua a la vez.' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A1_DAYOFWEEK_CONSUMPTION_INCR'), 'en', '{percent_change}% more than your {day_of_week} average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A1_DAYOFWEEK_CONSUMPTION_INCR'), 'es', '{percent_change}% more than your {day_of_week} average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A1_DAYOFWEEK_CONSUMPTION_DECR'), 'en', '{percent_change}% less than your {day_of_week} average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A1_DAYOFWEEK_CONSUMPTION_DECR'), 'es', '{percent_change}% less than your {day_of_week} average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A2_DAILY_CONSUMPTION_INCR'), 'en', '{percent_change}% more than your average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A2_DAILY_CONSUMPTION_INCR'), 'es', '{percent_change}% more than your average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A2_DAILY_CONSUMPTION_DECR'), 'en', '{percent_change}% less than your average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A2_DAILY_CONSUMPTION_DECR'), 'es', '{percent_change}% less than your average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_MORNING_CONSUMPTION_INCR'), 'en', '{percent_change}% increase in morning consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_MORNING_CONSUMPTION_INCR'), 'es', '{percent_change}% increase in morning consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_MORNING_CONSUMPTION_DECR'), 'en', '{percent_change}% decrease in morning consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_MORNING_CONSUMPTION_DECR'), 'es', '{percent_change}% decrease in morning consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_AFTERNOON_CONSUMPTION_INCR'), 'en', '{percent_change}% increase in afternoon consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_AFTERNOON_CONSUMPTION_INCR'), 'es', '{percent_change}% increase in afternoon consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_AFTERNOON_CONSUMPTION_DECR'), 'en', '{percent_change}% decrease in afternoon consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_AFTERNOON_CONSUMPTION_DECR'), 'es', '{percent_change}% decrease in afternoon consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_NIGHT_CONSUMPTION_INCR'), 'en', '{percent_change}% increase in night consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_NIGHT_CONSUMPTION_INCR'), 'es', '{percent_change}% increase in night consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_NIGHT_CONSUMPTION_DECR'), 'en', '{percent_change}% decrease in night consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A3_NIGHT_CONSUMPTION_DECR'), 'es', '{percent_change}% decrease in night consumption', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A4_CONSUMPTION_MAINLY_IN_MORNING'), 'en', 'Highest consumption during morning', '<i>morning</i>: {morning_percentage}% - <i>afternoon</i>: {afternoon_percentage}% - <i>night</i>: {night_percentage}%' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A4_CONSUMPTION_MAINLY_IN_MORNING'), 'es', 'Highest consumption during morning', '<i>morning</i>: {morning_percentage}% - <i>afternoon</i>: {afternoon_percentage}% - <i>night</i>: {night_percentage}%' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A4_CONSUMPTION_MAINLY_IN_AFTERNOON'), 'en', 'Highest consumption during afternoon', '<i>morning</i>: {morning_percentage}% - <i>afternoon</i>: {afternoon_percentage}% - <i>night</i>: {night_percentage}%' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A4_CONSUMPTION_MAINLY_IN_AFTERNOON'), 'es', 'Highest consumption during afternoon', '<i>morning</i>: {morning_percentage}% - <i>afternoon</i>: {afternoon_percentage}% - <i>night</i>: {night_percentage}%' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A4_CONSUMPTION_MAINLY_IN_NIGHT'), 'en', 'Highest consumption during night', '<i>morning</i>: {morning_percentage}% - <i>afternoon</i>: {afternoon_percentage}% - <i>night</i>: {night_percentage}%' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_A4_CONSUMPTION_MAINLY_IN_NIGHT'), 'es', 'Highest consumption during night', '<i>morning</i>: {morning_percentage}% - <i>afternoon</i>: {afternoon_percentage}% - <i>night</i>: {night_percentage}%' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B1_WEEKLY_CONSUMPTION_INCR'), 'en', '{percent_change}% more than your weekly average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B1_WEEKLY_CONSUMPTION_INCR'), 'es', '{percent_change}% more than your weekly average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B1_WEEKLY_CONSUMPTION_DECR'), 'en', '{percent_change}% less than your weekly average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B1_WEEKLY_CONSUMPTION_DECR'), 'es', '{percent_change}% less than your weekly average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B1_MONTHLY_CONSUMPTION_INCR'), 'en', '{percent_change}% more than your monthly average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B1_MONTHLY_CONSUMPTION_INCR'), 'es', '{percent_change}% more than your monthly average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B1_MONTHLY_CONSUMPTION_DECR'), 'en', '{percent_change}% less than your monthly average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B1_MONTHLY_CONSUMPTION_DECR'), 'es', '{percent_change}% less than your monthly average', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B2_WEEKLY_PREV_CONSUMPTION_INCR'), 'en', '{percent_change}% more than previous week', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B2_WEEKLY_PREV_CONSUMPTION_INCR'), 'es', '{percent_change}% more than previous week', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B2_WEEKLY_PREV_CONSUMPTION_DECR'), 'en', '{percent_change}% less than previous week', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B2_WEEKLY_PREV_CONSUMPTION_DECR'), 'es', '{percent_change}% less than previous week', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B2_MONTHLY_PREV_CONSUMPTION_INCR'), 'en', '{percent_change}% more than previous month', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B2_MONTHLY_PREV_CONSUMPTION_INCR'), 'es', '{percent_change}% more than previous month', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B2_MONTHLY_PREV_CONSUMPTION_DECR'), 'en', '{percent_change}% less than previous month', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B2_MONTHLY_PREV_CONSUMPTION_DECR'), 'es', '{percent_change}% less than previous month', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B3_DAYOFWEEK_CONSUMPTION_PEAK'), 'en', '{day_of_week} is your peak day', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B3_DAYOFWEEK_CONSUMPTION_PEAK'), 'es', '{day_of_week} is your peak day', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B3_DAYOFWEEK_CONSUMPTION_LOW'), 'en', '{day_of_week} is your low day', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B3_DAYOFWEEK_CONSUMPTION_LOW'), 'es', '{day_of_week} is your low day', '{consumption}lt vs. the average {average_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B4_MORE_ON_WEEKEND'), 'en', '{percent_change}% more water on weekends', '{weekend_consumption}lt vs. {weekday_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B4_MORE_ON_WEEKEND'), 'es', '{percent_change}% more water on weekends', '{weekend_consumption}lt vs. {weekday_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B4_LESS_ON_WEEKEND'), 'en', '{percent_change}% less water on weekends', '{weekend_consumption}lt vs. {weekday_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B4_LESS_ON_WEEKEND'), 'es', '{percent_change}% less water on weekends', '{weekend_consumption}lt vs. {weekday_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B5_MONTHLY_CONSUMPTION_INCR'), 'en', '{percent_change}% more than same month last year', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B5_MONTHLY_CONSUMPTION_INCR'), 'es', '{percent_change}% more than same month last year', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B5_MONTHLY_CONSUMPTION_DECR'), 'en', '{percent_change}% less than same month last year', '{consumption}lt vs. {previous_consumption}lt' ); INSERT INTO public.recommendation_template_translation (template, locale, title, description) VALUES ( recommendation_template_from_name('INSIGHT_B5_MONTHLY_CONSUMPTION_DECR'), 'es', '{percent_change}% less than same month last year', '{consumption}lt vs. {previous_consumption}lt' );
SELECT count(*) FROM haggle_credit.item_sell; DELIMITER $$ CREATE PROCEDURE myFunction3() -- ⓐ myFunction이라는 이름의 프로시져 BEGIN DECLARE i INT DEFAULT 1; -- ⓑ i변수 선언, defalt값으로 1설정 WHILE (i <= 6002) DO -- ⓒ for문 작성(i가 1000이 될 때까지 반복) update haggle_credit.item_sell set is_user_no=floor(1+RAND()*4) where is_no = i; -- ⓓ 테이블에 i값 넣어주기 SET i = i + 1; -- ⓔ i값에 1더해주고 WHILE문 처음으로 이동 END WHILE; END$$ DELIMITER ; CALL myFunction3(); -- 프로시저 실행, 테이블에 1~1000까지 숫자 채워주기 SELECT * FROM haggle_credit.item_sell;
-- Find popular movies select * from title_ratings r, title_basics b where r.tconst = b.tconst and b.title_type = 'movie' and b.start_year = 2018 and r.num_votes > 1000 order by r.num_votes DESC;
library ErrorsAndMessaging version '1.0' define TestMessageInfo: Message(1, true, '100', 'Message', 'Test Message') define TestMessageWarn: Message(2, true, '200', 'Warning', 'You have been warned!') define TestMessageTrace: Message({3, 4, 5}, true, '300', 'Trace', 'This is a trace') define TestMessageError: Message(3 + 1, true, '400', 'Error', 'This is an error!') define TestMessageObfuscation: Message(Tuple { a: 1, b: Tuple { c: 2 } }, true, '400', 'Error', 'This source should be redacted')
USE [VipunenTK] GO /****** Object: View [dbo].[v_f_tab_koulutukseen_sijoittuneet_6v_lukio] Script Date: 4.5.2018 15:17:21 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER VIEW [dbo].[v_f_tab_koulutukseen_sijoittuneet_6v_lukio] AS Select [lkm_int2] = lkm ,[tilastovuosi] AS Tilastovuosi ,d17.tarkastelujakso AS Tarkastelujakso ,d17.tarkastelujakso2 AS 'Tarkastelujakso II' ,d16.sukupuoli AS Sukupuoli ,d2.aidinkieli_versio1 AS Äidinkieli ,d5.ika AS Ikä ,d5b.ika5v AS Ikäryhmä ,d5c.ika AS 'Ikäryhmä tutkinnon suoritusvuonna' ,d6.tutkintoryhma AS "Tutkintoryhmä" ,d7.koulutus AS "Pohjakoulutus" ,d8.koulutusaste2002 AS "Koul. sijoittuneen koulutusaste" ,d8.koulutusala2002 AS "Koul. sijoittuneen koulutusala" ,d8.opintoala2002 AS "Koul. sijoittuneen opintoala" ,d8.koulutus AS "Koul. sijoittuneen koulutusnimike" --,d3.kunta AS "Asuinkunta" --,d3.maakunta AS "Asuinmaakunta" --,d3.avi AS "Asuinpaikan AVI" --,d3.ely AS "Asuinpaikan ELY" --,d3.seutukunta AS "Asuinpaikan seutukunta" --,d3.suuralue AS "Asuinpaikan suuralue" --,d3.kuntaryhma AS "Asuinpaikan kuntaryhmä" --,d3.laani AS "Asuinpaikan lääni" --,d3.kielisuhde AS "Asuinpaikan kunnan kielisuhde" ,d4.maakunta AS "Koul. sijoittuneen opiskelumaakunta" --,d4.avi AS "Koul. sijoittuneen opiskelupaikan AVI" --,d4.ely AS "Koul. sijoittuneen opiskelupaikan ELY" --,d4.seutukunta AS "Koul. sijoittuneen opiskelupaikan seutukunta" --,d4.suuralue AS "Koul. sijoittuneen opiskelupaikan suuralue" --,d4.kuntaryhma AS "Koul. sijoittuneen opiskelupaikan kuntaryhmä" --,d4.laani AS "Koul. sijoittuneen opiskelupaikan lääni" ,d4b.maakunta AS "Tutkinnon suoritusmaakunta" --,d4b.avi AS "Tutk. suorituspaikan AVI" --,d4b.ely AS "Tutk. suorituspaikan ELY" --,d4b.seutukunta AS "Tutk. suorituspaikan seutukunta" --,d4b.suuralue AS "Tutk. suorituspaikan suuralue" --,d4b.kuntaryhma AS "Tutk. suorituspaikan kuntaryhmä" --,d4b.laani AS "Tutk. suorituspaikan lääni" ,d13.oppilaitos AS "Oppilaitos" ,d13.oppilaitostyyppi AS "Oppilaitostyyppi" --,d13.oppilaitoksen_omistajatyyppi AS "Oppil. omistajatyyppi" ,d13.opetuskieli AS "Oppil. opetuskieli" ,d13.koulutuksen_jarjestaja AS "Koulutuksen järjestäjä" --,d13.koulutuksen_jarjestajan_omistajatyyppi AS "Koul. järjestäjän omistajatyyppi" --,d13.koulutuksen_jarjestajan_kieli AS "Koul. järjestäjän kieli" --,d13.peruskoulujen_ryhmitys AS "Peruskoulujen ryhmitys" --,d13.peruskoulujen_vuosilks AS "Peruskoulujen vuosiluokat" ,d14.oppilaitos AS "Koul. sijoittuneen oppilaitos" --,d14.oppilaitostyyppi AS "Koul. sijoittuneen oppil.tyyppi" --,d14.oppilaitoksen_omistajatyyppi AS "Koul. sijoittuneen oppil. omistajatyyppi" --,d14.opetuskieli AS "Koul. sijoittuneen oppil. opetuskieli" ,d14.koulutuksen_jarjestaja AS "Koul. sijoittuneen koul. järjestäjä" --,d14.koulutuksen_jarjestajan_omistajatyyppi AS "Koul. sijoittuneen koul. järjestäjän omistajatyyppi" --,d14.koulutuksen_jarjestajan_kieli AS "Koul. sijoittuneen koul. järjestäjän kieli" --,d14.peruskoulujen_ryhmitys AS "Koul. sijoittuneen peruskoulujen ryhmitys" --,d14.peruskoulujen_vuosilks AS "Koul. sijoittuneen peruskoulujen vuosiluokat" ,d15.vuosiselite AS "Tutkinnon suoritusvuosi" ,d18.lukukausiselite AS "Tutkinnon suorituslukukausi" --,d19.vuosiselite AS "Syntymävuosi" --,d20.pohjoismaa AS "Pohjoismaan kansalainen" ,d21.kansalaisuus_versio1 AS "Kansalaisuus" --,d22.opetuskieli AS "Opetuskieli" ,d23.ammatillisen_koulutuksen_koulutuslaji AS "Tutkintotyyppi" ,d24.opetussuunnitelmaperusteinen_koulutus_nayttotutkintoon_valmistava_koulutus AS "Järjestämistapa" ,d25.nuorten_aikuisten_koulutus AS "Nuoret/aikuiset" --,d26.moninkertainen_haku AS "Koul. sijoittuneiden haut" --,d27.paaasiallinen_toiminta AS "Pääasiallinen toiminta" --,d28.ammattiasema AS "Ammattiasema" ,d29.koulutuksen_paattaneiden_toiminta AS "Koul. päättäneiden toiminta" --,d30.eumaa AS "EU-maan kansalainen" --,d31.etamaa AS "ETA-maan kansalainen" --kumulatiiviset kylla/ei ,d32a.kylla_ei as 'Opiskellut lukiokoulutuksessa'--opisk_amm_kyllaei_id ,d32b.kylla_ei as 'Opiskellut ammatillisessa peruskoulutuksessa'--opisk_amm_kyllaei_id ,d32c.kylla_ei as 'Opiskellut ammattitutkintokoulutuksessa'--opisk_amm_kyllaei_id ,d32d.kylla_ei as 'Opiskellut erikoisammattitutkintokoulutuksessa'--opisk_amm_kyllaei_id ,d32e.kylla_ei as 'Opiskellut ammatillisessa koulutuksessa'--opisk_amm_kyllaei_id ,d33.kylla_ei as 'Opiskellut ammattikorkeakoulutuksessa'--opisk_amk_kyllaei_id ,d34.kylla_ei as 'Opiskellut yliopistokoulutuksessa'--opisk_yo_kyllaei_id ,case when d33.kylla_ei_koodi=1 or d34.kylla_ei_koodi=1 then 'Kyllä' else 'Ei' end as 'Opiskellut korkeakoulutuksessa' ,d35.kylla_ei as 'Opiskellut kasvatusalat (amk)'--opisk_amk_koulala1_kyllaei_id ,d36.kylla_ei as 'Opiskellut humanistiset ja taidealat (amk)'--opisk_amk_koulala2_kyllaei_id ,d37.kylla_ei as 'Opiskellut yhteiskunnalliset alat (amk)'--opisk_amk_koulala3_kyllaei_id ,d38.kylla_ei as 'Opiskellut kauppa, hallinto ja oikeustieteet (amk)'--opisk_amk_koulala4_kyllaei_id ,d39.kylla_ei as 'Opiskellut luonnontieteet (amk)'--opisk_amk_koulala5_kyllaei_id ,d40.kylla_ei as 'Opiskellut tietojenkäsittely ja tietoliikenne (ICT) (amk)'--opisk_amk_koulala6_kyllaei_id ,d41.kylla_ei as 'Opiskellut tekniikan alat (amk)'--opisk_amk_koulala7_kyllaei_id ,d42.kylla_ei as 'Opiskellut maa- ja metsätalousalat (amk)'--opisk_amk_koulala8_kyllaei_id ,d43.kylla_ei as 'Opiskellut terveys- ja hyvinvointialat (amk)'--opisk_amk_koulala9_kyllaei_id ,d44.kylla_ei as 'Opiskellut palvelualat (amk)'--opisk_amk_koulala10_kyllaei_id ,d45.kylla_ei as 'Opiskellut kasvatusalat (yo)'--opisk_yo_koulala1_kyllaei_id ,d46.kylla_ei as 'Opiskellut humanistiset ja taidealat (yo)'--opisk_yo_koulala2_kyllaei_id ,d47.kylla_ei as 'Opiskellut yhteiskunnalliset alat (yo)'--opisk_yo_koulala3_kyllaei_id ,d48.kylla_ei as 'Opiskellut kauppa, hallinto ja oikeustieteet (yo)'--opisk_yo_koulala4_kyllaei_id ,d49.kylla_ei as 'Opiskellut luonnontieteet (yo)'--opisk_yo_koulala5_kyllaei_id ,d50.kylla_ei as 'Opiskellut tietojenkäsittely ja tietoliikenne (ICT) (yo)'--opisk_yo_koulala6_kyllaei_id ,d51.kylla_ei as 'Opiskellut tekniikan alat (yo)'--opisk_yo_koulala7_kyllaei_id ,d52.kylla_ei as 'Opiskellut maa- ja metsätalousalat (yo)'--opisk_yo_koulala8_kyllaei_id ,d53.kylla_ei as 'Opiskellut terveys- ja hyvinvointialat (yo)'--opisk_yo_koulala9_kyllaei_id ,d54.kylla_ei as 'Opiskellut palvelualat (yo)'--opisk_yo_koulala10_kyllaei_id ,d55.kylla_ei as 'Opiskellut vähintään kahdella koulutusalalla'--opisk_vah2_koulala_kyllaei_id ,d56.kylla_ei as 'Hakenut ammatilliseen koulutukseen'--haku_amm_kyllaei_id ,d57.kylla_ei as 'Hakenut ammattikorkeakoulutukseen'--haku_amk_kyllaei_id ,d58.kylla_ei as 'Hakenut yliopistokoulutukseen'--haku_yo_kyllaei_id ,case when haku_kk_eiopisk_kk=1 or opisk_kk=1 then 'Kyllä' else 'Ei' end as 'Hakenut korkeakoulutukseen' --kumulatiiviset mittarit ,[eihaku_kk_eiopisk] ,[eihaku_kk_eiopisk_kk_opisk_ta] ,[eihaku_kk_eiopisk_kk_opisk_lu] ,[eihaku_kk_eiopisk_kk_opisk_pk] ,[eihaku_kk_eiopisk_kk_opisk_at] ,[eihaku_kk_eiopisk_kk_opisk_eat] ,[haku_kk_eiopisk_kk] ,[haku_kk_eiopisk_kk_eiopisk_ta] ,[haku_kk_eiopisk_kk_opisk_ta] ,[haku_amk_eiopisk_kk] ,[haku_yo_eiopisk_kk] ,[haku_amkyo_eiopisk_kk] ,[opisk_kk] ,[opisk_kk_eiopisk_ta] ,[opisk_kk_opisk_ta] ,[opisk_vain_amk] ,[opisk_vain_yo] ,[opisk_amkyo] --ruotsi ,[tilastovuosi] AS Statistikår ,d17.tarkastelujakso_SV AS Granskningsperiod ,d16.sukupuoli_SV AS Kön ,d2.aidinkieli_versio1_SV AS Modersmål ,d5.ika_SV AS Ålder ,d5b.ika5v_SV AS Åldersgrupp ,d6.tutkintoryhma_SV AS Examenskategori ,d7.koulutus_SV AS Grundutbildning ,d8.koulutusaste2002_SV AS "Placering i utbildning – utbildningsnivå" ,d8.koulutusala2002_SV AS "Placering i utbildning – utbildningsområde" ,d8.opintoala2002_SV AS "Placering i utbildning – studieområde" ,d8.koulutus_SV AS "Placering i utbildning – utbildningsbenämning" ,d4.maakunta_SV AS "Placering i utbildning – landskapet för studieplatsen" ,d4b.maakunta_SV AS [Landskap där examen avlagts] ,d13.oppilaitos AS "Läroanstalt" ,d13.oppilaitostyyppi_SV AS Läroanstaltstyp ,d13.opetuskieli_SV AS [Läroanstaltens undervisningsspråk] ,d13.koulutuksen_jarjestaja_SV AS Utbildningsanordnare ,d14.oppilaitos_SV AS "Placering i utbildning – läroanstalt" ,d14.koulutuksen_jarjestaja_SV AS "Placering i utbildning – utbildningsanordnare" ,d15.vuosiselite_SV AS [År då utbildningen avlagts] ,d18.lukukausiselite_SV AS [Termin då utbildningen avlagts] ,d21.kansalaisuus_versio1_SV AS Medborgaskap ,d25.nuorten_aikuisten_koulutus_SV AS [Ungdoms-/vuxenutbildning] ,d29.koulutuksen_paattaneiden_toiminta_SV AS [Sysselsättning av utexaminerade] --englanti ,[tilastovuosi] AS [Statistical year] ,d17.tarkastelujakso_EN AS [Reference period] ,d16.sukupuoli_EN AS Gender ,d2.aidinkieli_versio1_EN AS [Mother tongue] ,d5.ika_EN AS Age ,d5b.ika5v_EN AS [Age group] ,d6.tutkintoryhma_EN AS [Degree/Qualification group] ,d7.koulutus_EN AS [Previous education] ,d8.koulutusaste2002_EN AS [Placed in further ed. - level of education] ,d8.koulutusala2002_EN AS [Placed in further ed. - field of education] ,d8.opintoala2002_EN AS [Placed in further ed. - subfield of education] ,d8.koulutus_EN AS [Placed in further ed. - name of education] ,d4.maakunta_EN AS [Placed in further ed. - region] ,d4b.maakunta_EN AS [Region of degree/qualification] ,d13.oppilaitos AS "Educational institution" ,d13.oppilaitostyyppi_EN AS [Type of institution] ,d13.opetuskieli_EN AS [Language of the institution] ,d13.koulutuksen_jarjestaja_EN AS [Education provider] ,d14.oppilaitos_EN AS [Placed in further ed. - ed. institution] ,d14.koulutuksen_jarjestaja_EN AS [Placed in further ed. - education provider] ,d15.vuosiselite_EN AS [Graduation year] ,d18.lukukausiselite_EN AS [Term of graduation] ,d21.kansalaisuus_versio1_EN AS Nationality ,d25.nuorten_aikuisten_koulutus_EN AS [Youth/adult education] ,d29.koulutuksen_paattaneiden_toiminta_EN AS [Completers' activity] --isced ,d8.iscle2011 as "Koul. sijoittuneen koulutusaste, taso 1" ,d8.Koulutusaste_taso2 as "Koul. sijoittuneen koulutusaste, taso 2" ,d8.iscfibroad2013 as "Koul. sijoittuneen koulutusala, taso 1" ,d8.iscfinarrow2013 as "Koul. sijoittuneen koulutusala, taso 2" ,d8.iscfi2013 as "Koul. sijoittuneen koulutusala, taso 3" ,d8.OKM_ohjauksen_ala as "Koul. sijoittuneen OKM ohjauksen ala, korkeak." ,d8.iscle2011_SV as "Placering i utbildning – utb.nivå, nivå 1" ,d8.Koulutusaste_taso2_SV as "Placering i utbildning – utb.nivå, nivå 2" ,d8.iscfibroad2013_SV as "Placering i utbildning – utb.område, nivå 1" ,d8.iscfinarrow2013_SV as "Placering i utbildning – utb.område, nivå 2" ,d8.iscfi2013_SV as "Placering i utbildning – utb.område, nivå 3" ,d8.OKM_ohjauksen_ala_SV as "Placering i utbildning – UKM-styrningsområde, högskolor" ,d8.iscle2011_EN as "Placed in further ed. - level of education, tier 1" ,d8.Koulutusaste_taso2_EN as "Placed in further ed. - level of education, tier 2" ,d8.iscfibroad2013_EN as "Placed in further ed. - field of education, tier 1" ,d8.iscfinarrow2013_EN as "Placed in further ed. - field of education, tier 2" ,d8.iscfi2013_EN as "Placed in further ed. - field of education, tier 3" ,d8.OKM_ohjauksen_ala_EN as "Placed in further ed. - field of ed., HE steering" ,d8.jarjestys_iscle2011 as jarj_isced_koulast1 ,d8.jarjestys_Koulutusaste_taso2 as jarj_isced_koulast2 ,d8.jarjestys_iscfibroad2013 as jarj_isced_koulala1 ,d8.jarjestys_iscfinarrow2013 as jarj_isced_koulala2 ,d8.jarjestys_iscfi2013 as jarj_isced_koulala3 ,d8.jarjestys_OKM_ohjauksen_ala as jarj_isced_okmohjaus1 --koodit ,d8.koulutusala2002_koodi as "Koodit Koulutusala 2002" ,d8.opintoala1995_koodi as "Koodit Koulutusala 1995" ,d8.opintoala2002_koodi as "Koodit Opintoala 2002" ,d8.koulutus_koodi as "Koodit Koulutusnimike" ,d8.koulutusaste2002_koodi as "Koodit Koulutusaste 2002" ,d14.koulutuksen_jarjestajakoodi as "Koodit Koul. sij. koul. järjestäjä" ,d14.oppilaitoskoodi as "Koodit Koul. sij. oppilaitos" ,d13.koulutuksen_jarjestajakoodi as "Koodit Koul. järjestäjä" ,d4b.maakunta_koodi as "Koodit Tutk. suor.maakunta" ,d4.maakunta_koodi as "Koodit Opiskelumaakunta" ,d8.iscle2011_koodi as "Koodit Koulutusaste, taso 1" ,d8.Koulutusaste_taso2_koodi as "Koodit Koulutusaste, taso 2" ,d8.iscfibroad2013_koodi as "Koodit Koulutusala, taso 1" ,d8.iscfinarrow2013_koodi as "Koodit Koulutusala, taso 2" ,d8.iscfi2013_koodi as "Koodit Koulutusala, taso 3" ,d8.OKM_ohjauksen_ala_koodi as "Koodit OKM ohjauksen ala, korkeak." --järjestys ,d17.jarjestys AS tarkastelujakso_jarjestys ,d16.jarjestys AS sukupuoli_jarjestys ,d2.jarjestys AS aidinkieli_jarjestys ,d5.jarjestys_ika ,d5b.jarjestys_ika5v ,d5c.jarjestys_ika as jarjestys_ika5v_suorv ,d6.jarjestys AS tutkintoryhma_jarjestys ,d7.jarjestys AS jarjestys_pohjakoulutus ,d8.jarjestys_koulutusaste2002 AS jarjestys_sij_koulutusaste2002 ,d8.jarjestys_koulutusala2002 AS jarjestys_sij_koulutusala2002 ,d8.jarjestys_opintoala2002 AS jarjestys_sij_opintoala ,d8.jarjestys AS jarjestys_sij_koulutusnimike --,d3.jarjestys AS alueluokitus_jarjestys --,d3.jarjestys_maakunta --,d3.jarjestys_avi --,d3.jarjestys_ely --,d3.jarjestys_seutukunta --,d3.jarjestys_suuralue --,d3.jarjestys_kuntaryhma --,d3.jarjestys_laani --,d3.jarjestys_kielisuhde ,d4.jarjestys_maakunta AS sijoittuneen_al_jarjestys_maakunta --,d4.jarjestys_avi AS sijoittuneen_al_jarjestys_avi --,d4.jarjestys_ely AS sijoittuneen_al_jarjestys_ely --,d4.jarjestys_seutukunta AS sijoittuneen_al_jarjestys_seutukunta --,d4.jarjestys_suuralue AS sijoittuneen_al_jarjestys_suuralue --,d4.jarjestys_kuntaryhma AS sijoittuneen_al_jarjestys_kuntaryhma --,d4.jarjestys_laani AS sijoittuneen_al_jarjestys_laani --,d4.jarjestys_kielisuhde AS sijoittuneen_al_jarjestys_kielisuhde ,d4b.jarjestys_maakunta AS tutksuor_al_jarjestys_maakunta --,d4b.jarjestys_avi AS tutksuor_al_jarjestys_avi --,d4b.jarjestys_ely AS tutksuor_al_jarjestys_ely --,d4b.jarjestys_seutukunta AS tutksuor_al_jarjestys_seutukunta --,d4b.jarjestys_suuralue AS tutksuor_al_jarjestys_suuralue --,d4b.jarjestys_kuntaryhma AS tutksuor_al_jarjestys_kuntaryhma --,d4b.jarjestys_laani AS tutksuor_al_jarjestys_laani --,d4b.jarjestys_kielisuhde AS tutksuor_al_jarjestys_kielisuhde --,d13.jarjestys_oppilaitos ,d13.jarjestys_oppilaitostyyppi --,d13.jarjestys_omistajatyyppi ,d13.jarjestys_opetuskieli --,d13.jarjestys_koulutuksen_jarjestaja --,d13.jarjestys_koulutuksen_jarjestajan_kieli --,d13.jarjestys_peruskoulujen_ryhmitys --,d13.jarjestys_peruskoulujen_vuosilks --,d14.jarjestys_oppilaitos AS sijoittuneen_jarjestys_oppilaitos --,d14.jarjestys_oppilaitostyyppi AS sijoittuneen_jarjestys_oppilaitostyyppi --,d14.jarjestys_omistajatyyppi AS sijoittuneen_jarjestys_omistajatyyppi --,d14.jarjestys_opetuskieli AS sijoittuneen_jarjestys_opetuskieli --,d14.jarjestys_koulutuksen_jarjestaja AS sijoittuneen_jarjestys_koulutuksen_jarjestaja --,d14.jarjestys_koulutuksen_jarjestajan_kieli AS sijoittuneen_jarjestys_koulutuksen_jarjestajan_kieli --,d14.jarjestys_peruskoulujen_ryhmitys AS sijoittuneen_peruskoulujen_ryhmitys --,d14.jarjestys_peruskoulujen_vuosilks AS sijoittuneen_peruskoulujen_vuosilks ,d18.lukukausi AS tutksuor_lukukausi_jarjestys --,d20.jarjestys AS pohjoismaa_jarjestys ,d21.jarjestys AS kansalaisuus_jarjestys --,d22.jarjestys AS opetuskieli_jarjestys ,d23.jarjestys AS tutktyyppi_jarjestys ,d24.jarjestys AS jarjestamistapa_jarjestys ,d25.jarjestys AS nuoraik_jarjestys --,d26.jarjestys AS monihaku_jarjestys --,d27.jarjestys AS paaastoim_jarjestys --,d28.jarjestys AS ammasema_jarjestys ,d29.jarjestys AS koul_paattaneiden_toiminta_jarjestys --,d30.jarjestys_eumaa --,d31.jarjestys_etamaa ,[lukiokoulutuksessa_ja_ammatillisessa_koulutuksessa_ke] AS "Koul. sijoittuneet lukiokoulutuksessa ja ammatillisessa koulutuksessa" ,[lukiokoulutuksessa_ke] AS "Koul. sijoittuneet lukiokoulutuksessa" ,[ammatillisessa_koulutuksessa_ke] AS "Koul. sijoittuneet ammatillisessa koulutuksessa" ,[ammattikorkeakoulutuksessa_ke] AS "Koul. sijoittuneet ammattikorkeakoulutuksessa" ,[yliopistokoulutuksessa_ke] AS "Koul. sijoittuneet yliopistokoulutuksessa" ,[ammattikorkeakoulutuksessa_ja_yliopistokoulutuksessa_ke] AS "Koul. sijoittuneet ammattikorkeakoulutuksessa ja yliopistokoulutuksessa" ,[toisen_asteen_ammatillisessa_koulutuksessa_ja_korkeakoulutuksessa_ke] AS "Koul. sijoittuneet toisen asteen ammatillisessa koulutuksessa ja korkeakoulutuksessa" ,[lukiokoulutuksessa_ja_ammatillisessa_koulutuksessa] ,[lukiokoulutuksessa] ,[ammatillisessa_koulutuksessa] ,[ammattikorkeakoulutuksessa] ,[yliopistokoulutuksessa] ,[ammattikorkeakoulutuksessa_ja_yliopistokoulutuksessa] ,[toisen_asteen_ammatillisessa_koulutuksessa_ja_korkeakoulutuksessa] FROM dbo.f_koulutukseen_sijoittuneet_6v LEFT JOIN d_aidinkieli_versio1 d2 ON d2.id = aidinkieli_versio_1_id LEFT JOIN d_sukupuoli d16 ON d16.id = sukupuoli_id LEFT JOIN d_tarkastelujakso d17 ON d17.id = tarkastelujakso_id LEFT JOIN d_alueluokitus d3 ON d3.id = asuinkunta_id LEFT JOIN d_alueluokitus d4 ON d4.id = koulutukseen_sijoittuneen_maakunta_id LEFT JOIN d_alueluokitus d4b ON d4b.id = pohjakoulutuksen_tutkinnon_suoritusmaakunta_id LEFT JOIN d_ika d5 ON d5.id = ika_1v_id LEFT JOIN d_ika d5b ON d5b.id = ika_5v_id LEFT JOIN d_ika d5c ON d5c.id = ika_1v_suorv_id LEFT JOIN d_tutkintoryhma d6 ON d6.id = tutkintoryhma_id LEFT JOIN d_koulutusluokitus d7 ON d7.id = pohjakoulutus_id LEFT JOIN d_koulutusluokitus d8 ON d8.id = koulutukseen_sijoittuneen_koulutus_id LEFT JOIN d_oppilaitoksen_taustatiedot d13 ON d13.id = pohjakoulutuksen_oppilaitos_id LEFT JOIN d_oppilaitoksen_taustatiedot d14 ON d14.id = koulutukseen_sijoittuneen_oppilaitos_id LEFT JOIN d_kausi d15 on d15.kausi_id = suoritusvuosi_id LEFT JOIN d_kausi d18 on d18.kausi_id = suorituslukukausi_id LEFT JOIN d_kausi d19 on d19.kausi_id = syntymavuosi_id LEFT JOIN d_pohjoismaa d20 on d20.id = pohjoismaa_id LEFT JOIN d_kansalaisuus_versio1 d21 on d21.id = kansalaisuus_id LEFT JOIN d_opetuskieli d22 on d22.id = pohjakoulutuksen_opetuskieli_id LEFT JOIN d_ammatillisen_koulutuksen_koulutuslaji d23 on d23.id = pohjakoulutuksen_koulutuslaji_id LEFT JOIN d_opetussuunnitelmaperusteinen_koulutus_nayttotutkintoon_valmistava_koulutus d24 on d24.id = pohjakoulutuksen_tutktav_id LEFT JOIN d_nuorten_aikuisten_koulutus d25 on d25.id = pohjakoulutuksen_aikoul_id LEFT JOIN d_moninkertainen_haku d26 on d26.id = moninkertainen_haku_id LEFT JOIN d_paaasiallinen_toiminta d27 on d27.id = paaasiallinen_toiminta_id LEFT JOIN d_ammattiasema d28 on d28.id = ammattiasema_id LEFT JOIN d_koulutuksen_paattaneiden_toiminta d29 on d29.id = koulutuksen_paattaneiden_toiminta_id LEFT JOIN d_valtio d30 on d30.id = eumaa_id LEFT JOIN d_valtio d31 on d31.id = etamaa_id LEFT JOIN d_kylla_ei d32a on d32a.id = opisk_lu_kyllaei_id LEFT JOIN d_kylla_ei d32b on d32b.id = opisk_amm_pk_kyllaei_id LEFT JOIN d_kylla_ei d32c on d32c.id = opisk_amm_at_kyllaei_id LEFT JOIN d_kylla_ei d32d on d32d.id = opisk_amm_eat_kyllaei_id LEFT JOIN d_kylla_ei d32e on d32e.id = opisk_amm_kyllaei_id LEFT JOIN d_kylla_ei d33 on d33.id = opisk_amk_kyllaei_id LEFT JOIN d_kylla_ei d34 on d34.id = opisk_yo_kyllaei_id LEFT JOIN d_kylla_ei d35 on d35.id = opisk_amk_koulala1_kyllaei_id LEFT JOIN d_kylla_ei d36 on d36.id = opisk_amk_koulala2_kyllaei_id LEFT JOIN d_kylla_ei d37 on d37.id = opisk_amk_koulala3_kyllaei_id LEFT JOIN d_kylla_ei d38 on d38.id = opisk_amk_koulala4_kyllaei_id LEFT JOIN d_kylla_ei d39 on d39.id = opisk_amk_koulala5_kyllaei_id LEFT JOIN d_kylla_ei d40 on d40.id = opisk_amk_koulala6_kyllaei_id LEFT JOIN d_kylla_ei d41 on d41.id = opisk_amk_koulala7_kyllaei_id LEFT JOIN d_kylla_ei d42 on d42.id = opisk_amk_koulala8_kyllaei_id LEFT JOIN d_kylla_ei d43 on d43.id = opisk_amk_koulala9_kyllaei_id LEFT JOIN d_kylla_ei d44 on d44.id = opisk_amk_koulala10_kyllaei_id LEFT JOIN d_kylla_ei d45 on d45.id = opisk_yo_koulala1_kyllaei_id LEFT JOIN d_kylla_ei d46 on d46.id = opisk_yo_koulala2_kyllaei_id LEFT JOIN d_kylla_ei d47 on d47.id = opisk_yo_koulala3_kyllaei_id LEFT JOIN d_kylla_ei d48 on d48.id = opisk_yo_koulala4_kyllaei_id LEFT JOIN d_kylla_ei d49 on d49.id = opisk_yo_koulala5_kyllaei_id LEFT JOIN d_kylla_ei d50 on d50.id = opisk_yo_koulala6_kyllaei_id LEFT JOIN d_kylla_ei d51 on d51.id = opisk_yo_koulala7_kyllaei_id LEFT JOIN d_kylla_ei d52 on d52.id = opisk_yo_koulala8_kyllaei_id LEFT JOIN d_kylla_ei d53 on d53.id = opisk_yo_koulala9_kyllaei_id LEFT JOIN d_kylla_ei d54 on d54.id = opisk_yo_koulala10_kyllaei_id LEFT JOIN d_kylla_ei d55 on d55.id = opisk_vah2_koulala_kyllaei_id LEFT JOIN d_kylla_ei d56 on d56.id = haku_amm_kyllaei_id LEFT JOIN d_kylla_ei d57 on d57.id = haku_amk_kyllaei_id LEFT JOIN d_kylla_ei d58 on d58.id = haku_yo_kyllaei_id WHERE tutkintoryhma_koodi = 2 AND [Tilastovuosi] <> '2008' GO USE [ANTERO]
SELECT assert(count(*), 35560, 'syntax-numeric_field_not_null-2') FROM so_posts WHERE so_posts ==> 'answer_count!=null';
-- 'удаление ненужных таблиц' SELECT 'удаление ненужных таблиц' AS info; DROP TABLE users_id_seq; DROP TABLE unloading_events_id_seq; DROP TABLE system_settings_id_seq; DROP TABLE soms_settings_id_seq; DROP TABLE settings_id_seq; DROP TABLE service_normatives_id_seq; DROP TABLE report_parameters_id_seq; DROP TABLE register_action_normatives_id_seq; DROP TABLE portal_tickets_id_seq; DROP TABLE offices_id_seq; DROP TABLE office_settings_id_seq; DROP TABLE office_checks_id_seq; DROP TABLE feedback_question_answers_id_seq; DROP TABLE feedback_forms_id_seq; DROP TABLE eq_tickets_id_seq; DROP TABLE documents_id_seq; DROP TABLE dictionaries_id_seq; DROP TABLE counters_id_seq; DROP TABLE conversation_fs_id_seq; DROP TABLE client_infos_id_seq; DROP TABLE classifiers_id_seq; DROP TABLE classifier_versions_id_seq; DROP TABLE changes_id_seq; DROP TABLE board_settings_id_seq; DROP TABLE activities_id_seq; ALTER TABLE offices DROP COLUMN asvz_office_id; ALTER TABLE offices DROP COLUMN code; ALTER TABLE offices DROP COLUMN use_central_playlist; ALTER TABLE board_settings DROP COLUMN hide_slot_and_window_number; ALTER TABLE office_settings DROP COLUMN hide_fio_in_prerecord_mode; ALTER TABLE office_settings DROP COLUMN hide_fio_in_live_mode; ALTER TABLE office_settings DROP COLUMN hide_passport_in_prerecord_mode; ALTER TABLE office_settings DROP COLUMN hide_passport_in_live_mode; ALTER TABLE office_settings DROP COLUMN terminal_inactivity_timeout; ALTER TABLE office_settings DROP COLUMN max_appointments_for_user; ALTER TABLE office_settings DROP COLUMN max_objects_count; ALTER TABLE office_settings DROP COLUMN hide_objects_count_in_talon; ALTER TABLE office_settings DROP COLUMN hide_object_type_in_prerecord_mode; ALTER TABLE office_settings DROP COLUMN hide_object_type_in_live_mode; SELECT 'таблица additional_service_times больше не нужна' AS info; DROP TABLE additional_service_times; SELECT 'таблица applicant_types больше не нужна' AS info; DROP TABLE applicant_types; SELECT 'таблица feedback_questions больше не нужна' AS info; DROP TABLE feedback_questions; SELECT 'таблица instance_types больше не нужна' AS info; DROP TABLE instance_types; SELECT 'таблица mortgage_types больше не нужна' AS info; DROP TABLE mortgage_types; SELECT 'таблица register_actions больше не нужна' AS info; DROP TABLE register_actions; SELECT 'таблица reports больше не нужна' AS info; DROP TABLE reports; SELECT 'таблица resources больше не нужна' AS info; DROP TABLE resources; SELECT 'таблица schema_migrations больше не нужна' AS info; DROP TABLE schema_migrations; SELECT 'таблица security_images больше не нужна' AS info; DROP TABLE security_images; SELECT 'таблица service_frgus больше не нужна' AS info; DROP TABLE service_frgus; SELECT 'таблица services больше не нужна' AS info; DROP TABLE services; SELECT 'таблица sources больше не нужна' AS info; DROP TABLE sources; SELECT 'таблица supplying_methods больше не нужна' AS info; DROP TABLE supplying_methods; -- обновляем все id, которые связаны с офисами SELECT 'обновляем все id, которые связаны с офисами' AS info; UPDATE offices SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE slots SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE users SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE board_settings SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE office_settings SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE day_schedules SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE activities SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE slots_counters SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE office_checks SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE counters SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE settings SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); UPDATE offices_resources SET office_id = office_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from offices') AS t1(id int)); -- обновляем все id, которые связаны с пользователями SELECT 'обновляем все id, которые связаны с users' AS info; UPDATE users SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from users') AS t1(id int)); UPDATE slots SET user_id = user_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from users') AS t1(id int)); UPDATE feedback_forms SET user_id = user_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from users') AS t1(id int)); UPDATE activities SET owner_id = owner_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from users') AS t1(id int)); UPDATE counters SET logged_in = logged_in + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from users') AS t1(id int)) WHERE logged_in IS NOT NULL; UPDATE resources_users SET user_id = user_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from users') AS t1(id int)); -- обновляем все id, которые связаны со slots SELECT 'обновляем все id, которые связаны со slots' AS info; UPDATE slots SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from slots') AS t1(id int)); UPDATE feedback_forms SET slot_id = slot_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from slots') AS t1(id int)); UPDATE slots_counters SET slot_id = slot_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from slots') AS t1(id int)); -- обновляем все id, которые связаны с conversation_fs SELECT 'обновляем все id, которые связаны с conversation_fs' AS info; UPDATE conversation_fs SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from conversation_fs') AS t1(id int)); -- обновляем все id, которые связаны с board_settings SELECT 'обновляем все id, которые связаны с board_settings' AS info; UPDATE board_settings SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from board_settings') AS t1(id int)); UPDATE creeping_line_patterns SET board_setting_id = board_setting_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from board_settings') AS t1(id int)); -- обновляем все id, которые связаны с creeping_line_patterns SELECT 'обновляем все id, которые связаны с creeping_line_patterns' AS info; UPDATE creeping_line_patterns SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from creeping_line_patterns') AS t1(id int)); -- обновляем все id, которые связаны с office_settings SELECT 'обновляем все id, которые связаны с office_settings' AS info; UPDATE office_settings SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from office_settings') AS t1(id int)); -- обновляем все id, которые связаны с portal_tickets SELECT 'обновляем все id, которые связаны с portal_tickets' AS info; UPDATE portal_tickets SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from portal_tickets') AS t1(id int)); -- обвновляем все id, которые связаны с day_schedules SELECT 'обвновляем все id, которые связаны с day_schedules' AS info; UPDATE day_schedules SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from day_schedules') AS t1(id int)); UPDATE day_schedule_resources SET day_schedule_id = day_schedule_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from day_schedules') AS t1(id int)); -- обвновляем все id, которые связаны с activities SELECT 'обвновляем все id, которые связаны с activities' AS info; UPDATE activities SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from activities') AS t1(id int)); -- обновляем все id, которые связаны с register_action_normatives SELECT 'обновляем все id, которые связаны с register_action_normatives' AS info; UPDATE register_action_normatives SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from register_action_normatives') AS t1(id int)); -- обвновляем все id, которые связаны с service_normatives SELECT 'обвновляем все id, которые связаны с service_normatives' AS info; UPDATE service_normatives SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from service_normatives') AS t1(id int)); -- обновляем все id, которые связаны с eq_tickets SELECT 'обновляем все id, которые связаны с eq_tickets' AS info; UPDATE eq_tickets SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from eq_tickets') AS t1(id int)); -- обновляем все id, которые связаны с unloading_events SELECT 'обновляем все id, которые связаны с unloading_events' AS info; UPDATE unloading_events SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from unloading_events') AS t1(id int)); -- обновляем все id, которые связаны с classifier_versions SELECT 'обновляем все id, которые связаны с classifier_versions' AS info; UPDATE classifier_versions SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from classifier_versions') AS t1(id int)); -- обновляем все id, которые связаны с feedback_forms SELECT 'обновляем все id, которые связаны с feedback_forms' AS info; UPDATE feedback_forms SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from feedback_forms') AS t1(id int)); -- обновляем все id, которые связаны с slots_counters SELECT 'обновляем все id, которые связаны с slots_counters' AS info; UPDATE slots_counters SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from slots_counters') AS t1(id int)); -- под вопросом -- обновляем все id, которые связаны с classifiers SELECT 'обновляем все id, которые связаны с classifiers' AS info; UPDATE classifiers SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from classifiers') AS t1(id int)); UPDATE classifier_versions SET classifier_id = classifier_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from classifiers') AS t1(id int)); -- обновляем все id, которые связаны с feedback_question_answers SELECT 'обновляем все id, которые связаны с feedback_question_answers' AS info; UPDATE feedback_question_answers SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from feedback_question_answers') AS t1(id int)); -- обновляем все id, которые связаны с changes SELECT 'обновляем все id, которые связаны с changes' AS info; UPDATE changes SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from changes') AS t1(id int)); -- обновляем все id, которые связаны с client_infos SELECT 'обновляем все id, которые связаны с client_infos' AS info; UPDATE client_infos SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from client_infos') AS t1(id int)); -- обновляем все id, которые связаны с office_checks SELECT 'обновляем все id, которые связаны с office_checks' AS info; UPDATE office_checks SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from office_checks') AS t1(id int)); -- обновляем все id, которые связаны с counters SELECT 'обновляем все id, которые связаны с counters' AS info; UPDATE counters SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from counters') AS t1(id int)); UPDATE slots SET counter_id = counter_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from counters') AS t1(id int)); UPDATE day_schedules SET schedulable_id = schedulable_id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from counters') AS t1(id int)); -- обновляем все id, которые связаны с report_parameters SELECT 'обновляем все id, которые связаны с report_parameters' AS info; UPDATE report_parameters SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from report_parameters') AS t1(id int)); -- обновляем все id, которые связаны с soms_settings SELECT 'обновляем все id, которые связаны с soms_settings' AS info; UPDATE soms_settings SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from soms_settings') AS t1(id int)); -- обновляем все id, которые связаны с system_settings SELECT 'обновляем все id, которые связаны с system_settings' AS info; UPDATE system_settings SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from system_settings') AS t1(id int)); -- обновляем все id, которые связаны с documents SELECT 'обновляем все id, которые связаны с documents' AS info; UPDATE documents SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from documents') AS t1(id int)); -- обновляем все id, которые связаны с settings SELECT 'обновляем все id, которые связаны с settings' AS info; UPDATE settings SET id = id + (SELECT * FROM dblink('dbname=mydb', 'select case when max(id) is null then 0 else max(id) end from settings') AS t1(id int)); -- удаление глобальных пользователей SELECT 'удаление глобальных пользователей' AS info; -- UPDATE users SET email=CONCAT('admin', CAST(id AS VARCHAR),'@admin.ru') WHERE email='admin@admin.ru'; UPDATE users SET state='deleted', email=CONCAT(CAST((select properties -> 'code' AS code FROM dictionaries WHERE id=(SELECT dictionary_id FROM offices LIMIT 1)) AS VARCHAR), email) WHERE roles_mask = 4 OR roles_mask = 8 OR roles_mask = 12; -- обновление email-ов пользователям с дублирующимися email-ами SELECT 'обновление email-ов пользователям с дублирующимися email-ами' AS info; UPDATE users SET email=CONCAT('a', CAST(id AS VARCHAR),CAST(email AS VARCHAR)) WHERE email IN (SELECT email FROM dblink('dbname=mydb', 'select email from users') AS t1(email VARCHAR)); -- удаление "плохих" талонов SELECT 'удаление "плохих" талонов' AS info; DELETE FROM slots WHERE created_at >= CURRENT_DATE AND status != 'ready' AND status != 'not_come' AND status != 'denial_service'; -- обновление типов офисов на центральные SELECT 'обновление типов офисов на центральные' AS info; UPDATE offices SET remote_instance=false; -- 'удаление ненужных таблиц' SELECT 'таблица dictionaries больше не нужна' AS info; DROP TABLE dictionaries; SELECT id, name, region FROM offices;
DROP TABLE IF EXISTS `test_104`;
DELIMITER / CREATE TABLE PMC_AWARD ( PMC_AWARD_ID DECIMAL(12,0) NOT NULL, PERSON_MASS_CHANGE_ID DECIMAL(12,0) NOT NULL, INVESTIGATOR CHAR(1) DEFAULT 'N' NOT NULL, KEY_STUDY_PERSON CHAR(1) DEFAULT 'N' NOT NULL, UNIT_CONTACT CHAR(1) DEFAULT 'N' NOT NULL, SPONSOR_CONTACT CHAR(1) DEFAULT 'N' NOT NULL, APPROVED_FOREIGN_TRAVEL CHAR(1) DEFAULT 'N' NOT NULL, UPDATE_USER VARCHAR(60) NOT NULL, UPDATE_TIMESTAMP DATE NOT NULL, OBJ_ID VARCHAR(36) NOT NULL, VER_NBR DECIMAL(8,0) DEFAULT 1 NOT NULL ) ENGINE InnoDB CHARACTER SET utf8 COLLATE utf8_bin / ALTER TABLE PMC_AWARD ADD CONSTRAINT PK_PMC_AWARD PRIMARY KEY (PMC_AWARD_ID) / DELIMITER ;
prompt --application/shared_components/user_interface/templates/list/links_list begin -- Manifest -- REGION TEMPLATE: LINKS_LIST -- Manifest End wwv_flow_api.component_begin ( p_version_yyyy_mm_dd=>'2021.04.15' ,p_release=>'21.1.0' ,p_default_workspace_id=>1830750307483664 ,p_default_application_id=>220 ,p_default_id_offset=>0 ,p_default_owner=>'ANTON' ); wwv_flow_api.create_list_template( p_id=>wwv_flow_api.id(559124881958343439) ,p_list_template_current=>'<li class="t-LinksList-item is-current #A03#"><a href="#LINK#" class="t-LinksList-link" #A02#><span class="t-LinksList-icon"><span class="t-Icon #ICON_CSS_CLASSES#"></span></span><span class="t-LinksList-label">#TEXT#</span><span class="t-LinksList-b' ||'adge">#A01#</span></a></li>' ,p_list_template_noncurrent=>'<li class="t-LinksList-item #A03#"><a href="#LINK#" class="t-LinksList-link" #A02#><span class="t-LinksList-icon"><span class="t-Icon #ICON_CSS_CLASSES#"></span></span><span class="t-LinksList-label">#TEXT#</span><span class="t-LinksList-badge">#A01#' ||'</span></a></li>' ,p_list_template_name=>'Links List' ,p_internal_name=>'LINKS_LIST' ,p_theme_id=>42 ,p_theme_class_id=>18 ,p_list_template_before_rows=>'<ul class="t-LinksList #COMPONENT_CSS_CLASSES#" id="#LIST_ID#">' ,p_list_template_after_rows=>'</ul>' ,p_before_sub_list=>'<ul class="t-LinksList-list">' ,p_after_sub_list=>'</ul>' ,p_sub_list_item_current=>'<li class="t-LinksList-item is-current #A03#"><a href="#LINK#" class="t-LinksList-link" #A02#><span class="t-LinksList-icon"><span class="t-Icon #ICON_CSS_CLASSES#"></span></span><span class="t-LinksList-label">#TEXT#</span><span class="t-LinksList-b' ||'adge">#A01#</span></a></li>' ,p_sub_list_item_noncurrent=>'<li class="t-LinksList-item #A03#"><a href="#LINK#" class="t-LinksList-link" #A02#><span class="t-LinksList-icon"><span class="t-Icon #ICON_CSS_CLASSES#"></span></span><span class="t-LinksList-label">#TEXT#</span><span class="t-LinksList-badge">#A01#' ||'</span></a></li>' ,p_item_templ_curr_w_child=>'<li class="t-LinksList-item is-current is-expanded #A03#"><a href="#LINK#" class="t-LinksList-link" #A02#><span class="t-LinksList-icon"><span class="t-Icon #ICON_CSS_CLASSES#"></span></span><span class="t-LinksList-label">#TEXT#</span><span class="t' ||'-LinksList-badge">#A01#</span></a>#SUB_LISTS#</li>' ,p_item_templ_noncurr_w_child=>'<li class="t-LinksList-item #A03#"><a href="#LINK#" class="t-LinksList-link" #A02#><span class="t-LinksList-icon"><span class="t-Icon #ICON_CSS_CLASSES#"></span></span><span class="t-LinksList-label">#TEXT#</span><span class="t-LinksList-badge">#A01#' ||'</span></a></li>' ,p_a01_label=>'Badge Value' ,p_a02_label=>'Link Attributes' ,p_a03_label=>'List Item CSS Classes' ,p_reference_id=>4070914341144059318 ); wwv_flow_api.component_end; end; /
SELECT ProductId, LEFT(ProductCategory, CHARINDEX(' >', ProductCategory) - 1) AS Category, RIGHT(ProductCategory, LEN(ProductCategory) - CHARINDEX('>', ProductCategory)) AS Subcategory, Title AS Product, ProductImageUrl As [Product Image] FROM Products
LOAD DATA LOCAL INFILE './././download/geonames/countries/FM.txt' INTO TABLE geoname CHARACTER SET 'UTF8' (geonameid, name, asciiname, alternatenames, latitude, longitude, fclass, fcode, country, cc2, admin1, admin2, admin3, admin4, population, elevation, gtopo30, timezone, moddate);
DROP DATABASE IF EXISTS employee_db; CREATE DATABASE employee_db; USE employee_db; CREATE TABLE department ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(30), PRIMARY KEY (id) ); CREATE TABLE role ( id INT NOT NULL AUTO_INCREMENT, title VARCHAR(30), salary DECIMAL(10,2), department_id INT, PRIMARY KEY (id) ); CREATE TABLE employee ( id INT NOT NULL AUTO_INCREMENT, first_name VARCHAR(30), last_name VARCHAR(30), role_id INT NOT NULL, manager_id INT, PRIMARY KEY (id) );
--CREATE SCHEMA hr; --GO --CREATE TABLE hr.candidates( -- id INT PRIMARY KEY IDENTITY, -- fullname VARCHAR(100) NOT NULL --); --CREATE TABLE hr.employees( -- id INT PRIMARY KEY IDENTITY, -- fullname VARCHAR(100) NOT NULL --); --INSERT INTO -- hr.candidates(fullname) --VALUES -- ('John Doe'), -- ('Lily Bush'), -- ('Peter Drucker'), -- ('Jane Doe'); --INSERT INTO -- hr.employees(fullname) --VALUES -- ('John Doe'), -- ('Jane Doe'), -- ('Michael Scott'), -- ('Jack Sparrow'); --SELECT -- c.id candidate_id, -- c.fullname candidate_name, -- e.id employee_id, -- e.fullname employee_name --FROM -- hr.candidates c -- INNER JOIN hr.employees e -- ON e.fullname = c.fullname; --SELECT -- c.id candidate_id, -- c.fullname candidate_name, -- e.id employee_id, -- e.fullname employee_name --FROM -- hr.candidates c -- LEFT JOIN hr.employees e -- ON e.fullname = c.fullname; --SELECT -- c.id candidate_id, -- c.fullname candidate_name, -- e.id employee_id, -- e.fullname employee_name --FROM -- hr.candidates c -- LEFT JOIN hr.employees e -- ON e.fullname = c.fullname --WHERE --e.id IS NULL; --SELECT -- c.id candidate_id, -- c.fullname candidate_name, -- e.id employee_id, -- e.fullname employee_name --FROM -- hr.candidates c -- RIGHT JOIN hr.employees e -- ON e.fullname = c.fullname; --SELECT -- c.id candidate_id, -- c.fullname candidate_name, -- e.id employee_id, -- e.fullname employee_name --FROM -- hr.candidates c -- RIGHT JOIN hr.employees e -- ON e.fullname = c.fullname --WHERE -- c.id IS NULL; SELECT c.id candidate_id, c.fullname candidate_name, e.id employee_id, e.fullname employee_name FROM hr.candidates c FULL JOIN hr.employees e ON e.fullname = c.fullname;
-- -- Setup database permissions -- GRANT SELECT, INSERT, UPDATE ON `zeprs`.* TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT SELECT ON `admin`.`form` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT SELECT ON `mail`.`accountuser` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`client_setting` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT SELECT ON `userdata`.`address` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`encounter` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`encounter_value_archive` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`newborneval` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`rule_definition_param` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`patientregistration` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`patient_status` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`patient` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON `zeprs`.`ultrasoundfetuseval` TO 'zeprs_web_user'@'localhost' IDENTIFIED BY '**password**'; GRANT ALL ON zeprs.* TO 'zeprsAdmin'@'localhost' IDENTIFIED BY '**password**'; GRANT ALL ON admin.* TO 'zeprsAdmin'@'localhost' IDENTIFIED BY '**password**'; -- -- Setup perms for zeprsdemo db -- GRANT SELECT,INSERT,UPDATE ON zeprsdemo.* TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT SELECT ON admin.form TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT SELECT ON mail.accountuser TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.client_setting TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT SELECT ON userdata.address TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.encounter TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.encounter_value_archive TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.newborneval TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.rule_definition_param TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.patientregistration TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.patient TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.patient_status TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT DELETE ON zeprsdemo.ultrasoundfetuseval TO 'zeprs_demo_user'@'localhost' IDENTIFIED BY '**password**'; GRANT ALL ON zeprsdemo.* TO 'zeprsAdmin'@'localhost' IDENTIFIED BY '**password**';
GRANT ALL ON *.* TO 'vaultuser'@'%' IDENTIFIED BY 'vaultpass'; GRANT GRANT OPTION ON *.* TO 'vaultuser'@'%'; CREATE DATABASE appdb; USE appdb; CREATE TABLE greetings ( id smallint unsigned not null auto_increment , phrase nvarchar(255) , constraint pk_greetings primary key (id) ); INSERT INTO greetings ( phrase ) VALUES ('Hello MySQL!');
-- -- Test foreign-data wrapper and server management. -- -- Clean up in case a prior regression run failed -- Suppress NOTICE messages when roles don't exist SET client_min_messages TO 'error'; DROP ROLE IF EXISTS foreign_data_user, regress_test_role, regress_test_role2, regress_test_role_super, regress_test_indirect, unpriviled_role; RESET client_min_messages; CREATE ROLE foreign_data_user LOGIN SUPERUSER; SET SESSION AUTHORIZATION 'foreign_data_user'; CREATE ROLE regress_test_role; CREATE ROLE regress_test_role2; CREATE ROLE regress_test_role_super SUPERUSER; CREATE ROLE regress_test_indirect; CREATE ROLE unprivileged_role; CREATE FOREIGN DATA WRAPPER dummy; COMMENT ON FOREIGN DATA WRAPPER dummy IS 'useless'; CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator; -- At this point we should have 2 built-in wrappers and no servers. SELECT fdwname, fdwhandler::regproc, fdwvalidator::regproc, fdwoptions FROM pg_foreign_data_wrapper ORDER BY 1, 2, 3; SELECT srvname, srvoptions FROM pg_foreign_server; SELECT * FROM pg_user_mapping; -- CREATE FOREIGN DATA WRAPPER CREATE FOREIGN DATA WRAPPER foo VALIDATOR bar; -- ERROR CREATE FOREIGN DATA WRAPPER foo; \dew CREATE FOREIGN DATA WRAPPER foo; -- duplicate DROP FOREIGN DATA WRAPPER foo; CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1'); \dew+ DROP FOREIGN DATA WRAPPER foo; CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1', testing '2'); -- ERROR CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1', another '2'); \dew+ DROP FOREIGN DATA WRAPPER foo; SET ROLE regress_test_role; CREATE FOREIGN DATA WRAPPER foo; -- ERROR RESET ROLE; CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator; \dew+ -- ALTER FOREIGN DATA WRAPPER ALTER FOREIGN DATA WRAPPER foo; -- ERROR ALTER FOREIGN DATA WRAPPER foo VALIDATOR bar; -- ERROR ALTER FOREIGN DATA WRAPPER foo NO VALIDATOR; \dew+ ALTER FOREIGN DATA WRAPPER foo OPTIONS (a '1', b '2'); ALTER FOREIGN DATA WRAPPER foo OPTIONS (SET c '4'); -- ERROR ALTER FOREIGN DATA WRAPPER foo OPTIONS (DROP c); -- ERROR ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD x '1', DROP x); \dew+ ALTER FOREIGN DATA WRAPPER foo OPTIONS (DROP a, SET b '3', ADD c '4'); \dew+ ALTER FOREIGN DATA WRAPPER foo OPTIONS (a '2'); ALTER FOREIGN DATA WRAPPER foo OPTIONS (b '4'); -- ERROR \dew+ SET ROLE regress_test_role; ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD d '5'); -- ERROR SET ROLE regress_test_role_super; ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD d '5'); \dew+ ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_test_role; -- ERROR ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_test_role_super; ALTER ROLE regress_test_role_super NOSUPERUSER; SET ROLE regress_test_role_super; ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD e '6'); -- ERROR RESET ROLE; \dew+ ALTER FOREIGN DATA WRAPPER foo RENAME TO foo1; \dew+ ALTER FOREIGN DATA WRAPPER foo1 RENAME TO foo; -- DROP FOREIGN DATA WRAPPER DROP FOREIGN DATA WRAPPER nonexistent; -- ERROR DROP FOREIGN DATA WRAPPER IF EXISTS nonexistent; \dew+ DROP ROLE regress_test_role_super; -- ERROR SET ROLE regress_test_role_super; DROP FOREIGN DATA WRAPPER foo; RESET ROLE; DROP ROLE regress_test_role_super; \dew+ CREATE FOREIGN DATA WRAPPER foo; CREATE SERVER s1 FOREIGN DATA WRAPPER foo; COMMENT ON SERVER s1 IS 'foreign server'; CREATE USER MAPPING FOR current_user SERVER s1; \dew+ \des+ \deu+ DROP FOREIGN DATA WRAPPER foo; -- ERROR SET ROLE regress_test_role; DROP FOREIGN DATA WRAPPER foo CASCADE; -- ERROR RESET ROLE; DROP FOREIGN DATA WRAPPER foo CASCADE; \dew+ \des+ \deu+ -- exercise CREATE SERVER CREATE SERVER s1 FOREIGN DATA WRAPPER foo; -- ERROR CREATE FOREIGN DATA WRAPPER foo OPTIONS ("test wrapper" 'true'); CREATE SERVER s1 FOREIGN DATA WRAPPER foo; CREATE SERVER s1 FOREIGN DATA WRAPPER foo; -- ERROR CREATE SERVER s2 FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b'); CREATE SERVER s3 TYPE 'oracle' FOREIGN DATA WRAPPER foo; CREATE SERVER s4 TYPE 'oracle' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b'); CREATE SERVER s5 VERSION '15.0' FOREIGN DATA WRAPPER foo; CREATE SERVER s6 VERSION '16.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b'); CREATE SERVER s7 TYPE 'oracle' VERSION '17.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b'); CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (foo '1'); -- ERROR CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (host 'localhost', dbname 's8db'); \des+ SET ROLE regress_test_role; CREATE SERVER t1 FOREIGN DATA WRAPPER foo; -- ERROR: no usage on FDW RESET ROLE; GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role; SET ROLE regress_test_role; CREATE SERVER t1 FOREIGN DATA WRAPPER foo; RESET ROLE; \des+ REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM regress_test_role; GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_indirect; SET ROLE regress_test_role; CREATE SERVER t2 FOREIGN DATA WRAPPER foo; -- ERROR RESET ROLE; GRANT regress_test_indirect TO regress_test_role; SET ROLE regress_test_role; CREATE SERVER t2 FOREIGN DATA WRAPPER foo; \des+ RESET ROLE; REVOKE regress_test_indirect FROM regress_test_role; -- ALTER SERVER ALTER SERVER s0; -- ERROR ALTER SERVER s0 OPTIONS (a '1'); -- ERROR ALTER SERVER s1 VERSION '1.0' OPTIONS (servername 's1'); ALTER SERVER s2 VERSION '1.1'; ALTER SERVER s3 OPTIONS ("tns name" 'orcl', port '1521'); GRANT USAGE ON FOREIGN SERVER s1 TO regress_test_role; GRANT USAGE ON FOREIGN SERVER s6 TO regress_test_role2 WITH GRANT OPTION; \des+ SET ROLE regress_test_role; ALTER SERVER s1 VERSION '1.1'; -- ERROR ALTER SERVER s1 OWNER TO regress_test_role; -- ERROR RESET ROLE; ALTER SERVER s1 OWNER TO regress_test_role; GRANT regress_test_role2 TO regress_test_role; SET ROLE regress_test_role; ALTER SERVER s1 VERSION '1.1'; ALTER SERVER s1 OWNER TO regress_test_role2; -- ERROR RESET ROLE; ALTER SERVER s8 OPTIONS (foo '1'); -- ERROR option validation ALTER SERVER s8 OPTIONS (connect_timeout '30', SET dbname 'db1', DROP host); SET ROLE regress_test_role; ALTER SERVER s1 OWNER TO regress_test_indirect; -- ERROR RESET ROLE; GRANT regress_test_indirect TO regress_test_role; SET ROLE regress_test_role; ALTER SERVER s1 OWNER TO regress_test_indirect; RESET ROLE; GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_indirect; SET ROLE regress_test_role; ALTER SERVER s1 OWNER TO regress_test_indirect; RESET ROLE; DROP ROLE regress_test_indirect; -- ERROR \des+ ALTER SERVER s8 RENAME to s8new; \des+ ALTER SERVER s8new RENAME to s8; -- DROP SERVER DROP SERVER nonexistent; -- ERROR DROP SERVER IF EXISTS nonexistent; \des SET ROLE regress_test_role; DROP SERVER s2; -- ERROR DROP SERVER s1; RESET ROLE; \des ALTER SERVER s2 OWNER TO regress_test_role; SET ROLE regress_test_role; DROP SERVER s2; RESET ROLE; \des CREATE USER MAPPING FOR current_user SERVER s3; \deu DROP SERVER s3; -- ERROR DROP SERVER s3 CASCADE; \des \deu -- CREATE USER MAPPING CREATE USER MAPPING FOR regress_test_missing_role SERVER s1; -- ERROR CREATE USER MAPPING FOR current_user SERVER s1; -- ERROR CREATE USER MAPPING FOR current_user SERVER s4; CREATE USER MAPPING FOR user SERVER s4; -- ERROR duplicate CREATE USER MAPPING FOR public SERVER s4 OPTIONS ("this mapping" 'is public'); CREATE USER MAPPING FOR user SERVER s8 OPTIONS (username 'test', password 'secret'); -- ERROR CREATE USER MAPPING FOR user SERVER s8 OPTIONS (user 'test', password 'secret'); ALTER SERVER s5 OWNER TO regress_test_role; ALTER SERVER s6 OWNER TO regress_test_indirect; SET ROLE regress_test_role; CREATE USER MAPPING FOR current_user SERVER s5; CREATE USER MAPPING FOR current_user SERVER s6 OPTIONS (username 'test'); CREATE USER MAPPING FOR current_user SERVER s7; -- ERROR CREATE USER MAPPING FOR public SERVER s8; -- ERROR RESET ROLE; ALTER SERVER t1 OWNER TO regress_test_indirect; SET ROLE regress_test_role; CREATE USER MAPPING FOR current_user SERVER t1 OPTIONS (username 'bob', password 'boo'); CREATE USER MAPPING FOR public SERVER t1; RESET ROLE; \deu -- ALTER USER MAPPING ALTER USER MAPPING FOR regress_test_missing_role SERVER s4 OPTIONS (gotcha 'true'); -- ERROR ALTER USER MAPPING FOR user SERVER ss4 OPTIONS (gotcha 'true'); -- ERROR ALTER USER MAPPING FOR public SERVER s5 OPTIONS (gotcha 'true'); -- ERROR ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (username 'test'); -- ERROR ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (DROP user, SET password 'public'); SET ROLE regress_test_role; ALTER USER MAPPING FOR current_user SERVER s5 OPTIONS (ADD modified '1'); ALTER USER MAPPING FOR public SERVER s4 OPTIONS (ADD modified '1'); -- ERROR ALTER USER MAPPING FOR public SERVER t1 OPTIONS (ADD modified '1'); RESET ROLE; \deu+ -- DROP USER MAPPING DROP USER MAPPING FOR regress_test_missing_role SERVER s4; -- ERROR DROP USER MAPPING FOR user SERVER ss4; DROP USER MAPPING FOR public SERVER s7; -- ERROR DROP USER MAPPING IF EXISTS FOR regress_test_missing_role SERVER s4; DROP USER MAPPING IF EXISTS FOR user SERVER ss4; DROP USER MAPPING IF EXISTS FOR public SERVER s7; CREATE USER MAPPING FOR public SERVER s8; SET ROLE regress_test_role; DROP USER MAPPING FOR public SERVER s8; -- ERROR RESET ROLE; DROP SERVER s7; \deu -- CREATE FOREIGN TABLE CREATE SCHEMA foreign_schema; CREATE SERVER s0 FOREIGN DATA WRAPPER dummy; CREATE FOREIGN TABLE ft1 (); -- ERROR CREATE FOREIGN TABLE ft1 () SERVER no_server; -- ERROR CREATE FOREIGN TABLE ft1 () SERVER s0 WITH OIDS; -- ERROR CREATE FOREIGN TABLE ft1 ( c1 integer OPTIONS ("param 1" 'val1') PRIMARY KEY, c2 text OPTIONS (param2 'val2', param3 'val3'), c3 date ) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); -- ERROR CREATE TABLE ref_table (id integer PRIMARY KEY); CREATE FOREIGN TABLE ft1 ( c1 integer OPTIONS ("param 1" 'val1') REFERENCES ref_table (id), c2 text OPTIONS (param2 'val2', param3 'val3'), c3 date ) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); -- ERROR DROP TABLE ref_table; CREATE FOREIGN TABLE ft1 ( c1 integer OPTIONS ("param 1" 'val1') NOT NULL, c2 text OPTIONS (param2 'val2', param3 'val3'), c3 date, UNIQUE (c3) ) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); -- ERROR CREATE FOREIGN TABLE ft1 ( c1 integer OPTIONS ("param 1" 'val1') NOT NULL, c2 text OPTIONS (param2 'val2', param3 'val3') CHECK (c2 <> ''), c3 date, CHECK (c3 BETWEEN '1994-01-01'::date AND '1994-01-31'::date) ) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); COMMENT ON FOREIGN TABLE ft1 IS 'ft1'; COMMENT ON COLUMN ft1.c1 IS 'ft1.c1'; \d+ ft1 \det+ CREATE INDEX id_ft1_c2 ON ft1 (c2); -- ERROR SELECT * FROM ft1; -- ERROR EXPLAIN SELECT * FROM ft1; -- ERROR -- ALTER FOREIGN TABLE COMMENT ON FOREIGN TABLE ft1 IS 'foreign table'; COMMENT ON FOREIGN TABLE ft1 IS NULL; COMMENT ON COLUMN ft1.c1 IS 'foreign column'; COMMENT ON COLUMN ft1.c1 IS NULL; ALTER FOREIGN TABLE ft1 ADD COLUMN c4 integer; ALTER FOREIGN TABLE ft1 ADD COLUMN c5 integer DEFAULT 0; ALTER FOREIGN TABLE ft1 ADD COLUMN c6 integer; ALTER FOREIGN TABLE ft1 ADD COLUMN c7 integer NOT NULL; ALTER FOREIGN TABLE ft1 ADD COLUMN c8 integer; ALTER FOREIGN TABLE ft1 ADD COLUMN c9 integer; ALTER FOREIGN TABLE ft1 ADD COLUMN c10 integer OPTIONS (p1 'v1'); ALTER FOREIGN TABLE ft1 ALTER COLUMN c4 SET DEFAULT 0; ALTER FOREIGN TABLE ft1 ALTER COLUMN c5 DROP DEFAULT; ALTER FOREIGN TABLE ft1 ALTER COLUMN c6 SET NOT NULL; ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 DROP NOT NULL; ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) USING '0'; -- ERROR ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10); ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET DATA TYPE text; ALTER FOREIGN TABLE ft1 ALTER COLUMN xmin OPTIONS (ADD p1 'v1'); -- ERROR ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2'), ALTER COLUMN c8 OPTIONS (ADD p1 'v1', ADD p2 'v2'); ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1); ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET STATISTICS 10000; ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET (n_distinct = 100); ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STATISTICS -1; ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STORAGE PLAIN; \d+ ft1 -- can't change the column type if it's used elsewhere CREATE TABLE use_ft1_column_type (x ft1); ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET DATA TYPE integer; -- ERROR DROP TABLE use_ft1_column_type; ALTER FOREIGN TABLE ft1 ADD PRIMARY KEY (c7); -- ERROR ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c9_check CHECK (c9 < 0) NOT VALID; ALTER FOREIGN TABLE ft1 ALTER CONSTRAINT ft1_c9_check DEFERRABLE; -- ERROR ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c9_check; ALTER FOREIGN TABLE ft1 DROP CONSTRAINT no_const; -- ERROR ALTER FOREIGN TABLE ft1 DROP CONSTRAINT IF EXISTS no_const; ALTER FOREIGN TABLE ft1 SET WITH OIDS; ALTER FOREIGN TABLE ft1 OWNER TO regress_test_role; ALTER FOREIGN TABLE ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@'); ALTER FOREIGN TABLE ft1 DROP COLUMN no_column; -- ERROR ALTER FOREIGN TABLE ft1 DROP COLUMN IF EXISTS no_column; ALTER FOREIGN TABLE ft1 DROP COLUMN c9; ALTER FOREIGN TABLE ft1 SET SCHEMA foreign_schema; ALTER FOREIGN TABLE ft1 SET TABLESPACE ts; -- ERROR ALTER FOREIGN TABLE foreign_schema.ft1 RENAME c1 TO foreign_column_1; ALTER FOREIGN TABLE foreign_schema.ft1 RENAME TO foreign_table_1; \d foreign_schema.foreign_table_1 -- alter noexisting table ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c4 integer; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c6 integer; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c7 integer NOT NULL; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c8 integer; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c9 integer; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c10 integer OPTIONS (p1 'v1'); ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c6 SET NOT NULL; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c7 DROP NOT NULL; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 TYPE char(10); ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 SET DATA TYPE text; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2'), ALTER COLUMN c8 OPTIONS (ADD p1 'v1', ADD p2 'v2'); ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1); ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP CONSTRAINT IF EXISTS no_const; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP CONSTRAINT ft1_c1_check; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 OWNER TO regress_test_role; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@'); ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP COLUMN IF EXISTS no_column; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP COLUMN c9; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 SET SCHEMA foreign_schema; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 RENAME c1 TO foreign_column_1; ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 RENAME TO foreign_table_1; -- Information schema SELECT * FROM information_schema.foreign_data_wrappers ORDER BY 1, 2; SELECT * FROM information_schema.foreign_data_wrapper_options ORDER BY 1, 2, 3; SELECT * FROM information_schema.foreign_servers ORDER BY 1, 2; SELECT * FROM information_schema.foreign_server_options ORDER BY 1, 2, 3; SELECT * FROM information_schema.user_mappings ORDER BY lower(authorization_identifier), 2, 3; SELECT * FROM information_schema.user_mapping_options ORDER BY lower(authorization_identifier), 2, 3, 4; SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; SELECT * FROM information_schema.foreign_tables ORDER BY 1, 2, 3; SELECT * FROM information_schema.foreign_table_options ORDER BY 1, 2, 3, 4; SET ROLE regress_test_role; SELECT * FROM information_schema.user_mapping_options ORDER BY 1, 2, 3, 4; SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5; DROP USER MAPPING FOR current_user SERVER t1; SET ROLE regress_test_role2; SELECT * FROM information_schema.user_mapping_options ORDER BY 1, 2, 3, 4; RESET ROLE; -- has_foreign_data_wrapper_privilege SELECT has_foreign_data_wrapper_privilege('regress_test_role', (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE'); SELECT has_foreign_data_wrapper_privilege('regress_test_role', 'foo', 'USAGE'); SELECT has_foreign_data_wrapper_privilege( (SELECT oid FROM pg_catalog.pg_roles WHERE rolname='regress_test_role'), (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE'); SELECT has_foreign_data_wrapper_privilege( (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE'); SELECT has_foreign_data_wrapper_privilege( (SELECT oid FROM pg_catalog.pg_roles WHERE rolname='regress_test_role'), 'foo', 'USAGE'); SELECT has_foreign_data_wrapper_privilege('foo', 'USAGE'); GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role; SELECT has_foreign_data_wrapper_privilege('regress_test_role', 'foo', 'USAGE'); -- has_server_privilege SELECT has_server_privilege('regress_test_role', (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE'); SELECT has_server_privilege('regress_test_role', 's8', 'USAGE'); SELECT has_server_privilege( (SELECT oid FROM pg_catalog.pg_roles WHERE rolname='regress_test_role'), (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE'); SELECT has_server_privilege( (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE'); SELECT has_server_privilege( (SELECT oid FROM pg_catalog.pg_roles WHERE rolname='regress_test_role'), 's8', 'USAGE'); SELECT has_server_privilege('s8', 'USAGE'); GRANT USAGE ON FOREIGN SERVER s8 TO regress_test_role; SELECT has_server_privilege('regress_test_role', 's8', 'USAGE'); REVOKE USAGE ON FOREIGN SERVER s8 FROM regress_test_role; GRANT USAGE ON FOREIGN SERVER s4 TO regress_test_role; DROP USER MAPPING FOR public SERVER s4; ALTER SERVER s6 OPTIONS (DROP host, DROP dbname); ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (DROP username); ALTER FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator; -- Privileges SET ROLE unprivileged_role; CREATE FOREIGN DATA WRAPPER foobar; -- ERROR ALTER FOREIGN DATA WRAPPER foo OPTIONS (gotcha 'true'); -- ERROR ALTER FOREIGN DATA WRAPPER foo OWNER TO unprivileged_role; -- ERROR DROP FOREIGN DATA WRAPPER foo; -- ERROR GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role; -- ERROR CREATE SERVER s9 FOREIGN DATA WRAPPER foo; -- ERROR ALTER SERVER s4 VERSION '0.5'; -- ERROR ALTER SERVER s4 OWNER TO unprivileged_role; -- ERROR DROP SERVER s4; -- ERROR GRANT USAGE ON FOREIGN SERVER s4 TO regress_test_role; -- ERROR CREATE USER MAPPING FOR public SERVER s4; -- ERROR ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (gotcha 'true'); -- ERROR DROP USER MAPPING FOR regress_test_role SERVER s6; -- ERROR RESET ROLE; GRANT USAGE ON FOREIGN DATA WRAPPER postgresql TO unprivileged_role; GRANT USAGE ON FOREIGN DATA WRAPPER foo TO unprivileged_role WITH GRANT OPTION; SET ROLE unprivileged_role; CREATE FOREIGN DATA WRAPPER foobar; -- ERROR ALTER FOREIGN DATA WRAPPER foo OPTIONS (gotcha 'true'); -- ERROR DROP FOREIGN DATA WRAPPER foo; -- ERROR GRANT USAGE ON FOREIGN DATA WRAPPER postgresql TO regress_test_role; -- WARNING GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role; CREATE SERVER s9 FOREIGN DATA WRAPPER postgresql; ALTER SERVER s6 VERSION '0.5'; -- ERROR DROP SERVER s6; -- ERROR GRANT USAGE ON FOREIGN SERVER s6 TO regress_test_role; -- ERROR GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role; CREATE USER MAPPING FOR public SERVER s6; -- ERROR CREATE USER MAPPING FOR public SERVER s9; ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (gotcha 'true'); -- ERROR DROP USER MAPPING FOR regress_test_role SERVER s6; -- ERROR RESET ROLE; REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM unprivileged_role; -- ERROR REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM unprivileged_role CASCADE; SET ROLE unprivileged_role; GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role; -- ERROR CREATE SERVER s10 FOREIGN DATA WRAPPER foo; -- ERROR ALTER SERVER s9 VERSION '1.1'; GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role; CREATE USER MAPPING FOR current_user SERVER s9; DROP SERVER s9 CASCADE; RESET ROLE; CREATE SERVER s9 FOREIGN DATA WRAPPER foo; GRANT USAGE ON FOREIGN SERVER s9 TO unprivileged_role; SET ROLE unprivileged_role; ALTER SERVER s9 VERSION '1.2'; -- ERROR GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role; -- WARNING CREATE USER MAPPING FOR current_user SERVER s9; DROP SERVER s9 CASCADE; -- ERROR RESET ROLE; -- Triggers CREATE FUNCTION dummy_trigger() RETURNS TRIGGER AS $$ BEGIN RETURN NULL; END $$ language plpgsql; CREATE TRIGGER trigtest_before_stmt BEFORE INSERT OR UPDATE OR DELETE ON foreign_schema.foreign_table_1 FOR EACH STATEMENT EXECUTE PROCEDURE dummy_trigger(); CREATE TRIGGER trigtest_after_stmt AFTER INSERT OR UPDATE OR DELETE ON foreign_schema.foreign_table_1 FOR EACH STATEMENT EXECUTE PROCEDURE dummy_trigger(); CREATE TRIGGER trigtest_before_row BEFORE INSERT OR UPDATE OR DELETE ON foreign_schema.foreign_table_1 FOR EACH ROW EXECUTE PROCEDURE dummy_trigger(); CREATE TRIGGER trigtest_after_row AFTER INSERT OR UPDATE OR DELETE ON foreign_schema.foreign_table_1 FOR EACH ROW EXECUTE PROCEDURE dummy_trigger(); CREATE CONSTRAINT TRIGGER trigtest_constraint AFTER INSERT OR UPDATE OR DELETE ON foreign_schema.foreign_table_1 FOR EACH ROW EXECUTE PROCEDURE dummy_trigger(); ALTER FOREIGN TABLE foreign_schema.foreign_table_1 DISABLE TRIGGER trigtest_before_stmt; ALTER FOREIGN TABLE foreign_schema.foreign_table_1 ENABLE TRIGGER trigtest_before_stmt; DROP TRIGGER trigtest_before_stmt ON foreign_schema.foreign_table_1; DROP TRIGGER trigtest_before_row ON foreign_schema.foreign_table_1; DROP TRIGGER trigtest_after_stmt ON foreign_schema.foreign_table_1; DROP TRIGGER trigtest_after_row ON foreign_schema.foreign_table_1; DROP FUNCTION dummy_trigger(); -- Table inheritance CREATE TABLE pt1 ( c1 integer NOT NULL, c2 text, c3 date ); CREATE FOREIGN TABLE ft2 () INHERITS (pt1) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); \d+ pt1 \d+ ft2 DROP FOREIGN TABLE ft2; \d+ pt1 CREATE FOREIGN TABLE ft2 ( c1 integer NOT NULL, c2 text, c3 date ) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); \d+ ft2 ALTER FOREIGN TABLE ft2 INHERIT pt1; \d+ pt1 \d+ ft2 CREATE TABLE ct3() INHERITS(ft2); CREATE FOREIGN TABLE ft3 ( c1 integer NOT NULL, c2 text, c3 date ) INHERITS(ft2) SERVER s0; \d+ ft2 \d+ ct3 \d+ ft3 -- add attributes recursively ALTER TABLE pt1 ADD COLUMN c4 integer; ALTER TABLE pt1 ADD COLUMN c5 integer DEFAULT 0; ALTER TABLE pt1 ADD COLUMN c6 integer; ALTER TABLE pt1 ADD COLUMN c7 integer NOT NULL; ALTER TABLE pt1 ADD COLUMN c8 integer; \d+ pt1 \d+ ft2 \d+ ct3 \d+ ft3 -- alter attributes recursively ALTER TABLE pt1 ALTER COLUMN c4 SET DEFAULT 0; ALTER TABLE pt1 ALTER COLUMN c5 DROP DEFAULT; ALTER TABLE pt1 ALTER COLUMN c6 SET NOT NULL; ALTER TABLE pt1 ALTER COLUMN c7 DROP NOT NULL; ALTER TABLE pt1 ALTER COLUMN c8 TYPE char(10) USING '0'; -- ERROR ALTER TABLE pt1 ALTER COLUMN c8 TYPE char(10); ALTER TABLE pt1 ALTER COLUMN c8 SET DATA TYPE text; ALTER TABLE pt1 ALTER COLUMN c1 SET STATISTICS 10000; ALTER TABLE pt1 ALTER COLUMN c1 SET (n_distinct = 100); ALTER TABLE pt1 ALTER COLUMN c8 SET STATISTICS -1; ALTER TABLE pt1 ALTER COLUMN c8 SET STORAGE EXTERNAL; \d+ pt1 \d+ ft2 -- drop attributes recursively ALTER TABLE pt1 DROP COLUMN c4; ALTER TABLE pt1 DROP COLUMN c5; ALTER TABLE pt1 DROP COLUMN c6; ALTER TABLE pt1 DROP COLUMN c7; ALTER TABLE pt1 DROP COLUMN c8; \d+ pt1 \d+ ft2 -- add constraints recursively ALTER TABLE pt1 ADD CONSTRAINT pt1chk1 CHECK (c1 > 0) NO INHERIT; ALTER TABLE pt1 ADD CONSTRAINT pt1chk2 CHECK (c2 <> ''); -- connoinherit should be true for NO INHERIT constraint SELECT relname, conname, contype, conislocal, coninhcount, connoinherit FROM pg_class AS pc JOIN pg_constraint AS pgc ON (conrelid = pc.oid) WHERE pc.relname = 'pt1' ORDER BY 1,2; -- child does not inherit NO INHERIT constraints \d+ pt1 \d+ ft2 DROP FOREIGN TABLE ft2; -- ERROR DROP FOREIGN TABLE ft2 CASCADE; CREATE FOREIGN TABLE ft2 ( c1 integer NOT NULL, c2 text, c3 date ) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); -- child must have parent's INHERIT constraints ALTER FOREIGN TABLE ft2 INHERIT pt1; -- ERROR ALTER FOREIGN TABLE ft2 ADD CONSTRAINT pt1chk2 CHECK (c2 <> ''); ALTER FOREIGN TABLE ft2 INHERIT pt1; -- child does not inherit NO INHERIT constraints \d+ pt1 \d+ ft2 -- drop constraints recursively ALTER TABLE pt1 DROP CONSTRAINT pt1chk1 CASCADE; ALTER TABLE pt1 DROP CONSTRAINT pt1chk2 CASCADE; -- NOT VALID case INSERT INTO pt1 VALUES (1, 'pt1'::text, '1994-01-01'::date); ALTER TABLE pt1 ADD CONSTRAINT pt1chk3 CHECK (c2 <> '') NOT VALID; \d+ pt1 \d+ ft2 -- VALIDATE CONSTRAINT need do nothing on foreign tables ALTER TABLE pt1 VALIDATE CONSTRAINT pt1chk3; \d+ pt1 \d+ ft2 -- OID system column ALTER TABLE pt1 SET WITH OIDS; \d+ pt1 \d+ ft2 ALTER TABLE ft2 SET WITHOUT OIDS; -- ERROR ALTER TABLE pt1 SET WITHOUT OIDS; \d+ pt1 \d+ ft2 -- changes name of an attribute recursively ALTER TABLE pt1 RENAME COLUMN c1 TO f1; ALTER TABLE pt1 RENAME COLUMN c2 TO f2; ALTER TABLE pt1 RENAME COLUMN c3 TO f3; -- changes name of a constraint recursively ALTER TABLE pt1 RENAME CONSTRAINT pt1chk3 TO f2_check; \d+ pt1 \d+ ft2 -- TRUNCATE doesn't work on foreign tables, either directly or recursively TRUNCATE ft2; -- ERROR TRUNCATE pt1; -- ERROR DROP TABLE pt1 CASCADE; -- IMPORT FOREIGN SCHEMA IMPORT FOREIGN SCHEMA s1 FROM SERVER s9 INTO public; -- ERROR IMPORT FOREIGN SCHEMA s1 LIMIT TO (t1) FROM SERVER s9 INTO public; --ERROR IMPORT FOREIGN SCHEMA s1 EXCEPT (t1) FROM SERVER s9 INTO public; -- ERROR IMPORT FOREIGN SCHEMA s1 EXCEPT (t1, t2) FROM SERVER s9 INTO public OPTIONS (option1 'value1', option2 'value2'); -- ERROR -- DROP FOREIGN TABLE DROP FOREIGN TABLE no_table; -- ERROR DROP FOREIGN TABLE IF EXISTS no_table; DROP FOREIGN TABLE foreign_schema.foreign_table_1; -- REASSIGN OWNED/DROP OWNED of foreign objects REASSIGN OWNED BY regress_test_role TO regress_test_role2; DROP OWNED BY regress_test_role2; DROP OWNED BY regress_test_role2 CASCADE; -- Cleanup DROP SCHEMA foreign_schema CASCADE; DROP ROLE regress_test_role; -- ERROR DROP SERVER t1 CASCADE; DROP USER MAPPING FOR regress_test_role SERVER s6; -- This test causes some order dependent cascade detail output, -- so switch to terse mode for it. \set VERBOSITY terse DROP FOREIGN DATA WRAPPER foo CASCADE; \set VERBOSITY default DROP SERVER s8 CASCADE; DROP ROLE regress_test_indirect; DROP ROLE regress_test_role; DROP ROLE unprivileged_role; -- ERROR REVOKE ALL ON FOREIGN DATA WRAPPER postgresql FROM unprivileged_role; DROP ROLE unprivileged_role; DROP ROLE regress_test_role2; DROP FOREIGN DATA WRAPPER postgresql CASCADE; DROP FOREIGN DATA WRAPPER dummy CASCADE; \c DROP ROLE foreign_data_user; -- At this point we should have no wrappers, no servers, and no mappings. SELECT fdwname, fdwhandler, fdwvalidator, fdwoptions FROM pg_foreign_data_wrapper; SELECT srvname, srvoptions FROM pg_foreign_server; SELECT * FROM pg_user_mapping;
/********************************************************************************* # Copyright 2014 Observational Health Data Sciences and Informatics # # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ********************************************************************************/ /************************ ####### # # ####### ###### ##### ###### # # ####### ### # # ## ## # # # # # # # # ## ## # # # # # # ##### ###### # # ###### #### # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # ###### # # # # # # # # ###### # # # # # # ##### ## ##### #### # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ####### # # ####### # ##### ###### # # ## ##### ### # # ##### ###### # # ###### #### script to create the required indexes within OMOP common data model, version 5.0 for SQL Server database last revised: 12 Oct 2014 author: Patrick Ryan description: These indices are considered a minimal requirement to ensure adequate performance of analyses. *************************/ /************************ Standardized vocabulary ************************/ CREATE UNIQUE CLUSTERED INDEX idx_concept_concept_id ON concept (concept_id ASC); CREATE INDEX idx_concept_code ON concept (concept_code ASC); CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC); CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC); CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC); CREATE UNIQUE CLUSTERED INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC); CREATE UNIQUE CLUSTERED INDEX idx_domain_domain_id ON domain (domain_id ASC); CREATE UNIQUE CLUSTERED INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC); CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC); CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC); CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC); CREATE UNIQUE CLUSTERED INDEX idx_relationship_rel_id ON relationship (relationship_id ASC); CREATE CLUSTERED INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC); CREATE CLUSTERED INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC); CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC); CREATE CLUSTERED INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC); CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC); CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC); CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC); CREATE CLUSTERED INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC); CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC); CREATE CLUSTERED INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC); CREATE CLUSTERED INDEX idx_attribute_definition_id ON attribute_definition (attribute_definition_id ASC); /************************** Standardized meta-data ***************************/ /************************ Standardized clinical data ************************/ CREATE UNIQUE CLUSTERED INDEX idx_person_id ON person (person_id ASC); CREATE CLUSTERED INDEX idx_observation_period_id ON observation_period (person_id ASC); CREATE CLUSTERED INDEX idx_specimen_person_id ON specimen (person_id ASC); CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC); CREATE CLUSTERED INDEX idx_death_person_id ON death (person_id ASC); CREATE CLUSTERED INDEX idx_visit_person_id ON visit_occurrence (person_id ASC); CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC); CREATE CLUSTERED INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC); CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC); CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC); CREATE CLUSTERED INDEX idx_drug_person_id ON drug_exposure (person_id ASC); CREATE INDEX idx_drug_concept_id ON drug_exposure (drug_concept_id ASC); CREATE INDEX idx_drug_visit_id ON drug_exposure (visit_occurrence_id ASC); CREATE CLUSTERED INDEX idx_device_person_id ON device_exposure (person_id ASC); CREATE INDEX idx_device_concept_id ON device_exposure (device_concept_id ASC); CREATE INDEX idx_device_visit_id ON device_exposure (visit_occurrence_id ASC); CREATE CLUSTERED INDEX idx_condition_person_id ON condition_occurrence (person_id ASC); CREATE INDEX idx_condition_concept_id ON condition_occurrence (condition_concept_id ASC); CREATE INDEX idx_condition_visit_id ON condition_occurrence (visit_occurrence_id ASC); CREATE CLUSTERED INDEX idx_measurement_person_id ON measurement (person_id ASC); CREATE INDEX idx_measurement_concept_id ON measurement (measurement_concept_id ASC); CREATE INDEX idx_measurement_visit_id ON measurement (visit_occurrence_id ASC); CREATE CLUSTERED INDEX idx_note_person_id ON note (person_id ASC); CREATE INDEX idx_note_concept_id ON note (note_type_concept_id ASC); CREATE INDEX idx_note_visit_id ON note (visit_occurrence_id ASC); CREATE CLUSTERED INDEX idx_observation_person_id ON observation (person_id ASC); CREATE INDEX idx_observation_concept_id ON observation (observation_concept_id ASC); CREATE INDEX idx_observation_visit_id ON observation (visit_occurrence_id ASC); CREATE INDEX idx_fact_relationship_id_1 ON fact_relationship (domain_concept_id_1 ASC); CREATE INDEX idx_fact_relationship_id_2 ON fact_relationship (domain_concept_id_2 ASC); CREATE INDEX idx_fact_relationship_id_3 ON fact_relationship (relationship_concept_id ASC); /************************ Standardized health system data ************************/ /************************ Standardized health economics ************************/ CREATE CLUSTERED INDEX idx_period_person_id ON payer_plan_period (person_id ASC); /************************ Standardized derived elements ************************/ CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC); CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC); CREATE INDEX idx_ca_subject_id ON cohort_attribute (subject_id ASC); CREATE INDEX idx_ca_definition_id ON cohort_attribute (cohort_definition_id ASC); CREATE CLUSTERED INDEX idx_drug_era_person_id ON drug_era (person_id ASC); CREATE INDEX idx_drug_era_concept_id ON drug_era (drug_concept_id ASC); CREATE CLUSTERED INDEX idx_dose_era_person_id ON dose_era (person_id ASC); CREATE INDEX idx_dose_era_concept_id ON dose_era (drug_concept_id ASC); CREATE CLUSTERED INDEX idx_condition_era_person_id ON condition_era (person_id ASC); CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC);
DROP DATABASE IF EXISTS db_editor; CREATE DATABASE IF NOT EXISTS db_editor; USE db_editor; CREATE TABLE books ( book_isbn CHAR(10) PRIMARY KEY, book_title VARCHAR(128) NOT NULL, book_price SMALLINT UNSIGNED NOT NULL, book_price_currency CHAR(3) NOT NULL DEFAULT 'EUR', book_award_winning VARCHAR(256) ); CREATE TABLE writers ( writer_id INT PRIMARY KEY AUTO_INCREMENT, writer_firstname VARCHAR(64) NOT NULL, writer_lastname VARCHAR(64) NOT NULL, writer_nickname VARCHAR(64) ); CREATE TABLE draft ( book_isbn CHAR(10) NOT NULL, writer_id INT NOT NULL, FOREIGN KEY (book_isbn) REFERENCES books(book_isbn), FOREIGN KEY (writer_id) REFERENCES writers(writer_id) ); CREATE TABLE editions ( edition_id INT PRIMARY KEY AUTO_INCREMENT, edition_number TINYINT UNSIGNED NOT NULL, edition_release_date DATE NOT NULL, edition_stock INT UNSIGNED NOT NULL, edition_total_print INT UNSIGNED NOT NULL, book_isbn CHAR(10) NOT NULL, FOREIGN KEY (book_isbn) REFERENCES books(book_isbn) ); CREATE TABLE bookstores ( bookstore_name VARCHAR(128) PRIMARY KEY, bookstore_address_country VARCHAR(128) NOT NULL DEFAULT 'France', bookstore_address_city VARCHAR(128) NOT NULL, bookstore_address_postal_code CHAR(5) NOT NULL, bookstore_address_street VARCHAR(256) NOT NULL, bookstore_address_complement VARCHAR(256) ); CREATE TABLE commands ( command_id INT PRIMARY KEY, command_date DATETIME NOT NULL, command_quantities INT NOT NULL, bookstore_name VARCHAR(128) NOT NULL, FOREIGN KEY (bookstore_name) REFERENCES bookstores(bookstore_name) ); CREATE TABLE contains ( edition_id INT NOT NULL, command_id INT NOT NULL, FOREIGN KEY (edition_id) REFERENCES editions(edition_id), FOREIGN KEY (command_id) REFERENCES commands(command_id) );
-- phpMyAdmin SQL Dump -- version 4.0.4.1 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Dec 25, 2017 at 05:17 PM -- Server version: 5.5.32 -- PHP Version: 5.4.19 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `andri` -- CREATE DATABASE IF NOT EXISTS `andri` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; USE `andri`; -- -------------------------------------------------------- -- -- Table structure for table `tb_kendaraan` -- CREATE TABLE IF NOT EXISTS `tb_kendaraan` ( `platnomor` varchar(30) NOT NULL, `id_merk` varchar(5) NOT NULL, `warna` varchar(10) NOT NULL, `tahunterbit` int(5) NOT NULL, `status` enum('bebas','jalan') NOT NULL, PRIMARY KEY (`platnomor`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tb_kendaraan` -- INSERT INTO `tb_kendaraan` (`platnomor`, `id_merk`, `warna`, `tahunterbit`, `status`) VALUES ('AB2174QI', 'M2', 'putih', 2016, 'bebas'), ('AB3774UU', 'M4', 'kuning', 2015, 'bebas'), ('AB4892FY', 'M3', 'hitam', 2014, 'bebas'), ('AB6607XZ', 'M7', 'silver', 2013, 'bebas'), ('AB6719EZ', 'M5', 'pink', 2013, 'bebas'), ('AB6938HZ', 'M6', 'putih', 2013, 'bebas'); -- -------------------------------------------------------- -- -- Table structure for table `tb_merk` -- CREATE TABLE IF NOT EXISTS `tb_merk` ( `id_merk` varchar(5) NOT NULL, `merk_motor` varchar(15) NOT NULL, PRIMARY KEY (`id_merk`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tb_merk` -- INSERT INTO `tb_merk` (`id_merk`, `merk_motor`) VALUES ('M1', 'vario cw'), ('M2', 'vario'), ('M3', 'beat'), ('M4', 'mio m3'), ('M5', 'mio j'), ('M6', 'nex'), ('M7', 'lets'); -- -------------------------------------------------------- -- -- Table structure for table `tb_pelanggan` -- CREATE TABLE IF NOT EXISTS `tb_pelanggan` ( `id_pelanggan` int(11) NOT NULL AUTO_INCREMENT, `nama` varchar(50) NOT NULL, `univ` varchar(30) NOT NULL, `fakultas` varchar(12) NOT NULL, `alamat` varchar(50) NOT NULL, `nohp` int(13) NOT NULL, PRIMARY KEY (`id_pelanggan`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ; -- -- Dumping data for table `tb_pelanggan` -- INSERT INTO `tb_pelanggan` (`id_pelanggan`, `nama`, `univ`, `fakultas`, `alamat`, `nohp`) VALUES (13, 'anik', 'UIN Sunan Kalijagaa', 'DAKWAHa', 'Kebumena', 2147483647), (14, 'dani', 'UIN Sunan Kalijaga', 'FISHUM', 'Banjarnegara', 812345789), (15, 'dini', 'UIN Sunan Kalijaga', 'Tarbiyah', 'Banjarnegara', 812345789), (16, 'tami', 'UIN Sunan Kalijaga', 'FISHUM', 'Kebumen', 812345789); -- -------------------------------------------------------- -- -- Table structure for table `tb_tarif` -- CREATE TABLE IF NOT EXISTS `tb_tarif` ( `id_tarif` varchar(5) NOT NULL, `id_merk` varchar(11) NOT NULL, `harga` int(11) NOT NULL, PRIMARY KEY (`id_tarif`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tb_tarif` -- INSERT INTO `tb_tarif` (`id_tarif`, `id_merk`, `harga`) VALUES ('A04', 'M1', 25000), ('A12', 'M1', 30000), ('A24', 'M1', 50000), ('B04', 'M2', 25000), ('B12', 'M2', 28000), ('B24', 'M2', 55000), ('C04', 'M3', 20000), ('C12', 'M3', 25000), ('C24', 'M3', 45000), ('D04', 'M4', 20000), ('D12', 'M4', 23000), ('D24', 'M4', 40000), ('E04', 'M6', 18000), ('E12', 'M6', 20000), ('E24', 'M6', 35000); -- -------------------------------------------------------- -- -- Table structure for table `tb_transaksi` -- CREATE TABLE IF NOT EXISTS `tb_transaksi` ( `id_transaksi` int(11) NOT NULL AUTO_INCREMENT, `id_kasir` varchar(5) NOT NULL, `id_pelanggan` int(11) NOT NULL, `platnomor` varchar(11) NOT NULL, `tgl_transaksi` date NOT NULL, `jam_rental` time NOT NULL, `tgl_kembali` date NOT NULL, `jam_kembali` time NOT NULL, `id_tarif` varchar(5) NOT NULL, `transaksi_total` int(11) NOT NULL, `transaksi_status` enum('mulai','selesai') NOT NULL, PRIMARY KEY (`id_transaksi`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; -- -- Dumping data for table `tb_transaksi` -- INSERT INTO `tb_transaksi` (`id_transaksi`, `id_kasir`, `id_pelanggan`, `platnomor`, `tgl_transaksi`, `jam_rental`, `tgl_kembali`, `jam_kembali`, `id_tarif`, `transaksi_total`, `transaksi_status`) VALUES (3, '1', 12, 'AB2174QI', '2017-12-05', '08:00:00', '2017-12-05', '20:00:00', 'B12', 28000, 'mulai'), (4, '2', 14, 'AB3774UU', '2017-11-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (5, '2', 14, 'AB3774UU', '2017-10-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (6, '2', 14, 'AB3774UU', '2017-09-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (7, '2', 14, 'AB3774UU', '2017-08-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (8, '2', 14, 'AB3774UU', '2017-07-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (9, '1', 14, 'AB3774UU', '2017-06-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (10, '1', 14, 'AB3774UU', '2017-05-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (11, '1', 14, 'AB3774UU', '2017-04-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (12, '1', 14, 'AB3774UU', '2017-03-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (13, '1', 14, 'AB3774UU', '2017-02-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'), (14, '1', 14, 'AB3774UU', '2017-01-01', '09:00:00', '2017-11-01', '13:00:00', 'D04', 20000, 'mulai'); -- -------------------------------------------------------- -- -- Table structure for table `tb_user` -- CREATE TABLE IF NOT EXISTS `tb_user` ( `id_user` varchar(10) NOT NULL, `type` enum('admin','kasir') NOT NULL, `nama_user` varchar(25) NOT NULL, `password` varchar(10) NOT NULL, `status` varchar(4) NOT NULL, PRIMARY KEY (`id_user`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tb_user` -- INSERT INTO `tb_user` (`id_user`, `type`, `nama_user`, `password`, `status`) VALUES ('2', 'admin', 'maradiyah', 'mar', 'user'), ('4', 'kasir', 'ernawati', 'erna', 'user'), ('a', 'admin', 's', 'user', ''), ('q', 'kasir', 'q', 'q', 'user'), ('w1', 'admin', 'w', 'w', 'user'); /*!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 */;
-- -- This file should undo anything in `up.sql` ----------- DELETE from old_actual_port; DELETE from actual_tic; DELETE from actual_port; ----------- DELETE from goal_tic; DELETE from goal_port; ----------- DELETE from tickers; DELETE from exchanges; ----------- DELETE from users;
CREATE TABLE [dbo].[DDLSnapshots] ( [DatabaseID] INT NOT NULL, [SnapshotDate] DATETIME2 (3) NOT NULL, [ValidatedDate] DATETIME2 (3) NOT NULL, [DDLSnapshotOptionsID] INT NULL, [Created] INT NULL, [Modified] INT NULL, [Dropped] INT NULL, CONSTRAINT [PK_DDLSnapshots] PRIMARY KEY CLUSTERED ([DatabaseID] ASC, [SnapshotDate] ASC), CONSTRAINT [FK_DBSnapshots_Databases] FOREIGN KEY ([DatabaseID]) REFERENCES [dbo].[Databases] ([DatabaseID]), CONSTRAINT [FK_DDLSnapshots_DDLSnapshotOptions] FOREIGN KEY ([DDLSnapshotOptionsID]) REFERENCES [dbo].[DDLSnapshotOptions] ([DDLSnapshotOptionsID]) );
SELECT lcm(15, 10); SELECT lcm(-15, 10); SELECT lcm(15, -10); SELECT lcm(-15, -10); -- Implementation specific result on overflow: SELECT ignore(lcm(256, 9223372036854775807)); SELECT ignore(lcm(256, -9223372036854775807)); SELECT ignore(lcm(-256, 9223372036854775807)); SELECT ignore(lcm(-256, -9223372036854775807));
--/************************************************************************* -- (c) Copyright IBM Corp. 2007 All rights reserved. -- -- The following sample of source code ("Sample") is owned by International -- Business Machines Corporation or one of its subsidiaries ("IBM") and is -- copyrighted and licensed, not sold. You may use, copy, modify, and -- distribute the Sample in any form without payment to IBM, for the purpose of -- assisting you in the development of your applications. -- -- The Sample code is provided to you on an "AS IS" basis, without warranty of -- any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR -- IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Some jurisdictions do -- not allow for the exclusion or limitation of implied warranties, so the above -- limitations or exclusions may not apply to you. IBM shall not be liable for -- any damages you suffer as a result of using, copying, modifying or -- distributing the Sample, even if IBM has been advised of the possibility of -- such damages. -- ************************************************************************* -- -- SAMPLE FILE NAME: recxmldecomp.db2 -- -- PURPOSE: How to register a recursive XML schema to the XSR and -- enable the same for decomposition. -- -- USER SCENARIO: The existing PurchaseOrder schema in the Sample database is -- enhanced to have new Employee tables to process the purchase orders. -- We have Recursive Schema for Employee data management, an employee -- can be a manager and himself reporting to another employee. The XML document -- contains the employee information along with department details which needs -- to be stored in relational tables for easy retrieval of data. -- -- -- PREREQUISITE: -- The instance document and the annotated schema should exist in the same -- directory as the sample. Copy recemp.xml, recemp.xsd from directory -- <install_path>/sqllib/samples/xml/data in UNIX and -- <install_path>\sqllib\samples\xml\data in Windows to the working directory. -- -- EXECUTION: db2 -tvf recxmldecomp.db2 -- -- INPUTS: NONE -- -- OUTPUTS: Decomposition of XML document according to the annotations -- in recursive schema. -- -- OUTPUT FILE: recxmldecomp.out (available in the online documentation) -- -- SQL STATEMENTS USED: -- REGISTER XMLSCHEMA -- COMPLETE XMLSCHEMA -- DECOMPOSE XML DOCUMENT -- CREATE -- SELECT -- DROP -- -- ************************************************************************* -- For more information about the command line processor (CLP) scripts, -- see the README file. -- For information on using SQL statements, see the SQL Reference. -- -- For the latest information on programming, building, and running DB2 -- applications, visit the DB2 application development website: -- http://www.software.ibm.com/data/db2/udb/ad -- ************************************************************************* -- -- SAMPLE DESCRIPTION -- -- ************************************************************************* -- 1. Register the annotated XML schema. -- 2. Decompose the XML document using the registered XML schema. -- 3. Select data from the relational tables to see decomposed data. -- *************************************************************************/ -- /************************************************************************* -- SETUP -- **************************************************************************/ -- connect to the database sample CONNECT TO SAMPLE; -- create the table to store the decomposed data CREATE TABLE xdb.poemployee (empid VARCHAR(20), deptid VARCHAR(20), members XML); -- /************************************************************************* -- 1. Register the annotated XML schema. -- *************************************************************************/ -- register the schema document REGISTER XMLSCHEMA 'http://porder.com/employee.xsd' FROM 'recemp.xsd' AS xdb.employee; -- complete schema registration COMPLETE XMLSCHEMA xdb.employee ENABLE DECOMPOSITION; -- check catalog tables for information regarding registered schema. SELECT status, decomposition, decomposition_version FROM SYSIBM.SYSXSROBJECTS where XSROBJECTNAME = 'EMPLOYEE'; -- /************************************************************************* -- 2. Decompose the XML document using the registered XML schema. -- *************************************************************************/ -- decompose the XML document DECOMPOSE XML DOCUMENT recemp.xml XMLSCHEMA xdb.employee VALIDATE; -- /************************************************************************* -- 3. Select data from the relational tables to see decomposed data. -- *************************************************************************/ -- check Decomposition result SELECT * FROM xdb.poemployee ORDER BY empid; -- /************************************************************************* -- CLEANUP -- **************************************************************************/ -- drop the created objects DROP XSROBJECT xdb.employee; DROP TABLE xdb.poemployee ; -- Reset connection CONNECT RESET;
alter table ACT_RU_EXECUTION add SUSPENSION_STATE_ int; alter table ACT_RE_PROCDEF add SUSPENSION_STATE_ int; alter table ACT_RE_PROCDEF add REV_ int; update ACT_RE_PROCDEF set REV_ = 1; update ACT_RE_PROCDEF set SUSPENSION_STATE_ = 1; update ACT_RU_EXECUTION set SUSPENSION_STATE_ = 1; create table ACT_RU_EVENT_SUBSCR ( ID_ nvarchar(64) not null, REV_ int, EVENT_TYPE_ nvarchar(191) not null, EVENT_NAME_ nvarchar(191), EXECUTION_ID_ nvarchar(64), PROC_INST_ID_ nvarchar(64), ACTIVITY_ID_ nvarchar(64), CONFIGURATION_ nvarchar(191), CREATED_ datetime not null, primary key (ID_) ); create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on ACT_RU_EVENT_SUBSCR(CONFIGURATION_); alter table ACT_RU_EVENT_SUBSCR add constraint ACT_FK_EVENT_EXEC foreign key (EXECUTION_ID_) references ACT_RU_EXECUTION(ID_); alter table ACT_RU_EXECUTION add IS_EVENT_SCOPE_ tinyint; update ACT_RU_EXECUTION set IS_EVENT_SCOPE_ = 0; alter table ACT_HI_PROCINST add DELETE_REASON_ nvarchar(4000); alter table ACT_GE_BYTEARRAY add GENERATED_ tinyint; update ACT_GE_BYTEARRAY set GENERATED_ = 0;
/* Copyright 2014, 2015 OpenMarket Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ CREATE TABLE IF NOT EXISTS event_forward_extremities( event_id TEXT NOT NULL, room_id TEXT NOT NULL, UNIQUE (event_id, room_id) ); CREATE INDEX ev_extrem_room ON event_forward_extremities(room_id); CREATE INDEX ev_extrem_id ON event_forward_extremities(event_id); CREATE TABLE IF NOT EXISTS event_backward_extremities( event_id TEXT NOT NULL, room_id TEXT NOT NULL, UNIQUE (event_id, room_id) ); CREATE INDEX ev_b_extrem_room ON event_backward_extremities(room_id); CREATE INDEX ev_b_extrem_id ON event_backward_extremities(event_id); CREATE TABLE IF NOT EXISTS event_edges( event_id TEXT NOT NULL, prev_event_id TEXT NOT NULL, room_id TEXT NOT NULL, is_state BOOL NOT NULL, UNIQUE (event_id, prev_event_id, room_id, is_state) ); CREATE INDEX ev_edges_id ON event_edges(event_id); CREATE INDEX ev_edges_prev_id ON event_edges(prev_event_id); CREATE TABLE IF NOT EXISTS room_depth( room_id TEXT NOT NULL, min_depth INTEGER NOT NULL, UNIQUE (room_id) ); CREATE INDEX room_depth_room ON room_depth(room_id); create TABLE IF NOT EXISTS event_destinations( event_id TEXT NOT NULL, destination TEXT NOT NULL, delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered UNIQUE (event_id, destination) ); CREATE INDEX event_destinations_id ON event_destinations(event_id); CREATE TABLE IF NOT EXISTS state_forward_extremities( event_id TEXT NOT NULL, room_id TEXT NOT NULL, type TEXT NOT NULL, state_key TEXT NOT NULL, UNIQUE (event_id, room_id) ); CREATE INDEX st_extrem_keys ON state_forward_extremities( room_id, type, state_key ); CREATE INDEX st_extrem_id ON state_forward_extremities(event_id); CREATE TABLE IF NOT EXISTS event_auth( event_id TEXT NOT NULL, auth_id TEXT NOT NULL, room_id TEXT NOT NULL, UNIQUE (event_id, auth_id, room_id) ); CREATE INDEX evauth_edges_id ON event_auth(event_id); CREATE INDEX evauth_edges_auth_id ON event_auth(auth_id);
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
12