Question: I have set-up a table using the following SQL script:

```
CREATE TABLE MY_TABLE ( 
    ID NUMBER NOT NULL, 
    CODE VARCHAR2(40) NOT NULL,
    CONSTRAINT MY_TABLE PRIMARY KEY (ID)
);

CREATE UNIQUE INDEX XUNIQUE_MY_TABLE_CODE ON MY_TABLE (CODE);

```

The problem is that I need to ensure that CODE does not have a leading zero for its value.

How do I accomplish this in SQL so that a 40-char value without a leading zero is stored?

Answer: 
`CODE VARCHAR2 NOT NULL CHECK (VALUE not like '0%')`

sorry - slight misread on the original spec
If you can guarantee that all `INSERT`s and `UPDATE`s to this table are done through a **stored procedure**, you could put some code there to check that the data is valid and return an error if not.

P.S. A `CHECK CONSTRAINT` would be better, except that MySQL doesn't support them.