Posts Tagged ‘SQL’

SQL JOINS

SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables. The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables. To read more click here.

read more

How to Add Primary Key?

A primary key is used to uniquely identify each row in a table. Primary keys can be specified either when the table is created (using CREATE TABLE) or by changing the existing table structure (using ALTER TABLE). CREATING TABLE WITH PRIMARY KEY SYNTAX: CREATE TABLE table_name(field_name datatype(index),…,field_nameN datatype(index),PRIMARY KEY(field_name_primary_key)); Say for example, you are going […]

read more

How to Create a Foreign Key?

A foreign key is a field (or fields) that points to the primary key of another table. The purpose of the foreign key is to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted. For example, say we have two tables, a CUSTOMER […]

read more

How to create a foreign key in a database table?

A foreign key is a field (or fields) that points to the primary key of another table. The purpose of the foreign key is to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted. For example, say we have two tables, a CUSTOMER […]

read more

How to add a primary key in a database table?

A primary key is used to uniquely identify each row in a table. Primary keys can be specified either when the table is created (using CREATE TABLE) or by changing the existing table structure (using ALTER TABLE). CREATING TABLE WITH PRIMARY KEY SYNTAX: CREATE TABLE table_name(field_name datatype(index),…,field_nameN datatype(index),PRIMARY KEY(field_name_primary_key)); Say for example, you are going […]

read more

How to delete a column in a database table?

In a database table, all fields should always be related with each other. If there is/are fields which are not related to it, then it should be deleted immediately. Drop Column is used to remove an entire column and all its data from a table. Syntax: ALTER TABLE table_name DROP COLUMN field_name; Supposed we have […]

read more

How to add a column in a database table?

When a table is already created in your database and suddenly you wanted to add additional columns into it, the question is how are you going to do it. Well, the answer to that is to use the ADD COLUMN command. ADD COLUMN is used to add a column to your existing table. Syntax: ALTER […]

read more

How to get information from a database?

What if you forget the name of a database or table, or what the structure of a given table is (for example, what its columns are called)? MySQL addresses this problem through several statements that provide information about the databases and tables it supports. You have previously seen SHOW DATABASES, which lists the databases managed […]

read more