public function createTable($name, array $columns, $primaryKey=null)
    {
        $name = strtolower($name);
        if (strpos($name, 'sqlite_') === 0) {
            throw new \InvalidArgumentException('Created table name must not begin with sqlite_');
        }
        if (empty($columns)) {
            throw new \InvalidArgumentException('No columns specified for new table');
        }
        if ($primaryKey !== null and !is_array($primaryKey)) {
            $primaryKey = array($primaryKey);
        }
        $numAutoIncrement = 0;
        $autoPk = null;
        foreach ($columns as &$column) {
            if (is_array($column)) {
                $column = $this->createColumnFromArray($column);
            }
            if ($column->getAutoIncrement()) {
                $numAutoIncrement++;
                $autoPk = $column->getName();
            }
        }
        unset($column);
        if ($numAutoIncrement > 1) {
            throw new \InvalidArgumentException(
                'More than 1 autoincrement field specified, given: ' . $numAutoIncrement
            );
        }
        if ($autoPk) {
            if ($primaryKey === null) {
                $primaryKey = array($autoPk);
            } elseif (count($primaryKey) != 1 or $autoPk != $primaryKey[0]) {
                throw new \InvalidArgumentException('Invalid primary key: ' . implode(',', $primaryKey));
            }
        }
        if (!$primaryKey) {
            throw new \InvalidArgumentException('Missing primary key for table ' . $name);
        }
        if (in_array($name, $this->getTableNames())) {
            throw new \RuntimeException('Table already exists: ' . $name);
        }

        $colspecs = array();
        foreach ($columns as $column) {
            $colspecs[] = $this->prepareIdentifier($column->getName()) . ' ' . $column->getDefinition();
        }

        $sql = 'CREATE TABLE ' . $this->prepareIdentifier($name) . " (\n";
        $sql .= implode(",\n", $colspecs);
        $sql .= $this->_getTablePkDeclaration($primaryKey, (bool) $numAutoIncrement);
        $sql .= "\n)";

        $this->exec($sql);
        return $this->getTable($name);
    }