Skip to content

Commit 803613b

Browse files
authored
Add files via upload
add file
1 parent c6bf3ee commit 803613b

6 files changed

+195
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ALTER TABLE for adding column by POsition without constraints
2+
Add Column By Position
3+
.-> Last (by default)
4+
.-> first
5+
.-> After
6+
7+
// First
8+
syntax: ALTER TABLE table_name ADD COLUMN column_name datatype(size) FIRST;
9+
ex: ALTER TABLE new ADD COLUMN t_id int (10) FIRST;
10+
11+
12+
ex: select * from new;
13+
+------+----+---------+---------+--------+
14+
| t_id | id | name | address | number |
15+
+------+----+---------+---------+--------+
16+
| NULL | 5 | Hari | NULL | NULL |
17+
| NULL | 6 | Ram | NULL | NULL |
18+
| NULL | 7 | Sita | NULL | NULL |
19+
| NULL | 8 | testing | NULL | NULL |
20+
+------+----+---------+---------+--------+
21+
22+
// After
23+
syntax: ALTER TABLE new ADD COLUMN t_number int (10) AFTER name ;
24+
:- mysql> select * from new;
25+
+------+----+---------+----------+---------+--------+
26+
| t_id | id | name | t_number | address | number |
27+
+------+----+---------+----------+---------+--------+
28+
| NULL | 5 | Hari | NULL | NULL | NULL |
29+
| NULL | 6 | Ram | NULL | NULL | NULL |
30+
| NULL | 7 | Sita | NULL | NULL | NULL |
31+
| NULL | 8 | testing | NULL | NULL | NULL |
32+
+------+----+---------+----------+---------+--------+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//ALTER TABLE for adding multiple columns without constraints
2+
3+
1. add more than one column
4+
Syntax: ALTER TABLE table_name ADD COLUMN column_name datatype(size),
5+
ADD COLUMN column_name datatype(size);
6+
ex:
7+
select * from new;
8+
+----+---------+
9+
| id | name |
10+
+----+---------+
11+
| 5 | Hari |
12+
| 6 | Ram |
13+
| 7 | Sita |
14+
| 8 | testing |
15+
+----+---------+
16+
17+
18+
ex:ALTER TABLE new ADD COLUMN address varchar(50),ADD COLUMN number int (10);
19+
20+
+----+---------+---------+--------+
21+
| id | name | address | number |
22+
+----+---------+---------+--------+
23+
| 5 | Hari | NULL | NULL |
24+
| 6 | Ram | NULL | NULL |
25+
| 7 | Sita | NULL | NULL |
26+
| 8 | testing | NULL | NULL |
27+
+----+---------+---------+--------+

Alias in SQL.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Alisa
2+
-> Aliases are used to temporarily rename a table or a column name.
3+
For table:
4+
syntax: SELECT column_name FROM table_name AS alisa_name(nick name);
5+
6+
For column:
7+
syntax: SELECT column_name AS alisa_name FROM table_name;
8+
EX: SELECT name as new_name FROM new;
9+
+----------+
10+
| new_name |
11+
+----------+
12+
| Hari |
13+
| Ram |
14+
| Sita |
15+
| testing |
16+
+----------+
17+
18+
ex:SELECT name "ne name" FROM new;
19+
+---------+
20+
| ne name |
21+
+---------+
22+
| Hari |
23+
| Ram |
24+
| Sita |
25+
| testing |
26+
+---------+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/Alter table for adding one column without constraints
2+
-> This command sis used to add/change/modify/drop existing structure of the table.
3+
.-> ADD Column
4+
-> When a new column is to be added to the table structure without constraints.
5+
syntax: ALTER TABLE table_name ADD COLUMN column_name datatype(size);
6+
ex: ALTER TABLE student_reg ADD COLUMN id int (10);
7+
Output:- select * from student_reg;
8+
9+
+------+---------+---------+------------+-----------+------+
10+
| s_id | name | address | dob | fees | id |
11+
+------+---------+---------+------------+-----------+------+
12+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 | NULL |
13+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 | NULL |
14+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 | NULL |
15+
| 104 | BIMAl | KTM | NULL | 1001.23 | NULL |
16+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 | NULL |
17+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 | NULL |
18+
+------+---------+---------+------------+-----------+------+
19+
20+
.-> Enable/Disable constraints
21+
.-> change Column
22+
.-> Modify Column
23+
.-> Drop Column

