Page 2 of 2 FirstFirst 12
Results 21 to 37 of 37

Thread: about sql

  1. #21
    Expert Member
    Join Date
    Sep 2006
    Answers
    130

    Re: about sql

    Yes Aarusa, u can try Raghav's suggestion, so that u overcome the error hurdle which ur facing now.
    Or else, try deleting the existing records of the table & try to modify the column. Try to get rid of the error first using the suggestions given in the thread.

    *** Innila ***

    Last edited by Innila; 03-19-2007 at 06:03 AM.

  2. #22
    Junior Member
    Join Date
    Jan 2007
    Answers
    23

    Re: about sql

    hi ragav

    sorry for the distrubends

    i have posted what i created and what i have done

    please check that and give solution


    ''create table c (name varchar(20),id int)

    insert into c values('dss',32)

    alter table c modify name not null
    ''


  3. #23
    Contributing Member
    Join Date
    Jan 2007
    Answers
    31

    Re: about sql

    hi friend,

    what ever u did is working on my system, i do not know what has happened to it on your system. well i executed the same thing on my system, and see the result below:

    SQL> create table c (name varchar(20),id int);

    Table created.

    SQL> insert into c values('dss',32);

    1 row created.

    SQL> alter table c modify name not null;

    Table altered.

    SQL> desc c;
    Name Null? Type
    ------------------------------- -------- ----
    NAME NOT NULL VARCHAR2(20)
    ID NUMBER(38)

    well see the constraint is created.

    i do not know why its not getting created on your system.

    ok
    RSY

    Last edited by raghav_sy; 02-13-2007 at 03:53 AM.

  4. #24
    Junior Member
    Join Date
    Jan 2007
    Answers
    23

    Re: about sql

    hi ragav

    thnaks for your commitment

    i can add or drop constraint when creates the table with not null .

    but i did n't modify null to not null or vies versa.

    i have one doubt that will versions play mojor role about querry?

    this is my problem.........

    ok if is time permits ..............update your view .


    thank you all.............


  5. #25
    Expert Member
    Join Date
    Sep 2006
    Answers
    477

    Re: about sql

    I a certain. Versions WILL NOT play a role here. This is a very basic command and it CAN NOT go wrong. I don't know what mistake you are doing... Can you just execute these commands step by step and post them with the output here?

    (Refer the beautifel post by raghav_sy for formatting your post).

    I might be of some help then.

    -Kalayama

    [COLOR="Blue"][SIZE="2"]"If you are not living on the edge of your life, you are wasting space"[/SIZE][/COLOR]

    Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"

  6. #26
    Expert Member
    Join Date
    Sep 2006
    Answers
    477

    Re: about sql

    Ok dude. We might as well have been wrong all along. Try this for making a null column not null.
    Code:
    alter table c alter column name not null
    also try,
    Code:
    alter table c alter column name varchar(25) not null
    ps: unforunately i don't have sql server installed with me now. But msdn pages say the above syntax work. Please check and let me know.

    -kalayama

    Last edited by kalayama; 02-13-2007 at 05:18 AM. Reason: Another code snippet added
    [COLOR="Blue"][SIZE="2"]"If you are not living on the edge of your life, you are wasting space"[/SIZE][/COLOR]

    Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"

  7. #27
    Contributing Member
    Join Date
    Jan 2007
    Answers
    31

    Re: about sql

    hi,

    sorry i went to have lunch.

    well, the version will not have any effect.

    and yes, Kalayama the query 'alter table c alter column name not null' will not work on Oracle, i am not sure about SQL server, as i never worked on it.

    for not null we have to use Alter...... modify.....

    well, it was a nice question, after so much of gap i referred to the basic concepts. and it was good to revise.

    hope other people must have got the benefit.

    cheers,
    RSY


  8. #28
    Expert Member
    Join Date
    Sep 2006
    Answers
    477

    Re: about sql

    Well Raghav, it was a mistake from our part. Though I have worked on SQL Server , Oracle, MY SQL and SYBASE(Currently I'm more focused on this), Oracle has always been my favourite database.

    The alter table command with modify clause, works well both in Oracle and SYBASE. I checked official Microsoft MSDN pages, there they mention alter table ... alter column... syntax. No modify clause present. Just check it out.
    ALTER TABLE [ database_name . [ schema_name ] . | schema_name . ] table_name
    {
    ALTER COLUMN column_name
    {
    [ type_schema_name. ] type_name [ ( { precision [ , scale ]
    | max | xml_schema_collection } ) ]
    [ COLLATE collation_name ]
    [ NULL | NOT NULL ]
    | {ADD | DROP } { ROWGUIDCOL | PERSISTED }
    | DROP NOT FOR REPLICATION
    }
    | [ WITH { CHECK | NOCHECK } ] ADD
    {

    |
    |
    } [ ,...n ]
    | DROP
    {
    [ CONSTRAINT ] constraint_name
    [ WITH ( [ ,...n ] ) ]
    | COLUMN column_name
    } [ ,...n ]
    | [ WITH { CHECK | NOCHECK } ] { CHECK | NOCHECK } CONSTRAINT
    { ALL | constraint_name [ ,...n ] }
    | { ENABLE | DISABLE } TRIGGER
    { ALL | trigger_name [ ,...n ] }
    | SWITCH [ PARTITION source_partition_number_expression ]
    TO [ schema_name. ] target_table
    [ PARTITION target_partition_number_expression ]
    }
    [ ; ]

    ::=
    {
    MAXDOP = max_degree_of_parallelism
    | ONLINE = {ON | OFF }
    | MOVE TO { partition_scheme_name ( column_name ) | filegroup
    | "default"}
    }
    Here's the link MSDN Ref

    So, all along we were giving Oracle syntax for SQL server.

    -Kalayama

    Last edited by kalayama; 02-13-2007 at 06:17 AM. Reason: typo
    [COLOR="Blue"][SIZE="2"]"If you are not living on the edge of your life, you are wasting space"[/SIZE][/COLOR]

    Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"

  9. #29
    Contributing Member
    Join Date
    Jan 2007
    Answers
    31

    Re: about sql

    hi,

    hey good thing to know kalayama. i read that MSDN link. and u are correct for sql server alter...modify is not used.

    now aarusa will search for us.
    sorry aarusa. i gave u the suggestion pertaining to oracle and u were working on SQL server.

    sorry for troubling u. from next time i will check the Type of database.

    good learning at the end.

    cheers

    RSY


  10. #30
    Junior Member
    Join Date
    Jan 2007
    Answers
    23

    Re: about sql

    hi folks,

    i am aarusa,

    once i would like to tell thnks for you all.

    i got answer for that.

    when i used this querry that works,

    alter table alter column not null.

    thanks for alll................and one more thing

    1.what is the use of index ?
    2.how can i create that give with one example?


  11. #31
    Contributing Member
    Join Date
    Jan 2007
    Answers
    31

    Re: about sql

    hi good morning friends,

    Indexes are optional structures associated with tables used to speed query execution. an index is created if there is frequent retrieval of fewer than 10-15% of the rows in a large table and columns are referenced frequently in the WHERE clause.

    well it increases query speed but reduce update speed.

    Oracle automatically update indexes.
    Concatenated index can be max. on 16 columns.

    well , its a very huge topic. so its not possible to write about it here. u will have to read it on net or go through books.

    i will give very simple example:

    SQL> desc d1;
    Name Null? Type
    ------------------------------- -------- ----
    ID NUMBER
    NAME VARCHAR2(20)

    SQL> create index id on d1(id);

    Index created.

    u can see this index features with this query:

    SQL> select * from user_objects where object_name = 'ID';


    SQL> drop index id;

    Index dropped.

    i will give a link some of the material is there:

    http://www.techonthenet.com/oracle/indexes.php

    and its better u go through other material also, understans how index is created, then how it works during query execution. because there are around 32 types of indexes( i am not sure about this number).

    and one more thing, what ever i am writing its for ORACLE.

    regards,
    RSY


  12. #32
    Junior Member
    Join Date
    Feb 2007
    Answers
    5

    Re: about sql

    Hi Aaarusa,
    u were using MS-SQL 2000 i think..
    U told as u created one table with 2 column, just

    Execute this Query for Making existing Column from NULL to NOT NULL

    Alter table
    Alter Column Datatype not null

    this'll work.. If this not works let me know.. For creating Constraint, let me know wat constraint u need..

    Regards
    Vijay


  13. #33
    Junior Member
    Join Date
    Jan 2007
    Answers
    23

    Re: about sql

    hi vasu.

    i got answer for that.

    now i want details about index

    if is it possible please explain me wilth small example

    thank you...........................


  14. #34
    Junior Member
    Join Date
    Jan 2007
    Answers
    23

    Re: about sql

    hi folks,

    can i see weather how many tables are in one data base by using querrry?

    because if i want to see that i have to be go object browser .........


  15. #35
    Junior Member
    Join Date
    Feb 2007
    Answers
    5

    Re: about sql

    Hi aarusa,

    this query'll give u list of all userdefined tables,
    --to list all tables
    select distinct ist.* from information_schema.tables as ist
    inner join sysobjects as so on ist.table_name = so.name
    where so.status > 0

    -- to list all table name along with columns
    select distinct isc.* from information_schema.columns as isc
    inner join sysobjects as so on isc.table_name = so.name
    where so.status >0
    order by isc.table_name, isc.ordinal_position


    u can even paste this query in shortcut keys like (eg., ctrl+4).. In later when ever u reqd u can get it easily...

    Regards
    vijay


  16. #36
    Junior Member
    Join Date
    Feb 2007
    Answers
    5

    Re: about sql

    Hi aarusa,
    There are 2 kinds of Indexes, Clustered index and Non-Clustered Index.

    Clustered index
    Only one can create on One table
    This'll get create when ever u were creating Constraint like primary Key or Unique


    Non-Clustered index
    Many can create on One table
    This we can create many on the same table based on the Column (OR column combination if reqd)
    Syntax:
    Create Index On (Column1)
    Create Index On (Column1, Column2, ....)

    If Still more Reqd, give me the scenario and i'l explain u in detail as much i can
    Regards
    Vijay


  17. #37
    Junior Member
    Join Date
    Jan 2007
    Answers
    2

    Re: about sql

    no jusr use the easy way
    (inside the table design in Enterprise Manager)
    you can use constrait check in properties
    and jost right like:
    1- i='1'or i='2'
    2- like[1-2]

    thats mean just enetr the code with out alter but do that before enter the all data to table


Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact