The ORC database¶
This page shows how we look inside the ORC database with sfe. ORC is the database behind the student application. It holds the students, the programs they chose, and how far each one has got in the application. We use it to answer questions such as "how many students are in this stage?" or "which columns does this table have?". Everything on this page only reads, so none of it can change a record.
Video, about two and a half minutes, with narration and captions.
Words we use on this page¶
- Database: a program that keeps information in an organised way. ORC is a MySQL database.
- Table: one list of things, like one sheet in a spreadsheet. ORC has a table for stages, one for programs, and so on.
- Row: one thing in a table, such as one stage.
- Column: one fact about every row, such as its name or its launch date.
- SQL: the small language we use to ask a database a question.
SELECTmeans "show me". It never changes anything. - Read-only session: a connection that the database itself has set to refuse every change. sfe opens every ORC connection this way.
- Environment: which copy of the database we talk to.
devis the practice copy,stageis the rehearsal copy, andprodis production, the real one.
Before you start¶
- sfe is installed and our pack is on. If it is not, we do that first: The path at a glance.
- We saved our ORC database account once with
sfe orc login. The steps are in ORC database sign-in. The password goes into the Mac Keychain, and we type it ourselves. - We use the
devenvironment on this page. It is the safest place to practise.
Warning
ORC holds students. On this page we only look at the shape of tables and at counts. We never select a name, an email, a WGU id or any other row about a person. The example that sfe help orc prints selects ids from the user table, so we do not copy it.
Tip
Without -e dev, sfe uses the environment it is pointed at now. On this install that is production, and sfe marks it in red. We add -e dev to every command on this page so that we always know where we are.
Steps¶
1. Open a terminal and see the commands¶
We open the Terminal app. We type sfe help orc and press Enter.
sfe lists the six ORC commands.

login and logout keep our database password in the Keychain. ping, tables and describe look around. query runs a read statement. All of them only read.
2. Check the connection¶
We ping the database first. It asks one tiny question that touches no data, and it proves that the host, the account and the password all work.

The last two lines are the answer. user is the account we are, and db is the database we reached. The part -e dev picks the environment for this one command.
3. List the tables¶
We list the tables whose name contains a word. Here the word is stage.

There are three. The names match the models in the ORC code, so we can find the code that fills each table. Without --contains, sfe lists every table, which is a long list.
4. Read the columns of one table¶
describe shows the columns of one table, and no rows.

Each line is one column. Type is the kind of value it holds, for example varchar(60) is text of up to 60 characters. Null says whether it may be empty. Key marks PRI, the column that names each row, and UNI, a column where no two rows may share a value. We read this before we write any query, so that we use the right names.
5. Count the rows¶
A count is the simplest question we can ask. The quotes around the SQL matter, because the SQL has spaces in it.

The answer is one number. A count has no person in it.
6. Group the rows¶
We can also ask for one number per group. This counts the rows of the student stage table by their state.
sfe orc query "SELECT state, COUNT(*) AS how_many FROM user_application_stages GROUP BY state" -e dev

The answer is one line per state and a total for each. The query returns no name, no email and no id, so it is safe to run and to share.
7. Read what sfe says before the answer¶
Before every answer, sfe says what it is about to do. Here are the parts of that block for the last command:

Number 3 is the one to remember. SET SESSION TRANSACTION READ ONLY makes the database refuse any change for the whole connection, even if we typed a change by mistake. Number 4 shows that sfe added LIMIT 200 for us, so a wide query cannot flood the screen. Use --limit to change that.
Stage and production¶
The same commands work on stage and on prod. We add -e stage or -e prod. Both are SELECT only, in two ways: sfe sends every statement through a read-only session, and the production account can only read. Production is never changed through sfe. When we do need a change, we follow How changes work.
What we should see¶
read-onlyin green on every step, with the time it took andexit 0.ORC dev databasein green at the top right of the block. Production would show in red.- Table and column names, and numbers. No names, emails or ids of people.
Troubleshooting¶
| What we see | Likely cause | What to do |
|---|---|---|
login needed, and the exit code is 4 |
No saved database password for that environment, or it has expired | Run sfe orc login -e dev ourselves, and type the password when it asks. We never share it |
refused by the read-only policy, exit code 3 |
The statement is not a SELECT, SHOW, DESCRIBE or EXPLAIN |
Nothing to fix. We read with sfe, and make changes through How changes work |
Table '...' doesn't exist |
The table name is spelled differently | Run sfe orc tables -e dev --contains <part of the name> and copy the name from the list |
Unknown column |
The column name is wrong | Run sfe orc describe <table> -e dev and use a name from the list |
| The command hangs or cannot connect | The database cannot be reached from where we are | Check the network connection, then run sfe doctor orc. It says what is wrong and the exact fix |
| The block at the top is red and says production | We left out -e dev and sfe used production |
The command only read. We add -e dev and run it again if we meant the practice copy |
Next¶
- Notes sfe remembers, for what sfe keeps from one session to the next.
- Look into a ticket or incident.
Last reviewed: 2026-12-01