I'm always excited to take on new projects and collaborate with innovative minds.

Phone

+1 234 567 890

Email

contact@botble.com

Website

https://botble.com

Address

123 Main Street, New York, NY 10001

Social

MySQL

Following MySQL Here....

SQL Basics and Database Concepts

What is SQL?

SQL (Structured Query Language) is a standard programming language used to manage and manipulate relational databases. SQL enables you to create, retrieve, update, and delete data from databases.

Key Concepts in SQL

Database

A database is a collection of organized data, typically stored in tables, that can be easily accessed, managed, and updated.

Table

A table is a collection of related data stored in rows and columns. Each table is identified by a name, and each row in the table is a record containing data.

Record

A record is a row in a table, containing specific data for the columns (fields) in that table. For example, in the Customers table, each row represents a customer, with columns for CustomerID, CustomerName, ContactName, Address, etc.

Column

A column is a field in a table that holds a specific type of data (e.g., name, address, age).

 

Some of The Most Important SQL Commands

  • SELECT - extracts data from a database
  • UPDATE - updates data in a database
  • DELETE - deletes data from a database
  • INSERT INTO - inserts new data into a database
  • CREATE DATABASE - creates a new database
  • ALTER DATABASE - modifies a database
  • CREATE TABLE - creates a new table
  • ALTER TABLE - modifies a table
  • DROP TABLE - deletes a table
  • CREATE INDEX - creates an index (search key)
  • DROP INDEX - deletes an index


 

-- Step 1: Select the database
USE niteshsynergy;

-- Step 2: Create the Customers table
CREATE TABLE IF NOT EXISTS Customers (
   CustomerID INT PRIMARY KEY,
   CustomerName VARCHAR(100),
   ContactName VARCHAR(100),
   Address VARCHAR(150),
   City VARCHAR(50),
   PostalCode VARCHAR(20),
   Country VARCHAR(50)
);

-- Step 3: Insert the data
INSERT INTO Customers (CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES
   (1, 'Alfreds Futterkiste', 'Maria Anders', 'Obere Str. 57', 'Berlin', '12209', 'Germany'),
   (2, 'Ana Trujillo Emparedados y helados', 'Ana Trujillo', 'Avda. de la Constitución 2222', 'México D.F.', '05021', 'Mexico'),
   (3, 'Antonio Moreno Taquería', 'Antonio Moreno', 'Mataderos 2312', 'México D.F.', '05023', 'Mexico'),
   (4, 'Around the Horn', 'Thomas Hardy', '120 Hanover Sq.', 'London', 'WA1 1DP', 'UK'),
   (5, 'Berglunds snabbköp', 'Christina Berglund', 'Berguvsvägen 8', 'Luleå', 'S-958 22', 'Sweden');
 

2 min read
दिस. 05, 2024
By Nitesh Synergy
Share