![]() ![]() If you want to create a new user and grant them privileges in one command, you can do so by issuing a GRANT statement. PostgreSQL uses a similar, but slightly different, syntax:ĬREATE USER user WITH PASSWORD 'password' To create a user profile for your database without specifying any privileges for it, run the following command:ĬREATE USER username IDENTIFIED BY 'password' To delete a database, including any tables and data held within it, run a command that follows this structure: In PostgreSQL, you can see what databases have been created with the following command: To see what databases exist in your MySQL or MariaDB installation, run the following command: ![]() If you want your database to use a character set and collation different than the defaults, you can specify those using this syntax:ĬREATE DATABASE database_name CHARACTER SET character_set COLLATE collation The following command creates a database with default settings. If you'd like to supply your password as part of the command, immediately follow the -p option with your password, with no space between them: The above command will prompt you for your password after you run it. If you've already set up a non-root user account for your database, you can also use this method to log in as that user: If your root MySQL user is set to authenticate with a password, you can do so with the following command: Opening up the Database Prompt (using Password Authentication) This example will log you in as the postgres user, which is the included superuser role, but you can replace that with any already-created role: To open up a PostgreSQL prompt, use the following command. Opening up the Database Prompt (using Socket/Trust Authentication)īy default on Ubuntu 18.04, the root MySQL user can authenticate without a password using the following command: Where there are significant differences between RDBMSs, we have included the alternative commands. This guide uses MySQL as the example relational database management system (RDBMS), but the commands given will work with other relational database programs, including PostgreSQL, MariaDB, and SQLite. Please note that, while SQL is recognized as a standard, most SQL database programs have their own proprietary extensions. This isn't required for numeric data, but it also won't cause any issues if you do include apostrophes. In SQL, it is necessary to wrap any data values that consist of strings in apostrophes. This cheat sheet-style guide provides a quick reference to some of the most commonly-used SQL commands. SQL databases come installed with all the commands you need to add, modify, delete, and query your data. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |