{"id":552,"date":"2024-08-28T11:29:34","date_gmt":"2024-08-28T09:29:34","guid":{"rendered":"https:\/\/schoppe.it\/wiki\/?p=552"},"modified":"2024-09-20T08:48:31","modified_gmt":"2024-09-20T06:48:31","slug":"die-wichtigsten-postgresql-befehle","status":"publish","type":"post","link":"https:\/\/schoppe.it\/wiki\/die-wichtigsten-postgresql-befehle\/","title":{"rendered":"Die wichtigsten PostgreSQL Befehle"},"content":{"rendered":"\n<p>Hier ist eine \u00dcbersicht der wichtigsten PostgreSQL-Befehle, die dir bei der Arbeit mit der Datenbank n\u00fctzlich sein k\u00f6nnen:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Allgemeine Befehle<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Verbinden zu einer Datenbank:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n USE datenbankname;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Beenden der psql-Sitzung:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nQUIT;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Datenbankverwaltung<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Erstellen einer neuen Datenbank:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  CREATE DATABASE datenbankname;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>L\u00f6schen einer Datenbank:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  DROP DATABASE datenbankname;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Liste aller Datenbanken anzeigen:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n SHOW DATABASES;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Datenbank \u00f6ffnen:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nUSE datenbankname;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Tabellenverwaltung<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Erstellen einer neuen Tabelle:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  CREATE TABLE tabellenname (\n      spaltenname1 datentyp1 &#x5B;OPTIONEN],\n      spaltenname2 datentyp2 &#x5B;OPTIONEN],\n      ...\n  );\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>L\u00f6schen einer Tabelle:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  DROP TABLE tabellenname;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Liste aller Tabellen anzeigen:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  SHOW TABLES;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Struktur einer Tabelle anzeigen:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n DESCRIBE tabellenname;\n\noder\n\nSHOW COLUMNS FROM tabellenname;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Dateneingabe und -manipulation<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Einf\u00fcgen von Daten in eine Tabelle:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  INSERT INTO tabellenname (spalte1, spalte2, ...)\n  VALUES (wert1, wert2, ...);\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Daten aus einer Tabelle abfragen:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  SELECT spalte1, spalte2, ...\n  FROM tabellenname\n  &#x5B;WHERE bedingung];\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Daten in einer Tabelle aktualisieren:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  UPDATE tabellenname\n  SET spalte1 = wert1, spalte2 = wert2, ...\n  WHERE bedingung;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Daten aus einer Tabelle l\u00f6schen:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  DELETE FROM tabellenname\n  WHERE bedingung;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Indizes<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Erstellen eines Index:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  CREATE INDEX indexname\n  ON tabellenname (spaltenname);\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>L\u00f6schen eines Index:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  DROP INDEX indexname;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Berechtigungen<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Berechtigung zum Nutzer vergeben:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  GRANT berechtigung\n  ON objekt\n  TO nutzer;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Berechtigung vom Nutzer entziehen:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  REVOKE berechtigung\n  ON objekt\n  FROM nutzer;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Transaktionen<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Transaktion beginnen:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  BEGIN;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Transaktion best\u00e4tigen (Commit):<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  COMMIT;\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Transaktion zur\u00fccksetzen (Rollback):<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  ROLLBACK;\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"><strong>Spezielle Befehle<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Tabellen und Datens\u00e4tze auflisten:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  \\d tabellenname\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SQL-Ausf\u00fchrungsergebnisse zur Datei umleiten:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  \\o dateiname\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SQL-Skripte ausf\u00fchren:<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  \\i pfad\/zum\/script.sql\n<\/pre><\/div>\n\n\n<p>Diese Befehle sollten dir eine gute Grundlage bieten, um mit PostgreSQL zu arbeiten. Nat\u00fcrlich gibt es viele weitere spezialisierte Befehle und Optionen, aber dies ist ein solider Ausgangspunkt.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hier ist eine \u00dcbersicht der wichtigsten PostgreSQL-Befehle, die dir bei der Arbeit mit der Datenbank n\u00fctzlich sein k\u00f6nnen: Allgemeine Befehle Datenbankverwaltung Tabellenverwaltung Dateneingabe und -manipulation Indizes Berechtigungen Transaktionen Spezielle Befehle Diese Befehle sollten dir eine gute Grundlage bieten, um mit PostgreSQL zu arbeiten. Nat\u00fcrlich gibt es viele weitere spezialisierte Befehle und Optionen, aber dies ist&hellip; <a class=\"more-link\" href=\"https:\/\/schoppe.it\/wiki\/die-wichtigsten-postgresql-befehle\/\"><span class=\"screen-reader-text\">Die wichtigsten PostgreSQL Befehle<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":556,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118,119],"tags":[],"powershell":[],"wordpress":[],"exchange":[],"linux":[214],"class_list":["post-552","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-postgresql","linux-psql","entry"],"_links":{"self":[{"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/posts\/552","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/comments?post=552"}],"version-history":[{"count":10,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/posts\/552\/revisions"}],"predecessor-version":[{"id":570,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/posts\/552\/revisions\/570"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/media\/556"}],"wp:attachment":[{"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/media?parent=552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/categories?post=552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/tags?post=552"},{"taxonomy":"powershell","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/powershell?post=552"},{"taxonomy":"wordpress","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/wordpress?post=552"},{"taxonomy":"exchange","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/exchange?post=552"},{"taxonomy":"linux","embeddable":true,"href":"https:\/\/schoppe.it\/wiki\/wp-json\/wp\/v2\/linux?post=552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}