Now that we've created and populated our test database, we can insert additional data, export to outside data sources, and even backup with sqlcmd. INSERT INTO inventory VALUES (2, 'pencils', 174) INSERT INTO inventory VALUES (1, 'pens', 170) Now we’ll insert data into the database by entering the following lines: GONext we’ll create a table in our dummy database by entering the following lines: CREATE TABLE inventory (id INT, name NVARCHAR(50), quantity INT) GO We can prep our newly created database for use by entering the following lines: You’ll see that SQL Server already has a default test database available, but we’ll create our own by entering the following lines: To query SQL Server for a list of existing databases, enter the following lines: Our preview has its own set of databases, so it's perfect for this little test. Read More: Top 5 Linux Community Resources for IT Pros SQL Server Database Administration on LinuxOnce confident I had everything up and running correctly, I decided I'd get a feel for the app by playing database administrator. I tried to set it up so I could show you guys how much easier database management is with a graphical user interface, but the installation kept hanging at about 70 percent. Note: You can also connect from SQL Server Management Studio. You’ll know for sure if you see output that resembles the following screenshot: If the terminal doesn’t throw up any errors, all systems are most likely go. For some reason, Linux gives no indication that we made a successful connection to the server. I find shorter commands are easier to execute and not screw up.Here’s where things get tricky. Sqlcmd -S localhost -U SA Note: You can type 'localhost' in place of the username and omit the password to be prompted for it in the next line, as I illustrated in the command above. Your command will look something like the following: We can create a secure connection to SQL Server by simply opening the terminal and running sqlcmd with parameters for our username and the password we created earlier. Read More: Troubleshooting Linux: Problems That Drive You Mad and Solutions to Save the Day! Connect to SQL ServerAnother critical function sqlcmd performs is connecting to the database server itself, which is necessary to create databases, import data, and so forth. But of instead of installing SQL Server again in line 4, we'll install the updated tools by entering the following commands:Ĭomplete the installation process by accepting the License terms and proceed to the next step. We'll start by repeating the first three steps of the installation process. Fortunately it's all pretty simple and straightforward. The command line tools are not included with the installation, so we'll have to install both the sqlcmd and bcp utilities on our own. BCP is so flexible that it can handle the 'bulk' of your import and export needs. A simple example would be importing existing employee data into a table you created with SQL Server. Short for Bulk Copy Program, bcp is a command line utility that lets you copy larger than average query jobs from a database into a data file and vice versa. For example, it's great for batching processing and other repetitive processes as well as simulating the load of test databases.īcp is another interesting tool available to SQL Server vNext CTP1 testers. The sqlcmd utility is designed to optimize SQL queries and simplify a number of database administration tasks. Microsoft offers some very useful tools for the job, including sqlcmd. SQL Server for Linux Command Line ToolsThe SQL Server for Linux preview is a command line application so you're gonna need the right tools in order to dink around in this environment. Finally, install an updated SQL Server for Linux by typing the following commands: Register the Microsoft SQL Server Ubuntu repository by typing the following line:Ĭurl | sudo tee /etc/apt//mssql-server.listĤ. Grab the public GPG keys to encrypt your sessions by typing the following line:ģ. The thought alone filled me nervous tension, but it's actually a simple process. InstallationLike many applications, the SQL Server for Linux preview must be installed from the command line. Since I'm running Linux Mint on my box, the examples in this review will pertain to Ubuntu. Distro SupportThe live preview, dubbed SQL Server vNext CTP1, is currently available for Ubuntu, Red Hat Enterprise, and other distros via Docker containers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |