Data Types: Filtering, Functions, Subqueries

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Filtering, Functions, Subqueries

LIKE and MIN

- '%a'- ends with a


- '%[asp]' - ends with a, s or p
- '[asp]' - ends with a, s or p
- '_a' - a in second position
- '%a%'- a in any position
- 'a%a'- start and end with a
- '[a-z]%' start with any letter
- 'a_%_%'- start with a, and has at least 3 characters

These are the ones I know, which can be used for like
Please update the list if I have left out any cases

Data Types

Data types specify the type of data for a particular column.

If a column called "LastName" is going to hold names, then that particular column should have a "varchar" (variable-
length character) data type.
The most common data types:
Numeric
INT -A normal-sized integer that can be signed or unsigned.
FLOAT(M,D) - A floating-point number that cannot be unsigned. You can optionally define the display length (M) and
the number of decimals (D).
DOUBLE(M,D) - A double precision floating-point number that cannot be unsigned. You can optionally define the
display length (M) and the number of decimals (D).

Date and Time


DATE - A date in YYYY-MM-DD format.
DATETIME - A date and time combination in YYYY-MM-DD HH:MM:SS format.
TIMESTAMP - A timestamp, calculated from midnight, January 1, 1970
TIME - Stores the time in HH:MM:SS format.

String Type
CHAR(M) - Fixed-length character string. Size is specified in parenthesis. Max 255 bytes.
VARCHAR(M) - Variable-length character string. Max size is specified in parenthesis.
BLOB - "Binary Large Objects" and are used to store large amounts of binary data, such as images or other types of files.

TEXT - Large amount of text data.


Choosing the correct data type for your columns is the key to good database design.
SQL Constraints

SQL constraints are used to specify rules for table data.

The following are commonly used SQL constraints:


NOT NULL - Indicates that a column cannot contain any NULL value.
UNIQUE - Does not allow to insert a duplicate value in a column. The UNIQUE constraint maintains the uniqueness of a
column in a table. More than one UNIQUE column can be used in a table.
PRIMARY KEY - Enforces the table to accept unique data for a specific column and this constraint create a unique
index for accessing the table faster.
CHECK - Determines whether the value is valid or not from a logical expression.
DEFAULT - While inserting data into a table, if no value is supplied to a column, then the column gets the value set as
DEFAULT.

For example, the following means that the name column disallows NULL values.

name varchar(100) NOT NULL

During table creation, specify column level constraint(s) after the data type of that column.

-------------------------------------------------------------------------------------------------------------------

GIT comandaments

Config file location

--global use global config file


--system use system config file
--local use repository config file
-f, --file <file> use given config file
--blob <blob-id> read config from given blob object

Action

--get get value: name [value-regex]


--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--get-urlmatch get value specific for the URL: section[.var] URL
--replace-all replace all matching variables: name value [value_regex]
--add add a new variable: name value
--unset remove a variable: name [value-regex]
--unset-all remove all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit open an editor
--get-color find the color configured: slot [default]
--get-colorbool find the color setting: slot [stdout-is-tty]
Type

--bool value is "true" or "false"


--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)
--expiry-date value is an expiry date

Other

-z, --null terminate values with NUL byte


--name-only show variable names only
--includes respect include directives on lookup
--show-origin show origin of config (file, standard input, blob, command line)

You might also like