{"record":{"id":"1273d155b479f69a","repo":"yiisoft/yii2","slug":"unknown-table-table","errorCode":null,"errorMessage":"Unknown table: $table","messagePattern":"Unknown table: \\$table","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"framework/db/oci/QueryBuilder.php","lineNumber":145,"sourceCode":"     * Builds a SQL statement for dropping an index.\n     *\n     * @param string $name the name of the index to be dropped. The name will be properly quoted by the method.\n     * @param string $table the table whose index is to be dropped. The name will be properly quoted by the method.\n     * @return string the SQL statement for dropping an index.\n     */\n    public function dropIndex($name, $table)\n    {\n        return 'DROP INDEX ' . $this->db->quoteTableName($name);\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    public function executeResetSequence($table, $value = null)\n    {\n        $tableSchema = $this->db->getTableSchema($table);\n        if ($tableSchema === null) {\n            throw new InvalidArgumentException(\"Unknown table: $table\");\n        }\n        if ($tableSchema->sequenceName === null) {\n            throw new InvalidArgumentException(\"There is no sequence associated with table: $table\");\n        }\n\n        if ($value !== null) {\n            $value = (int) $value;\n        } else {\n            if (count($tableSchema->primaryKey) > 1) {\n                throw new InvalidArgumentException(\"Can't reset sequence for composite primary key in table: $table\");\n            }\n            // use master connection to get the biggest PK value\n            $value = $this->db->useMaster(function (Connection $db) use ($tableSchema) {\n                return $db->createCommand(\n                    'SELECT MAX(\"' . $tableSchema->primaryKey[0] . '\") FROM \"' . $tableSchema->name . '\"'\n                )->queryScalar();\n            }) + 1;\n        }","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/db/oci/QueryBuilder.php#L127-L163","documentation":"yii\\db\\oci\\QueryBuilder::executeResetSequence() drops and recreates the Oracle sequence that backs a table's primary key, so it first resolves the table through $this->db->getTableSchema($table). A null schema produces InvalidArgumentException 'Unknown table'. Unlike the SQL-building resetSequence(), this variant executes multiple statements directly.","triggerScenarios":"Calling $db->createCommand()->executeResetSequence('tbl') where 'tbl' is misspelled, lives in a different Oracle schema than the connected user, or uses different case (Oracle upper-cases unquoted identifiers).","commonSituations":"Connecting as a user different from the table owner; forgetting the SCHEMA.TABLE prefix in multi-schema Oracle setups; fixture code assuming the same defaults as the MySQL driver; lowercase table names on a case-sensitive Oracle installation.","solutions":["Verify visibility first: $db->getTableSchema($table, true) must return a schema.","Use the schema-qualified, correctly-cased name exactly as introspection reports it (typically uppercase for unquoted Oracle names).","Confirm the connection user matches the schema, or grant/select access and add the prefix.","Run migrations or imports that create the table before resetting its sequence."],"exampleFix":"// before\n$db->createCommand()->executeResetSequence('item');\n\n// after\n$table = 'APP.ITEM'; // schema-qualified, uppercase\nif ($db->getTableSchema($table, true) === null) {\n    throw new InvalidArgumentException(\"Unknown table: $table\");\n}\n$db->createCommand()->executeResetSequence($table);","handlingStrategy":"validation","validationCode":"// Oracle: verify schema-qualified, correctly-cased table first\nif ($db->getTableSchema($table, true) === null) {\n    throw new InvalidArgumentException(\"Unknown table: $table\");\n}\n$db->createCommand()->executeResetSequence($table)->execute();","typeGuard":"use yii\\db\\TableSchema;\n\nfunction tableSchemaOrFail(?TableSchema $schema, string $name): TableSchema\n{\n    if ($schema === null) {\n        throw new InvalidArgumentException(\"Unknown table: $name\");\n    }\n    return $schema;\n}","tryCatchPattern":"try {\n    $db->createCommand()->executeResetSequence($table)->execute();\n} catch (\\yii\\base\\InvalidArgumentException $e) {\n    // recheck with refresh: $db->getTableSchema($table, true)\n}","preventionTips":["Standardize on schema-qualified, uppercase table names in Oracle projects.","Verify the connected user's default schema at bootstrap and log it.","Run sequence resets only after confirming the fixture schema was created."],"tags":["yii2","php","oracle","oci","database","sequence","table-not-found"],"backgroundTag":"database-table-not-found","analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}