Arithmetic Operators in SQl.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Arithmetic Operators
2+
syntax: SELECT column_name,column_name Operators VALUES from table_name;
3+
4+
Add operator ex
5+
ex:SELECT s_id,name,address,dob,fees+100 from student_reg;
6+
+------+---------+---------+------------+-----------+
7+
| s_id | name | address | dob | fees+100 |
8+
+------+---------+---------+------------+-----------+
9+
| 101 | RAM | KTM | 1998-12-15 | 1100.23 |
10+
| 102 | SITA | KTM | 2001-10-11 | 200100.12 |
11+
| 103 | HARI | PKR | 2001-01-12 | 10100.52 |
12+
| 104 | BIMAl | KTM | NULL | 1101.23 |
13+
| 105 | KAMAL | PKR | 1956-12-12 | 100100.12 |
14+
| 106 | SITA KC | PKR | 1998-02-02 | 20100.12 |
15+
+------+---------+---------+------------+-----------+
16+
sub operator ex:
17+
ex: SELECT s_id,name,address,dob,fees-100 from student_reg;
18+
+------+---------+---------+------------+-----------+
19+
| s_id | name | address | dob | fees-100 |
20+
+------+---------+---------+------------+-----------+
21+
| 101 | RAM | KTM | 1998-12-15 | 900.23 |
22+
| 102 | SITA | KTM | 2001-10-11 | 199900.12 |
23+
| 103 | HARI | PKR | 2001-01-12 | 9900.52 |
24+
| 104 | BIMAl | KTM | NULL | 901.23 |
25+
| 105 | KAMAL | PKR | 1956-12-12 | 99900.12 |
26+
| 106 | SITA KC | PKR | 1998-02-02 | 19900.12 |
27+
+------+---------+---------+------------+-----------+
28+
29+
// div ex:
30+
ex: SELECT s_id,name,address,dob,fees/100 from student_reg;
31+
+------+---------+---------+------------+-------------+
32+
| s_id | name | address | dob | fees/100 |
33+
+------+---------+---------+------------+-------------+
34+
| 101 | RAM | KTM | 1998-12-15 | 10.002300 |
35+
| 102 | SITA | KTM | 2001-10-11 | 2000.001200 |
36+
| 103 | HARI | PKR | 2001-01-12 | 100.005200 |
37+
| 104 | BIMAl | KTM | NULL | 10.012300 |
38+
| 105 | KAMAL | PKR | 1956-12-12 | 1000.001200 |
39+
| 106 | SITA KC | PKR | 1998-02-02 | 200.001200 |
40+
+------+---------+---------+------------+-------------+
41+
42+
// mul operator
43+
ex:SELECT s_id,name,address,dob,fees*100 from student_reg;
44+
+------+---------+---------+------------+-------------+
45+
| s_id | name | address | dob | fees*100 |
46+
+------+---------+---------+------------+-------------+
47+
| 101 | RAM | KTM | 1998-12-15 | 100023.00 |
48+
| 102 | SITA | KTM | 2001-10-11 | 20000012.00 |
49+
| 103 | HARI | PKR | 2001-01-12 | 1000052.00 |
50+
| 104 | BIMAl | KTM | NULL | 100123.00 |
51+
| 105 | KAMAL | PKR | 1956-12-12 | 10000012.00 |
52+
| 106 | SITA KC | PKR | 1998-02-02 | 2000012.00 |
53+
+------+---------+---------+------------+-------------+

Data Definition Language.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// DATA Definitions language
2+
topics:
3+
4+
ALTER EVENT
5+
ALTER FUNCTION
6+
ALTER INSTANCE
7+
ALTER LOGFILE GROUP
8+
ALTER PROCEDURE
9+
ALTER SCHEMA
10+
ALTER SERVER
11+
ALTER TABLESPACE
12+
ALTER VIEW
13+
CREATE EVENT
14+
CREATE FUNCTION
15+
CREATE INDEX
16+
CREATE LOGFILE GROUP
17+
CREATE PROCEDURE
18+
CREATE SCHEMA
19+
CREATE SERVER
20+
CREATE SPATIAL REFERENCE SYSTEM
21+
CREATE TABLE
22+
CREATE TABLESPACE
23+
CREATE TRIGGER
24+
DROP EVENT
25+
DROP FUNCTION
26+
DROP PROCEDURE
27+
DROP SCHEMA
28+
DROP SERVER
29+
DROP SPATIAL REFERENCE SYSTEM
30+
DROP TABLESPACE
31+
DROP TRIGGER
32+
FOREIGN KEY
33+
RENAME TABLE
34+
TRUNCATE TABLE

0 commit comments

Comments
 (0)