Posts

SQL 2

Image
Primary Key : Primary key is used to uniquely identify the each row in the table. Primary key column must contain unique value and can not be null means that column has to contain some value. If we want to define any column as primary key, we can define a primary key when we create table or modify it. One table can contain multiple primary key, it is called composite primary key. Syntax:                      create table table_name(column1 data type primary key,                     column2 datatype, ...);                     or                     create table table_name(column1 data type,                     column2 datatype, ..., primary key (column1)); Created... How to add primary ke...

SQL Examples

Image
SQL Examples How to run SQL commands: Here are some examples... 1. Create Statement -  Using create statement , we can create table or database. Example: Using create statement for database creation         create database database_name; Example: Using create statement for table creation.        create table table_name (column1 datatype, column2 datatype, column3 datatype, ...); That's how you create table in the database. Now, we need to enter data in the database. 2. Insert Statement -  Using insert statement , we can insert data in the table. There are two ways to insert data in the table using insert statement. Example 1: Enter data in the table using insert statement (1st way) insert into table_name values (value1, value2, value3, ...); Example 2: Enter data in the table using insert statement (2nd way) insert into table_name (column1, column2, column3, ...) values (value1, value2, value3, ...); 3. Select Statement -   Using se...

SQL Commands

SQL Commands This is a kind of instructions used to communicate with the database. By using sql commands, we can execute set of tasks on a database. Types of sql commands DDL  -   DDL stands for Data Definition Language. This command is used to change schema/structure of a table. These commands can not be roll back. Example: 1. Create - This command is used to create table or database. 2.  Alter - This command is used to update schema in a database. 3. Drop - This command is used to delete schema in a database. 4. Truncate - This command is used to delete rows from the table. DML  -  DML stands for Data Manipulation Language.  This command is used to modify the database. These commands can be roll back. Example: 1. Insert - This command is used to insert data into database. 2. Update - This command is used to update data in a database. 3. Delete - This command is used to delete data in a database. DCL  -  DCL  stands for Data Control Lan...

SQL

What is SQL ? SQL stands for Structured Query Language. This is structured based query language which is used to read/write data on relational database management system. It is a database language which is used for database creation, deletion, fetching and modifying. To accomplish query language, you need database. Example - Oracle, MySQL, SQL Server, etc. Use of SQL To insert data To update data To retrieve data To delete data Simple rules of SQL SQL is not case sensitive, means you can write query in upper case, lower case or camel case. We can write a single SQL statement in one or multiple line. Example of simple SQL statement Select * from table_name; where every sql statement is ended with semicolon(;) . SQL data types Being IT student or working in IT firm, you must have heard about data types which is used in every programming language.  It is very similar to it. Data types are used to illustrate type of data that can be stored in the database. Example - If we want to store...