Questions tagged [scripting]

For questions about generating or using language scripts, for example scripting a database object definition.

49 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
2answers
226 views

how to remove all permissions in a database?

every time I need to either restore a database or reinitialize a replication publication I first (on the restored to be or subscription database) I script all the permissions, triggers, indexes, ...
3
votes
0answers
15k views

DROP DATABASE IF EXISTS CREATE DATABASE IF NOT EXISTS USE in PostgreSQL

I always was used following header in files that defined database in MySql: DROP DATABASE IF EXISTS base; CREATE DATABASE IF NOT EXISTS base; USE base; In PostgreSQL there are the following ...
3
votes
0answers
1k views

execute R script using a postgresql trigger:

This is my first question here, so excuse me if it does not look well organized: I want to call a R script from a trigger (postgresql) so this script will be executed after an INSERT on my table (...
3
votes
1answer
1k views

select two tables and print the columns side by side with matching key in hive

I have the below tables: table_1 name_1 id_1 value_1 avi 1 21 adi 2 X table_2 name_2 id_2 value_2 avi 1 21 adi 2 22 metadata_info: can be read from ...
2
votes
0answers
91 views

the mystery of the table showing up in the subscription, but not in the publication

TL;DR: This question refer to sql server 2016, transactional replication I've got a table that shows up in the subscription but not in the publication. Here are the details: In one of my servers ...
2
votes
1answer
45 views

How can I optimize this MYSQL Script For many Records?

I have This script by Helping @lukstorms , -- DROP TABLE IF EXISTS test_words; CREATE TABLE IF NOT EXISTS test_words ( id int unsigned NOT NULL PRIMARY KEY, words text NOT NULL ); -- DROP TABLE ...
2
votes
1answer
38 views

How to order databases by size? (For use in full backups)

Recently, I've been trying to make our company's full backup process more efficient. In order to do this, my team has decided that instructing the backup job to tackle the full backups starting with ...
2
votes
0answers
728 views

SSIS Script Component errors sporadically with the same code

I have a SSIS Data Flow Task that takes CSV output (from a flat file connection) and passes that to a Script Component. When I run the task I get the following error: Script Component has encountered ...
2
votes
1answer
123 views

My SSMS is bringing wrong object in "Script Stored Procedure as" > "CREATE To" > "New Query Editor Window"

When I go to Object Explorer and expand down to Stored Procedures (or Tables), right-click on one of them and choose "Script Stored Procedure / Table as" > "CREATE To" > "New Query Editor Window", it ...
2
votes
0answers
929 views

How to get status of "opatch prereq CheckApplicable" via script

I want to check if a patch is Applicable via opatch prereq CheckApplicable -oh <oracle home> -ph <patch home> but the returncode is always 0! It doesn't matter if the text output says ...
2
votes
0answers
1k views

Scripting Local Policy Perform Volume Maintenance Tasks

I am working on an automated SQL 2012 install process on Windows 2012 R2 and have everything complete except for one task. My process launches secpol.msc but I am still required to drill in and ...
1
vote
1answer
60 views

Cannot script stored procedure while restoring another copy of current db

I have some large DB that I need to restore to another db from time to time, this process take some time to conclude. The annoying thing I found out in last version of SSMS is that I cannot script any ...
1
vote
0answers
178 views

How to simulate slow queries on MongoDB

I need to write a shell script that finds and kills long running mongodb queries, but I don't have access to the database that runs slow queries, how to I simulate running slow queries on my local ...
1
vote
0answers
41 views

Keeping the same order of selected records while inserting to another table

I am running a below query in big query insert into `test-project.temp_test_dataset.cluster_records` (pm,col1,col2,col3,total) select pm,col1,col2,col3,total from ( select 'ingest' as pm,col1,col2,...
1
vote
0answers
1k views

Show Collections in MongoDB throwing

I am connecting to MongoDB hosted on EC2 instance of AWS. I am connecting through ssh command. Upon entering the command "show collections", I am getting uncaught exceptions. Please see the sequence ...
1
vote
0answers
37 views

Checking if schema name is included in every sentence

I got some oracle database scripts for creating the whole database of an application, including sentences for creating tables, sequences, synonyms, inserts and updates of data, etc I need to ensure ...
1
vote
1answer
64 views

is there a way to improve this query by not re calculating functions? cross apply?

when I set up replication I like to take a count of each table in the publisher, then I go to the subscriber I do the same thing in order to compare both pictures. this is the picture from the ...
1
vote
1answer
130 views

How to upgrade a MySQL database using numbered scripts based on a version field

I have a database that contains a version table with one value stored in it which is the database version number. I would like to be able to update the database version automatically using numbered ...
1
vote
1answer
82 views

How to make performance tests for DML

I created two multi-column indexes on a big table (~2,5 millions rows 370Mb and 621Mb with indexes). SELECT queries are very fast. Know I want to check if we have a regression for INSERT/UPDATE ...
1
vote
0answers
63 views

How to save SSMS 2012 Object Explorer Scripting Settings?

I'm generating a bunch of object creation scripts in SSMS 2012, using the Object Explorer context menu. The default options for these generated scripts are not to my liking (for example, I want the ...
1
vote
0answers
224 views

How to investigate non-specific Generate and Publish Scripts Wizard errors

I am trying to use the Generate and Publish Scripts wizard in SSMS 2012 against a 2012 SQL instance and am getting errors. Trying to generate a schema-only script of the tables and schemas. I allowed ...
1
vote
0answers
182 views

Loop a script for all DBs in SQL Server

I am trying to run Kendra's script for all DBs but running into issues.I have tried below. http://www.littlekendra.com/2016/05/05/how-to-script-out-indexes-from-sql-server/ DECLARE @SQLCmd VARCHAR(...
1
vote
0answers
160 views

SQL Server and Network considerations to transfer backup file to a shared folder

I'm facing with a situation where backups are being transferred manually to a Shared Folder and my goal is to optimize all of this. What I have to deal with is: 8 Windows 2008 R2 Servers 2 Windows ...
1
vote
0answers
130 views

What should be the best practice to alter the table using the script to shift columns

I have a MySQL table which has columns 93 in it. All first 92 columns are INT(11) and the last column is of type DATE. |number|0|1|2|3........|88|89|90|ddate| | | | | | ........| | | | | ...
1
vote
0answers
55 views

Disable the Task action button

How can I disable the "Tasks ->" button in SQL Server Management Studio? I need to prevent users scripting objects.
1
vote
0answers
50 views

T-SQL stored procedure: granting general user access to specific stored procedure

I'm attempting to alter a stored procedure that needs the line added: grant exec on dbo.sproc_name to exec_proc I believe the admin setup the exec_proc as a group. I added this grant line following ...
1
vote
0answers
331 views

Parallel insert in db2

I am trying to import from 8 files and insert into a single table in db2. I am running 8 .sql files that will do the task, but only one of them actually seem to be running and inserting into table. ...
0
votes
0answers
34 views

Problems using catcon.pl

We are investigating the use of catcon.pl to launch scripts on multitenant Oracle DBs. In this case, with APEX upgrade scripts. For example, the apexins.sql script, is made to give it the arguments at ...
0
votes
1answer
32 views

Read and Get Data from ExcelFile using powershell

I'm starting with powershell and this time. I have to read all the values from a excel file In this case from a specific sheet. The ultimate goal of this task is to get the values from two columns and ...
0
votes
1answer
40 views

Oracle database 12C restore script

i'm trying to create backup restore script . in short my backup script creating new directory every day from the operating system level and then backup the database using the directory created i tried ...
0
votes
1answer
32 views

Silence Sqlplus Login Message but Retain Echo

Running a series of automated checks on our databases for the security folks checking our STIG compliance. Mostly simple stuff like certain parameters turned off, etc. We're in the stone ages, so this ...
0
votes
0answers
59 views

The SQL Scripter library is running a SELECT COUNT(*), how do I stop it?

I'm using the Microsoft.SqlServer.Management.Smo.Scripter library from within a PowerShell script to pull SQL object creation scripts from a DB as part of an automated process. The user account used ...
0
votes
0answers
30 views

Appropriate language to write a Script that Kills Long running query MongoDB

I want to create a script that kills queries when they reach specific time threshold, I will be using db.currentOp() method to get information about currently running queries, and use db.killOp to ...
0
votes
0answers
31 views

using regular expression in bigquery

I have a table in bigquery with some formulas and would like to replace few things from it. SELECT FORMULA,element.name,FUNCTIONS.fun_temporal FROM `test-project.FORMULAS.FORMULA_HISTORY` ,unnest(...
0
votes
0answers
20 views

cloning foreign keys after prod-dev wipe

I am currently using mariadb, and I am working with quite a bit of data. we are creating nightly wiped clones of our production database, so our devs have a fresh copy without any customer data. I am ...
0
votes
0answers
95 views

I need a script to cycle all tables in postgres to analyze if needed

I need a script to cycle all tables in postgres to analyze if needed. Something like: create or replace PROCEDURE analyze_all_tables () language plpgsql as $$ declare q TEXT; r RECORD;...
0
votes
1answer
477 views

Oracle - Delete dmp files from ASM diskgroup

I want to delete my export files daily from ASM diskgroup with a crontab job. I want to prepare a script for it. ASMCMD> ls exp1.dmp exp2.dmp exp3.dmp exp4.dmp ASMCMD> pwd +DATA/EXP How ...
0
votes
0answers
15 views

How to shutdown and startup a database to delete datafiles in between

OS: Windows 10 Professional / DBMS: Oracle 18c XE How would one approach the issue of losing a connection while shutting down the database? I would like to have one script which deletes datafilepaths ...
0
votes
0answers
57 views

Loading 260GB worth of CSV into MySQL in Linux

I'm bulk loading a few thousand CSVs totaling ~260GB and ~4.5 billion rows to MySQL using mysqlimport calls on each CSV executed within a bash script. The MySQL installation and the data itself are ...
0
votes
1answer
1k views

Script to install Oracle client 12c2 on Redhat linux 7.5

Can someone help me to provide a script which I can use to install the Oracle client as part of the server build or AMI. Below script I was able to pull out from the guide in the Oracle site. But ...
0
votes
0answers
139 views

Using SQL script in Toad, how do I suppress the echo of the SQL statements

I'm using a script (Toad, Oracle) so that I can use variables and enter two values that get repeated in multiple SQL statements. That's working great, but the SQL statements echo into the console ...
0
votes
1answer
226 views

Realtime Update MySQL on every Update occurred on PostgreSQL

I have a PostgreSQL for my accounting system and a MySQL database for my php website, i want to sync these two database for every update may occurred on PostgreSQL it also updates MySQL database, they ...
0
votes
0answers
10k views

execute .sql script inside an anonymous pl/sql block which is invoked by a shell script

I got a shell script which connects to SQLPLUS and executes the .sql file like below: read a x=`echo $a | cut -d , -f 1` y=`echo $a | sed 's/.*,//'` c=`echo $USER | cut -c -2`"OPR"`echo $USER | ...
0
votes
1answer
101 views

databases cross references baselines

We have on several databases on same instances, some stored procedures have references to tables on other databases. We are in the middle of a big project to take our database under source control. ...
-1
votes
1answer
299 views

Syntax Error in Create Table Statement

I'm using Oracle 12c, I want to create a table with partition by year and subpartition by month like this. create table par.Log_his ( ID NUMBER(20) not null, Year number(4,0), -- ...
-2
votes
1answer
252 views

How to resolve error "SQL0104N" when running "db2 prune logfile prior to" command?

I wrote an script to delete transaction log files in db2. I need to delete all the files prior to the active log file.I wrote this code as .sh file db2 connect to DWHDB db2 get db cfg | grep '/...
-2
votes
1answer
72 views

How to write a shell script to disable the database accounts from a list of user IDs

I am new to Unix scripting...I have a list of userids for terminated employees. I want to write a script that will check these userids against my databases and disable/remove the user accounts ...
-3
votes
2answers
831 views

Need a shell script that can run a oracle query and produce output in .csv format

Can you please help- need a shell script that will have a oracle query inside it and produce a .csv format output in specific location, that script should be a scheduled in a cron job which runs, the ...
-4
votes
1answer
13 views

I have provided the database script where I have to run Sql script that answer the following question. I want Sql script for question given below

/******************************************************** * This script creates the database named music_store_system *********************************************************/ DROP DATABASE IF ...