Archives

The List

« Installing MySQL 5.1 on Kubuntu, Ubuntu or Asus EEE | Main | MySQL Pop Quiz #2 »

MySQL Pop Quiz

By Carsten | February 14, 2008

Spanish flag Spanish translation by Marcos Besteiro

The table t is defined thus:

  CREATE TABLE t (
   id INT NOT NULL,
   data CHAR(30) DEFAULT NULL,
   UNIQUE (id, data)
  );

You now do…

  INSERT INTO t VALUES (1, NULL);

Which causes one row to be inserted into the table. Keeping in mind that the UNIQUE index spans across both columns, what would happen if you were to repeat the INSERT command?


Click here to show answer

Topics: MySQL, Pop Quiz |

8 Responses to “MySQL Pop Quiz”

  1. Bill Karwin Says:
    February 14th, 2008 at 2:02 am

    If a NULL falls in the forest, is it true or false?

  2. Carsten Says:
    February 14th, 2008 at 10:01 am

    I suppose that would depend on whether someone is around to hear it falling.

  3. fenixshadow Says:
    February 14th, 2008 at 2:01 pm

    Because modern DBMS is based on three-valued logic which is not very logical.This quiz will has different implementation.
    It will inserted again in MySQL,but not Oracle(ORA-00001).

  4. gigiduru Says:
    February 14th, 2008 at 8:57 pm

    I think MySQL will explode but the remaining bits and pieces will clog together Terminator style and form a lil’ Oracle instance. As they should.

  5. MySQL Pop Quiz #2 | Carsten’s Random Ramblings Says:
    February 14th, 2008 at 10:22 pm

    [...] MySQL Pop Quiz [...]

  6. LiFo2 Says:
    February 21st, 2008 at 12:29 pm

    It would do the same in Oracle. However, without the not null constraint on id, inserting (null, null) two times would fail. Would it fail to in MySQL ?

  7. Propiedad Privada » Blog Archive » Test rĂ¡pidos de MySQL - Test 1 Says:
    February 28th, 2008 at 2:03 pm

    [...] Mysql Test Quiz 1 Original [...]

  8. Andrew Dashin ? ?????, ???? ? ?????? » MySQL Pop Quiz #1 Says:
    March 28th, 2008 at 1:50 pm

    [...] ???????? [...]

Comments