This SQL keywords reference contains the reserved words in SQL. Continue reading SQL Keywords Reference
Tag: sql joins
SQL Data Types for MySQL, SQL Server, and MS Access
The data type of a column defines what value the column can hold: integer, character, money, date and time, binary, and so on.
SQL Data Types
Each column in a database table is required to have a name and a data type.
An SQL developer must decide what type of data that will be stored inside each column when creating a table. The data type is a guideline for SQL to understand what type of data is expected inside of each column, and it also identifies how SQL will interact with the stored data.
Note: Data types might have different names in different database. And even if the name is the same, the size and other details may be different! Always check the documentation!
Continue reading SQL Data Types for MySQL, SQL Server, and MS Access
SQL Hosting
SQL Hosting
If you want your web site to be able to store and retrieve data from a database, your web server should have access to a database-system that uses the SQL language.
If your web server is hosted by an Internet Service Provider (ISP), you will have to look for SQL hosting plans.
The most common SQL hosting databases are MS SQL Server, Oracle, MySQL, and MS Access. Continue reading SQL Hosting
SQL Injection
SQL Injection
SQL injection is a code injection technique that might destroy your database.
SQL injection is one of the most common web hacking techniques.
SQL injection is the placement of malicious code in SQL statements, via web page input.
SQL Views
SQL CREATE VIEW Statement
In SQL, a view is a virtual table based on the result-set of an SQL statement.
A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.
You can add SQL statements and functions to a view and present the data as if the data were coming from one single table.
A view is created with the CREATE VIEW
statement. Continue reading SQL Views
SQL Working With Dates
SQL Dates
The most difficult part when working with dates is to be sure that the format of the date you are trying to insert, matches the format of the date column in the database.
As long as your data contains only the date portion, your queries will work as expected. However, if a time portion is involved, it gets more complicated.
SQL AUTO INCREMENT Field
AUTO INCREMENT Field
Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table.
Often this is the primary key field that we would like to be created automatically every time a new record is inserted.
Syntax for MySQL
The following SQL statement defines the “Personid” column to be an auto-increment primary key field in the “Persons” table:
CREATE TABLE Persons (
Personid int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (Personid)
);
MySQL uses the AUTO_INCREMENT
keyword to perform an auto-increment feature. Continue reading SQL AUTO INCREMENT Field
SQL CREATE INDEX Statement
SQL CREATE INDEX Statement
The CREATE INDEX
statement is used to create indexes in tables.
Indexes are used to retrieve data from the database more quickly than otherwise. The users cannot see the indexes, they are just used to speed up searches/queries.
Note: Updating a table with indexes takes more time than updating a table without (because the indexes also need an update). So, only create indexes on columns that will be frequently searched against.
SQL DEFAULT Constraint
SQL DEFAULT Constraint
The DEFAULT
constraint is used to set a default value for a column.
The default value will be added to all new records, if no other value is specified.
SQL DEFAULT on CREATE TABLE
The following SQL sets a DEFAULT
value for the “City” column when the “Persons” table is created: Continue reading SQL DEFAULT Constraint
SQL CHECK Constraint
SQL CHECK Constraint
The CHECK
constraint is used to limit the value range that can be placed in a column.
If you define a CHECK
constraint on a column it will allow only certain values for this column.
If you define a CHECK
constraint on a table it can limit the values in certain columns based on values in other columns in the row.