{"id":1217,"date":"2016-04-10T00:18:39","date_gmt":"2016-04-09T22:18:39","guid":{"rendered":"https:\/\/vielhuber.de\/?p=1217"},"modified":"2017-02-03T23:29:36","modified_gmt":"2017-02-03T22:29:36","slug":"spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel","status":"publish","type":"post","link":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/","title":{"rendered":"Spalten tauschen in PostgreSQL"},"content":{"rendered":"<p>Das Vertauschen\u00a0von SQL-Tabellenspalten geh\u00f6rt bei MySQL zum Standardrepertoire\u00a0\u2013 bei PostgreSQL wird dies (noch) nicht unterst\u00fctzt. Zwar widmet das offizielle Wiki dem Problem einen eigenen <a href=\"https:\/\/wiki.postgresql.org\/wiki\/Alter_column_position\" target=\"_blank\">Beitrag<\/a>, zeigt aber keine praktikable L\u00f6sung auf, die auch Views, Indizes und Triggers unterst\u00fctzt. Folgende Klasse erledigt diesen Job (sowohl f\u00fcr MySQL als auch f\u00fcr PostgreSQL) entweder auf der Kommandozeile \u2013 oder alternativ direkt in Laravel 5.<\/p>\n<p><!--more--><\/p>\n<pre>&lt;?php\r\nnamespace App\\Helpers;\r\nclass ColumnChanger\r\n{\r\n\r\n\tpublic static $quotes;\r\n\r\n\tpublic static $path;\r\n\r\n\tpublic static function swap($table, $col1, $col2)\r\n\t{\r\n\r\n\t\t\/\/ initialize\r\n\r\n\t\tself::$quotes = self::getQuotes();\r\n\t\tself::$path = self::getPath();\r\n\r\n\t\t\/\/ export\r\n\r\n\t\t$content = self::exportDB();\r\n\r\n\t\t\/\/ swap\r\n\r\n\t\t$content = self::swapNow($table, $col1, $col2, $content);\r\n\r\n\t\t\/\/ import\r\n\r\n\t\tself::importDB($content);\r\n\t}\r\n\r\n\tpublic static function getQuotes()\r\n\t{\r\n\t\tif (getenv(\"DB_CONNECTION\") == \"pgsql\")\r\n\t\t{\r\n\t\t\treturn \"\";\r\n\t\t}\r\n\r\n\t\tif (getenv(\"DB_CONNECTION\") == \"mysql\")\r\n\t\t{\r\n\t\t\treturn \"`\";\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static function getPath()\r\n\t{\r\n\t\tif (getenv(\"DB_CONNECTION\") == \"pgsql\")\r\n\t\t{\r\n\t\t\t$sql = new \\PDO('pgsql:host=' . getenv('DB_HOST') . ';port=' . getenv('DB_PORT') . ';dbname=' . getenv('DB_DATABASE') , getenv('DB_USERNAME') , getenv('DB_PASSWORD'));\r\n\t\t\t$stmt = $sql-&gt;prepare(\"SHOW data_directory\");\r\n\t\t\t$stmt-&gt;execute();\r\n\t\t\t$path = str_replace(\"data\", \"bin\", $stmt-&gt;fetchObject()-&gt;data_directory) . \"\/\";\r\n\t\t}\r\n\r\n\t\tif (getenv(\"DB_CONNECTION\") == \"mysql\")\r\n\t\t{\r\n\t\t\t$sql = new \\PDO('mysql:host=' . getenv('DB_HOST') . ';port=' . getenv('DB_PORT') . ';dbname=' . getenv('DB_DATABASE') , getenv('DB_USERNAME') , getenv('DB_PASSWORD'));\r\n\t\t\t$stmt = $sql-&gt;prepare(\"SHOW VARIABLES LIKE 'basedir'\");\r\n\t\t\t$stmt-&gt;execute();\r\n\t\t\t$path = $stmt-&gt;fetchObject()-&gt;Value . \"bin\/\";\r\n\t\t}\r\n\r\n\t\treturn $path;\r\n\t}\r\n\r\n\tpublic static function exportDB()\r\n\t{\r\n\t\tif (getenv(\"DB_CONNECTION\") == \"pgsql\")\r\n\t\t{\r\n\t\t\tputenv(\"PGPASSWORD=\" . getenv('DB_PASSWORD'));\r\n\t\t\texec('\"' . self::$path . 'pg_dump\" --clean --inserts -h ' . getenv('DB_HOST') . ' -p ' . getenv('DB_PORT') . ' -U ' . getenv('DB_USERNAME') . ' ' . getenv('DB_DATABASE') . ' &gt; db.sql');\r\n\t\t}\r\n\r\n\t\tif (getenv(\"DB_CONNECTION\") == \"mysql\")\r\n\t\t{\r\n\t\t\texec('\"' . self::$path . 'mysqldump\" -h ' . getenv('DB_HOST') . ' --port ' . getenv('DB_PORT') . ' -u ' . getenv('DB_USERNAME') . ' -p\"' . getenv('DB_PASSWORD') . '\" ' . getenv('DB_DATABASE') . ' &gt; db.sql');\r\n\t\t}\r\n\r\n\t\treturn file_get_contents(\"db.sql\");\r\n\t}\r\n\r\n\tpublic static function importDB($content)\r\n\t{\r\n\t\tfile_put_contents(\"db.sql\", $content);\r\n\t\tif (getenv(\"DB_CONNECTION\") == \"pgsql\")\r\n\t\t{\r\n\t\t\tputenv(\"PGPASSWORD=\" . getenv('DB_PASSWORD'));\r\n\t\t\texec('\"' . self::$path . 'psql\" -h ' . getenv('DB_HOST') . ' -p ' . getenv('DB_PORT') . ' -U ' . getenv('DB_USERNAME') . ' -d ' . getenv('DB_DATABASE') . ' -1 -f db.sql');\r\n\t\t}\r\n\r\n\t\tif (getenv(\"DB_CONNECTION\") == \"mysql\")\r\n\t\t{\r\n\t\t\texec('\"' . self::$path . 'mysql\" -h ' . getenv('DB_HOST') . ' --port ' . getenv('DB_PORT') . ' -u ' . getenv('DB_USERNAME') . ' -p\"' . getenv('DB_PASSWORD') . '\" ' . getenv('DB_DATABASE') . ' --default-character-set=utf8 &lt; db.sql');\r\n\t\t}\r\n\r\n\t\tunlink(\"db.sql\");\r\n\t}\r\n\r\n\tpublic static function getPositions($haystack, $needle)\r\n\t{\r\n\t\t$positions = [];\r\n\t\t$lastPos = 0;\r\n\t\twhile (($lastPos = strpos($haystack, $needle, $lastPos)) !== false)\r\n\t\t{\r\n\t\t\t$positions[] = $lastPos;\r\n\t\t\t$lastPos = $lastPos + strlen($needle);\r\n\t\t}\r\n\r\n\t\treturn $positions;\r\n\t}\r\n\r\n\tpublic static function getEnd($content, $begin)\r\n\t{\r\n\t\t$end = $begin;\r\n\t\t$outside = true;\r\n\t\twhile ($outside !== true || $content[$end] != \";\")\r\n\t\t{\r\n\t\t\tif ($content[$end] == \"'\")\r\n\t\t\t{\r\n\t\t\t\tif ($end === 0 || $content[$end - 1] != \"\\\\\")\r\n\t\t\t\t{\r\n\t\t\t\t\t$outside = !$outside;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t$end++;\r\n\t\t}\r\n\r\n\t\treturn ++$end;\r\n\t}\r\n\r\n\tpublic static function splitString($string)\r\n\t{\r\n\t\treturn preg_split('\/(?&lt;!^)(?!$)\/u', $string);\r\n\t}\r\n\r\n\tpublic static function getColumns($query)\r\n\t{\r\n\t\t$i = 0;\r\n\t\t$outside = true;\r\n\t\t$query = self::splitString($query);\r\n\t\tforeach($query as $i =&gt; $char)\r\n\t\t{\r\n\t\t\tif ($query[$i] == \"'\")\r\n\t\t\t{\r\n\t\t\t\tif ($i === 0 || $query[$i - 1] != \"\\\\\")\r\n\t\t\t\t{\r\n\t\t\t\t\t$outside = !$outside;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif ($outside === true &amp;&amp; $query[$i] == \",\")\r\n\t\t\t{\r\n\t\t\t\t$query[$i] = \"\u2665\";\r\n\t\t\t}\r\n\r\n\t\t\t$i++;\r\n\t\t}\r\n\r\n\t\t$query = implode(\"\", $query);\r\n\t\t$cols = explode(\"\u2665\", $query);\r\n\t\treturn $cols;\r\n\t}\r\n\r\n\tpublic static function swapNow($table, $col1, $col2, $content)\r\n\t{\r\n\r\n\t\t\/\/ loop through relevant statements\r\n\r\n\t\tforeach([\"CREATE TABLE \" . self::$quotes . $table . self::$quotes, \"INSERT INTO \" . self::$quotes . $table . self::$quotes] as $skey =&gt; $statement)\r\n\t\t{\r\n\t\t\t$positions = self::getPositions($content, $statement);\r\n\t\t\tforeach($positions as $position)\r\n\t\t\t{\r\n\t\t\t\t$begin = $position;\r\n\t\t\t\t$end = self::getEnd($content, $begin);\r\n\t\t\t\t$query_all = substr($content, $begin, $end - $begin);\r\n\t\t\t\t$query_inside = substr($query_all, strpos($query_all, \"(\") + 1, strrpos($query_all, \")\") - strpos($query_all, \"(\") - 1);\r\n\r\n\t\t\t\t\/\/ get columns\r\n\r\n\t\t\t\t$cols = self::getColumns($query_inside);\r\n\r\n\t\t\t\t\/\/ get relevant column indexes\r\n\r\n\t\t\t\tif ($skey == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\t$col1pos = 0;\r\n\t\t\t\t\t$col2pos = 0;\r\n\t\t\t\t\tforeach($cols as $pos =&gt; $col)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t$col = trim($col);\r\n\t\t\t\t\t\tif (strpos($col, self::$quotes . $col1 . self::$quotes) === 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t$col1pos = $pos;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (strpos($col, self::$quotes . $col2 . self::$quotes) === 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t$col2pos = $pos;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\/\/ swap columns\r\n\r\n\t\t\t\t$tmp = $cols[$col1pos];\r\n\t\t\t\t$cols[$col1pos] = $cols[$col2pos];\r\n\t\t\t\t$cols[$col2pos] = $tmp;\r\n\t\t\t\t$query_inside_new = implode(\",\", $cols);\r\n\r\n\t\t\t\t\/\/ insert query into content\r\n\r\n\t\t\t\t$query_all_new = str_replace($query_inside, $query_inside_new, $query_all);\r\n\t\t\t\t$content = str_replace($query_all, $query_all_new, $content);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn $content;\r\n\t}\r\n}\r\n\r\n\/\/ usage from the command line\r\n\r\nif (isset($argv) &amp;&amp; is_array($argv))\r\n{\r\n\t$args = [];\r\n\tforeach($argv as $key =&gt; $arg)\r\n\t{\r\n\t\tswitch ($arg)\r\n\t\t{\r\n\t\tcase \"-e\":\r\n\t\t\t$args[\"engine\"] = $argv[$key + 1];\r\n\t\t\tbreak;\r\n\r\n\t\tcase \"-h\":\r\n\t\t\t$args[\"hostname\"] = $argv[$key + 1];\r\n\t\t\tbreak;\r\n\r\n\t\tcase \"-P\":\r\n\t\t\t$args[\"port\"] = $argv[$key + 1];\r\n\t\t\tbreak;\r\n\r\n\t\tcase \"-u\":\r\n\t\t\t$args[\"username\"] = $argv[$key + 1];\r\n\t\t\tbreak;\r\n\r\n\t\tcase \"-p\":\r\n\t\t\t$args[\"password\"] = $argv[$key + 1];\r\n\t\t\tbreak;\r\n\r\n\t\tcase \"-d\":\r\n\t\t\t$args[\"database\"] = $argv[$key + 1];\r\n\t\t\tbreak;\r\n\r\n\t\tcase \"-t\":\r\n\t\t\t$args[\"table\"] = $argv[$key + 1];\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\t\/\/ set default values\r\n\r\n\tif (!isset($args[\"hostname\"]))\r\n\t{\r\n\t\t$args[\"hostname\"] = \"127.0.0.1\";\r\n\t}\r\n\r\n\tif (!isset($args[\"port\"]) &amp;&amp; isset($args[\"engine\"]) &amp;&amp; $args[\"engine\"] == \"mysql\")\r\n\t{\r\n\t\t$args[\"port\"] = \"3306\";\r\n\t}\r\n\r\n\tif (!isset($args[\"port\"]) &amp;&amp; isset($args[\"engine\"]) &amp;&amp; $args[\"engine\"] == \"pgsql\")\r\n\t{\r\n\t\t$args[\"port\"] = \"5432\";\r\n\t}\r\n\r\n\tforeach($args as $option =&gt; $arg)\r\n\t{\r\n\t\tif (!isset($arg))\r\n\t\t{\r\n\t\t\tdie('missing option ' . $option);\r\n\t\t}\r\n\t}\r\n\r\n\tif (count($argv) &lt; 2)\r\n\t{\r\n\t\tdie('error');\r\n\t}\r\n\r\n\t$args[\"col1\"] = $argv[count($argv) - 2];\r\n\t$args[\"col2\"] = $argv[count($argv) - 1];\r\n\tputenv(\"DB_CONNECTION=\" . $args[\"engine\"]);\r\n\tputenv(\"DB_HOST=\" . $args[\"hostname\"]);\r\n\tputenv(\"DB_PORT=\" . $args[\"port\"]);\r\n\tputenv(\"DB_DATABASE=\" . $args[\"database\"]);\r\n\tputenv(\"DB_USERNAME=\" . $args[\"username\"]);\r\n\tputenv(\"DB_PASSWORD=\" . $args[\"password\"]);\r\n\tColumnChanger::swap($args[\"table\"], $args[\"col1\"], $args[\"col2\"]);\r\n\t\r\n}<\/pre>\n<p>Der Aufruf auf der Kommandozeile\u00a0ist selbsterkl\u00e4rend:<\/p>\n<pre>php ColumnChanger.php -e pgsql -h 127.0.0.1 -P 5432 -u username -p password -d database -t table col1 col2\r\nphp ColumnChanger.php -e mysql -h 127.0.0.1 -P 3306 -u username -p password -d database -t table col1 col2<\/pre>\n<p>Auch die Integration in Laravel 5 ist durch einfaches Kopieren von ColumnChanger.php in den Ordner\u00a0app\/Helpers schnell erledigt. Innerhalb von <a href=\"https:\/\/laravel.com\/docs\/5.2\/migrations\" target=\"_blank\">Migrations<\/a>\u00a0kann man dann direkt Spalten vertauschen:<\/p>\n<pre>&lt;?php\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\n\r\nclass SwitchColumns extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function up()\r\n    {\r\n        App\\Helpers\\ColumnChanger::swap(\"users\",\"email\",\"password\");\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function down()\r\n    {\r\n        App\\Helpers\\ColumnChanger::swap(\"users\",\"password\",\"email\");\r\n    }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Das Vertauschen\u00a0von SQL-Tabellenspalten geh\u00f6rt bei MySQL zum Standardrepertoire\u00a0\u2013 bei PostgreSQL wird dies (noch) nicht unterst\u00fctzt. Zwar widmet das offizielle Wiki dem Problem einen eigenen Beitrag, zeigt aber keine praktikable L\u00f6sung auf, die auch Views, Indizes und Triggers unterst\u00fctzt. Folgende Klasse erledigt diesen Job (sowohl f\u00fcr MySQL als auch f\u00fcr PostgreSQL) entweder auf der Kommandozeile \u2013 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"gtbabel_prevent_lngs":"","gtbabel_alt_lng":"","footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-1217","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-blog"},"acf":[],"yoast_head":"<title>Spalten tauschen in PostgreSQL &#060; Vielhuber David<\/title>\n<meta name=\"description\" content=\"Das Vertauschen\u00a0von SQL-Tabellenspalten geh\u00f6rt bei MySQL zum Standardrepertoire\u00a0\u2013 bei PostgreSQL wird dies (noch) nicht unterst\u00fctzt. Zwar widmet...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spalten tauschen in PostgreSQL &#060; Vielhuber David\" \/>\n<meta property=\"og:description\" content=\"Das Vertauschen\u00a0von SQL-Tabellenspalten geh\u00f6rt bei MySQL zum Standardrepertoire\u00a0\u2013 bei PostgreSQL wird dies (noch) nicht unterst\u00fctzt. Zwar widmet das\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/\" \/>\n<meta property=\"og:site_name\" content=\"Vielhuber David\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-09T22:18:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-02-03T22:29:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"552\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"David\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vielhuber\" \/>\n<meta name=\"twitter:site\" content=\"@vielhuber\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"David\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"5\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\\\/\"},\"author\":{\"name\":\"David\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#\\\/schema\\\/person\\\/64d4ff14713d413ea4d9b210d0c2c6ef\"},\"headline\":\"Spalten tauschen in PostgreSQL\",\"datePublished\":\"2016-04-09T22:18:39+00:00\",\"dateModified\":\"2017-02-03T22:29:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\\\/\"},\"wordCount\":106,\"publisher\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#\\\/schema\\\/person\\\/64d4ff14713d413ea4d9b210d0c2c6ef\"},\"articleSection\":[\"Blog\"],\"inLanguage\":\"de\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\\\/\",\"url\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\\\/\",\"name\":\"Spalten tauschen in PostgreSQL &#060; Vielhuber David\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#website\"},\"datePublished\":\"2016-04-09T22:18:39+00:00\",\"dateModified\":\"2017-02-03T22:29:36+00:00\",\"description\":\"Das Vertauschen\u00a0von SQL-Tabellenspalten geh\u00f6rt bei MySQL zum Standardrepertoire\u00a0\u2013 bei PostgreSQL wird dies (noch) nicht unterst\u00fctzt. Zwar widmet das\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vielhuber.de\\\/blog\\\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/blog\\\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vielhuber.de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spalten tauschen in PostgreSQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#website\",\"url\":\"https:\\\/\\\/vielhuber.de\\\/\",\"name\":\"Vielhuber David\",\"description\":\"Full-Stack Developer\",\"publisher\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#\\\/schema\\\/person\\\/64d4ff14713d413ea4d9b210d0c2c6ef\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/vielhuber.de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/vielhuber.de\\\/#\\\/schema\\\/person\\\/64d4ff14713d413ea4d9b210d0c2c6ef\",\"name\":\"David\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/vielhuber.de\\\/wp-content\\\/uploads\\\/about.jpg\",\"url\":\"https:\\\/\\\/vielhuber.de\\\/wp-content\\\/uploads\\\/about.jpg\",\"contentUrl\":\"https:\\\/\\\/vielhuber.de\\\/wp-content\\\/uploads\\\/about.jpg\",\"width\":700,\"height\":552,\"caption\":\"David\"},\"logo\":{\"@id\":\"https:\\\/\\\/vielhuber.de\\\/wp-content\\\/uploads\\\/about.jpg\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/vielhuber\"]}]}<\/script>","yoast_head_json":{"title":"Spalten tauschen in PostgreSQL &#060; Vielhuber David","description":"Das Vertauschen\u00a0von SQL-Tabellenspalten geh\u00f6rt bei MySQL zum Standardrepertoire\u00a0\u2013 bei PostgreSQL wird dies (noch) nicht unterst\u00fctzt. Zwar widmet...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/","og_locale":"de_DE","og_type":"article","og_title":"Spalten tauschen in PostgreSQL &#060; Vielhuber David","og_description":"Das Vertauschen\u00a0von SQL-Tabellenspalten geh\u00f6rt bei MySQL zum Standardrepertoire\u00a0\u2013 bei PostgreSQL wird dies (noch) nicht unterst\u00fctzt. Zwar widmet das","og_url":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/","og_site_name":"Vielhuber David","article_published_time":"2016-04-09T22:18:39+00:00","article_modified_time":"2017-02-03T22:29:36+00:00","og_image":[{"width":700,"height":552,"url":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg","type":"image\/jpeg"}],"author":"David","twitter_card":"summary_large_image","twitter_creator":"@vielhuber","twitter_site":"@vielhuber","twitter_misc":{"Verfasst von":"David","Gesch\u00e4tzte Lesezeit":"5\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/#article","isPartOf":{"@id":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/"},"author":{"name":"David","@id":"https:\/\/vielhuber.de\/#\/schema\/person\/64d4ff14713d413ea4d9b210d0c2c6ef"},"headline":"Spalten tauschen in PostgreSQL","datePublished":"2016-04-09T22:18:39+00:00","dateModified":"2017-02-03T22:29:36+00:00","mainEntityOfPage":{"@id":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/"},"wordCount":106,"publisher":{"@id":"https:\/\/vielhuber.de\/#\/schema\/person\/64d4ff14713d413ea4d9b210d0c2c6ef"},"articleSection":["Blog"],"inLanguage":"de"},{"@type":"WebPage","@id":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/","url":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/","name":"Spalten tauschen in PostgreSQL &#060; Vielhuber David","isPartOf":{"@id":"https:\/\/vielhuber.de\/#website"},"datePublished":"2016-04-09T22:18:39+00:00","dateModified":"2017-02-03T22:29:36+00:00","description":"Das Vertauschen\u00a0von SQL-Tabellenspalten geh\u00f6rt bei MySQL zum Standardrepertoire\u00a0\u2013 bei PostgreSQL wird dies (noch) nicht unterst\u00fctzt. Zwar widmet das","breadcrumb":{"@id":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vielhuber.de\/blog\/spalten-tauschen-in-postgresql-auf-der-kommandozeile-oder-in-laravel\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vielhuber.de\/"},{"@type":"ListItem","position":2,"name":"Spalten tauschen in PostgreSQL"}]},{"@type":"WebSite","@id":"https:\/\/vielhuber.de\/#website","url":"https:\/\/vielhuber.de\/","name":"Vielhuber David","description":"Full-Stack Developer","publisher":{"@id":"https:\/\/vielhuber.de\/#\/schema\/person\/64d4ff14713d413ea4d9b210d0c2c6ef"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vielhuber.de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":["Person","Organization"],"@id":"https:\/\/vielhuber.de\/#\/schema\/person\/64d4ff14713d413ea4d9b210d0c2c6ef","name":"David","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg","url":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg","contentUrl":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg","width":700,"height":552,"caption":"David"},"logo":{"@id":"https:\/\/vielhuber.de\/wp-content\/uploads\/about.jpg"},"sameAs":["https:\/\/x.com\/vielhuber"]}]}},"_links":{"self":[{"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/posts\/1217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/comments?post=1217"}],"version-history":[{"count":2,"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/posts\/1217\/revisions"}],"predecessor-version":[{"id":1435,"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/posts\/1217\/revisions\/1435"}],"wp:attachment":[{"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/media?parent=1217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/categories?post=1217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vielhuber.de\/bn\/wp-json\/wp\/v2\/tags?post=1217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}