// Create an index on staff number CREATE INDEX staff_no; ON staff (staff_no) // Create an index on descending hire date and ascending staff number CREATE INDEX hiredate; ON staff (hiredate DESC, staff_no ASC) // Create an index on last name converted to lower case CREATE INDEX lname; ON staff (lower(lastname))
use patrons index events, dates, names seek "BALLET" list while event = "BALLET" // Close index files in the current workarea close index list for event = "BALLET"
use example display indexes to file ind_info
use example list indexes to file ind_info
use accounts exclusive delete tag zip
use patrons index on event tag event
https://www.lianja.com/doc/index.php/INDEX
set exclusive on use patrons index events, names, dates reindex
https://www.lianja.com/doc/index.php/REINDEX
use patrons set index to names, events && opens up the index files seek "smith"
https://www.lianja.com/doc/index.php/SET_INDEX
use accounts set index to ordno, invno copy indexes ordno, invno
https://www.lianja.com/doc/index.php/COPY_INDEXES
open database southwind use products set order tag productid set key to range 20, 30 list set order tag productname set key to "Chai" list set key to range "A","C" list
https://www.lianja.com/doc/index.php/SET_KEY
use patrons index address.dbx set order to tag zip of address
https://www.lianja.com/doc/index.php/SET_ORDER
use patrons index on event to events seek "BALLET" index on date to dates seek ctod("01/01/2000") index on dtos(eventdate) + "/" + event to dates seek "20010101/BALLET"
https://www.lianja.com/doc/index.php/SEEK
use patrons index events, name m_find = "OPERA" find &m_find if found() edit else dialog message "Record not found." endif
https://www.lianja.com/doc/index.php/FIND
set icache to 100 use patrons index events, dates, names // Another example use accounts index acc_prefix, paid_date set icache to reccount() reindex
https://www.lianja.com/doc/index.php/SET_ICACHE
use patrons set unique on index on name to persons
https://www.lianja.com/doc/index.php/SET_UNIQUE
// Rebuild the index staff_no index on staff table ALTER INDEX staff_no; ON staff; REBUILD; SHARED
https://www.lianja.com/doc/index.php/ALTER_INDEX
DROP INDEX staff_no ON staff
https://www.lianja.com/doc/index.php/DROP_INDEX
CREATE TABLE contact; (LastName char(25), FirstName char(25),; INDEX FullName (LastName, FirstName))
https://www.lianja.com/doc/index.php/INDEX_Table_Constraint
CREATE TABLE contact; (LastName char(25), FirstName char(25),; KEY FullName (LastName, FirstName))
https://www.lianja.com/doc/index.php/KEY_Table_Constraint
CREATE TABLE newcust; (acc_ref char(5); default strzero(seqno(),5); PRIMARY KEY,; acc_name char(20))
https://www.lianja.com/doc/index.php/PRIMARY_KEY_Column_Constraint
CREATE TABLE newcust; (acc_ref char(5) default strzero(seqno(),5),; acc_name char(20)) ALTER TABLE newcust; ADD PRIMARY KEY acc_ref+acc_name TAG RefName
https://www.lianja.com/doc/index.php/PRIMARY_KEY_Table_Constraint
CREATE TABLE orderitem; (ord_ref char(5) FOREIGN KEY,; item_ref char(5) PRIMARY KEY)
https://www.lianja.com/doc/index.php/FOREIGN_KEY_Column_Constraint
CREATE TABLE supplier; (SuppId int PRIMARY KEY,; SuppRef char(10) UNIQUE,; SuppName char(40) UNIQUE) CREATE TABLE purchase_order; (POId int PRIMARY KEY,; PO_SuppRef char(10),; POtotal num(10,2)) ALTER TABLE purchase_order ADD FOREIGN KEY po_suppref TAG fk_po_suppref ALTER TABLE purchase_order ADD FOREIGN KEY (po_suppref) TAG fk_po_suppref; REFERENCES supplier TAG SuppRef
https://www.lianja.com/doc/index.php/FOREIGN_KEY_Table_Constraint
CREATE TABLE newcust; (acc_ref char(5) default strzero(seqno(),5),; acc_name char(20)) ALTER TABLE newcust; ADD UNIQUE acc_ref+acc_name TAG RefName CREATE TABLE contact; (ContRef char(5), LastName char(25), FirstName char(25),; UNIQUE FullName (LastName, FirstName, ContRef))
https://www.lianja.com/doc/index.php/UNIQUE_Table_Constraint
CREATE TABLE newcust; (acc_ref char(5) default strzero(seqno(),5) UNIQUE,; acc_name char(20) UNIQUE)
https://www.lianja.com/doc/index.php/UNIQUE_Column_Constraint
create table country; (id char(36) description "ID" default guid(),; countryname char(100) description "Name",; countrycurr char(100) description "Currency",; countrycap char(100) description "Capital") create index id on country (id) insert into country (countryname, countrycurr, countrycap); values ("United Kingdom","Pound sterling","London"),; ("United States of America","United States dollar","Washington, D.C."),; ("France","Euro","Paris"),; ("Italy","Euro","Rome"),; ("Germany","Euro","Berlin"),; ("Brazil","Brazilian real","Brasilia"),; ("Thailand","Thai baht","Bangkok") select * from country
https://www.lianja.com/doc/index.php/GUID()
CREATE TABLE cust (acc_num INT , acc_name char(20)) INSERT INTO cust (acc_num, acc_name) VALUES (NEXTVAL, "Smith") INSERT INTO cust (acc_name) VALUES ("Brown") INSERT INTO cust (acc_num, acc_name) VALUES (CURRVAL+2, "Jones") SELECT * from cust
https://www.lianja.com/doc/index.php/NEXTVAL
SELECT * FROM sysindexinfo
https://www.lianja.com/doc/index.php/SYSINDEXINFO
SELECT * FROM sysprimarykeys
https://www.lianja.com/doc/index.php/SYSPRIMARYKEYS
set indexext to ".ntx", ".cdx" index on name to names use name index names
https://www.lianja.com/doc/index.php/SET_INDEXEXT
//Open up dbf with a dbx file use customer copy tag zip to zip.ndx
https://www.lianja.com/doc/index.php/COPY_TAG
?mdx(1, account) invoice.dbx
https://www.lianja.com/doc/index.php/MDX()
?cdx(1, account) invoice.dbx
https://www.lianja.com/doc/index.php/CDX()
set view to accounting ? for(3) acct = "CAR"
https://www.lianja.com/doc/index.php/FOR()
use accounts index on name to name unique ? unique(0) .T.
https://www.lianja.com/doc/index.php/UNIQUE()
use accounts index acc_no, date_paid ? indexkey(1) acc_no + dtos(date_rec) set order to 2 ? indexkey(indexorder()) dtos(date_paid) + str(amo_paid,11,2) index on lower(left(company,20)) tag company ? indexkey() lower(left(company,20))
https://www.lianja.com/doc/index.php/INDEXKEY()
? indexext() .ndx
https://www.lianja.com/doc/index.php/INDEXEXT()
open database southwind use customers set order tag companyname_search ? indexorder() companyname_search
https://www.lianja.com/doc/index.php/INDEXORDER()
? ifilecount("*.ndx") 5
https://www.lianja.com/doc/index.php/IFILECOUNT()
set view to accounting ?descending(3) .T.
https://www.lianja.com/doc/index.php/DESCENDING()
use accounts index acc_no, date_paid ? key(1) acc_no + dtos(date_rec) set order to 2 ? key(indexorder()) dtos(date_paid) + str(amo_paid,11,2) index on lower(left(company,20)) tag company ? key() lower(left(company,20))
https://www.lianja.com/doc/index.php/KEY()
use accounts index acc_no,date_paid ? ndx(1) acc_no.ndx set order to 2 ? ndx(indexorder()) date_paid.ndx
https://www.lianja.com/doc/index.php/NDX()
open database southwind use customers set order tag companyname_search ? order() companyname_search
https://www.lianja.com/doc/index.php/ORDER()
?tag(2) LAST_NAME tag("alternate.dbx",3) ZIPCODE
https://www.lianja.com/doc/index.php/TAG()
if indexexists("southwind","customers","products","productid") open database southwind use products order productid else open database southwind use products index on productid tag productid endif
https://www.lianja.com/doc/index.php/INDEXEXISTS()
use accounts ? tagcount() 4 set order to 0 ?tagcount() 0
https://www.lianja.com/doc/index.php/TAGCOUNT()
?tagno("city") 3 ?tagno("last_name", "customer.dbx", "customer") 1
https://www.lianja.com/doc/index.php/TAGNO()
open database southwind use customers in 1 select 2 use orders ?tagexpr(2,"customers")
https://www.lianja.com/doc/index.php/TAGEXPR()
open database southwind use customers ? tagfor("customerid") // returns empty string ? tagfor("label_germany") // returns 'CONTAINS("Germany", .f.)' ? tagno("label_germany", "customers.dbx", "customers") // returns 'CONTAINS("Germany", .f.)'
https://www.lianja.com/doc/index.php/TAGFOR()
open database southwind use customers in 1 select 2 use orders ?tagkey(2,"customers")
https://www.lianja.com/doc/index.php/TAGKEY()
open database southwind use customers in 1 select 2 use orders ?tagunique(2,"customers")
https://www.lianja.com/doc/index.php/TAGUNIQUE()
index on descend(name) to descendname seek descend("Smith")
https://www.lianja.com/doc/index.php/DESCEND()
if tagcount() > 0 for i = 1 to tagcount() ? "Candidate status for " + tag() + " is " + ltos(candidate(i)) next endif
https://www.lianja.com/doc/index.php/CANDIDATE()
index on name tag descendname descending seek dbxdescend("Smith")
https://www.lianja.com/doc/index.php/DBXDESCEND()
use names index names size = icache(indexkey(1)) set icache to size reindex use names set icache to icache(name+left(address, 5)) index on name+left(address, 5) to names
https://www.lianja.com/doc/index.php/ICACHE()
m_val=part_no if keymatch(m_val) dialog box "This part number already exists!" endif
https://www.lianja.com/doc/index.php/KEYMATCH()
use accounts in 1 use supp in 2 index name select 1 display name BCD CORPORATION ? iif(seek(name,supp),supp_name,"***name not on file***") BCD CORPORATION
https://www.lianja.com/doc/index.php/SEEK()
create index lname; on example (lower(last_name))
alter index lname; on example; rebuild
drop index lname; on example
https://www.lianja.com/doc/index.php/Using_Recital_SQL
create index lname; on example (lower(last_name))
alter index lname; on example; rebuild
drop index lname; on example
https://www.lianja.com/doc/index.php/Using_Lianja_SQL
use orders index on orderid tag orderid unique index on orderid+dtos(orderdate) tag order_date index on customerid+str(orderid) tag cust_order for empty(shippeddate) index on dtos(orderdate) tag latest descending
use orders reindex
https://www.lianja.com/doc/index.php/Using_Navigational_Data_Access_Commands_in_Lianja