Re: Regarding NOT NULL Option for Table Fields....

2005-06-13 Thread mfatene
Hi ashok,
With check, you could do iy, but they don't work with mysql.

The only solution i ican see is an application control or :

drop table if exists tempo;
create table tempo like mine;
insert into tempo values('','');
insert into mine select * from tempo where length(...)>0;
drop table tempo;


Mathias

Selon Ashok Kumar <[EMAIL PROTECTED]>:

> hi Mathias,
>  My question is how can i protect the empty strings
> (that contains length 0).
>
> thanks and regards,
>  Ashok Kumar.P.S.
>
> --- [EMAIL PROTECTED] wrote:
>
> > Hi,
> > '' or empty string is not a null in mysql. This is
> > true for Oracle !
> > this simple test lets you understand :
> >
> > * Without NULLs
> > mysql> create table notnull (t varchar(10) NOT
> > NULL);
> > Query OK, 0 rows affected (0.14 sec)
> >
> > mysql> insert into notnull values('test1');
> > Query OK, 1 row affected (0.01 sec)
> >
> > mysql> insert into notnull values('');
> > Query OK, 1 row affected (0.02 sec)
> >
> > mysql> insert into notnull values(NULL);
> > ERROR 1048 (23000): Column 't' cannot be null
> > mysql> select * from notnull;
> > +---+
> > | t |
> > +---+
> > | test1 |
> > |   |
> > +---+
> > 2 rows in set (0.02 sec)
> >
> > mysql> select * from notnull where isnull(t);
> > Empty set (0.02 sec)
> >
> > * With NULLs
> > mysql> create table isnulle(a varchar(10));
> > Query OK, 0 rows affected (0.08 sec)
> >
> > mysql> insert into isnulle values(NULL);
> > Query OK, 1 row affected (0.03 sec)
> >
> > mysql> select * from isnulle where isnull(a);
> > +--+
> > | a|
> > +--+
> > | NULL |
> > +--+
> > 1 row in set (0.00 sec)
> >
> >
> > Hope that helps.
> > Mathias
> >
> >
> > Selon Ashok Kumar <[EMAIL PROTECTED]>:
> >
> > > Hi friends,
> > >  I'm having one doubt on "NOT NULL" specification
> > for
> > > the table field properties. That is i have created
> > on
> > > table-mine which contains name(Not Null) and
> > pwd(Not
> > > Null). Now I intended to execute the following
> > query.
> > >
> > > "insert into mine values('','')"
> > >
> > > This means that i'm trying to insert the null
> > fields
> > > to the table. but this query is successfully
> > executed
> > > and 1 row is inserted into table with empty
> > values.
> > > why it's happening and how can i resolve this
> > problem.
> > >
> > > Pls give me suggestions regarding this.
> > >
> > > Thanks and Regards,
> > >  Ashok Kumar.P.S
> > >
> > >
> > >
> > > __
> > > Discover Yahoo!
> > > Stay in touch with email, IM, photo sharing and
> > more. Check it out!
> > > http://discover.yahoo.com/stayintouch.html
> > >
> > > --
> > > MySQL General Mailing List
> > > For list archives: http://lists.mysql.com/mysql
> > > To unsubscribe:
> > http://lists.mysql.com/[EMAIL PROTECTED]
> > >
> > >
> >
> >
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:
> >
> http://lists.mysql.com/[EMAIL PROTECTED]
> >
> >
>
>
>
>
> __
> Discover Yahoo!
> Get on-the-go sports scores, stock quotes, news and more. Check it out!
> http://discover.yahoo.com/mobile.html
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Regarding NOT NULL Option for Table Fields....

2005-06-12 Thread mfatene
Hi,
'' or empty string is not a null in mysql. This is true for Oracle !
this simple test lets you understand :

* Without NULLs
mysql> create table notnull (t varchar(10) NOT NULL);
Query OK, 0 rows affected (0.14 sec)

mysql> insert into notnull values('test1');
Query OK, 1 row affected (0.01 sec)

mysql> insert into notnull values('');
Query OK, 1 row affected (0.02 sec)

mysql> insert into notnull values(NULL);
ERROR 1048 (23000): Column 't' cannot be null
mysql> select * from notnull;
+---+
| t |
+---+
| test1 |
|   |
+---+
2 rows in set (0.02 sec)

mysql> select * from notnull where isnull(t);
Empty set (0.02 sec)

* With NULLs
mysql> create table isnulle(a varchar(10));
Query OK, 0 rows affected (0.08 sec)

mysql> insert into isnulle values(NULL);
Query OK, 1 row affected (0.03 sec)

mysql> select * from isnulle where isnull(a);
+--+
| a|
+--+
| NULL |
+--+
1 row in set (0.00 sec)


Hope that helps.
Mathias


Selon Ashok Kumar <[EMAIL PROTECTED]>:

> Hi friends,
>  I'm having one doubt on "NOT NULL" specification for
> the table field properties. That is i have created on
> table-mine which contains name(Not Null) and pwd(Not
> Null). Now I intended to execute the following query.
>
> "insert into mine values('','')"
>
> This means that i'm trying to insert the null fields
> to the table. but this query is successfully executed
> and 1 row is inserted into table with empty values.
> why it's happening and how can i resolve this problem.
>
> Pls give me suggestions regarding this.
>
> Thanks and Regards,
>  Ashok Kumar.P.S
>
>
>
> __
> Discover Yahoo!
> Stay in touch with email, IM, photo sharing and more. Check it out!
> http://discover.yahoo.com/stayintouch.html
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
>
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Regarding NOT NULL Option for Table Fields....

2005-06-12 Thread Michael Stassen

Ashok Kumar wrote:

Hi friends,
 I'm having one doubt on "NOT NULL" specification for
the table field properties. That is i have created on
table-mine which contains name(Not Null) and pwd(Not
Null). Now I intended to execute the following query.

"insert into mine values('','')"

This means that i'm trying to insert the null fields
to the table. but this query is successfully executed
and 1 row is inserted into table with empty values.
why it's happening and how can i resolve this problem.

Pls give me suggestions regarding this.

Thanks and Regards,
 Ashok Kumar.P.S


Because '' is an empty string, not NULL.

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Regarding NOT NULL Option for Table Fields....

2005-06-12 Thread Ashok Kumar
Hi friends,
 I'm having one doubt on "NOT NULL" specification for
the table field properties. That is i have created on
table-mine which contains name(Not Null) and pwd(Not
Null). Now I intended to execute the following query.

"insert into mine values('','')"

This means that i'm trying to insert the null fields
to the table. but this query is successfully executed
and 1 row is inserted into table with empty values.
why it's happening and how can i resolve this problem.

Pls give me suggestions regarding this.

Thanks and Regards,
 Ashok Kumar.P.S



__ 
Discover Yahoo! 
Stay in touch with email, IM, photo sharing and more. Check it out! 
http://discover.yahoo.com/stayintouch.html

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]