How to limit data type to 6 digit numbers in SQL?
<p>I have a table in sql for a bank account</p>

<pre><code>CREATE TABLE (
    name VARCHAR(100),
    bsb INTEGER,
    account_num INTEGER,
    PRIMARY KEY (bsb, account_num)
);
</code></pre>

<p>How do I put a constraint that will limit BSB to only integers that have 6 digits including 000,000 all the way to 999,999? Do I need a constraint or to use a different data type?</p>

<p>I know I can do this check restraint to limit the size of an int to be 6 digits <code>CONSTRAINT Bank_BSB_CHK CHECK (BSB &lt; 999999)</code> but a BSB can start with 0's but just has to be 6 digits long.</p>