Computer problems,Computer help
*AX SOFT>>>Programming & Design

Creating tables in sql?


i am having trouble running a create table query in sql view. the data type is integer with a field size of 8. the query will only run if i enter a field size of "not null" how do i limit the field size to 8?

CREATE TABLE `person` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 64 ) NOT NULL ,
`age` INT( 8 ) NOT NULL ,
UNIQUE (
`id`
)
) ENGINE = innodb;

Simple example that works for me.

write a trigger to check the lenght of the entered data

In MS-SQL Server Integer's don't have sizes as such. It's worked out from the data type. If you want to change the size use Bigint, smallint or tinyint.

You'll need the NOT NULL if you don't have a default value...

Integers are the size the database uses for integers - you can't define the size of an integer (in a SQL database or in a programming language).

CREATE mytable (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
anum INT UNSIGNED NOT NULL DEFAULT 0
)

You can't limit the size of an integer field in the table definition. You will have to limit it in either your business or client layer.

You could create something like numeric(8,0) in SQL Server or number(8,0) in Oracle. These create floating point numbers which only allow 8 digits with no decimal places.
Nige

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Ftp swf html question. First time uploading into server.?

    You can edit the .htaccess file placed in your wwwroot directory and add the line: DirectoryIndex index.html index.htm index.php Using this line you can specify (the order in) which documents...

  • I need a script that can verify if a link is on a certain page. Please read all details before answering, Thx!

    getElementsByTagName('a') will return an array of all anchor elements in the page. Compare the href attributes of those items to the requested url until you find a match or fail. <h...

  • How can market knowledge be improved for GlaxoSmithKline using the internt or the WWW??

    You're lucky girl coz i answer you : Use this .. ...

  • How to Write a SQL statement to display the repeated rows of the table below:?

    Ok, I will assume that 'topic_id' is the criteria for determining if the row is repeated (i.e. topic_id is the same on two or more items). I am giving you a generic way of dealing wit...

  • Html software doubt?

    www.w3.org has an HTML validator and a CSS validator that are great for helping you to debug your code: HTML Validator (first step) ...

  • Output of a C++ program?

    we come to if (a++ <= --b && c != b) first b is pre-decremented now a=6 b=5 c=20 now the "if" expression is evaluated, which, translates to (6 <= 5 && 20 !=...

  • I am using oracle 9i. i have a column in a table,that column is a foreign key. can that froign key as a uniqu?

    Your English is very garbled, but I will try to answer as best I can. A foreign key does not have to be unique IN THE TABLE IN WHICH IT IS THE FOREIGN KEY. In fact, it is very commonly the case ...

  • Assembler language: what is the condition code when comparing the characters 1 and ' '.?

    Comparing the '1', '0' and the space are comparing hex values: 0x31, 0x30, and 0x20 CLC '1', ' '; // compare 0x31, 0x20 CLC '0', ' ' ...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster