-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMySecond.sql
More file actions
71 lines (56 loc) · 1.71 KB
/
MySecond.sql
File metadata and controls
71 lines (56 loc) · 1.71 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
CREATE DATABASE RADHEYSWEETS;
USE RADHEYSWEETS;
CREATE TABLE employeeinfo(
id INT PRIMARY KEY,
name varchar(50),
salary INT
);
INSERT INTO employeeinfo
(id, name, salary)
VALUES
(1, "PRASHANTSAINI", 10000),
(2, "MOHITSHRIVASATVA", 2000),
(3, "ARYANTHAKUR", 3000),
(4, "RITIKKUMAR", 4000),
(5, "RITIKSINGH", 5000);
INSERT INTO employeeinfo
(id, name, salary)
VALUES
(6, "ADAM", 25000),
(7, "BOB", 30000),
(8, "CASEY", 35000);
SELECT * FROM employeeinfo;
------------------------------------------------------------------------------------------
/*in this UNIQUE command defines we cannot store same values in unique command*/
CREATE TABLE temp1(
id INT UNIQUE
);
INSERT INTO temp1 VALUES (101);
INSERT INTO temp1 VALUES (101);
SELECT * FROM temp1;
-------------------------------------------------------------------------------------------
/*This is the first syntax to make primary key of any column*/
CREATE TABLE temp2 (
id INT PRIMARY KEY
);
INSERT INTO temp2 VALUES (103);
INSERT INTO temp2 VALUES (104);
SELECT * FROM temp2;
--------------------------------------------------------------------------------------------
/*This is the second syntax to make primary key of any column*/
CREATE TABLE temp3 (
id INT,
name VARCHAR(50),
age INT,
city VARCHAR(50),
PRIMARY KEY (id)
);
---------------------------------------------------------------------------------------------
/*in default constraint the default value/salary which is set by us for the employees can be automatically transfer to the emppoyee if the proper salary wasnot store in our database
so the default salary will be tranfered automatically to the emmployees*/
CREATE TABLE emp (
id INT,
salary INT DEFAULT 25000
);
INSERT INTO emp (id) VALUES (101);
SELECT * FROM emp;