Skip to main content

CREATE DATABASE Statement πŸ—οΈ

Mentor's Note: Before you can build a table, you need a house for it. The Database is that house. Creating it is the very first step in any project. πŸ’‘


🌟 The Scenario: The Empty Plot πŸ—ΊοΈβ€‹

Imagine you just bought a piece of land.

  • Currently, it's just "System Space".
  • You need to officially mark it as "My Office" or "My Home".
  • Once marked, you can start building rooms (tables) inside it.

πŸ’» 1. The Basic Syntax​

CREATE DATABASE database_name;

Example: Creating a School Database​

CREATE DATABASE school_db;

πŸ’» 2. Advanced Creation (With Checks)​

It's good practice to check if a database already exists before trying to create it, to avoid errors.

-- βœ… Safe Creation
CREATE DATABASE IF NOT EXISTS school_db;

πŸ’» 3. Selecting the Database (USE)​

Once created, you must "enter" the house to start working.

USE school_db;

(Note: PostgreSQL uses \c school_db in the command line tool, but USE is standard for most GUI clients).


πŸ’‘ Best Practices for Naming​

  1. Lowercase: school_db (Avoids OS case-sensitivity issues).
  2. Underscores: my_app_db (Easier to read than myappdb).
  3. Descriptive: ecommerce_prod vs db1.

πŸ“ˆ Learning Path​

πŸ“ Visit Us

🏫 VD Computer Tuition Surat

VD Computer Tuition
πŸ“ Address
2/66 Faram Street, Rustompura
Surat – 395002, Gujarat, India
πŸ“ž Phone / WhatsApp
+91 84604 41384
🌐 Website

Computer Classes & Tuition β€” Areas We Serve in Surat

Adajanβ€’Althanβ€’Amroliβ€’Athwaβ€’Athwalinesβ€’Bhagalβ€’Bhatarβ€’Bhestanβ€’Canal Roadβ€’Chowkβ€’Citylightβ€’Dumasβ€’Gaurav Pathβ€’Ghod Dod Roadβ€’Haziraβ€’Jahangirpuraβ€’Kamrejβ€’Kapodraβ€’Katargamβ€’Limbayatβ€’Magdallaβ€’Majura Gateβ€’Mota Varachhaβ€’Nanpuraβ€’New Citylightβ€’Olpadβ€’Palβ€’Pandesaraβ€’Parle Pointβ€’Piplodβ€’Punaβ€’Randerβ€’Ring Roadβ€’Rustampuraβ€’Sachinβ€’Salabatpuraβ€’Sarthanaβ€’Sosyo Circleβ€’Udhnaβ€’Varachhaβ€’Ved Roadβ€’Vesuβ€’VIP Road
πŸ“ž Call SirπŸ’¬ WhatsApp Sir