Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Jul 222010
 

Display attributes of a logical volume under LVM

Answer:

If you are using LVM, you can easily display attributes of a logical volume using the command lvmdisplay

# sudo /usr/sbin/lvdisplay

  /dev/sdb: read failed after 0 of 2048 at 0: Input/output error
  /dev/sdb1: read failed after 0 of 2048 at 0: Input/output error
  /dev/sdb2: read failed after 0 of 2048 at 0: Input/output error
  /dev/sdb3: read failed after 0 of 2048 at 0: Input/output error
  --- Logical volume ---
  LV Name                /dev/vg0/d148
  VG Name                vg0
  LV UUID                JhG2hr-lnyx-yT2h-rUMN-7tuP-yW0j-rQ1YSu
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                80.00 GB
  Current LE             20480
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
Jul 212010
 

How to check the ./configure arguments used during last program compilation

Answer:

Normally, when you downloaded a program source and compile youself, you need to run the ./configure for customized settings.

In order to check the ./configure arguments used during last program compilation, you can check the following three files (depends on package) in the source folder .

  1. config.status
  2. config.nice
  3. config.log
Jul 202010
 

What is the storage overhead in using VARCHAR in MySQL

Answer:

MySQL allow VARCHAR to have length from a value from 0 to 65,535.

Since MySQL need to store the length of each VARCHAR field, in additional to the actual data itself, it needs 16 bits = 2 bytes for each field. But if the length of VARCHAR during table creation is less than or equal to 255, it only take 1 byte per field.

Reference: http://dev.mysql.com/doc/refman/5.1/en/char.html

Jul 192010
 

Compare binary value in MySQL

Answer:

Assume you have the following table.

mysql> CREATE TABLE t ( 
    c BINARY(3)
) ENGINE = INNODB;

And you insert some sample value...

mysql> INSERT INTO t VALUES ('fo');
mysql> INSERT INTO t VALUES ('foo');

Finally you select it

mysql> SELECT * FROM t WHERE c = 'foo';
+------+
| c    |
+------+
| foo  |
+------+
1 row in set (0.00 sec)

mysql> SELECT * FROM t WHERE c = 'fo';
Empty set (0.00 sec)

Why you cannot find the result in the second query? Because the column is BINARY, the trailing space(s) is not ignored like this.

You need to query like...

mysql> SELECT * FROM WHERE c = 'fo\0';
+------+
| c    |
+------+
| fo   |
+------+
1 row in set (0.00 sec)

As you can see, you need to append the the 0x00 (the zero byte). at the end of the character.