Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Give example : How I can Use index in sql table

Give example : How I can Use index in sql table

Scheduled Pinned Locked Moved Database
databasetutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ashish Kumar Vyas
    wrote on last edited by
    #1

    Hi, Anyboby can give me real scenario example how to use indexing on the table. Requirement: example in MS-SQL. Thanks

    A J 2 Replies Last reply
    0
    • A Ashish Kumar Vyas

      Hi, Anyboby can give me real scenario example how to use indexing on the table. Requirement: example in MS-SQL. Thanks

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Please define your question better. What do you want to do, create an index (try BOL) or decide on what column(s) should be in the index?

      Bob Ashfield Consultants Ltd

      A 1 Reply Last reply
      0
      • A Ashfield

        Please define your question better. What do you want to do, create an index (try BOL) or decide on what column(s) should be in the index?

        Bob Ashfield Consultants Ltd

        A Offline
        A Offline
        Ashish Kumar Vyas
        wrote on last edited by
        #3

        Hi, GM first of all thanx for replying. mine queries are -how to create index -in which field it should be -explain me this concept in example thanks Ashish

        A 1 Reply Last reply
        0
        • A Ashish Kumar Vyas

          Hi, GM first of all thanx for replying. mine queries are -how to create index -in which field it should be -explain me this concept in example thanks Ashish

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          You are having a laugh aren't you? Can I collect whatever qualification is is you are trying for?

          Ashish Kumar Vyas wrote:

          how to create index

          Try BOOKS ON LINE, thats what they are for

          Ashish Kumar Vyas wrote:

          in which field it should be

          Rather dependant on the table, usage etc etc

          Ashish Kumar Vyas wrote:

          explain me this concept in example

          Where do you start? I know, google! just to show I'm not all bad: CREATE INDEX index_name ON table(column,column....)

          Bob Ashfield Consultants Ltd

          1 Reply Last reply
          0
          • A Ashish Kumar Vyas

            Hi, Anyboby can give me real scenario example how to use indexing on the table. Requirement: example in MS-SQL. Thanks

            J Offline
            J Offline
            Justin Porteous
            wrote on last edited by
            #5

            Create a Database To create a database: CREATE DATABASE database_name Create a Table To create a table in a database: CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, ....... ) Example This example demonstrates how you can create a table named "Person", with four columns. The column names will be "LastName", "FirstName", "Address", and "Age": CREATE TABLE Person ( LastName varchar, FirstName varchar, Address varchar, Age int ) This example demonstrates how you can specify a maximum length for some columns: CREATE TABLE Person ( LastName varchar(30), FirstName varchar, Address varchar, Age int(3) ) The data type specifies what type of data the column can hold. The table below contains the most common data types in SQL:

            Data Type Description
            integer(size)
            int(size)
            smallint(size)
            tinyint(size) Hold integers only. The maximum number of digits are specified in parenthesis.
            decimal(size,d)
            numeric(size,d) Hold numbers with fractions. The maximum number of digits are specified in "size". The maximum number of digits to the right of the decimal is specified in "d".
            char(size) Holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis.
            varchar(size) Holds a variable length string (can contain letters, numbers, and special characters). The maximum size is specified in parenthesis.
            date(yyyymmdd) Holds a date

            Create Index Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes, they are just used to speed up queries. Note: Updating a table containing indexes takes more time than updating a table without, this is because the indexes also need an update. So, it is a good idea to create indexes only on columns that are often used for a search. A Unique Index Creates a unique index on a table. A unique index means that two rows cannot have the same index value. CREATE UNIQUE INDEX index_name ON table_name (column_name) The "column_name" specifies the column you want indexed. A Simple Index Creates a simple index on a table. When the UNIQUE keyword is omitted, duplicate values are allowed. CREATE INDEX index_name ON table_name (column_name) The "column_name

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups