Professional Documents
Culture Documents
Database
A database is a collection of information that is organized so that it can be easily accessed,
managed and updated. Computer databases typically contain aggregations of data records
or files.
SQL
SQL is a database computer language designed for the retrieval and management of data in a
relational database. SQL stands for Structured Query Language.
What is SQL?
Structured Query Language (SQL) is the standard language for data manipulation in a DBMS. In
in simple words its used to talk to the data in a DBMS. Following are types of SQL Statements
1. Data Definition Language (DDL) allows you to create objects like Schemas, Tables in the
database
2. Data Control Language (DCL) allows you to manipulate and manage access rights on
database objects
3. Data Manipulation Language (DML) is used for searching, inserting, updating, and
deleting data, which will be partially covered in this SQL tutorial.
What is Query?
A Query is a set of instruction given to the database management system. It tells any database
what information you would like to get from the database. For example, to fetch the student
name from the database table STUDENT, you can write the SQL Query like this:
CREATE DATABASE
Syntax
CREATE DATABASE databasename;
Example
CREATE DATABASE testDB;
USE DATABASE
When you have multiple databases in your SQL Schema, then before starting your operation,
you would need to select a database where all the operations would be performed.
The SQL USE statement is used to select any existing database in the SQL schema.
Syntax
The basic syntax of the USE statement is as shown below –
USE DatabaseName;
CREATE TABLE
The SQL CREATE TABLE statement is used to create a new table.
Syntax
The LastName, FirstName, Address, and City columns are of type varchar and will hold
characters and the maximum length for these fields is 255 characters.
2. If you are adding values for all the columns of the table, you do not need to
specify the column names in the SQL query. However, make sure the order of
the values is in the same order as the columns in the table. Here, the INSERT
INTO syntax would be as follows:
SELECT Syntax
SELECT column1, column2, ...
FROM table_name;
Here, column1, column2, ... are the field names of the table you want to select data from. If you
want to select all the fields available in the table, use the following syntax:
Primary keys must contain UNIQUE values, and cannot contain NULL values.
A table can have only ONE primary key; and in the table, this primary key can consist of single
or multiple columns (fields).
Citizen_IDvarchar(255)
);
The roll number attribute can never have identical and NULL value, because every student
enrolled in a university can have unique Roll_number, therefore two students cannot have same
Roll_number and each row in a table is uniquely identified with student’s roll number. So, we
can make Roll_number attribute as a primary key.
The ALTER TABLE statement is also used to add and drop various constraints on an existing
table.
Importing SQL DATABASE TO EXCEL
It will open a data connection wizard to save data connection and finish the process of
connecting to the employee's data.
Click on OK button
SQL data imported to Excel