Questions tagged [scripting]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
120 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
31 views

how do you escape single quotes in a mysql script?

I need to create a trigger via mysql script CREATE TRIGGER sync_new_oauth_sessions AFTER INSERT ON oauth_sessions FOR EACH ROW BEGIN SET @s = 'INSERT INTO oauth_sessions_new(id, client_id, ...
1
vote
2answers
42 views

Shell script to grep current PostgreSQL log [closed]

I have tried by google but unable to find. I wanted to grep string from below no. of files which is most recent files. by using this command i am able to fetch most recent file but , not able to grep ...
2
votes
1answer
115 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 ...
1
vote
1answer
28 views

MySQL dump to MariaDB issue with collation

I have a django app running on a staging server (windows server 2012) with a MariaDB database. I have a git hook running mysqldump locally when I push to the staging branch. On the server I have a ...
3
votes
1answer
9k views

use variable to determine the name of a column in the select in Postgres

I'm trying create a update for a new structure of tables from a old table, but not using functions. I'm trying create a script to it. The old table is like this: Old table (OldTable) name col_a col_b ...
1
vote
1answer
48 views

Shell Script to kill slow running Mongo Queries

I need to create a shell script that finds and kills long running mongo queries more than a specified threshold e.g. 15sec I plan to use db.currentOp(); and db.killOp(); to find and kill queries but I ...
1
vote
3answers
443 views

DB2, How to save all stored procedures as files

How does one extract all stored procedures from a DB2 schema as individual files (without using Data Studio so it can be scripted). I need them all so I can uploaded to source control. I have found ...
0
votes
1answer
31 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 ...
2
votes
3answers
5k views

Use psql --set variable in a function

I want to create a script that will create some custom named schema and within it some tables and functions. Like this: The example.sh file: #!/bin/bash # this is the only place I want to set the ...
0
votes
1answer
42 views

What does this statement mean: SELECT … COLLATE SQL_Latin1_General_CP1_CI_AS AS [-‌- Logins To Be Created --]

What does this statement mean? SELECT ... COLLATE SQL_Latin1_General_CP1_CI_AS AS [-- Logins To Be Created --] It is part of a script I'm trying to adapt for listing out the SQL Server logins in an ...
0
votes
1answer
297 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 ...
12
votes
4answers
13k views

Scripting SQLite with dot commands

Is it possible to write scripts that contain SQLite dot commands ( vis. .read file.sql; .separator ,; .import file.csv; )? I'm building and repeatedly rebuilding an SQLite database and need to type ...
0
votes
1answer
29 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
1answer
221 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 ...
5
votes
2answers
157 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
1answer
983 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
1answer
852 views

db2ckbkp - How to determine what tablespaces are temp-tablespace

I am writing a script to restore databases from backup. The script should need as little input as possible to fulfill this task (in an efficient way). The restore command takes the parallelism ...
0
votes
3answers
612 views

Postgresql Backup all databases seperate files

I need to create an automatic backup of all databases from PostgreSQL ( running on a Windows machine ). I need to know if is possible to get backup of all databases but on separate files? Using ...
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
3answers
56 views

History of actions that occured on a table in SQL Server

I am running a shell script that runs insert, update, delete queries on a table in an SQL Server DB. Is there a way to get a history of all transactions that happened on the table to validate that ...
0
votes
1answer
78 views

Take a “slice” of a SQL Server database: for all tables, get only the rows that join (directly or indirectly) to a specific row

For audit purposes, I'm trying to obtain a copy/export of a DB but including only the rows from each table that have relevance to a small collection of rows in some table. So every row of every table ...
0
votes
0answers
54 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 ...
1
vote
1answer
54 views

How to script server level objects in sql server?

I regularly do sql server installations (mainly sql server 2016), in virtual machines or otherwise, and I have a bunch of things like permissions, and linked servers and endpoints that I have mostly ...
1
vote
0answers
89 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 ...
7
votes
6answers
8k views

How do I format the output from OBJECT_DEFINITION so that it looks the same as sp_helptext?

object_definition and sp_helptext both return the source code of a stored procedure - but how can I use object_definition and get the source code including the line breaks as the sp_helptext currently ...
0
votes
0answers
20 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
26 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
19 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 ...
14
votes
4answers
28k views

Script out Oracle DDL in an automated fashion

Oracle SQL Developer is able to export DDL through Tools -> Database Export... This works very well, but requires manual intervention. I know of DBMS_METADATA.get_ddl(), but have found that the ...
0
votes
0answers
43 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;...
11
votes
6answers
8k views

