• SQL

    SQL TOP

    No, SQL top doesn’t look at the status of a database the way the TOP command in bash does. It looks at the top number of records returned in a query, so a bit more like head. This makes SELECT TOP useful with larger tables where this will be millions of records getting loaded into memory during a query. In this article, we’ll use the same “Customers” table from our first articles to test out TOP: ID Site Contact Address City Zip Country 1 Krypted Charles Edge my house Minneapolis 55418 US 2 Apple Tim Cook spaceship Cupertino 95014 US 3 Microsoft Satya Nadella campus Redmond 98053 US 4 Facebook…

  • SQL

    Reset A Lost MySQL Password

    The first step to reset a password is to stop the MySQL daemon. This will cause mysqld to accept no new connections and terminate existing connections. But this can all be done in a matter of seconds, usually. To stop MySQL on Mac, use the System Preference pane or launchctl. To stop on Linux, use init.d: sudo /etc/init.d/mysql stop Or if it’s mysqld instead: sudo /etc/init.d/mysqld stop Then start the SQL daemon using the –skip-grant-tables option: sudo mysqld_safe --skip-grant-tables & Next, login to mysql, which won’t require a password running in this mode: mysql -u root And use the UPDATE USER statement to set a new password: UPDATE USER set…

  • SQL

    SQL Constraints

    SQL constraints the data that can be in a table. A violation of a constraint causes an action to be aborted. Constraints can be defined upon creation or using the ALTER TABLE statement once created. The general syntax of a CREATE (or use ALTER instead of CREATE) when defining constraints is as follows: CREATE TABLE tablename ( columnname datatype(size) constraintname, columnname datatype(size) constraintname, columnname datatype(size) constraintname, columnname datatype(size) constraint name, columnname datatype(size) constraint name, ); Obviously, replace columnname with the name of each of your column, datatype with the types of data your column contains and constraint name with the constraint you wish to use. You have the following constraints…

  • SQL

    User And Permissions Management In MySQL

    By default, MySQL comes with a root user configured. You can also create additional users, change passwords for users, and assign what databases and tables they have access to. From MySQL, you can can create a basic user using the CREATE USER statement, providing a user, a location, and then using IDENTIFIED BY followed by a password. In production, this would look similar to the following, using krypted as the user and mysecretpassword as the password: CREATE USER 'krypted'@'localhost' IDENTIFIED BY 'mysecretpassword'; Once you’ve created a user, you’ll want to assign what the user can access. Here, the * wildcard is pretty handy. In the following command, we’ll use the…

  • Apple Configurator,  iPhone,  Mac OS X,  Mac OS X Server,  Mac Security

    Mac-Only MDM Profile Keys

    Below is a listing of all the profile payloads that you see listed when using the Profile Manager web interface as well as their corresponding keys in the mobileconfig files. You can use these to generate profile keys programmatically: Distribution Type: Automatic Push Manual Download Organization: PayloadOrganization Description: PayloadDisplayName Automatically Remove Profile: PayloadRemovalDisallowed Payload scope: User or computer —— Identification User Display Name: Email address: EmailAddress User Name: FullName Password: Password User Enters Password: AuthMethod Prompt: Prompt Prompt Message: PromptMessage ——— Restrictions (com.apple.applicationaccess.new) Preferences tab: Restrict Items in System Preferences: familyControlsEnabled Allow array: EnabledPreferencePanes with each identified in a string for its domain: EnabledPreferencePanes com.apple.preferences.users com.apple.preference.general com.apple.preference.universalaccess com.apple.preferences.appstore com.apple.preferences.softwareupdate com.apple.preferences.Bluetooth…

  • SQL

    Install MySQL On OS X

    OS X might be the easiest platform to install MySQL on. To do so, simply download the MySQL installation package from the MySQL Download site. I like to use the third link (the DMG). Once downloaded, run the package. The package will ask you a few questions and you can easily just select the default choice during the installation process. Once installed, you’ll be prompted that a temporary password has been used for your MySQL instance. The password will get you in the first time, so you can change it. Once you have documented the password, open System Preferences and click on MySQL in the bottom row of System Preference Panes. Click Start…

  • SQL

    A Couple Of Ways To Backup SQL Data

    Create a backup copy of a table called Customers into a table called Customers2 on a running database called Backup: SELECT * INTO Customers2 IN 'Backup.mdb' FROM Customers; You can also specify multiple tables to pull data from when bringing that data into a new table, effectively merging data into a backup database: SELECT Customers.Site, IPs.IP INTO CustomerIPsbackup FROM Customers LEFT JOIN IPs ON Customers.Site=IPs.IP; Since this is more like replication than backup, MySQL also has a mysqldump command, used to dump a sql database to a file or screen, or whatever. Here, we’ll export all of our databases in a running MySQL instance into a file called dumpfile.sql: mysqldump…

  • SQL

    Use SELECT INTO To Copy Data Between Tables

    You can use the SELECT INTO statement finds data and then copies that data between tables or databases. To do so, use the following syntax: SELECT * INTO newtablename FROM tablename; So to copy that Customers table to a new table called Customers2: SELECT * INTO Customers2 FROM Customers; Or to copy only certain columns into Customers2, we’d use the following: SELECT ID,Site INTO Customers2 FROM Customers;

  • SQL

    Create A SQL Database

    So you’re ready to write some software? Or test some cool stuff. Or build something awesome. You can use the CREATE DATABASE statement to get started, by creating a database. To do so is pretty easy, simply run that statement followed by a name for the database (called Customers): CREATE DATABASE Customers; Once you’ve created a database, it’s time to create tables, which can be done using the CREATE TABLE statement. The Syntax of that statement looks something like this, defining a set of columns, their data type and the size of the column (in the form of a maximum length), all wrapped in parenthesis with each column separated by…