-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_Create_Drop_Table.sql
More file actions
54 lines (39 loc) · 1.52 KB
/
01_Create_Drop_Table.sql
File metadata and controls
54 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
CREATE DATABASE IF NOT EXISTS JavaCan;
-- Using IF NOT EXISTS prevents duplicate database creation errors when creating a database for the first time.
CREATE DATABASE JavaCan;
-- Creates a new database named JavaCan (if it does not already exist).
USE JavaCan;
-- Switches to the existing database JavaCan.
USE imren;
-- Switches to database imren (if it exists).
-- Single-line comment
/* Multi-line comment */
CREATE TABLE students(
id VARCHAR(4),
name VARCHAR(50),
grade INT,
age INT
);
-- Column definitions with data types.
/******************************************************
DATA INSERTION
******************************************************/
INSERT INTO students VALUES('1001','haluk',77,23);
INSERT INTO students VALUES('1002','tulin',88,15);
INSERT INTO students VALUES('1003','erdem',95,11);
INSERT INTO students VALUES('1002','mehmet',63,21);
/******************************************************
DATA QUERYING
******************************************************/
SELECT * FROM students;
-- Retrieves all records from students table.
/******************************************************
PARTIAL DATA INSERTION
******************************************************/
INSERT INTO students(id,age) VALUES('99',50);
SELECT * FROM students;
/******************************************************
DROP TABLE
******************************************************/
DROP TABLE students;
-- Deletes students table from database.