MCLIENT(1)
π MCLIENT(1) β the MonetDB command-line tool, explained by your favorite unix girlie
okay so real talk, this is mclient(1) from the MonetDB Applications manual, and by the end of this you're gonna be obsessed. periodt.
β¨ NAME β¨
mclient β the MonetDB command-line tool. that's it. that's the icon.
π«Ά SYNOPSIS π«Ά
mclient [ options ] [ file or database [ file ... ] ]
mclient --help
πΈ DESCRIPTION πΈ
so first, the vibe check on MonetDB itself: it's a database management system built from a main-memory perspective, using a fully decomposed storage model, automatic index management, extensibility of data types and search accelerators, and an SQL front end. no cap, it's giving engineering excellence.
mclient is the command-line interface to the MonetDB server. it's literally the main character of your terminal.
Here's how it decides what to run, bestie:
- if the
--statement=query(-s query) option is given, that query gets executed. - if any files are listed after the options, queries get read from those files and executed.
- the special filename
-means standard input. iykyk. - lowkey important: if there's both a
--statementoption and filename arguments, the query given with--statementruns first. - if no
--statementis given and no files are specified on the command line,mclientreads queries from standard input. default behavior, no notes.
When reading from standard input β if standard input is a terminal or if the --interactive (-i) option is given β mclient interprets lines starting with \ (backslash) specially. see the BACKSLASH COMMANDS section below. (that's later in the page, not here, keep scrolling energy.)
π the config file lore π
Before mclient even starts parsing command line options, it reads a configuration file. the order is very specific, so pay attention:
- If the environment variable
DOTMONETDBFILEis set and not empty, it reads the file pointed to by that variable. - If it's set but empty, no configuration file is read. at all. nothing.
- If it's unset,
mclientfirst looks for a file.monetdbin the current working directory. if that doesn't exist, it looks for a filemonetdbin the XDG configuration directory ($XDG_CONFIG_HOME, which defaults to$HOME/.configif not set). and finally for a file.monetdbin the current user's home directory.
This file can contain defaults for the flags user, password, language, database, save_history, format, host, port, and width. slay, a whole defaults system.
For example, an entry in a .monetdb file that sets the default language for mclient to mal looks like this:
language=mal
To disable reading the .monetdb file, set the variable DOTMONETDBFILE to the empty string in the environment. bye felicia.
π the interrupt moment π
When working interactively, an interrupt (usually Ctrl+C) will clear any query being edited and will stop any running query. genuinely so useful, we love a clean escape.
β OPTIONS β
π General Options π
--help,-?β print usage information and exit. your lil cheat sheet.--version,-vβ print version information and exit. for when you gotta know.--quiet,-qβ be quiet: don't print the welcome message at startup. no small talk, just vibes.--encoding=encoding,-E encodingβ specify the character encoding of the input. heads up though, this option applies to both the standard input ofmclientand to the argument of the--statement(-s) option, but not to the contents of files specified on the command line (except for-, which refers to standard input) or to files specified using the\<command β those must be encoded usingUTF-8. the default encoding is taken from the locale.--language=language,-l languageβ specify the query language. the following languages are recognized:malandsql. a unique prefix suffices. when the--languageoption is omitted, the default ofsqlis assumed. iconic default tbh.--database=database,-d databaseβ specify the name or URI of the database to connect to. the-dcan be omitted if an equally named file does not exist in the current directory. as such, the first non-option argument will be interpreted as database to connect to if the argument does not exist as file. valid URIs are as returned bymonetdb discover, seemonetdb(1), and look likemapi:monetdb://hostname:port/database. fancy β¨--host=hostname,-h hostnameβ specify the name of the host on which the server runs (default:localhost). when the argument starts with a forward slash (/),hostis assumed to be the directory where the UNIX sockets are stored, for platforms where these are supported.--port=portnr,-p portnrβ specify the portnumber of the server (default:50000).--interactive,-iβ when reading from standard input, interpret lines starting with\(backslash) specially. see the section BACKSLASH COMMANDS below.--timer=timermode,-t timermodeβ the timer command controls the format of the time reported for queries. the default mode isnone, which turns off timing reporting. the timer modeclockreports the client-side wall-clock time (clk) in a human-friendly format. the timer modeperformancereports client-side wall-clock time (clk) as well as detailed server-side timings, all in milliseconds (ms): the time to parse the SQL query, optimize the logical relational plan and create the initial physical (MAL) plan (sql); the time to optimize the physical (MAL) plan (opt); the time to execute the physical (MAL) plan (run). all timings are reported on stderr.
note that the client-measured wall-clock time is reported per query only when options--interactiveor--echoare used, because only then doesmclientsend individual lines (statements) of the SQL script to the server. otherwise, whenmclientsends the SQL script in large(r) batch(es), only the total wall-clock time per batch is measured and reported. the server-measured detailed performance timings are always measured and reported per query. π so specific, so important.
--user=user,-u userβ specify the user to connect as. if this flag is absent, the client will ask for a user name, unless a default was found in the.monetdbor$DOTMONETDBFILEfile.--format=format,-f formatβ specify the output format. the possible values aresql,expanded,x,csv,csv-noquote,tab,raw,xml,trash, androwcount. here's the rundown, bestie:csvis comma-separated values.csv-noquoteis comma-separated values without escaping any quotes.tabis tab-separated values.rawis no special formatting (data is dumped the way the server sends it to the client).sqlis a pretty format meant for human consumption where columns are clearly shown.expandedandxare synonyms and are another pretty format meant for human consumption where column values are printed in full and below each other.xmlis a valid (in the XML sense) document.trashdoes not render any output, enabling performance measurements free of any output rendering/serialization costs.rowcountis a variation ontrashwhere only the number of affected rows is printed.
Normal csv and tab formatting will use double quotes around any fields that contain double quotes, white space or the separator. the csv-noquote format will prevent that and dump the contents of the field without any interpretation. in addition to plain csv, two other forms are possible: csv=c uses c as column separator; csv+c uses c as column separator and produces a single header line in addition to the data. π¦
--echo,-eβ echo the query. note that using this option slows down processing. (worth it sometimes, just saying.)--history,-Hβ if compiled with thereadline(3)library, load and save the command line history (default off).--log=logfile,-L logfileβ save client/server interaction in the specified file. receipts, literally.--statement=stmt,-s stmtβ execute the specified query. the query is run before any queries from files specified on the command line are run.--timezone,-zβ do not tell the client's timezone to the server.--Xdebug,-Xβ trace network interaction betweenmclientand the server. peek behind the curtain β¨--pager=cmd,-| cmdβ send query output through the specifiedcmd. onecmdis started for each query. note that the|will have to be quoted or else the shell will interpret it. (shell girlies know.)
π SQL Options π
--null=nullstr,-n nullstrβ set the string to be used as NULL representation when using thesql,csv, ortaboutput formats. if not used, NULL values are represented by the string"null"in thesqloutput format, and as the empty string in thecsvandtaboutput formats. note that an argument is required, so in order to use the empty string, use-n ""(with the space) or--null=. don't forget the space, bestie.--autocommit,-aβ switch autocommit mode off. by default, autocommit mode is on. so this flag is a little chaos gremlin, but a useful one.--allow-remote,-Rβ allow remote content (URLs) in theCOPY INTO table FROM file ON CLIENT ...query. remote content is retrieved bymclient.--rows=nr,-r nrβ if specified, query results will be paged by an internal pager at the specified number of lines. if set to0(zero), use the height of the terminal. the default is-1, which means no pager is used.--width=nr,-w nrβ specify the width of the screen. the default is the (initial) width of the terminal. π--dump,-Dβ create an SQL dump.--inserts,-Nβ useINSERT INTOstatements instead ofCOPY INTO+ CSV values when dumping the data of a table. this option can be used when trying to load data from MonetDB into another database, or when e.g. JDBC applications are used to reload the dump.
(part 1 done, but like... there's more, don't go anywhere π)
π BACKSLASH COMMANDS π
okay so these are the little backslash thingies you type right into the client β no semicolon needed, they're client-side β¨
General Commands
\?β pops up a help message that explains all the backslash commands. your built-in cheat sheet, bestie π\qβ exitsmclient. bye bestie π¦\< fileβ reads input from the named file.\> fileβ writes output to the named file. if you don't name a file, it writes to standard output instead.\| commandβ pipes output to the given command. heads up tho: each query gets piped to a new invocation of the command π and if you don't give a command, it reverts to writing output to standard output.\hβ shows thereadline(3)history. all your past queries, right there π\L fileβ logs client/server interaction into the given file. if you don't name a file, it stops logging information.\Xβ traces whatmclientis doing. mostly for debugging purposes, so like, dev mode π§\eβ echoes the query in SQL formatting mode.\f formatβ uses the specified format mode to format the output. the possible modes are the same as for the--format(-f) option π\w widthβ sets the max page width when rendering in the sql formatting mode. if width is-1the page width is unlimited, if width is0it uses the terminal width, and if width is greater than0it uses that given width. pick your vibe β¨\r rowsβ uses an internal pager with that many rows per page. if rows is-1it stops using the internal pager, and if rows is0it uses the height of the terminal.
SQL Commands
\Dβ dumps the complete database. this is equivalent to using the programmsqldump(1)π\D tableβ dumps the given table.\dβ alias for\dvt.\d[Stvmsfn]+β lists database objects of the given type. you can stack multiple type specifiers at the same time, no cap. the specifiersS,t,v,m,s,fandnstand for System, table, view, merge table, sequence, function and schema respectively. note thatSjust switches on viewing system catalog objects, which is orthogonal to the other specifiers π\d[Stvsfnm]+ objectβ describes the given object in the database using SQL statements that reconstruct the object. same specifiers as above, same rules too. when you give no specifiers,vtis assumed. the object can be given with or without a schema, separated by a dot. the object name can contain the wildcard characters*and_, which represent zero or more, and exactly one character respectively. an object name gets converted to lowercase, unless it's quoted with double quotes ("). examples of this are e.g.*.mytable,tabletype*, or"myschema.FOO". note that wildcard characters do not work in quoted objects, and quoting follows SQL quoting rules: arbitrary parts can be quoted, and two quotes following each other in a quoted string represent the quote itself π\Aβ enables auto commit mode.\aβ disables auto commit mode.
β¨ EXAMPLES β¨
so you wanna import data from a CSV (comma-separated values) file into a table, efficiently? say less π
Method 1: the file has to be readable by the server
here $file is the absolute path name of the file, $table is the name of the table, and $db is the name of the database:
mclient -d $db -s "COPY INTO $table FROM '$file' USING DELIMITERS ',',E'\\n','\"'"
Method 2: when the file is read by mclient itself
this one's for when the server has no access to the file π $file is the (absolute or relative) path name of the file, $table is the name of the table, $db is the name of the database:
mclient -d $db -s "COPY INTO $table FROM STDIN USING DELIMITERS ',',E'\\n','\"'" - < $file
β οΈ note that in this latter case, if a count of records is supplied, it should be at least as large as the number of records actually present in the CSV file. this, because otherwise the remainder of the file will be interpreted as SQL queries π literally not what you want.
Method 3: another, easier way
another, easier method to have the client read the file content is as follows:
mclient -d $db -s "COPY INTO $table FROM '$file' ON CLIENT USING DELIMITERS ',',E'\\n',\"'"
in this case the value of $file can be a path name relative to the directory in which mclient was started. and if, in addition, the option --allow-remote is passed to mclient, the $file in the above query can also be a URL π it then has to have the form schema://string, e.g., https://www.example.org/dumpdata.csv.
for more information about the COPY INTO query, see https://www.monetdb.org/documentation/user-guide/sql-manual/data-loading/copy-from/ π
π SEE ALSO π
msqldump(1), mserver5(1) β go give them a read bestie, iykyk π«Ά
and that's the whole page, babes π this was MonetDB, dated 2025-12-09, and you were reading MCLIENT(1) β iconic, no notes, periodt πβ¨
π¦ where this page comes from
- nixpkgs unstable: monetdb 11.55.7
- π the page's license: MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms