Questions tagged [scripting]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
45 views

Script server level user securables onto another server

I have restored a backup of the live DB on a test SQL Server VM. Then I scripted the server level SQL users and restored them on the test SQL Server and fixed the orphaned user situation. But the user ...
user avatar
  • 2,371
0 votes
1 answer
26 views

How to use psql command with no password prompt? [duplicate]

I'm trying to write shell script to avoid entering password every time while login to psql.
user avatar
  • 1
1 vote
0 answers
85 views

Scalar function parses and runs in SSMS, incorrect syntax in ScriptDOM

I'm preparing the Database migration from compatibility level 140 (SQL Server 2017) to level 150 (SQL Server 2019). As part of the preparation, Data Migration Assistant (DMA) has been run and it found ...
user avatar
  • 1,411
0 votes
1 answer
66 views

Pentaho does not read sql script (csv)

I was trying to use a different sql script for one job. For doing this i need to pass the script by file csv, so i set the script like a variable and then i make a transformation that "copy to ...
user avatar
0 votes
1 answer
516 views

Postgres how do return a message if no results for SELECT query

Have been trying to work out how to return a message if the result is empty. I am running a select statement as below: select * from maxIDValue where max_value > 1000000 order by max_value desc; I ...
user avatar
  • 173
1 vote
1 answer
69 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 ...
user avatar
  • 10.3k
0 votes
0 answers
119 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 ...
user avatar
0 votes
2 answers
629 views

Oracle: Simple way to compare all objects of a schema in two databases?

I'm attempting to compare all objects of two schemas located in two different databases. I know there may be ways to do this with TOAD and SQL Developer, but is there another way to do this by script ...
user avatar
  • 11
-1 votes
1 answer
52 views

How to generate constraint sql?

I'm looking for a method that can generate the creating sql, like PgAdmin's SQL tab while having selected the constraint. (how pg admin does it?) I want to implement a generic method that can drop and ...
user avatar
  • 131
0 votes
1 answer
406 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 ...
user avatar
0 votes
1 answer
60 views

Space estimates for each table if compression is removed

I am trying to gather space estimates if compression is removed from tables in a database. I started with a temp table and generated statements to execute sp_estimate_data_compression_savings as ...
user avatar
  • 656
1 vote
1 answer
91 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, ...
user avatar
  • 115
1 vote
1 answer
515 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 ...
user avatar
  • 13
0 votes
1 answer
118 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 ...
user avatar
0 votes
1 answer
131 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 ...
user avatar
  • 231
0 votes
1 answer
38 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 ...
user avatar
0 votes
3 answers
76 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 ...
user avatar
0 votes
1 answer
302 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 ...
user avatar
1 vote
2 answers
200 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 ...
user avatar
1 vote
1 answer
242 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 ...
user avatar
  • 69
1 vote
0 answers
341 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 ...
user avatar
  • 69
0 votes
0 answers
61 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 ...
user avatar
  • 69
0 votes
0 answers
23 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 ...
user avatar
  • 1
0 votes
0 answers
287 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;...
user avatar
1 vote
3 answers
1k 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 ...
user avatar
  • 73
1 vote
0 answers
44 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,...
user avatar
2 votes
1 answer
59 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.
user avatar
0 votes
3 answers
2k 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 ...
user avatar
0 votes
1 answer
353 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: (...
user avatar
  • 1,379
0 votes
1 answer
252 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 ...
user avatar
0 votes
1 answer
738 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 ...
user avatar
  • 25
1 vote
4 answers
2k 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 ...
user avatar
  • 119
0 votes
0 answers
17 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 ...
user avatar
1 vote
1 answer
161 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 ...
user avatar
  • 4,088
0 votes
1 answer
72 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 ...
user avatar
0 votes
1 answer
1k 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 ...
user avatar
  • 103
4 votes
3 answers
15k 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 (...
user avatar
  • 203
2 votes
1 answer
32 views

How to change user running audits mssql

I've been tasked with setting up our SQL server audits - despite having never done this before. So please forgive a really basic question. I setup a specific user, sqlAudits, that I would like to own ...
user avatar
  • 209
0 votes
1 answer
309 views

PostgreSQL - How to list all foreign key link to Primary key of a table

I have a table res_users with primary key id I would like to list all the foreign key link to id from all the tables in my database.
user avatar
0 votes
1 answer
2k views

output psql results and errors to a file

I want to display the results of psql queries on a file.In the log just the name DO for the anonymous Bloc is being displayed. The following is being executed from a shell script file : psql --host=...
user avatar
0 votes
1 answer
1k views

Shell script - psql run multiple statements from a variable one by one in one transaction

Im preparing a shell script to generate analyze command and all the commands will go to a variable. echo $analyze_query analyze tbl1; analyze tbl2; analyze tbl3; Now I want to run one by one, and ...
user avatar
  • 1,698
1 vote
1 answer
280 views

how to script out proxy accounts?

I have servers where I use proxy accounts to run ETL processes or even to backup SSAS databases using powershell through a job. I can see what AD Accounts are related to my proxies: use msdb go ...
user avatar
0 votes
1 answer
266 views

v$ tables not recognized in a sql statement of a shell script

I have .sh script with this block: sqlplus -S / as sysdba <<EOFILE set feedback off set lines 2000 set pages 20000 col db_size for a15 alter session set nls_date_format = 'DD-MM-YYYY HH24:MI:...
user avatar
  • 1
0 votes
1 answer
98 views

script to find all bigint that can be converted to int fields in postgresql performance

I want to compact a postgresql 11 db and my idea is to convert lots of bigint to int data types if and only if there is a reasonable lag to the limit of int data type considering the data inside. So, ...
user avatar
-2 votes
1 answer
434 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 '/...
user avatar
0 votes
0 answers
61 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 ...
user avatar
  • 181
1 vote
2 answers
2k views

How to pass Oracle Wallet auth to sh script?

I am running an Oracle DB update script that requires password. I have Oracle wallet installed. How to pass Oracle wallet to sh script so that I don't have to enter password when running the script? ...
user avatar
  • 213
5 votes
2 answers
474 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, ...
user avatar
0 votes
1 answer
434 views

MySQL ERROR 1064 (42000) insert via bash script (RHEL)

MySQL Server: 8.0.16 Commercial OS: RHEL 7.5 I have written a simple script, to insert certain information into a database table. Following is my script # cat ~mysqldba/bin/connections.sh #!/...
user avatar
0 votes
4 answers
4k views

oracle oraenv script bash

I want to do same commande shell CLi into a script Command shell without script (CLI) su - oracle export ORAENV_ASK=NO export ORACLE_SID=HRPRD . oraenv env | grep ora output: USER=oracle **...
user avatar
  • 17

1
2 3 4 5
7