How can I detect broken stored procedures after a schema change?

I've modified a central table in my database, and sp_depends literally returns hundreds of results, and I'm concerned some of those stored-procedures might not compile anymore after my change. ...
1
vote
0answers
40 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
1answer
1k views

Restoring multiple files to multiple database with pg_restore

I have multiple dump files and want to restore them with single command. something like this pg_restore -h localhost -p 5432 -U postgres -d gl_election gl_world gl_tourism -c "gl_election" ...
3
votes
0answers
1k views

Generate scripts wizard hangs when loading database information [closed]

I am trying to script out a database from an instance of SQL Server 2017, so I can load it into an instance of SQL Server 2014. I right-clicked on the database, chose Tasks -> Generate Scripts, and ...
2
votes
1answer
43 views

Where can I find SQL Developer Database examples (scripts) to add data to practice?

Where can I find SQL Developer Database examples (scripts) to add data to practice? I require SQL scripts that will add tables and data on those tables in order to practice with Power Bi.
1
vote
1answer
81 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 ...
0
votes
1answer
117 views

SQL Server Command Line Install - How to change the edition?

I am creating a script to install SQL Server via the command line. I cannot see a way to choose the edition I want to install. The GUI on my install media offers Evaluation, Developer or Express: (...
0
votes
1answer
90 views

How to save Outlook attachment in a drive with a new name and overwrite if it already exists? [closed]

I am using below VBA script to download attachments from email and save it to my windows directory. I need help to modify this script - 1) to save rename the attachment before saving it 2) Overwrite ...
2
votes
3answers
828 views

Moving all Heap Tables to another Filegroup in SQL Server

In SQL Server 2017, I want to move ALL Heaps in a DB to a secondary filegroup. What's the easiest way to do this? This question is only for Nonclustered Indexes. https://stackoverflow.com/questions/...
1
vote
3answers
4k views

Running Oracle Export Utility within a Shell script [closed]

I have wasted a lot of time on this. Any ideas of what I am doing wrong here? Script in bash #!/usr/bin/bash . . . /export/home/app/oracle/product/10.2.0/bin/exp $uname/$passw \ FILE="$...
1
vote
4answers
907 views

Error “the system cannot find the file specified” when opening a large SQL Server file

I have generated the script of my whole SQL Server database into a file and it's more than 36 GB. When I try to open it, I get the following error: The system cannot find the file specified. At ...
0
votes
0answers
13 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
64 views

SQL Failover and Failback Script for SRM Recovery Plan(preferably power shell or CMD or Batch script)

OS: Windows Server 2016 Standard SQL: SQL Server 2016 Enterprise SQL Setup: Two Nodes(Primary and Secondary Node) in PDC(Primary Data Center) having Always On Availability Group with Synchronous Mode ...
1
vote
1answer
74 views

Generate SQL scripts in powershell

I want to be able to generate simple repetitive scripts in SQL using Powershell as the scripting language. For example, If I want to generate a SQL GRANT command for every table in a database, and ...
3
votes
1answer
1k views

Passwordless mysqldump via shell script in /etc/cron.daily

I'm aware that there are dozens of questions similar to this, but it seems none has a definitive answer to my problem, so that's why I'm posting this... I hope in the right place. The problem: I ...
0
votes
1answer
104 views

Create a table with the same constraints,triggers,indexes, and statistics for house-keeping table

I have a current database with few hundred tables, say, tables A,B,C... and I want to create the same tables with the same constraints,triggers,indexes, and stats as the original tables. I know I ...
0
votes
1answer
43 views

How to quote a SQL*Plus identifier in a bash script?

I get "ORA-00904: "MEMORY_TARGET": invalid identifier" no matter how I try to quote the identifier in the following command: MEMORY_TARGET=$(su - orat01 -c " echo 'select ...
0
votes
1answer
486 views

generated column in mySQL workbench

I am a beginner and start designing small database. I've found that to automatically generate value from the table, I can either use a trigger or compute them when forward engineering. Therefore, I've ...
4
votes
2answers
8k views

What does “psql: /usr/pgsql-11/lib/libpq.so.5: no version information available (required by psql)” actually mean?

I have a question regarding following output: [nikola@192 ~] $ sudo su - postgres [postgres@192 ~] $ psql dvdrental postgres psql: /usr/pgsql-11/lib/libpq.so.5: no version information available (...

1
2 3 4 5
7