This article will show you how to drop/delete a stored function from a PostgreSQL database. In PostgreSQL, a stored function is a user-definable set of database queries that can be called by name, allowing for easy code re-use. Unlike stored procedures, stored functions require a return value, so they are usually used for calculating values for display, storage, or for further use. Before you Delete a Function from your Database… There are a few things you should do before you remove a stored function from … Read more
Welcome to LinuxScrew
View our featured tutorials and projects in the slider below or scroll down to see all recent articles.
This short tutorial will show you how to completely delete/destroy/drop a table in PostgreSQL using the DROP TABLE statement, and provide examples. Before you Delete a Table… There are a few things you should check before you try and destroy a table in PostgreSQL, especially if you’re working on a production database that is serving users. First and most important, take a backup of your PostgreSQL server – just in case you delete the wrong table, or change your mind later. Next, make sure you’re logged in as the default … Read more
This short tutorial will show you how to connect to a PostgreSQL database server from the Linux command line. Instructions are included for Ubuntu, Fedora, and Arch Linux. The PostgreSQL Client – psql Command To connect to a PostgreSQL database server from the Linux command, you need to install and use the psql program – the PostgreSQL client. By default, when installing the PostgreSQL server on Linux, the client is also installed – but you may want to install the client without the server if you are only planning … Read more
This post will demonstrate how to list all users, permissions, and roles on a PostgreSQL database server. Maintaining data security is paramount in any application or database deployment, and making sure users only have access to the data they need is the cornerstone of this security. PostgreSQL has robust user, role, and permission management features, particularly with role based access that allows you to assign permissions to roles, and roles to users, making management tasks more straightforward and reducing the chance of accidentally assigning the … Read more
This question gets asked quite a lot… How do you pronounce PostgreSQL? For that matter, how do you pronounce SQL? This is often debated among tech-types, this article will take a look at the pronunciations for these two data terms. PostgreSQL is a database management system which uses SQL syntax. As there is argument over how SQL is pronounced, so too is there for PostgreSQL. How Do You Pronounce ‘SQL’? There are two common pronunciations for SQL – pronouncing it like the word “sequel”: …and spelling out the letters: I’m partial to the latter as … Read more
PostgreSQL is one of the most popular open-source database systems. This article will show you how to list all databases in PostgreSQL from the command line with the \l command. Prerequisites To use PostgreSQL, you’ll need to have a PostgreSQL database server set up, and have the psql PostgreSQL command line tools installed. Connecting to the Server If you are running your database on the same machine that you are connecting from and are connecting as the default postgres user, you can simply log in using: If you … Read more
This tutorial will show you several ways to clear the terminal/screen in your Python scripts, with code examples that you can copy and paste into your own project. Clearing the screen will remove all text from the screen, blanking/resetting it. This is useful to hide output from the command line or previous Python statements so that you can more easily see newly added output, and keep your command line apps looking tidy. There are a few ways to achieve this, so here they are: Clearing … Read more
This short tutorial will demonstrate how to get the path to the currently running Bash/Shell script in Linux, and provide a code example. Getting the path to the current script is useful if you have other files in the same directory as the script that you want to access when calling the script from elsewhere. For example, you may have a script that plays music located with your music files, and have a second script on your Desktop that calls it. The first script will … Read more
This short post will explain how to use the bash wait command to wait until a process has finished, and how if differs to the sleep command. What does the Bash wait Command Do? The wait command is a simple program that waits for a process to change state – this means waiting for it to exit. How to Use the Bash wait Command The wait command expects a list of process ids that it should wait to complete, for example: Above, the process ids 111 and 222 are supplied to wait. wait will only complete its own execution once the processes supplied to … Read more
This short article will demonstrate how to check whether a string variable is empty in Bash and other Shell scripts in Linux, with examples. Bash Operators Bash operators are the symbols and expressions that perform comparisons, assignments, and arithmetic. The -z Bash Operator The -z operator returns true if a string variable is null or empty. How the use the -z Bash Operator After declaring a string variable, use the -z operator in an if statement to check whether a string is empty or not: For more Shell scripting tips, check out or Bash/Shell scripting articles!