Posts

Showing posts with the label SQL query

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...