Reset a sequence to the id field of a table.
@param string|xmldb_table $table Name of table.
@throws ddl_exception thrown upon reset errors.
342252
public function reset_sequence($table) {
        if (!is_string($table) and !($table instanceof xmldb_table)) {
            throw new ddl_exception('ddlunknownerror', NULL, 'incorrect table parameter!');
        } else {
            if ($table instanceof xmldb_table) {
                $tablename = $table->getName();
            } else {
                $tablename = $table;
            }
        }

        // Do not test if table exists because it is slow

        if (!$sqlarr = $this->generator->getResetSequenceSQL($table)) {
            throw new ddl_exception('ddlunknownerror', null, 'table reset sequence sql not generated');
        }

        $this->execute_sql_arr($sqlarr, array($tablename));
    }
272684
protected function createTable(Table $table): void
	{
		$table->addPrimaryKey('id')
			->int()
			->setAutoIncrement();
		$table->addForeignKey('pageId', PagesMapper::class);
		$table->addColumn('name')
			->text();
		$table->addColumn('quantity')
			->tinyint(2)
			->setDefault(null);
		$table->addColumn('position')
			->int(3);
		$table->addColumn('visible')
			->bool()
			->setDefault(1);
	}
544194
public function dropAutoIncrementObjects($table)
    {
        // drop sequence and trigger object
        $prefix = $this->connection->getTablePrefix();
        // get the actual primary column name from table
        $col = $this->getPrimaryKey($prefix . $table);
        // if primary key col is set, drop auto increment objects
        if (isset($col) && ! empty($col)) {
            // drop sequence for auto increment
            $sequenceName = $this->createObjectName($prefix, $table, $col, 'seq');
            $this->sequence->drop($sequenceName);

            // drop trigger for auto increment work around
            $triggerName = $this->createObjectName($prefix, $table, $col, 'trg');
            $this->trigger->drop($triggerName);
        }
    }
583223
public function dropAndCreateTable(Table $table)
    {
        $this->tryMethod('dropTable', $table->getQuotedName($this->_platform));
        $this->createTable($table);
    }
730331
private function createTable(Table &$table) {
        $annotations = $this->getClassSettings();
        $create = false;
        foreach ($annotations as $columnName => $descArray) {
            $create = true;
            $dbColumnName = Util::camelTo_($columnName);

            if (isset($descArray['attrs']['primary']) && $descArray['attrs']['primary']) {
                $table->setPrimaryKey($dbColumnName);
            }

            if (isset($descArray['attrs']['reference'])) { // Reference not ReferenceMany
                $onDelete = (isset($descArray['attrs']['reference']['onDelete'])) ?
                        $descArray['attrs']['reference']['onDelete'] : 'RESTRICT';
                $onUpdate = (isset($descArray['attrs']['reference']['onUpdate'])) ?
                        $descArray['attrs']['reference']['onUpdate'] : 'RESTRICT';
                $table->addReference($dbColumnName, $descArray['attrs']['reference']['table'], $descArray['attrs']['reference']['column'], $onDelete, $onUpdate);

                $refTable = new Table($descArray['attrs']['reference']['table'], $table->getConnection());
                $refColumns = $refTable->getColumns();
                if (!empty($refColumns[$descArray['attrs']['reference']['column']]['charset'])) {
                    $descArray['attrs']['charset'] = $refColumns[$descArray['attrs']['reference']['column']]['charset'];
                    $descArray['attrs']['collation'] = $refColumns[$descArray['attrs']['reference']['column']]['collation'];
                }

                unset($descArray['attrs']['reference']['table']);
                unset($descArray['attrs']['reference']['column']);
                unset($descArray['attrs']['reference']['model']);

                if (isset($descArray['attrs']['reference']['onUpdate']))
                    unset($descArray['attrs']['reference']['onUpdate']);
                if (isset($descArray['attrs']['reference']['onDelete']))
                    unset($descArray['attrs']['reference']['onDelete']);

                if (!empty($descArray['attrs']['reference'])) {
                    $descArray['attrs'] = array_merge($descArray['attrs'], $descArray['attrs']['reference']);
                    unset($descArray['attrs']['reference']);
                }
            }

            $table->addColumn($dbColumnName, $this->parseAttributes($columnName, $descArray));
            $this->checkIndexes($dbColumnName, $descArray, $table);
        }

        return ($create) ? $table->getConnection()->createTable($table, false) : false;
    }
851445
private void deleteTable(String tableName) {
        m_logger.info("Deleting table: {}", tableName);
        try {
            m_ddbClient.deleteTable(new DeleteTableRequest(tableName));
            for (int seconds = 0; seconds < 10; seconds++) {
                try {
                    m_ddbClient.describeTable(tableName);
                    Thread.sleep(1000);
                } catch (ResourceNotFoundException e) {
                    break;  // Success
                }   // All other exceptions passed to outer try/catch
            }
        } catch (ResourceNotFoundException e) {
            // Already deleted.
        } catch (Exception e) {
            throw new RuntimeException("Error deleting table: " + tableName, e);
        }
    }
