Skip to content

How to Resolve RMAN-01009: syntax error: found

  • by

RMAN-01009

There're several error patterns that throw RMAN-01009 during RMAN statement execution.

  1. found "database"
  2. found "list"
  3. found "identifier"

RMAN-01009 means that the word at the position error occurred is not correct, you should use a proper keyword to respond the command. Most likely, there's a syntax error.

found "database"

80% of RMAN-01009 errors have syntax problem, you should use the right keyword at the right position. Let's see a backup command.

RMAN> backup as database;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "database": expecting one of: "backupset, compressed, copy, nonsparse, sparse"
RMAN-01007: at line 1 column 11 file: standard input

The correct syntax of BACKUP AS is one of the following statements:

RMAN> backup as copy database; RMAN> backup as backupset database; RMAN> backup as compressed backupset database;

found "list"

Some statements cannot be executed in a RMAN run block. For example, LIST BACKUP statements.

Let's see a case that we want to list backup record in a rman run block.

[oracle@test ~]$ rman target / @/backup/rman/backup_database.rman
...
RMAN> run {
2>      list
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "list": expecting one of: "advise, allocate, alter, analyze, associate statistics, audit, backup, begin, @, call, catalog, change, comment, commit, configure, convert, copy, create, crosscheck, declare, delete, delete from, describe, describe catalog, disassociate statistics, drop, drop database, duplicate, execute, explain plan, flashback, flashback table, grant, host, insert, lock, merge, mount, noaudit, open, purge, recover, release, rename, repair, report, reset, restore, resync, revoke, rollback, savepoint, select, send, set, set constraint, set role, set transaction, show, shutdown, sql, startup, switch, "
RMAN-01007: at line 2 column 2 file: /backup/rman/backup_database.rman


Recovery Manager complete.

In the above case, RMAN-01009 notified us that at line 2 column 2 in the file is not acceptable in such situation. Let's inspect the file content.

[oracle@test ~]$ cat backup_database.rman
run {
        list backup of database summary;
        backup database;
}

As we can see, in the position error occurred is LIST command. In other words, LIST command is not allowed to use in run block.

Solutions

Remove LIST Statement

To solve RMAN-01009 in such case, we have to remove the LIST command from the run block.

[oracle@test ~]$ vi backup_database.rman
run {
        backup database;
}

Remove Run Block

If you insist to list the backup record before or after backup, then you should remove the run block.

[oracle@test ~]$ vi backup_database.rman
        list backup of database summary;
        backup database;

Without using the run block, all commands in the file are executed with the default setting of RMAN. Let's see how we execute the file in RMAN.

[oracle@test ~]$ rman target / @/backup/rman/backup_database.rman

Recovery Manager: Release 19.0.0.0.0 - Production on Sat Feb 26 07:20:37 2022
Version 19.9.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCLCDB (DBID=3411734329)

RMAN>   list backup of database summary;
2>      backup database;
3>
using target database control file instead of recovery catalog

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
3       B  F  A DISK        26-JAN-22       1       1       NO         TAG20220126T211628
4       B  F  A DISK        26-JAN-22       1       1       NO         TAG20220126T211628
5       B  F  A DISK        26-JAN-22       1       1       NO         TAG20220126T211628

Starting backup at 26-FEB-22
...

We passed.

found "identifier"

On the other side, issuing statements that must be executed in a run block generate RMAN-01009, too. For example, ALLOCATE CHANNEL statements.

[oracle@test ~]$ rman target / @/backup/rman/backup_database.rman
...
RMAN> allocate channel d1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "for"
RMAN-01008: the bad identifier was: d1
RMAN-01007: at line 1 column 18 file: /backup/rman/backup_database.rman


Recovery Manager complete.

The error shows us that ALLOCATE CHANNEL statements must be executed in a run block.

Solutions

Use RMAN Run Block

The first solution is to use a RMAN run block to wrap those statements so as to confine its scope of usage.

[oracle@test ~]$ vi backup_database.rman
run {
        allocate channel d1 type disk;
        backup database;
}

Use Default Channels

Actually, it's unnecessarily to allocate channels to backup the database. Without allocating channels, it will run your statements by using default channels if you have configured the device type and parallelism well in RMAN.

Leave a Reply

Your email address will not be published.