In SQL a null value is undefined or inapplicable or the field has no value assigned or defined. It is not equal to zero or space. Zero is a number and space is a character. Null is undefined value. Any rows of any data type can contain a null unless the column defined has primary key or is set not null ( which means the column cannot contain null values).
If a table field is null you see a value like null when you run a query which fetches data from that table.
Category: sql
SQL: The Select Statement tutorial 1
SELECT statement falls under DQL (Data Query Language ) of SQL. It is used to query or retrieve data from sql. Here is a sample table for use to practise. The table name is trees.
+—————————————–Table————————————–+
PlotID | TreeTagNumber | SpeciesID | DBH | Height | Researcher | Date |
---|---|---|---|---|---|---|
110 | 461 | 5 | 3.00 | 4.00 | Fernando | 1999-01-01 |
110 | 462 | 51 | 19.30 | 25.73 | Fernando | 1999-01-01 |
110 | 465 | 76 | 4.10 | 5.46 | Fernando | 1999-01-01 |
110 | 466 | 76 | 4.50 | 6.00 | Fernando | 1999-01-01 |
110 | 467 | 76 | 4.40 | 5.86 | Fernando | 1999-01-01 |
110 | 468 | 76 | 9.50 | 12.66 | Fernando | 1999-01-01 |
110 | 469 | 76 | 5.30 | 7.06 | Fernando | 1999-01-01 |
110 | 470 | 62 | 7.20 | 9.60 | Fernando | 1999-01-01 |
110 | 471 | 62 | 3.40 | 4.53 | Fernando | 1999-01-01 |
110 | 472 | 62 | 7.10 | 9.46 | Fernando | 1999-01-01 |
+——————————————-+——————————————+
SELECT * from trees;
GENERIC SYNTAX below
SELECT * from TABLENAME
This is show all the columns and rows in table trees. If you want to see only specific columns you have to issue the sql command like this
[GENERIC FORMAT]
SELECT column1,column2 from TABLENAME
column1 & column2 are column names in the table.
SELECT PlotID,TreeTagNumber from trees;
This command displays only PlotID and TreeTagNumber from above table. The output will be like this
+————————————OUTPUT——————————————+
PlotID | TreeTagNumber |
---|---|
110 | 461 |
110 | 462 |
110 | 465 |
110 | 466 |
110 | 467 |
110 | 468 |
110 | 469 |
110 | 470 |
110 | 471 |
110 | 472 |
+——————————————-+——————————————+
SQL: Types of sub languages in SQL
All commands of sql fall in one of the following categories.
- DDL (Data Definition Language)
These statements are used to create tables and databases and define field properties or table properties. Examples of commands that fall in this category are CREATE,ALTER and DROP statements
2. DML (Data Manipulation Language)
The statements that falls under this category are used to update data or add or remove data from tables. UPDATE, DELETE and INSERT commands fall under this category.
3. DCL (Data Control Language)
It is used to control who access the data. The commands that come under this category are GRANT and REVOKE
4. TCL (Transaction Control Language)
This language is used to commit data and restore data. COMMIT and ROLLBACK falls under this category.
5. DQL (Data Query Language)
This is to retrieve data from sql server. SELECT statement falls in this category.
All above languages are SQL. They are just categories of SQL. they are not different from SQL.
SQL:What is sql statement
To retrieve or manipulate data present in tables of a database we issue some commands to the server. They are called sql statements. One of the sql statement is
[sql]SELECT * from titles;[/sql]
In above statement we are calling for all rows in the table to be displayed.
SQL: What is SQL
SQL stands for Structured Query Language. It is used to retrieve and manipulate data in database. SQL can enter data into database
SQL can update data in database
SQL can remove data from database
SQL can add tables in database
remove or add fields in a table
retrieve data using specific criteria in database etc
SQL: What is a table
Table is a set of values arranged in rows and columns as shown in figure. Each values is place in an area called field and vertical list of values is called column. Horizontal List of values is called a row. In database server normally we store information in tables as shown in below figure. Table contains information in very easily presentable format. You can access information from these tables using sql commands.