325391
public function initialize($schema, $table=null)
    {
        $mapper = $this->_mapper($schema);
        $table = $table ? $this->_connection($schema)->table($table) : $mapper->table();

        $sequencePool = $this->_connection($schema)->sequencePool();
        $sequencePool->initialize();

        $columns = array();

        // build a map of properties to create
        foreach ($schema->properties() as $prop) {
            $columns[$prop->name] = $prop->type;

            // reset sequences as we go
            if (property_exists($prop->type, 'sequence')) {
                $sequencePool->delete($mapper->sequenceName($prop));
            }
        }

        $table->create($columns);

        return $this;
    }
176209
public function setTable($table)
    {
        if (!is_string($table)) {
            throw new InvalidArgumentException(sprintf(
                'DatabaseSource::setTable() expects a string as table. (%s given). [%s]',
                gettype($table),
                get_class($this->model())
            ));
        }

        /**
         * For security reason, only alphanumeric characters (+ underscores)
         * are valid table names; Although SQL can support more,
         * there's really no reason to.
         */
        if (!preg_match('/[A-Za-z0-9_]/', $table)) {
            throw new InvalidArgumentException(sprintf(
                'Table name "%s" is invalid: must be alphanumeric / underscore.',
                $table
            ));
        }

        $this->table = $table;
        return $this;
    }
927600
public function resetConsumedUnits($table = null)
    {
        if (is_null($table)) {
            if (null !== $this->logger) {
                $this->log('Reset all consumed units counters');
            }
            $this->readUnit  = array();
            $this->writeUnit = array();
        } else {
            if (null !== $this->logger) {
                $this->log('Reset consumed units counters for table '.$table);
            }
            unset(
                $this->readUnit[$table],
                $this->writeUnit[$table]
            );
        }
    }
53214
public function setTable(Table $table)
    {
        $this->_table = $table;
        $eventManager = $table->getEventManager();
        if ($eventManager !== null) {
            $this->setEventManager($eventManager);
        }
    }
350200
private function SaveToTable($table)
    {
        $sql = Access::SqlBuilder();
        $fields = array();
        $setList = null;
        foreach ($this->Elements()->GetElements() as $element)
        {
            $this->HandleElement($table, $element, $fields, $setList);
        }
        if ($setList)
        {
            Access::Connection()->ExecuteQuery($sql->Insert($sql->Table($table, $fields), $setList));
        }
    }
883283
public function getResetSequenceSQL($table) {

        if ($table instanceof xmldb_table) {
            $tablename = $table->getName();
        } else {
            $tablename = $table;
        }

        // From http://dev.mysql.com/doc/refman/5.0/en/alter-table.html
        $value = (int)$this->mdb->get_field_sql('SELECT MAX(id) FROM {'.$tablename.'}');
        $value++;
        return array("ALTER TABLE $this->prefix$tablename AUTO_INCREMENT = $value");
    }
326939
public function setTable($table)
    {
        if ($table === null) {
            $this->table = $table;
            return $this;
        }

        if (!is_string($table)) {
            throw new InvalidArgumentException(
                'Table reference must be a string.'
            );
        }

        if ($table === '') {
            throw new InvalidArgumentException(
                'Table reference can not be empty.'
            );
        }

        $this->table = $table;
        return $this;
    }
582742
public function sort(Table $table)
    {
        $column = $table->getSortColumn();
        $dir = $table->getSortDir();

        if (!$column)
            return;

        $sqlId = null;
        foreach ($table->getColumns() as $id => $params) {
            if ($id == $column) {
                $sqlId = $params['sql_id'];
                break;
            }
        }

        if (!$sqlId)
            throw new \Exception("No 'sql_id' for column: $column");

        $qb = $this->getQueryBuilder();
        $qb->addOrderBy($sqlId, $dir);
    }
595188
public function setTable($table) {

		if(false === is_string($table)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($table)), E_USER_ERROR);
		}

		$this -> table = $table;

		return $this;
	}
504266
public function insert_id($table = null)
    {
        if (!$this->db_connected || $this->db_mode == 'r' || empty($table)) {
            return false;
        }

        $sequence = $this->quote_identifier($this->sequence_name($table));
        $result   = $this->query("SELECT $sequence.currval FROM dual");
        $result   = $this->fetch_array($result);

        return $result[0] ?: false;
    }
1247797
public function EmptyTable($Table = '') {
      if ($Table == '') {
         if (!isset($this->_Froms[0]))
            return FALSE;

         $Table = $this->_Froms[0];
      } else {
         $Table = $this->EscapeIdentifier($this->Database->DatabasePrefix.$Table);
      }


      $Sql = $this->GetDelete($Table);
      
      return $this->Query($Sql, 'delete');
   }