Posts

Showing posts from July, 2010

Indexes and Views in MySql

INDEX           Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. Simple Index: An index created on a single column of a table. Syntax:  create INDEX index_name ON tablename; Composite Index: An index created on more than one column of a table . Syntax:  create INDEX index_name ON tablename(column_name,column_name); Simple Unique Index: Same as simple ixdex but key must be unique. Composite  Unique Index: Same as composit index but key must be unique. DELETE INDEX:           drop INDEX index_name ON table_name; VIEW:      ...

String Operator in MySql

//////////////STRING OPERATOR/////////////// Name Description ASCII() Return numeric value of left-most character BIN() Return a string representation of the argument BIT_LENGTH() Return length of argument in bits CHAR_LENGTH() Return number of characters in argument CHAR() Return the character for each integer passed CHARACTER_LENGTH() A synonym for CHAR_LENGTH() CONCAT_WS() Return concatenate with separator CONCAT() Return concatenated string ELT() Return string at index number EXPORT_SET() Return a string such that for every bit set in the value bits, you get an on string and for every unset bit, you get an off string FIELD() Return the index (position) of the first argument in the subsequent arguments FIND_IN_SET() Return the index position of the first argument within the second argument FORMAT() Return a number formatted to specified number of decimal places HEX() Return a hexadecimal representation of a decimal or string value INSERT() Insert a substring at ...

MySql Basic Part 1

Image
///////////////Select/Show/Use--DATABASE//////////////// #Show databases ->SHOW databases; #use database ->USE database_name; #During the working if we want to know that currently in which database we are working. ->SELECT database(); #Show tables of any database ->SHOW tables; //////////We Are Giving The Example As Per The Following Table///////////// ->Here the table name is STUDENT_05 And COLLUMNS are:     roll_no    student_name    course    course_year    marks    percentage    city    Enroll_no   ////////Select Command//////////////////// #Select any table from database ->select * from student_05; #Select Collumns from table ->select roll_no,student_name from student_05; #Select row from table ->select * from student_05 where roll_no='012'; #Select row and collumn from table ->select roll_no,student_name from student_05 where roll_no='012'; # collecti...

Group Function in MySql

//////////////FUNCTIONS/////////////// Group Function(Aggregate Function) ->select MIN(marks) 'MINIMUM MARKS' from student_05; ->select AVG(marks) 'AVERAGE MARKS' from student_05; ->select COUNT(roll_no) "NUMBER OF STUDENT" from student_05; ->select COUNT(roll_no) "NUMBER OF ROWS" from student_05; ->select SUM(marks) 'SUM OF MARKS' from student_05; ->select ABS(-15) 'ABSOLUTE VALUE OF -15' from DUAL; ->select POWER(2,3) 'RAISED' from DUAL; ->select ROUND(15.24532343,3) 'ROUND VALUE' from DUAL; ->select SQRT(36) 'SQUARE ROOT' from DUAL; ->select LOWER('SHARJEEL BILALI') 'LOWER CASE' from DUAL; ->select INITCAP('SHARJEEL BILALI') 'TITLE CASE' from DUAL; ->select UPPER('shaghil bilali') 'UPPER CASE' from DUAL; ->select SUBSTR('SHARJEEL',2,3) 'SUBSTRING' from DUAL; ->select LENGTH('SHARJEEL BILALI')...