File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ use world;
2
+
3
+ show tables;
4
+
5
+ select * from city;
6
+
7
+ describe city;
8
+
9
+ create table newCity (ID int primary key auto_increment, Name CHAR (35 ) NOT NULL ,
10
+ CountryCode CHAR (3 ) NOT NULL , District CHAR (20 ) NOT NULL , Population int NOT NULL DEFAULT 0 );
11
+
12
+ select * from newCity;
13
+
14
+ -- now inserting the city records into newCity
15
+ insert into newCity
16
+ select * from city; -- for copying all the data
17
+
18
+
19
+ -- for copying some data
20
+ create table newCity1 (ID int primary key auto_increment, Name CHAR (35 ) NOT NULL , CountryCode CHAR (3 ) NOT NULL );
21
+
22
+ insert into newCity1
23
+ select id, name, countrycode from city;
24
+
25
+ select * from newCity1;
26
+
27
+ -- if we want to do some column when there are multiple column then
28
+ insert into newCity1(id, name)
29
+ select id, name from city; -- this can also be done
30
+
31
+
32
+ -- we can also use where clause means we can do anything with the select statement accordingly and then store the data
You can’t perform that action at this time.
0 commit comments