If a pattern is a plain string --- it contains no metacharacters --- locate displays all pathnames in the database that contain that string anywhere. If a pattern does contain metacharacters, it only displays pathnames that match the pattern exactly. As a result, patterns that contain metacharacters should usually begin with a `*', and will most often end with one as well. The exceptions are patterns that are intended to explicitly match the beginning or end of a pathname.
The filename databases contain lists of the files that were on the system whenever the database was last updated. The pathname of the default database, the frequency with which it is updated, and the directories for which it contains entries are configurable by the system administrator.
locate supports having multiple filename databases; for example, there could be one on each filesystem. You can tell locate to use alternate filename databases instead of the default one by giving a colon-separated list of database pathnames as either an argument to the -d or --database options or as the value of the environment variable LOCATE_PATH. The option overrides the environment variable if both are used.