MySQL + SQL · Lesson 35
CREATE DATABASE and CREATE TABLE
Create a Database
CREATE DATABASE school;
USE school;
SHOW DATABASES;
Create a Table
CREATE TABLE students (
roll_no INT PRIMARY KEY,
name VARCHAR(60) NOT NULL,
class VARCHAR(10),
marks INT DEFAULT 0
);A table "students" is created with 4 columns and a primary key.
See the Structure
DESC students; -- shows columns and types
SHOW TABLES; -- lists all tables
Summary
- CREATE DATABASE makes a database; USE selects it.
- CREATE TABLE defines columns, types and constraints.
- DESC shows table structure.
💻 Live Code Editor
Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.