[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Making an Index on Database

Posted on 2002-06-23
9
Medium Priority
?
187 Views
Last Modified: 2010-04-04
How can i make an index of a table (INTERBASE)?

here is my code to create a table how can i add an index for the username and employee ID

Procedure T_DataModule1.CreateUsersDB(NameFile: string);
begin
 Try
 With wwQuery1 do
 begin
  Active := false;
  DatabaseName :=  _Main.DatabaseName;
  SessionName  :=  _Main.sSessionName;
  SQL.Clear;
  SQL.Add('CREATE TABLE '+NameFile);
  SQL.Add('(');
  SQL.Add('EmplyeeID      VARCHAR(10),');
  SQL.Add('sUserName     VARCHAR(10),');
  SQL.Add('sPassWord     VARCHAR(10),');
  SQL.Add('AccessRights  VARCHAR(30)');
  SQL.Add(');');
  ExecSQL;
 end;
 except
  //do nothing
 end;
end;
0
Comment
Question by:girlswants_me
  • 5
  • 4
9 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7102771
just from head

create [unique] index index_name on tablename (fieldnamelist)

[] means optional

meikl ;-)
0
 

Author Comment

by:girlswants_me
ID: 7102842
can you give me codes for it
0
 

Author Comment

by:girlswants_me
ID: 7102843
for the username and employee ID
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 7102886
query1.sql.text := 'create unique index aname on tablename (employeeID, sUsername)');
query1.execSQL;

tablename and aname must be replaced by your values

not tested

meikl ;-)
0
 

Author Comment

by:girlswants_me
ID: 7102897
that only have 1 index how about i like to have both
employeeID and sUsername having a Unique Index each.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 400 total points
ID: 7102918
query1.sql.text := 'create unique index aname on tablename (sUsername)');
query1.execSQL;

query1.sql.text := 'create unique index aname on tablename (employeeID)');
query1.execSQL;

tablename and aname must be replaced by your values

not tested

meikl ;-)
0
 

Author Comment

by:girlswants_me
ID: 7123791
whats wrong with my code?


Try
 With wwQuery1 do
 begin
  Active := false;
  DatabaseName :=  _Main.DatabaseName;
  SessionName  :=  _Main.sSessionName;
  SQL.Clear;
  SQL.Add('CREATE TABLE '+NameFile);
  SQL.Add('(');
  SQL.Add('EmplyeeID      VARCHAR(10),');
  SQL.Add('sUserName     VARCHAR(10),');
  SQL.Add('sPassWord     VARCHAR(10),');
  SQL.Add('AccessRights  VARCHAR(30)');
  SQL.Add(');');
  ExecSQL;

{  SQL.clear;
  SQL.Add('CREATE INDEX NAMEX ON '+NameFile+' (EmplyeeID,sUserName)');
  ExecSQL;}

  sql.text := 'create unique index _Username   on '+NameFile+' (sUserName)';
  execSQL;

  sql.text := 'create unique index _employeeID on '+NameFile+' (EmplyeeID)';
  execSQL;


 end;
 except
  //do nothing
 end;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7123845
what error do you get?
0
 

Author Comment

by:girlswants_me
ID: 7125851
Thank you its my code have error. thanks a lot for the help
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question