GEOTECHNEPAL
|
Database statement with
example
|
Nerd Hacker
|
Database is used in all type of places like schools,hospitals and even websites use it.
These fields store their information in database.
Database managgement system known as DBMS is an software that interacts with user and database. It helps us to create database.
its examples are Ms Access,, Microsoft SQL server etc..
To create a database we use different type of languages like DDL,DML etc.
DDL-Database definition language.
DML-Database mmanipulating language.
In these language they use a different kind of language to store data and those language are called statements i.e they
use statements to store data
In database we mainly deal in creating,deleting,updating and inserting the datas.
----Creating new database
CREATE DATABASE NAME;
----Creating new table
CREATE TABLE NAME (Columns
Separated by comma with its type);
----Creating entry
INSERT INTO TABLENAME (Columns) VALUES (DATAS SEPERATED BY COMMA);
(*Note if data are beside numbers then keep them in single quote)
OR
INSERT INTO TABLENAME VALUES (DATAS SEPERATED BY COMMA);
----Updating entry
UPDATE TABLENAME SET ROW= WHERE
ROW= ;
----DELETING
DELETE TABLENAME WHERE ROW=;
EXAMPLE:
Database Name: Office
Table Name: User
Id_user
|
FirstName
|
LastName
|
Age
|
----Creating database Office
CREATE DATABASE Office;
----Creating table User
CREATE TABLE User (Id_user
INT,FirstName TEXT,LastName TEXT,Age INT);
----Creating
entry
INSERT INTO User (Id_user INT,FirstName TEXT,LastName TEXT,Age INT)
VALUES (1,’A’,’B’,20);
OR
INSERT INTO TABLENAME VALUES (1,’A’,’B’,20);
RESULT
Id_user
|
FirstName
|
LastName
|
Age
|
1
|
A
|
B
|
20
|
----Updating
entry
UPDATE USER SET FirstName =D WHERE
Age=20 ;
RESULT
Id_user
|
FirstName
|
LastName
|
Age
|
1
|
D
|
B
|
20
|
----DELETING
DELETE User WHERE Age=20;
RESULT
Id_user
|
FirstName
|
LastName
|
Age
|
NULL
|
NULL
|
NULL
|
No comments:
Post a Comment