User Tools

Site Tools


databases

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

databases [2013/06/03 09:53]
sandeep
databases [2018/03/24 11:13]
Line 1: Line 1:
-====== MySQL ====== 
-===== Installing ===== 
-Run this with root permission in your terminal. 
-<​code>​ 
-apt-get install mysql-server 
-</​code>​ 
-This will ask you for a password. Type '​password'​ there. 
- 
-===== Tasks ===== 
-  - Create a '​camp'​ database 
-  - Create a '​students'​ table in it with the fields 
-    - Name 
-    - College 
-    - District 
-    - Email 
-    - Age 
-    - Year 
-    - Semester 
-    - Team number 
-    - Branch ​ 
-  - Insert atleast 10 records in it. 
-  - Retrieve all the students whose age is greater than 20 
-  - Retrieve all the students who are in 3rd year 
-  - Retrieve all the students who are in 4th,5th or the 6th team 
-  - Retrieve all the students who are in 2nd year, 2nd semester. 
-  - Retrieve all the students who are in ECE branch. 
-  - Retrieve all the students whose name starts with '​a'​ and ends with '​d'​. 
-  - Create a table called '​favourites'​ it must have four fields 
-    - Name  
-    - Favourite Session 1 
-    - Favourite Session 2 
-    - Favourite Session 3 
-  - Now, Insert the records with the values of the '​Favourite Sessions'​ being any session in the camp that you like. For example I like '​python','​git','​communication-skills'​ so, I will insert ('​ganesh','​python','​git','​communication-skills'​). ​ 
-  - Retrieve all the students who have '​python'​ as favourite 1. 
-  - Retrieve all the students who dont have '​databases'​ as favourite 2. 
-  - Retrieve all the students who have '​git'​ or '​documentation'​ as favourite 1. 
-  - Retrieve all the students who have '​python'​ as favourite 1, '​editors'​ as favourite 2, and '​databases'​ as favourite 3. 
-  - Update the email of a student in the '​students'​ table to '​[email protected]'​ where the name is '​john'​ (Create a row with name = john for this.) 
-  - Find the number of students in students table. 
- 
-===== Reference =====  
-=== Create === 
-Replace tablename with your table'​s name, the fieild1,​field2 with your field'​s names' and the type1,type2 with your respective types. 
-<code sql> 
-CREATE table tablename (field1 type1,​field2 type2); 
-</​code>​ 
-=== Select === 
-== Selecting all columns ==  
-<code sql> 
-SELECT * from tablename; 
-</​code>​ 
- 
-== Selecting some columns ==  
-<code sql> 
-SELECT field1,​field2 from tablename; 
-</​code>​ 
- 
-== Selecting with conditions ==  
-<code sql> 
-SELECT * from tablename where field == value; 
-</​code>​ 
- 
-== Supported Conditions ==  
-<code sql> 
-field > number (Eg : age > 10 ) 
-field < number ​ 
-field == number 
-field >= number 
-field <= number 
-field in  (v1,v2,v3) (Eg: name in ('​ganesh','​divya'​)) 
-field not n  (v1,v2,v3) 
-field like '​%'​ (Eg: name like '​g%'​ [Matches all names starting with g] or name like '​%g'​ [matches all names ending with g]) 
-field not like '​%'​ 
- 
-</​code>​ 
- 
- 
- 
-=== Update === 
-=== Insert === 
- 
- 
  
databases.txt ยท Last modified: 2018/03/24 11:13 (external edit)