đź“ť Feedback

SQL – Structured/Standardized Query Language

The SQL language could be considered among the significant reasons for the commercial success of relational databases. Due to the fact that it ended up being a standard for relational databases, users were less concerned about moving their database applications from various other types of database systems– for example, older network or hierarchical systems– to relational systems. This is because even if the users became discontented with the particular relational DBMS product they were using, converting to another relational DBMS product was not anticipated to be too costly and time-consuming because both systems adhered to the very same language standards.

In practice, certainly, there are differences among various commercial relational DBMS packages. However, if the user is diligent in using only those functions that are part of the standard and if two relational DBMS’s consistently support the standard, after that conversion between two systems should be simplified. One more benefit of having such a standard is that users may write statements in a database application program that could access data stored in 2 or more relational DBMSs without needing to change the database sublanguage (SQL), as long as both/all of the relational DBMSs support standard SQL.

SQL Data Definition and Data Types

SQL uses the terms table, row, and column for the formal relational model terms, connection, tuple, and attribute, respectively. We will use the corresponding terms interchangeably. The main SQL command for data definition is the CREATE statement, which can be used to create schemas, tables (relations), kinds, and domain names, as well as various other constructs such as views, assertions, and triggers.

CREATE TABLE Command in SQL

The CREATE TABLE command is used to define a new relation by providing it a name and specifying its attributes and initial constraints. The attributes are specified first and each attribute is given a name, a data type to specify its domain of values, and possibly attribute constraints, such as NOT NULL. The key, entity integrity, and referential integrity constraints can be specified within the CREATE TABLE statement after the attributes are declared, or they can be included later on making use of the ALTER TABLE command. Generally, the SQL schema in which the relations are declared is implicitly specified in the environment in which the CREATE TABLE statements are executed. Alternatively, we can explicitly connect the schema name to the relation name, separated by a period. For instance, by writing:

CREATE TABLE TEAM.PLAYER

Rather than

CREATE TABLE PLAYER

We can make the PLAYER table part of the TEAM schema explicitly.

The relations declared through CREATE TABLE statements are called base tables (or base relations); this means that the table and its rows are actually created and stored as a file by the DBMS. Base relations are differentiated from virtual relations, created via the CREATE VIEW statement, which might or might not correspond to an actual physical file. In SQL, the attributes in a base table are considered to be bought in the sequence in which they are defined in the CREATE TABLE statement. However, rows (tuples) are not considered to be ordered within a table (relation).

Rate this Article: 1 Star2 Stars3 Stars4 Stars5 Stars (53 votes, average: 4.67 out of 5)
Loading...
x
Trusted By The World’s Best