Monday, March 14, 2011

Byte Stream vs Character Stream

Byte Stream Class:
  • Byte Stream are defined by two hierarchies 
    1. InputStream
    2. OutputStream
  •  The abstract class InputStream and OutputStream define several key method that the other stream classes implement. The two most Important are
    1. read()
    2. write()
  • Stream class (Subclass)
    • BufferedInputStream
    • BufferedOutputStream
    • ByteArrayInputStream
    • ByteArrayOutputStream
    • DataInputStream
    • DataOutputStream
    • FileInputStream
    • FileOutputStream
    • PrintStream
    • PushbackInputStream
Character Stream class:
  • Character stream are defined by two class hierarchies
    1. Reader
    2. Writer
  • These class handle unicode character stream.
  • The most important method are
    1. read()
    2. write()  which read/write the character of data.
  • character classes
    • BufferedReader
    • BufferedWriter
    • CharArrayReader
    • CharArrayWriter
    • InputStreamReader
    • OutputStreamReader
    • FileReader
    • FileWriter
    • PrintWriter
    • PushbackReader
 Streams - Byte Based(Read or write Bytes)[Mainly used for Binary files)
Reader - Character Based(Read or Write Character)[for Text files]

 Filereader is the best option as it reads the file characterwise or u can use bufferedreader because it reads stringwise. 

Saturday, March 12, 2011

FULL or LEFT JOIN

The FULL / LEFT JOIN keyword returns all rows from the left table (table 1), even if there are no matches in the right table (table 2).

Table 1: adetails


Table 2: assignto


Query:
select adetails.*, assignto.*  
    from adetails FULL JOIN assignto  
    on adetails.machine_sno=assignto.machine_sno

    or

    select adetails.*, assignto.*  
    from adetails LEFT JOIN assignto  
    on adetails.machine_sno=assignto.machine_sno
Result:


JOIN or INNER JOIN

INNER JOIN is the same as JOIN.
The INNER JOIN keyword return rows when there is at least one match in both tables.

Table 1: adetails
adetails

Table 2:  Orders


Query:
select adetails.*, assignto.* 
    from adetails JOIN assignto 
    on adetails.machine_sno=assignto.machine_sno

    or
    select adetails.*, assignto.*
    from adetails INNER JOIN assignto 
    on adetails.machine_sno=assignto.machine_sno
Result:

Check Size of your Database

This command will help you for checking the Database space, Here Database Name is login.

Command:    Exec sp_spaceused

Result
 

Comment


create table alertclub  /* Creating a Table is a comment*/
(
    uname varchar(20),
    phoneno varchar(10),
    address varchar(20)
)

Select columns from Table



Type 1: For select all column from table alertclub
Select * from alertclub

Type 2: For select Particular column from table, suppose if you want to select uname (column name) from 
 alertclub  (table name). then execute this query:

Select uname from alertclub

Rename Table Name


Suppose your table is alertclub and you will change it to AC

Step 1: Execute this query:
EXEC sp_rename 'alertclub', 'AC'
 After execute this query, one msg will come out like this:
Caution: Changing any part of an object name could break scripts and stored procedures.
Step 2: select * from AC 
Table name raname from alertclub to AC



Rename Column Name


Before rename column name

Step 1: sp_rename 'alertclub.uname', 'username'

After excute this query one msg will come like this:

Caution: Changing any part of an object name could break scripts and stored procedures.

and open table
Step 2:  select * from alertclub

you will see that column name changed from uname to username

After Rename column name