Creating Database Objects

Creating Tables in SQL New tables are defined in a database by entering a CREATE TABLE statement. In its simplest form, the CREATE TABLE statement includes a new table name and one or more column definitions. Tables are removed using the DROP TABLE statement. SQL Syntax for Creating Tables: 1 2 3 4 5 CREATE TABLE table_name ( column1 datatype constraints, column2 datatype constraints, ... ); table_name: The name of the table you want to create. column1, column2, etc.: The names of the columns in the table. datatype: The data type for each column (e.g., INT, VARCHAR, DATE, etc.). constraints: Optional constraints (discussed in the next section) Example: Creating a simple table with basic columns: 1 2 3 4 5 6 7 CREATE TABLE Employees ( EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Salary DECIMAL(10, 2), HireDate DATE ); You can check the structure of a specific table using the DESCRIBE statement....

Sep 30, 2023 · 4 min · 648 words · Kiprono

Maintaining and Managing Database Objects in SQL

Before we learn how to update data in SQL tables, let’s create two tables we will use: customers and orders. customers table 1 2 3 4 5 6 7 8 9 USE ds2; # select database show tables; CREATE TABLE customers ( id INT PRIMARY KEY, name VARCHAR(30) NOT NULL, age INT DEFAULT - 99, address VARCHAR(45), salary DECIMAL(18 , 2 ) DEFAULT 2000.00 ); orders table 1 2 3 4 5 6 7 CREATE TABLE orders ( id INT NOT NULL, date datetime, customer_id INT REFERENCES customers (id), amount DOUBLE, PRIMARY KEY (id) ); Inserting Rows Updating Rows New rows may be inserted into a table one at a time using the SQL INSERT statement. A table name and column list are specified in the INTO clause, and a value list, enclosed in parentheses, is entered in the VALUES clause....

Sep 30, 2023 · 4 min · 650 words · Kiprono

How to Install Python Manually in Linux

This guide will discuss how to install Python manually on a Linux machine. For your convenience, we will also discuss how to uninstall Python installed in this way. Steps to Follow to Install Python Manually First of all, we need to update package repositories and install dependencies. Step 1: Update repositories On Debian-based distributions, execute (modify the commands according to the distro you are running): 1 2 3 4 sudo apt update sudo apt install build-essential zlib1g-dev \ libncurses5-dev libgdbm-dev libnss3-dev \ libssl-dev libreadline-dev libffi-dev curl Step 2: Download the stable release of Python on its official website In this step, go to https://www.python.org/downloads/source/ and download XZ compressed source tarball (.tar.xz) file. This file contains all the source files we can build to get the Python we want (I am downloading Python 3.10.5, so I get, Python-3.10.5.tar.xz file). Step 3: Extract the tarball Use the inbuilt extraction functionality to extract the tarball, or you can use the tar command in Python as follows...

Nov 28, 2022 · 2 min · 379 words · Kiprono

SSH Essentials

Connecting to a Remote Server through SSH SSH (Secured Shell) is a program for accessing and managing remote machines. It is intended to provide secure encrypted communications between two untrusted hosts over an insecure network. In this article, we will refer to the machine initiating the SSH connection as the local or client system and the device on the receiving end as the server or remote machine. Note that the installation commands may be different based on the system you are running. Nevertheless, it should be easy to tweak these commands on Linux and MacOS. Install an OpenSSH Client on the Local Machine Check if the SSH client is installed by running ssh on the terminal. If the OpenSSH client is not installed, you can install it using the line 1 sudo apt install openssh-client Install an OpenSSH Server on the Remote System Check if OpenSSH Server is installed by running ssh localhost....

Nov 24, 2022 · 4 min · 784 words · Kiprono

Notes on Hugo and Markdown

Some MarkDown Syntax Working with URLs on MarkDown Some URL 1 Some link [Link to Unsplash](https://unsplash.com/@chelseanscott?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) Rendered as Some link Link to Unsplash Use HTML code if you want to open link on a new tab. Here is an example. 1 <a href="https://unsplash.com" target="_blank"> Link2<a/> Rendering code on MarkDown The Code can be rendered using the the following Syntax. 1 2 3 `<language> (use 3 `) (some code here) ` (use 3 `) Here is some Python code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 import psycopg2 data_folder = "clean_data/August" import os import pandas as pd import numpy as np #Establishing the connection conn = psycopg2.connect( database="kiprono_database2", user='postgres', password='pass1', host='127.0.0.1', port= '5432' ) #Setting auto commit false conn....

Nov 21, 2022 · 4 min · 730 words · Kiprono