<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sarina Heshmati on Medium]]></title>
        <description><![CDATA[Stories by Sarina Heshmati on Medium]]></description>
        <link>https://medium.com/@sarinaheshmatii?source=rss-68dd9c957889------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2dob2nhZwU9hBGeFLYvdvA.jpeg</url>
            <title>Stories by Sarina Heshmati on Medium</title>
            <link>https://medium.com/@sarinaheshmatii?source=rss-68dd9c957889------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 21:53:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sarinaheshmatii/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PgAdmin-part3: How to Query]]></title>
            <link>https://medium.com/@sarinaheshmatii/pgadmin-part3-how-to-query-88123090d106?source=rss-68dd9c957889------2</link>
            <guid isPermaLink="false">https://medium.com/p/88123090d106</guid>
            <category><![CDATA[table]]></category>
            <category><![CDATA[pgadmin]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Sarina Heshmati]]></dc:creator>
            <pubDate>Tue, 25 Jan 2022 10:31:23 GMT</pubDate>
            <atom:updated>2022-01-25T10:31:23.168Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@sarinaheshmatii/install-start-postgresql-server-on-macos-e6fedb1198c1">postgreSQL-part1: Install &amp; Start PostgreSQL Server on macOS</a></p><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part2-roles-users-f7a462da1079">postgreSQL-part2: Roles &amp; Users</a></p><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part3-create-db-tables-2682c3a4c966">postgreSQL-part3: Create DB &amp; Tables</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part1-install-setup-3803c673b94">pgAdmin-part1: Install &amp; Setup</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part2-create-db-tables-e59a2f61647f">pgAdmin-part2: Create DB &amp; Tables</a></p><ul><li>Open query tool:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wSTcLwT5x4DF-SeuvoU-fA.png" /></figure><ul><li><em>Now you can write any query you want.</em></li><li>Show data:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q4EF-THNG4usvQ2Lz15nGA.png" /></figure><blockquote>SELECT * FROM public.log<br>ORDER BY id ASC LIMIT 100</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MrUTleDn432H3JGOgVq9Pg.png" /></figure><ul><li>Get data with condition:</li></ul><blockquote>SELECT * FROM public.users<br>WHERE username LIKE ‘%1’</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZW4-GS66bIATOg_9wCbTw.png" /></figure><ul><li>Insert data:</li></ul><blockquote>INSERT INTO &lt;table_name&gt; (&lt;calumn1_name&gt;, &lt;calumn2_name&gt;, …)<br>VALUES (value1, value2, …);</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*0-0AK95xHTPHpMxQMmTrhg.png" /></figure><ul><li>Update data:</li></ul><blockquote>UPDATE table_name<br>SET column1 = value1,<br> column2 = value2,<br> …<br>WHERE condition;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*6--Fwrr0nYSQVCef3IrQjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lf2kf6Rmg833iBCLZCtZRQ.png" /></figure><ul><li>Delete data:</li></ul><blockquote>DELETE FROM &lt;table_name&gt;</blockquote><blockquote>WHERE &lt;condition&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*oSN8C6XiwWeZbHyRuj-SOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WOHFNT4xs4_LidUVvmYgQ.png" /></figure><h3>WE’RE DONE.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88123090d106" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PgAdmin-part2: Create DB & Tables]]></title>
            <link>https://medium.com/@sarinaheshmatii/pgadmin-part2-create-db-tables-e59a2f61647f?source=rss-68dd9c957889------2</link>
            <guid isPermaLink="false">https://medium.com/p/e59a2f61647f</guid>
            <category><![CDATA[pgadmin]]></category>
            <category><![CDATA[table]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Sarina Heshmati]]></dc:creator>
            <pubDate>Tue, 25 Jan 2022 09:19:51 GMT</pubDate>
            <atom:updated>2022-01-25T10:40:15.592Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@sarinaheshmatii/install-start-postgresql-server-on-macos-e6fedb1198c1">postgreSQL-part1: Install &amp; Start PostgreSQL Server on macOS</a></p><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part2-roles-users-f7a462da1079">postgreSQL-part2: Roles &amp; Users</a></p><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part3-create-db-tables-2682c3a4c966">postgreSQL-part3: Create DB &amp; Tables</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part1-install-setup-3803c673b94">pgAdmin-part1: Install &amp; Setup</a></p><ul><li>Create a DataBase:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BvvVQvU4mBxU9Qci362LmA.png" /><figcaption>(a)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WCw5zbbL6uCZBhRwbLEISA.png" /><figcaption>(b)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*Xvc6jFFWox27iUWF2eBAzQ.png" /><figcaption>(c)</figcaption></figure><ul><li>Create a table:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zewpWR_a18WzBJ3CzlEPNA.png" /><figcaption>(a)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cYBWUsAwCsVRU1aTdmefBQ.png" /><figcaption>(b)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uS4OT2YbMczGxvneSgLSfw.png" /><figcaption>(c)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YGxKPFKsU73ABQmtO2vBcQ.png" /><figcaption>(d)</figcaption></figure><h3>WE’RE DONE.</h3><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part3-how-to-query-88123090d106">pgAdmin-part3: How to Query</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e59a2f61647f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PgAdmin-part1: Install & Setup]]></title>
            <link>https://medium.com/@sarinaheshmatii/pgadmin-part1-install-setup-3803c673b94?source=rss-68dd9c957889------2</link>
            <guid isPermaLink="false">https://medium.com/p/3803c673b94</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[pgadmin]]></category>
            <dc:creator><![CDATA[Sarina Heshmati]]></dc:creator>
            <pubDate>Tue, 25 Jan 2022 08:42:27 GMT</pubDate>
            <atom:updated>2022-01-25T10:39:59.298Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@sarinaheshmatii/install-start-postgresql-server-on-macos-e6fedb1198c1">postgreSQL-part1: Install &amp; Start PostgreSQL Server on macOS</a></p><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part2-roles-users-f7a462da1079">postgreSQL-part2: Roles &amp; Users</a></p><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part3-create-db-tables-2682c3a4c966">postgreSQL-part3: Create DB &amp; Tables</a></p><ul><li>install pgAdmin (on macOS):</li></ul><ol><li><a href="https://www.pgadmin.org/download/pgadmin-4-macos/">Go to the pgAdmin mac download page</a></li></ol><p>2. Select the latest version and on the next page click on the pgadmin.dmg file to download.</p><p>3. Double click the .dmg file and agree the terms. Then drag and drop the pgAdmin 4 app elephant icon to the Application folder.</p><p>4. Go to the Application folder and double click on the pgAdmin 4 icon to open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*UEryD-tQ6mrcxc3fRElZnA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7uaME4DWFJn1Ky49_irGyg.png" /></figure><ul><li>Add a server:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1pO1sd89ZcVw_9Zv2XZHMQ.png" /><figcaption>(a)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H0MJgZOLikCkDoSiQZM5HQ.png" /><figcaption>(b)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5m7wRpLE-H_guzXI_irQLQ.png" /><figcaption>(c)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7uaME4DWFJn1Ky49_irGyg.png" /></figure><ul><li>Delete / Remove a server:</li></ul><blockquote>double click on the name of the server.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c12QWLv6jFdnARA7UpE7PA.png" /></figure><h3>WE’RE DONE.</h3><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part2-create-db-tables-e59a2f61647f">pgAdmin-part2: Create DB &amp; Tables</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part3-how-to-query-88123090d106">pgAdmin-part3: How to Query</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3803c673b94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PostgreSQL-part3: Create DB & Tables]]></title>
            <link>https://medium.com/@sarinaheshmatii/postgresql-part3-create-db-tables-2682c3a4c966?source=rss-68dd9c957889------2</link>
            <guid isPermaLink="false">https://medium.com/p/2682c3a4c966</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[table]]></category>
            <dc:creator><![CDATA[Sarina Heshmati]]></dc:creator>
            <pubDate>Mon, 24 Jan 2022 13:42:32 GMT</pubDate>
            <atom:updated>2022-01-28T19:38:51.216Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@sarinaheshmatii/install-start-postgresql-server-on-macos-e6fedb1198c1">postgreSQL-part1: Install &amp; Start PostgreSQL Server on macOS</a></p><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part2-roles-users-f7a462da1079">postgreSQL-part2: Roles &amp; Users</a></p><ol><li>Open terminal.</li><li>Open psql.</li></ol><blockquote><em>psql postgres</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*IQ5yypUQWlfFLavxUio_3Q.png" /></figure><ul><li>Create a database:</li></ul><blockquote>CREATE DATABASE &lt;dbname&gt;;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*j9JwWWz5vtfw-4Dp4yzCxQ.png" /></figure><ul><li>List all the databases:</li></ul><blockquote>\list</blockquote><p>or</p><blockquote>\l</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-lwr72Zcoz4ZHJUgJaWBw.png" /></figure><ul><li>Delete / Remove / Drop a database:</li></ul><blockquote>DROP DATABASE &lt;database_name&gt;;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*MjUc7FLdimXOT9MQnMIUBw.png" /></figure><ul><li>Create a table:</li></ul><blockquote>CREATE TABLE &lt;table_name&gt; (<br> &lt;column1_name&gt; &lt;datatype&gt; &lt;contraints…&gt;,<br> &lt;column2_name&gt; &lt;datatype&gt; &lt;contraints…&gt;,<br> &lt;column3_name&gt; &lt;datatype&gt; &lt;contraint…&gt;,<br> &lt;table_constraints…&gt;<br>);</blockquote><ul><li>Ex.1:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*9RUG_4qWyOHCXexJDCY_Lg.png" /></figure><ul><li><em>serial pseudo-type is a special kind of database object that generates a sequence of integers. A sequence is often used as the primary key column in a table.</em></li></ul><h3><strong>A. Data Types:</strong></h3><ul><li><strong>Boolean</strong></li></ul><p>A Boolean data type can hold one of three possible values: true, false or null. You use boolean or bool keyword to declare a column with the Boolean data type.</p><p>When you insert data into a Boolean column, PostgreSQL converts it to a Boolean value</p><ul><li>1, yes, y, t, true values are converted to true.</li><li>0, no, false, f values are converted to false.</li></ul><p>When you select data from a Boolean column, PostgreSQL converts the values back e.g., t to true, f to false and space to null.</p><ul><li><strong>Character</strong></li></ul><p>PostgreSQL provides three character data types: CHAR(n), VARCHAR(n), and TEXT</p><ul><li>CHAR(n) is the fixed-length character with space padded. If you insert a string that is shorter than the length of the column, PostgreSQL pads spaces. If you insert a string that is longer than the length of the column, PostgreSQL will issue an error.</li><li>VARCHAR(n) is the variable-length character string. With VARCHAR(n), you can store up to n characters. PostgreSQL does not pad spaces when the stored string is shorter than the length of the column.</li><li>TEXT is the variable-length character string. Theoretically, text data is a character string with unlimited length.</li><li><strong>Numeric</strong></li></ul><p>PostgreSQL provides two distinct types of numbers:</p><ul><li>integers</li><li>floating-point numbers</li><li><strong>Integer</strong></li></ul><p>There are three kinds of integers in PostgreSQL:</p><ul><li>Small integer ( SMALLINT) is 2-byte signed integer that has a range from -32,768 to 32,767.</li><li>Integer ( INT) is a 4-byte integer that has a range from -2,147,483,648 to 2,147,483,647.</li><li>Serial is the same as integer except that PostgreSQL will automatically generate and populate values into the SERIAL column. This is similar to AUTO_INCREMENT column in MySQL or AUTOINCREMENT column in SQLite.</li><li><strong>Floating-point number</strong></li></ul><p>There three main types of floating-point numbers:</p><ul><li>float(n) is a floating-point number whose precision, at least, n, up to a maximum of 8 bytes.</li><li>realor float8is a 4-byte floating-point number.</li><li>numeric or numeric(p,s) is a real number with p digits with s number after the decimal point. The numeric(p,s) is the exact number.</li><li><strong>Temporal data types</strong></li></ul><p>The temporal data types allow you to store date and /or time data. PostgreSQL has five main temporal data types:</p><ul><li>DATEstores the dates only.</li><li>TIMEstores the time of day values.</li><li>TIMESTAMPstores both date and time values.</li><li>TIMESTAMPTZ is a timezone-aware timestamp data type. It is the abbreviation for timestamp with the time zone.</li><li>INTERVAL stores periods of time.</li></ul><p>The TIMESTAMPTZ is the PostgreSQL’s extension to the SQL standard’s temporal data types.</p><ul><li><strong>Arrays</strong></li></ul><p>In PostgreSQL, you can store an array of strings, an array of integers, etc., in array columns. The array comes in handy in some situations e.g., storing days of the week, months of the year.</p><ul><li><strong>JSON</strong></li></ul><p>PostgreSQL provides two JSON data types: JSON and JSONB for storing JSON data.</p><p>The JSON data type stores plain JSON data that requires reparsing for each processing, while JSONB data type stores JSON data in a binary format which is faster to process but slower to insert. In addition, JSONB supports indexing, which can be an advantage.</p><ul><li><strong>UUID</strong></li></ul><p>The UUID data type allows you to store Universal Unique Identifiers defined by RFC 4122 . The UUID values guarantee a better uniqueness than SERIAL and can be used to hide sensitive data exposed to the public such as values of id in URL.</p><ul><li><strong>Special data types</strong></li></ul><p>Besides the primitive data types, PostgreSQL also provides several special data types related to geometric and network.</p><ul><li>box– a rectangular box.</li><li>line – a set of points.</li><li>point– a geometric pair of numbers.</li><li>lseg– a line segment.</li><li>polygon– a closed geometric.</li><li>inet– an IP4 address.</li><li>macaddr– a MAC address.</li></ul><p><strong>B. Column Constraints:</strong></p><ul><li><strong>NOT NULL</strong></li></ul><p>ensures that values in a column cannot be NULL.</p><ul><li><strong>UNIQUE</strong></li></ul><p>ensures the values in a column unique across the rows within the same table.</p><ul><li><strong>PRIMARY KEY</strong></li></ul><p>a primary key column uniquely identify rows in a table. A table can have one and only one primary key. The primary key constraint allows you to define the primary key of a table.</p><ul><li><strong>CHECK</strong></li></ul><p>a CHECK constraint ensures the data must satisfy a boolean expression.</p><ul><li><strong>FOREIGN KEY</strong></li></ul><p>ensures values in a column or a group of columns from a table exists in a column or group of columns in another table. Unlike the primary key, a table can have many foreign keys.</p><h3><strong>C. Table Constraints:</strong></h3><p>Table constraints are similar to column constraints except that they are applied to more than one column.</p><ul><li>Ex.2:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*9xpTRqyvcEFETxJ7BFSI5g.png" /></figure><ul><li>Ex.3:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*9oUBEg9Ajz8lCnbqNHymvg.png" /></figure><ul><li>List all the tables:</li></ul><blockquote>SELECT * FROM information_schema.tables WHERE table_schema = ‘&lt;schema_name&gt;’;</blockquote><ul><li>Ex:</li></ul><blockquote>SELECT * FROM information_schema.tables WHERE table_schema = ‘public’;</blockquote><ul><li>Add a column to an existing table:</li></ul><blockquote>ALTER TABLE &lt;table_name&gt;</blockquote><blockquote>ADD &lt;column_name&gt; &lt;column_definition&gt;;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*JJEo7gRSAEUD3I0LIrujtA.png" /></figure><ul><li>Add a constraint to an existing table:</li></ul><p>A. Every constraint except NOT NULL:</p><blockquote>ALTER TABLE &lt;table_name&gt;</blockquote><blockquote>ADD CONSTRAINT &lt;constraint_name&gt; &lt;constraint&gt; (&lt;column_name&gt;);</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*xRvWkDpwE8IJH6RkWzy5RQ.png" /></figure><ul><li><em>constraint_name: custom as you desire</em></li><li><em>constraint: UNIQUE, NOT NULL, …</em></li></ul><p>B. NOT NULL constraint:</p><blockquote>ALTER TABLE &lt;table_name&gt; ALTER COLUMN &lt;column_name&gt; SET NOT NULL;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iw_iXD8wsnl9t6T_DzmG0w.png" /></figure><ul><li>Add Foreign key constraint:</li></ul><blockquote>ALTER TABLE &lt;table_name&gt; ADD CONSTRAINT &lt;foreign_key_name&gt; FOREIGN KEY (&lt;foreign_key_column_name&gt;) REFERENCES &lt;primary_table_name&gt; (&lt;primary_key_name&gt;);</blockquote><ul><li>Ex:</li></ul><blockquote>ALTER TABLE log ADD CONSTRAINT fk1 FOREIGN KEY (user_id) REFERENCES users (id);</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nK1_4sXhrKOsyvyLZ0PaxA.png" /></figure><ul><li>Set a default value for a column:</li></ul><blockquote>ALTER TABLE &lt;table_name&gt;</blockquote><blockquote>ALTER COLUMN &lt;column_type&gt; SET DEFAULT &lt;default_value&gt;;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*1TNPFqOcMvqwrVEAxeNDLA.png" /></figure><ul><li>Delete / Remove / Drop a table:</li></ul><blockquote>DROP TABLE token;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*xa2aGjSlur53icXGRmd6MQ.png" /></figure><ul><li>read postgreSQL document <a href="https://www.postgresql.org/docs/9.1/sql-altertable.html">here</a>.</li></ul><h3>WE’RE DONE.</h3><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part1-install-setup-3803c673b94">pgAdmin-part1: Install &amp; Setup</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part2-create-db-tables-e59a2f61647f">pgAdmin-part2: Create DB &amp; Tables</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part3-how-to-query-88123090d106">pgAdmin-part3: How to Query</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2682c3a4c966" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PostgreSQL-part2: Roles & Users]]></title>
            <link>https://medium.com/@sarinaheshmatii/postgresql-part2-roles-users-f7a462da1079?source=rss-68dd9c957889------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7a462da1079</guid>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Sarina Heshmati]]></dc:creator>
            <pubDate>Sun, 23 Jan 2022 12:20:17 GMT</pubDate>
            <atom:updated>2022-01-28T18:01:32.617Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@sarinaheshmatii/install-start-postgresql-server-on-macos-e6fedb1198c1">postgreSQL-part1: Install &amp; Start PostgreSQL Server on macOS</a></p><ol><li>Open terminal.</li><li>Open psql.</li></ol><blockquote>psql postgres</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*IQ5yypUQWlfFLavxUio_3Q.png" /></figure><ul><li>List all the users (roles):</li></ul><blockquote>\du</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cissvz4aFRmHg-lT1wUfhA.png" /></figure><ul><li>Create a new user:</li></ul><blockquote>CREATE ROLE &lt;your_username&gt; WITH LOGIN PASSWORD ‘&lt;your_password&gt;’;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c60QsDngir1d6kz3UrNghg.png" /></figure><ul><li>Change user’s password:</li></ul><blockquote>\password &lt;your_username&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*ryodljk4kZSqk45U6RbMuw.png" /></figure><ul><li>Grant and Revoke role’s attributes (user’s permission):</li></ul><blockquote>ALTER ROLE &lt;your_username&gt; CREATEDB;</blockquote><blockquote>ALTER ROLE &lt;your_username&gt; <strong>NO</strong>CREATEDB;</blockquote><ul><li><em>Semicolon (;) is necessary at the end of every query.</em></li><li><em>By adding a “no” to the first of any attribute, revoke it.</em></li></ul><h4><strong>Roles’s attribute options</strong></h4><ul><li>LOGIN: Allows users to initially connect to the database cluster using this role. The CREATE USER command automatically adds this attribute, while CREATE ROLE command does not.</li><li>NOLOGIN: disAllows users to initially connect to the database cluster using this role. The CREATE USER command automatically adds this attribute, while CREATE ROLE command does not.</li><li>SUPERUSER: Allows the role to bypass all permission checks except the right to log in. Only other SUPERUSER roles can create roles with this attribute.</li><li>CREATEDB: Allows the role to create new databases.</li><li>CREATEROLE: Allows the role to create, alter, and delete other roles. This attribute also allows the role to assign or alter role membership. An exception is that a role with the CREATEROLE attribute cannot alter SUPERUSER roles without also having the SUPERUSER attribute.</li><li>REPLICATION: Allows the role to initiate streaming replication. Roles with this attribute must also have the LOGIN attribute.</li><li>PASSWORD: Assigns a password to the role that will be used with password or md5 authentication mechanisms. This attribute takes a password in quotations as an argument directly after the attribute keyword.</li><li>INHERIT: Determines whether the role inherits the privileges of roles it is a member of. Without the INHERIT, members must use SET ROLE to change into the other role in order to access those exclusive privileges. This attribute is set for new roles by default.</li></ul><p><a href="https://www.postgresql.org/docs/current/sql-createrole.html">You can find out more about role attributes by checking out PostgreSQL’s documentation on role attributes and the </a><a href="https://www.postgresql.org/docs/current/sql-createrole.html">CREATE ROLE command.</a></p><ul><li>Remove role (user)</li></ul><blockquote>DROP ROLE &lt;your_username&gt;;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*uyVr4Q5XotlOL2k1VCC_Jw.png" /></figure><h3>WE’RE DONE.</h3><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part3-create-db-tables-2682c3a4c966">postgreSQL-part3: Create DB &amp; Tables</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part1-install-setup-3803c673b94">pgAdmin-part1: Install &amp; Setup</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part2-create-db-tables-e59a2f61647f">pgAdmin-part2: Create DB &amp; Tables</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part3-how-to-query-88123090d106">pgAdmin-part3: How to Query</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7a462da1079" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PostgreSQL-part1: Install & Start PostgreSQL Server on macOS]]></title>
            <link>https://medium.com/@sarinaheshmatii/install-start-postgresql-server-on-macos-e6fedb1198c1?source=rss-68dd9c957889------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6fedb1198c1</guid>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Sarina Heshmati]]></dc:creator>
            <pubDate>Sat, 22 Jan 2022 12:19:49 GMT</pubDate>
            <atom:updated>2022-01-25T10:37:44.664Z</atom:updated>
            <content:encoded><![CDATA[<p>1. Check Homebrew version if installed:</p><blockquote>brew -V</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4uQdVOBkk7jO914ZylpB7A.png" /></figure><ul><li><em>if not installed; use this command to install it:</em></li></ul><blockquote>/bin/bash -c “$(curl -fsSL <a href="https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh">https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh</a>)&quot;</blockquote><ul><li><em>in case of any problem use the following link:</em></li></ul><p><a href="https://brew.sh/">Homebrew</a></p><p>2. In the terminal run the following commands:</p><blockquote>brew doctor</blockquote><ul><li><strong><em>if everything goes fine you may see something similar to this.</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nuXmDyM2C9_9CTsMD_YTDg.png" /></figure><blockquote>brew update</blockquote><ul><li><strong><em>if everything goes fine you may see something similar to this or some new packages will be installed.</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vA6ojpH9wbZBtIVNWzVKUA.png" /></figure><p>3. Now install postgres:</p><blockquote>brew install postgres</blockquote><ul><li><em>by running the following command check if the installation has been done successfully:</em></li></ul><blockquote>postgres -V</blockquote><ul><li>“V” in <em>postgres -V</em> is uppercase.</li></ul><figure><img alt="postgres -V" src="https://cdn-images-1.medium.com/max/1024/1*E90upyiTPSE3taWFu543Bg.png" /></figure><p>4. start postgreSQL server:</p><blockquote>pg_ctl -D /usr/local/var/postgres start</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKmafGVDD96tPSFAo1oxJw.png" /></figure><ul><li><em>if you want to run postgres server automatically after restart, use this command instead of the command above:</em></li></ul><blockquote>brew services start postgresql</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*APiELDRtu9SXhn6XHlFN3g.png" /></figure><blockquote>psql postgres</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rU6RulD6qgaJ3dOzYS2Ngg.png" /></figure><h3><strong><em>WE’RE DONE.</em></strong></h3><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part2-roles-users-f7a462da1079">postgreSQL-part2: Roles &amp; Users</a></p><p><a href="https://medium.com/@sarinaheshmatii/postgresql-part3-create-db-tables-2682c3a4c966">postgreSQL-part3: Create DB &amp; Tables</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part1-install-setup-3803c673b94">pgAdmin-part1: Install &amp; Setup</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part2-create-db-tables-e59a2f61647f">pgAdmin-part2: Create DB &amp; Tables</a></p><p><a href="https://medium.com/@sarinaheshmatii/pgadmin-part3-how-to-query-88123090d106">pgAdmin-part3: How to Query</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6fedb1198c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>