On this page
How do I check a figure in QA, then in production, without switching?
What you'll accomplish
A tester reports a figure from the QA database, and you need to know whether production shows the same. Switching connections, running the query again and switching back takes three steps and leaves you on production longer than necessary.
You will run the query on the QA connection, then run it once on the production connection of the same application with / PROD, without leaving QA. You end up with both figures on screen, one after the other, and your prompt still on QA.
Short answer
Run the query on the QA connection, then type / PROD on a line by itself. The query runs once on the production connection of the same Database Group, and you stay on QA.
Before you start
This recipe uses the practice connections WORLD-QA and WORLD (playing production), which do not exist by default: create them with Set up QA and production copies of WORLD. With the WORLD connection alone, you can still run the query and use / to run it again on the same connection.
Example
Open the QA copy and count the cities of France, with their total population:
CONNECT WORLD-QA;
SELECT COUNT(*) AS CITIES, SUM(POPULATION) AS POPULATION FROM CITY WHERE COUNTRYCODE = 'FRA';
/ PRODThe query runs on WORLD-QA, then / PROD runs it once on WORLD. The two copies start identical, so both runs show the same figures:
WORLD-QA> SELECT COUNT(*) AS CITIES, SUM(POPULATION) AS POPULATION FROM CITY WHERE COUNTRYCODE = 'FRA';
|--------------------|--------------------|
|CITIES |POPULATION |
|--------------------|--------------------|
|40 |9244494 |
|--------------------|--------------------|
1 rows fetched in 4 ms.
WORLD-QA> / PROD
Running last query on WORLD [PROD]...
|--------------------|--------------------|
|CITIES |POPULATION |
|--------------------|--------------------|
|40 |9244494 |
|--------------------|--------------------|
1 rows fetched in 1 ms.
WORLD-QA>The prompt still shows WORLD-QA: only that one run went to WORLD.
See a difference
To see what a difference looks like, add a test city to the QA copy only. This changes WORLD-QA, a copy you created for practice, and never WORLD:
INSERT INTO CITY (NAME, COUNTRYCODE, DISTRICT, POPULATION) VALUES ('Testville', 'FRA', 'Test', 1000);
SELECT COUNT(*) AS CITIES, SUM(POPULATION) AS POPULATION FROM CITY WHERE COUNTRYCODE = 'FRA';
/ PRODQA now shows 41 cities and 9245494 inhabitants, production still 40 and 9244494. Remove the test city when you are done:
DELETE FROM CITY WHERE NAME = 'Testville';Variations
- Stay in production for a while:
ENV PROD;opens thePRODconnection of the same Database Group, andENV QA;brings you back. - Check which connection
/ PRODwill use:SHOW GROUP;lists the connections of the current Database Group with their Environments. - Run the query again where you are:
/alone.//shows the last query without running it. - The integration copy too:
/ INruns the same query once onWORLD-IN.
Watch out
/ <environment>looks only in the current Database Group. From a connection without a Database Group (theWORLDconnection of a new installation, for example), or when the group has no connection for that Environment, it reports why and runs nothing.- If the
PRODEnvironment is flagged Production and the last statement can change data, BroadSQL asks for a confirmation first: see Production confirmation. ASELECTnever asks. /and/ PRODare typed on a line by themselves.
Related
- Patterns: / and / <environment>
- Connections, Database Groups and Environments
- Syntax and shortcuts
- Run a post-deployment smoke check on every environment
Commands used
Found something wrong or unclear on this page? Tell us, with the page address.